source: trunk/source/lisp-kernel/area.h @ 10588

Last change on this file since 10588 was 10588, checked in by gb, 11 years ago

IMAGE_BASE_ADDRESS for win32.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.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 __AREA_H__
18#define __AREA_H__ 1
19
20
21#include "bits.h"
22#include "memprotect.h"
23
24
25
26typedef enum {
27  AREA_VOID = 0,                /* Not really an area at all */
28  AREA_CSTACK = 1<<fixnumshift, /* A control stack */
29  AREA_VSTACK = 2<<fixnumshift, /* A value stack.  The GC sees it as being doubleword-aligned */
30  AREA_TSTACK = 3<<fixnumshift, /* A temp stack.  It -is- doubleword-aligned */
31  AREA_READONLY = 4<<fixnumshift, /* A (cfm) read-only section. */
32  AREA_MANAGED_STATIC = 5<<fixnumshift, /* A resizable static area */
33  AREA_STATIC = 6<<fixnumshift, /* A  static section: contains
34                                 roots, but not GCed */
35  AREA_DYNAMIC = 7<<fixnumshift /* A heap. Only one such area is "the heap."*/
36} area_code;
37
38typedef struct area {
39  struct area* pred;            /* linked list predecessor */
40  struct area* succ;            /* linked list successor */
41  char* low;                    /* arithmetic lower limit on addresses
42                                   (inclusive) */
43  char* high;                   /* arithmetic upper limit on addresses
44                                   (exclusive) */
45  char* active;                 /* low bound (stack) or high bound
46                                   (heap) */
47  char* softlimit;              /* only makes sense for dynamic heaps
48                                   & stacks */
49  char* hardlimit;              /* only makes sense for dynamic heaps
50                                   & stacks */
51  natural code;
52  natural*  markbits;           /* markbits for active area */
53  natural ndnodes;              /* "active" size of dynamic area or
54                                   stack */
55  struct area* older;           /* if ephemeral, the next older ephemeral area
56                                 or the dynamic area */
57  struct area* younger;         /* if ephemeral, the next "younger"
58                                  ephemeral area if there is one.  If
59                                  dynamic, the oldest ephemeral
60                                  area. */
61  char*  h;                     /* The pointer allocated to contain
62                                 this area, or NULL if the operating
63                                 system allocated it for us. */
64  protected_area* softprot;     /* "soft" protected_area */
65  protected_area* hardprot;     /* "hard" protected_area */
66  TCR * owner;                  /* TCR that the area belongs to, if a stack */
67  natural*  refbits;            /* intergenerational references.  May
68                                               or may not be the same
69                                               as markbits */
70  natural threshold;            /* egc threshold (boxed "fullword
71                                   count") or 0 */
72  LispObj gccount;              /* boxed generation GC count. */
73  natural static_dnodes;        /* for hash consing, maybe other things. */
74  natural *static_used;         /* bitvector */
75} area;
76
77
78/*
79  Areas are kept in a doubly-linked list.
80  The list header is just a distinguished element of
81  that list; by convention, the "active" dynamic
82  area is described by that header's successor, and areas
83  that may have entries in their "markbits" vector (heaps)
84  precede (in the area_list->succ sense) those  that don't (stacks).
85  The list header's "area" pointer is an "AREA_VOID" area; the header
86  (once allocated during kernel initialization) never
87  moves or changes.  Lisp code can get its hands on
88  the list header via a nilreg global, and carefully,
89  atomically, traverse it to do ROOM, etc.
90*/
91
92
93area *new_area(BytePtr, BytePtr, area_code);
94void add_area(area *, TCR *);
95void add_area_holding_area_lock(area *);
96void condemn_area(area *, TCR *);
97void condemn_area_holding_area_lock(area *);
98area *area_containing(BytePtr);
99area *stack_area_containing(BytePtr);
100area *heap_area_containing(BytePtr);
101void tenure_to_area(area *);
102void untenure_from_area(area *);
103
104/* serialize add_area/remove_area, and also the tcr queue */
105void *tcr_area_lock;
106
107#define reserved_area ((area *)(all_areas))
108#define active_dynamic_area ((area *)(reserved_area->succ))
109
110typedef struct area_list {
111  area *the_area;
112  struct area_list *next;
113} area_list;
114
115/* The useable size of a tsp or vsp stack segment.
116  */
117/* #define STACK_SEGMENT_SIZE (64<<10) */
118#define MIN_CSTACK_SIZE (1<<17)
119#define CSTACK_HARDPROT (100<<10)
120#define CSTACK_SOFTPROT (100<<10)
121#define MIN_VSTACK_SIZE (1<<16)
122#define VSTACK_HARDPROT (1<<12)
123#define VSTACK_SOFTPROT (1<<16)
124#define MIN_TSTACK_SIZE (1<<18)
125#define TSTACK_HARDPROT 0
126#define TSTACK_SOFTPROT (1<<16)
127#ifdef PPC
128#define CS_OVERFLOW_FORCE_LIMIT ((natural)(-(sizeof(lisp_frame))))
129#endif
130
131#ifdef X86
132#define CS_OVERFLOW_FORCE_LIMIT ((natural)(-16))
133#endif
134
135
136#ifdef PPC
137#ifdef LINUX
138#ifdef PPC64
139#define IMAGE_BASE_ADDRESS 0x100000000L
140#else
141#define IMAGE_BASE_ADDRESS 0x31000000
142#endif
143#endif
144#ifdef DARWIN
145#ifdef PPC64
146#define IMAGE_BASE_ADDRESS 0x100000000L
147#else
148#define IMAGE_BASE_ADDRESS 0x04000000
149#endif
150#endif
151#endif
152
153#ifdef X86
154#ifdef LINUX
155#ifdef X8664
156#define IMAGE_BASE_ADDRESS 0x300000000000L
157#endif
158#endif
159#ifdef FREEBSD
160#define IMAGE_BASE_ADDRESS 0x300000000000L /* 0x100000000L */
161#endif
162#ifdef SOLARIS
163#define IMAGE_BASE_ADDRESS 0x300000000000L
164#endif
165#ifdef DARWIN
166#ifdef X8664
167#define IMAGE_BASE_ADDRESS 0x300000000000L
168#else
169#define IMAGE_BASE_ADDRESS 0x04000000
170#endif
171#endif
172#endif
173#ifdef WINDOWS
174#ifdef X8664
175#define IMAGE_BASE_ADDRESS 0x100000000LL
176#else
177#define IMAGE_BASE_ADDRESS 0x04000000
178#endif
179#endif
180
181#ifdef X8664
182#define PURESPACE_RESERVE 0x40000000 /* 1GB */
183#else
184#define PURESPACE_RESERVE 0x04000000 /* 64MB */
185#endif
186
187#define STATIC_RESERVE heap_segment_size
188
189#ifndef X86
190#define STATIC_BASE_ADDRESS 0x00002000
191#else
192#define STATIC_BASE_ADDRESS 0x00012000
193#endif
194
195extern LispObj image_base;
196extern BytePtr pure_space_start, pure_space_active, pure_space_limit;
197extern BytePtr static_space_start, static_space_active, static_space_limit;
198extern area *find_readonly_area(void);
199
200#endif /* __AREA_H__ */
Note: See TracBrowser for help on using the repository browser.