source: trunk/source/lisp-kernel/memprotect.h @ 8701

Last change on this file since 8701 was 8701, checked in by gb, 12 years ago

ProtectMemory?,UnprotectMemory?: second arg should be "natural", not "int".

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1/*
2   Copyright (C) 1994-2001 Digitool, Inc
3   This file is part of OpenMCL. 
4
5   OpenMCL is licensed under the terms of the Lisp Lesser GNU Public
6   License , known as the LLGPL and distributed with OpenMCL as the
7   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
8   which is distributed with OpenMCL as the file "LGPL".  Where these
9   conflict, the preamble takes precedence. 
10
11   OpenMCL is referenced in the preamble as the "LIBRARY."
12
13   The LLGPL is also available online at
14   http://opensource.franz.com/preamble.html
15*/
16
17#ifndef __memprotect_h__
18#define __memprotect_h__
19
20
21
22#include "lisptypes.h"
23#ifdef PPC
24#include "ppc-constants.h"
25#endif
26#include <signal.h>
27#ifndef WINDOWS
28#include <ucontext.h>
29#endif
30
31#ifdef WINDOWS
32#define PROT_NONE (0)
33#define PROT_READ (1)
34#define PROT_WRITE (2)
35#define PROT_EXEC (3)
36
37#define MAP_PRIVATE (1)
38#define MAP_FIXED (2)
39#define MAP_ANON (3)
40
41void *mmap(void *, size_t, int, int, int, off_t);
42
43#define MAP_FAILED ((void *)(-1))
44
45#endif
46
47int
48ProtectMemory(LogicalAddress, natural);
49
50int
51UnProtectMemory(LogicalAddress, natural);
52
53typedef enum {
54  kNotProtected,                /* At least not at the moment. */
55  kVSPsoftguard,
56  kSPsoftguard,
57  kTSPsoftguard,
58  kSPhardguard,                 /* Touch one and die. */
59  kVSPhardguard,
60  kTSPhardguard,
61  kHEAPsoft,                    /* Uninitialized page in the heap */
62  kHEAPhard,                    /* The end-of-the-line in the heap */
63  /* Phony last entry. */
64  kNumProtectionKinds
65  } lisp_protection_kind;
66
67typedef
68struct protected_area {
69  struct protected_area *next;
70  BytePtr start;                /* first byte (page-aligned) that might be protected */
71  BytePtr end;                  /* last byte (page-aligned) that could be protected */
72  unsigned nprot;               /* Might be 0 */
73  unsigned protsize;            /* number of bytes to protect */
74  lisp_protection_kind why;
75} protected_area, *protected_area_ptr;
76
77
78/* Various functions that try to respond to a protection violation */
79typedef 
80  OSStatus (protection_handler)(ExceptionInformation *, protected_area_ptr, BytePtr);
81
82protection_handler
83  do_spurious_wp_fault,
84  do_soft_stack_overflow,
85  do_hard_stack_overflow,
86  do_tenured_space_write,
87  do_heap_soft_probe,
88  do_heap_hard_probe;
89
90extern protection_handler
91  *protection_handlers[];
92
93
94void
95exception_cleanup(void);
96
97
98 
99#endif /* __memprotect_h__ */
Note: See TracBrowser for help on using the repository browser.