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

Last change on this file since 14145 was 14145, checked in by gb, 9 years ago

Don't #include ppc-constants.h directly.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/*
2   Copyright (C) 2009 Clozure Associates
3   Copyright (C) 1994-2001 Digitool, Inc
4   This file is part of Clozure CL. 
5
6   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public
7   License , known as the LLGPL and distributed with Clozure CL as the
8   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
9   which is distributed with Clozure CL as the file "LGPL".  Where these
10   conflict, the preamble takes precedence. 
11
12   Clozure CL is referenced in the preamble as the "LIBRARY."
13
14   The LLGPL is also available online at
15   http://opensource.franz.com/preamble.html
16*/
17
18#ifndef __memprotect_h__
19#define __memprotect_h__
20
21
22
23#include <signal.h>
24#ifndef WINDOWS
25#ifdef DARWIN
26#include <sys/ucontext.h>
27#else
28#include <ucontext.h>
29#endif
30#endif
31
32#ifdef WINDOWS
33#define MAP_FAILED ((void *)(-1))
34
35#define MEMPROTECT_NONE PAGE_NOACCESS
36#define MEMPROTECT_RO   PAGE_READONLY
37#define MEMPROTECT_RW   PAGE_READWRITE
38#define MEMPROTECT_RX   PAGE_EXECUTE_READ
39#define MEMPROTECT_RWX  PAGE_EXECUTE_READWRITE
40
41#else
42
43#define MEMPROTECT_NONE PROT_NONE
44#define MEMPROTECT_RO   PROT_READ
45#define MEMPROTECT_RW   (PROT_READ|PROT_WRITE)
46#define MEMPROTECT_RX   (PROT_READ|PROT_EXEC)
47#define MEMPROTECT_RWX  (PROT_READ|PROT_WRITE|PROT_EXEC)
48#ifndef MAP_GROWSDOWN
49#define MAP_GROWSDOWN (0)
50#endif
51
52
53#endif
54
55LogicalAddress
56ReserveMemoryForHeap(LogicalAddress want, natural totalsize);
57
58int
59CommitMemory (LogicalAddress start, natural len);
60
61void
62UnCommitMemory (LogicalAddress start, natural len);
63
64LogicalAddress
65MapMemory(LogicalAddress addr, natural nbytes, int protection);
66
67LogicalAddress
68MapMemoryForStack(natural nbytes);
69
70int
71UnMapMemory(LogicalAddress addr, natural nbytes);
72
73int
74ProtectMemory(LogicalAddress, natural);
75
76int
77UnProtectMemory(LogicalAddress, natural);
78
79int
80MapFile(LogicalAddress addr, natural pos, natural nbytes, int permissions, int fd);
81
82typedef enum {
83  kNotProtected,                /* At least not at the moment. */
84  kVSPsoftguard,
85  kSPsoftguard,
86  kTSPsoftguard,
87  kSPhardguard,                 /* Touch one and die. */
88  kVSPhardguard,
89  kTSPhardguard,
90  kHEAPsoft,                    /* Uninitialized page in the heap */
91  kHEAPhard,                    /* The end-of-the-line in the heap */
92  /* Phony last entry. */
93  kNumProtectionKinds
94  } lisp_protection_kind;
95
96typedef
97struct protected_area {
98  struct protected_area *next;
99  BytePtr start;                /* first byte (page-aligned) that might be protected */
100  BytePtr end;                  /* last byte (page-aligned) that could be protected */
101  unsigned nprot;               /* Might be 0 */
102  unsigned protsize;            /* number of bytes to protect */
103  lisp_protection_kind why;
104} protected_area, *protected_area_ptr;
105
106
107/* Various functions that try to respond to a protection violation */
108typedef 
109  OSStatus (protection_handler)(ExceptionInformation *, protected_area_ptr, BytePtr);
110
111protection_handler
112  do_spurious_wp_fault,
113  do_soft_stack_overflow,
114  do_hard_stack_overflow,
115  do_tenured_space_write,
116  do_heap_soft_probe,
117  do_heap_hard_probe;
118
119extern protection_handler
120  *protection_handlers[];
121
122
123void
124exception_cleanup(void);
125
126
127 
128#endif /* __memprotect_h__ */
Note: See TracBrowser for help on using the repository browser.