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

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

Merge changes from branches/win64.

As well as the expected low-level exception/suspend/interrupt stuff,
these changes also include changes to [f]printf format strings. Note
that on win64, a 'long' is 32-bits wide, which complicates matters:

  • an address (viewed as an integer) or a natural-sized integer isn't

(portably) a long, and so can't be printed with %l.

  • an address (viewed as an integer) or a natural-sized integer isn't

(portably) a long long, and so can't be printed with %ll.

  • an address (viewed as an integer) or a natural-sized integer can be

portably printed with '%p', but implementations differ as to whether
or not '%p' prepends a gratuitous '0x' to the hex address. (Linux
does, other current platforms seem not to.)

The approach that seems to work is to cast arguments to natural, then
to u64_t, then use %ll. That approach probably isn't taken consistently
(yet), so some debugging information printed by the kernel may be
incorrect.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 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 MAP_FAILED ((void *)(-1))
33
34#define MEMPROTECT_NONE PAGE_NOACCESS
35#define MEMPROTECT_RO   PAGE_READONLY
36#define MEMPROTECT_RW   PAGE_READWRITE
37#define MEMPROTECT_RX   PAGE_EXECUTE_READ
38#define MEMPROTECT_RWX  PAGE_EXECUTE_READWRITE
39
40#else
41
42#define MEMPROTECT_NONE PROT_NONE
43#define MEMPROTECT_RO   PROT_READ
44#define MEMPROTECT_RW   (PROT_READ|PROT_WRITE)
45#define MEMPROTECT_RX   (PROT_READ|PROT_EXEC)
46#define MEMPROTECT_RWX  (PROT_READ|PROT_WRITE|PROT_EXEC)
47#ifndef MAP_GROWSDOWN
48#define MAP_GROWSDOWN (0)
49#endif
50
51
52#endif
53
54LogicalAddress
55ReserveMemoryForHeap(LogicalAddress want, natural totalsize);
56
57int
58CommitMemory (LogicalAddress start, natural len);
59
60void
61UnCommitMemory (LogicalAddress start, natural len);
62
63LogicalAddress
64MapMemory(LogicalAddress addr, natural nbytes, int protection);
65
66LogicalAddress
67MapMemoryForStack(natural nbytes);
68
69int
70UnMapMemory(LogicalAddress addr, natural nbytes);
71
72int
73ProtectMemory(LogicalAddress, natural);
74
75int
76UnProtectMemory(LogicalAddress, natural);
77
78int
79MapFile(LogicalAddress addr, natural pos, natural nbytes, int permissions, int fd);
80
81typedef enum {
82  kNotProtected,                /* At least not at the moment. */
83  kVSPsoftguard,
84  kSPsoftguard,
85  kTSPsoftguard,
86  kSPhardguard,                 /* Touch one and die. */
87  kVSPhardguard,
88  kTSPhardguard,
89  kHEAPsoft,                    /* Uninitialized page in the heap */
90  kHEAPhard,                    /* The end-of-the-line in the heap */
91  /* Phony last entry. */
92  kNumProtectionKinds
93  } lisp_protection_kind;
94
95typedef
96struct protected_area {
97  struct protected_area *next;
98  BytePtr start;                /* first byte (page-aligned) that might be protected */
99  BytePtr end;                  /* last byte (page-aligned) that could be protected */
100  unsigned nprot;               /* Might be 0 */
101  unsigned protsize;            /* number of bytes to protect */
102  lisp_protection_kind why;
103} protected_area, *protected_area_ptr;
104
105
106/* Various functions that try to respond to a protection violation */
107typedef 
108  OSStatus (protection_handler)(ExceptionInformation *, protected_area_ptr, BytePtr);
109
110protection_handler
111  do_spurious_wp_fault,
112  do_soft_stack_overflow,
113  do_hard_stack_overflow,
114  do_tenured_space_write,
115  do_heap_soft_probe,
116  do_heap_hard_probe;
117
118extern protection_handler
119  *protection_handlers[];
120
121
122void
123exception_cleanup(void);
124
125
126 
127#endif /* __memprotect_h__ */
Note: See TracBrowser for help on using the repository browser.