source: branches/ia32/lisp-kernel/x86-constants32.h @ 8225

Last change on this file since 8225 was 8225, checked in by rme, 13 years ago

Try to get unconfused about things tagged with fulltag-imm.

File size: 13.0 KB
Line 
1/* offsets into uc_mcontext.ss */
2#ifdef DARWIN
3#define REG_EAX 0
4#define REG_EBX 1
5#define REG_ECX 2
6#define REG_EDX 3
7#define REG_EDI 4
8#define REG_ESI 5
9#define REG_EBP 6
10#define REG_ESP 7
11#define REG_EFL 9
12#define REG_EIP 10
13#endif
14
15/* Indicies of GPRs in the mcontext component of a ucontext */
16#define Iimm0  REG_EAX
17#define Ifn    REG_EBX
18#define Itemp0 REG_ECX
19#define Itemp1 REG_ECX
20#define Iarg_y REG_EDI
21#define Iarg_z REG_ESI
22#define Iesp   REG_ESP
23#define Iebp   REG_EBP
24#define Ieip   REG_EIP
25
26#define Isp Iesp
27#define Iip Ieip
28#define Iallocptr Itemp0
29#define Ira0 Itemp0
30#define Inargs Iimm0
31#define Ixfn Itemp1
32
33#define nbits_in_word 32
34#define log2_nbits_in_word 5
35#define nbits_in_byte 8
36#define ntagbits 3
37#define nlisptagbits 2
38#define nfixnumtagbits 2
39#define num_subtag_bits 8
40#define fixnumshift 2
41#define fixnum_shift 2
42#define fulltagmask 7
43#define tagmask  3
44#define fixnummask 3
45#define subtagmask ((1<<num_subtag_bits)-1)
46#define ncharcodebits 8
47#define charcode_shift 8
48#define node_size 4
49#define node_shift 2
50
51#define tag_fixnum 0
52#define tag_list 1
53#define tag_misc 2
54#define tag_imm 3
55
56#define fulltag_even_fixnum 0
57#define fulltag_cons 1
58#define fulltag_nodeheader 2
59#define fulltag_imm 3
60#define fulltag_odd_fixnum 4
61#define fulltag_tra 5
62#define fulltag_misc 6
63#define fulltag_immheader 7
64
65#define SUBTAG(tag,subtag) ((tag) | ((subtag) << ntagbits))
66#define IMM_SUBTAG(subtag) SUBTAG(fulltag_immheader,(subtag))
67#define NODE_SUBTAG(subtag) SUBTAG(fulltag_nodeheader,(subtag))
68
69#define subtag_bignum IMM_SUBTAG(0)
70#define min_numeric_subtag subtag_bignum
71#define subtag_ratio NODE_SUBTAG(1)
72#define max_rational_subtag subtag_ratio
73#define subtag_single_float IMM_SUBTAG(1)
74#define subtag_double_float IMM_SUBTAG(2)
75#define min_float_subtag subtag_single_float
76#define max_float_subtag subtag_double_float
77#define max_real_subtag subtag_double_float
78#define subtag_complex NODE_SUBTAG(3)
79#define max_numeric_subtag subtag_complex
80
81#define subtag_bit_vector IMM_SUBTAG(31)
82#define subtag_double_float_vector IMM_SUBTAG(30)
83#define subtag_s16_vector IMM_SUBTAG(29)
84#define subtag_u16_vector IMM_SUBTAG(28)
85#define min_16_bit_ivector_subtag subtag_u16_vector
86#define max_16_bit_ivector_subtag subtag_s16_vector
87
88/* subtag 27 unused*/
89#define subtag_s8_vector IMM_SUBTAG(26)
90#define subtag_u8_vector IMM_SUBTAG(25)
91#define min_8_bit_ivector_subtag subtag_u8_vector
92#define max_8_bit_ivector_subtag IMM_SUBTAG(27)
93
94#define subtag_simple_base_string IMM_SUBTAG(24)
95#define subtag_fixnum_vector IMM_SUBTAG(23)
96#define subtag_s32_vector IMM_SUBTAG(22)
97#define subtag_u32_vector IMM_SUBTAG(21)
98#define subtag_single_float_vector IMM_SUBTAG(20)
99#define max_32_bit_ivector_subtag IMM_SUBTAG(24)
100#define min_cl_ivector_subtag subtag_single_float_vector
101
102#define subtag_vectorH NODE_SUBTAG(20)
103#define subtag_arrayH NODE_SUBTAG(19)
104#define subtag_simple_vector NODE_SUBTAG(21)    /*  Only one such subtag */
105#define min_vector_subtag subtag_vectorH
106#define min_array_subtag subtag_arrayH
107
108#define subtag_macptr IMM_SUBTAG(3)
109#define min_non_numeric_imm_subtag subtag_macptr
110
111#define subtag_dead_macptr IMM_SUBTAG(4)
112#define subtag_code_vector IMM_SUBTAG(5)
113#define subtag_creole IMM_SUBTAG(6)
114
115#define max_non_array_imm_subtag ((19<<ntagbits)|fulltag_immheader)
116
117#define subtag_catch_frame NODE_SUBTAG(4)
118#define subtag_function NODE_SUBTAG(5)
119#define subtag_basic_stream NODE_SUBTAG(6)
120#define subtag_symbol NODE_SUBTAG(7)
121#define subtag_lock NODE_SUBTAG(8)
122#define subtag_hash_vector NODE_SUBTAG(9)
123#define subtag_pool NODE_SUBTAG(10)
124#define subtag_weak NODE_SUBTAG(11)
125#define subtag_package NODE_SUBTAG(12)
126#define subtag_slot_vector NODE_SUBTAG(13)
127#define subtag_instance NODE_SUBTAG(14)
128#define subtag_struct NODE_SUBTAG(15)
129#define subtag_istruct NODE_SUBTAG(16)
130#define max_non_array_node_subtag ((19<<ntagbits)|fulltag_immheader)
131
132#define subtag_unbound SUBTAG(fulltag_imm, 6)
133#define unbound_marker subtag_unbound
134#define undefined subtag_unbound
135#define unbound subtag_unbound
136#define subtag_character SUBTAG(fulltag_imm, 9)
137#define slot_unbound SUBTAG(fulltag_imm, 10)
138#define slot_unbound_marker slot_unbound
139#define subtag_illegal SUBTAG(fulltag_imm,11)
140#define illegal_marker subtag_illegal
141#define subtag_reserved_frame  SUBTAG(fulltag_imm,29)
142#define reserved_frame_marker subtag_reserved_frame
143#define subtag_no_thread_local_binding SUBTAG(fulltag_imm,30)
144#define no_thread_local_binding_marker subtag_no_thread_local_binding
145#define subtag_function_boundary_marker SUBTAG(fulltag_imm,31)
146#define function_boundary_marker subtag_function_boundary_marker
147
148typedef struct cons {
149    LispObj cdr;
150    LispObj car;
151} cons;
152
153typedef struct lispsymbol {
154    LispObj header;
155    LispObj pname;
156    LispObj vcell;
157    LispObj fcell;
158    LispObj package_predicate;
159    LispObj flags;
160    LispObj plist;
161    LispObj binding_index;
162} lispsymbol;
163
164typedef struct ratio {
165    LispObj header;
166    LispObj numer;
167    LispObj denom;
168} ratio;
169
170typedef struct double_float {
171    LispObj header;
172    LispObj pad;
173    LispObj value_low;
174    LispObj value_high;
175} double_float;
176
177typedef struct single_float {
178    LispObj header;
179    LispObj value;
180} single_float;
181
182typedef struct macptr {
183    LispObj header;
184    LispObj address;
185    LispObj class;
186    LispObj type;
187} macptr;
188
189typedef struct xmacptr {
190    LispObj header;
191    LispObj address;
192    LispObj class;
193    LispObj type;
194    LispObj flags;
195    LispObj link;
196} xmacptr;
197
198typedef struct special_binding {
199    struct special_binding *link;
200    struct lispsymbol *sym;
201    LispObj value;
202} special_binding;
203
204typedef struct lisp_frame {
205    struct lisp_frame *backlink;
206    LispObj tra;
207    LispObj xtra;               /* if tra is nvalretn */
208} lisp_frame;
209
210typedef struct exception_callback_frame {
211    struct lisp_frame *backlink;
212    LispObj tra;                /* ALWAYS 0 FOR AN XCF */
213    LispObj nominal_function;   /* the current function at the time of the exception */
214    LispObj relative_pc;        /* Boxed byte offset within actual function or absolute address */
215    LispObj containing_uvector; /* the uvector that contains the relative PC or NIL */
216    LispObj xp;                 /* exception context */
217    LispObj ra0;                /* value of ra0 from context */
218} xcf;
219
220/* The GC (at least) needs to know what a
221   package looks like, so that it can do GCTWA. */
222typedef struct package {
223    LispObj header;
224    LispObj itab;               /* itab and etab look like (vector (fixnum . fixnum) */
225    LispObj etab;
226    LispObj used;
227    LispObj used_by;
228    LispObj names;
229    LispObj shadowed;
230} package;
231
232typedef struct catch_frame {
233    LispObj header;
234    LispObj catch_tag;
235    LispObj link;
236    LispObj mvflag;
237    LispObj csp;
238    LispObj db_link;
239    LispObj regs[4];
240    LispObj xframe;
241    LispObj tsp_segment;
242} catch_frame;
243
244#define catch_frame_element_count ((sizeof(catch_frame)/sizeof(LispObj))-1)
245#define catch_frame_header make_header(subtag_catch_frame,catch_frame_element_count)
246
247/*
248   All exception frames in a thread are linked together
249 */
250typedef struct xframe_list {
251    ExceptionInformation *curr;
252    struct xframe_list *prev;
253} xframe_list;
254
255#define fixnum_bitmask(n)  (1<<((n)+fixnumshift))
256
257/*
258  The GC (at least) needs to know about hash-table-vectors and their flag bits.
259*/
260
261typedef struct hash_table_vector_header {
262  LispObj header;
263  LispObj link;                 /* If weak */
264  LispObj flags;                /* a fixnum; see below */
265  LispObj free_alist;           /* preallocated conses for finalization_alist */
266  LispObj finalization_alist;   /* key/value alist for finalization */
267  LispObj weak_deletions_count; /* incremented when GC deletes weak pair */
268  LispObj hash;                 /* backpointer to hash-table */
269  LispObj deleted_count;        /* number of deleted entries */
270  LispObj cache_idx;            /* index of last cached pair */
271  LispObj cache_key;            /* value of last cached key */
272  LispObj cache_value;          /* last cached value */
273} hash_table_vector_header;
274
275/*
276  Bits (masks) in hash_table_vector.flags:
277*/
278
279/* GC should track keys when addresses change */ 
280#define nhash_track_keys_mask fixnum_bitmask(28)
281
282/* GC should set when nhash_track_keys_bit & addresses change */
283#define nhash_key_moved_mask  fixnum_bitmask(27)
284
285/* weak on key or value (need new "weak both" encoding.) */
286#define nhash_weak_mask       fixnum_bitmask(12)
287
288/* weak on value */
289#define nhash_weak_value_mask fixnum_bitmask(11)
290
291/* finalizable */
292#define nhash_finalizable_mask fixnum_bitmask(10)
293
294
295/* Lfun bits */
296
297#define lfbits_nonnullenv_mask fixnum_bitmask(0)
298#define lfbits_keys_mask fixnum_bitmask(1)
299#define lfbits_restv_mask fixnum_bitmask(7)
300#define lfbits_optinit_mask fixnum_bitmask(14)
301#define lfbits_rest_mask fixnum_bitmask(15)
302#define lfbits_aok_mask fixnum_bitmask(16)
303#define lfbits_lap_mask fixnum_bitmask(23)
304#define lfbits_trampoline_mask fixnum_bitmask(24)
305#define lfbits_evaluated_mask fixnum_bitmask(25)
306#define lfbits_cm_mask fixnum_bitmask(26)         /* combined_method */
307#define lfbits_nextmeth_mask fixnum_bitmask(26)   /* or call_next_method with method_mask */
308#define lfbits_gfn_mask fixnum_bitmask(27)        /* generic_function */
309#define lfbits_nextmeth_with_args_mask fixnum_bitmask(27)   /* or call_next_method_with_args with method_mask */
310#define lfbits_method_mask fixnum_bitmask(28)     /* method function */
311/* PPC only but want it defined for xcompile */
312#define lfbits_noname_mask fixnum_bitmask(29)
313
314/*
315  known values of an "extended" (gcable) macptr's flags word:
316*/
317
318typedef enum {
319  xmacptr_flag_none = 0,        /* Maybe already disposed by Lisp */
320  xmacptr_flag_recursive_lock,  /* recursive-lock */
321  xmacptr_flag_ptr,             /* malloc/free */
322  xmacptr_flag_rwlock,          /* read/write lock */
323  xmacptr_flag_semaphore        /* semaphore */
324} xmacptr_flag;
325
326/* Creole */
327
328#define doh_quantum 400
329#define doh_block_slots ((doh_quantum >> 2) - 3)
330
331typedef struct doh_block {
332  struct doh_block *link;
333  unsigned size;
334  unsigned free;
335  LispObj data[doh_block_slots];
336} doh_block, *doh_block_ptr;
337
338#define population_weak_list (0<<fixnum_shift)
339#define population_weak_alist (1<<fixnum_shift)
340#define population_termination_bit (16+fixnum_shift)
341#define population_type_mask ((1<<population_termination_bit)-1)
342
343#define gc_retain_pages_bit fixnum_bitmask(0)
344#define gc_integrity_check_bit fixnum_bitmask(2)
345#define egc_verbose_bit fixnum_bitmask(3)
346#define gc_verbose_bit fixnum_bitmask(4)
347#define gc_allow_stack_overflows_bit fixnum_bitmask(5)
348#define gc_postgc_pending fixnum_bitmask(26)
349
350#include "lisp-errors.h"
351
352#ifdef DARWIN
353#include <architecture/i386/sel.h>
354#endif
355
356#define TCR_BIAS 0
357
358/*
359 * bits correspond to reg encoding used in instructions
360 *   7   6   5   4   3   2   1   0
361 *  edi esi ebp esp ebx edx ecx eax
362 */
363
364#define X8632_DEFAULT_NODE_REGS_MASK 0xce
365
366typedef struct tcr {
367    struct tcr *next;
368    struct tcr *prev;
369    u32_t node_regs_mask; /* bit set means correspnding reg contains node */
370    struct tcr *linear;
371  /* this spill area must be 16-byte aligned */
372    LispObj save0;              /* spill area for node registers */
373    LispObj save1;
374    LispObj save2;
375    LispObj save3;
376    LispObj *save_ebp;          /* EBP when in foreign code */
377    u32_t lisp_mxcsr;
378    u32_t foreign_mxcsr;
379    special_binding *db_link;     /* special binding chain head */
380    LispObj catch_top;            /* top catch frame */
381    LispObj *save_vsp;            /* VSP when in foreign code */
382    LispObj *save_tsp;            /* TSP when in foreign code */
383    LispObj *foreign_sp;
384    struct area *cs_area;               /* cstack area pointer */
385    struct area *vs_area;               /* vstack area pointer */
386    struct area *ts_area;               /* tstack area pointer */
387    LispObj cs_limit;                   /* stack overflow limit */
388    natural bytes_allocated;
389    natural bytes_consed_high;
390    natural log2_allocation_quantum;      /* for per-thread consing */
391    signed_natural interrupt_pending;     /* pending interrupt flag */
392    xframe_list *xframe;          /* exception-frame linked list */
393    int *errno_loc;               /* per-thread (?) errno location */
394    LispObj ffi_exception;        /* fpscr bits from ff-call */
395    LispObj osid;                 /* OS thread id */
396    signed_natural valence;       /* odd when in foreign code */
397    signed_natural foreign_exception_status; /* non-zero -> call lisp_exit_hook */
398    void *native_thread_info;                /* platform-dependent */
399    void *native_thread_id;     /* mach_thread_t, pid_t, etc. */
400    void *last_allocptr;
401    void *save_allocptr;
402    void *save_allocbase;
403    void *reset_completion;
404    void *activate;
405    signed_natural suspend_count;
406    ExceptionInformation *suspend_context;
407    ExceptionInformation *pending_exception_context;
408    void *suspend;                /* suspension semaphore */
409    void *resume;                 /* resumption semaphore */
410    natural flags;
411    ExceptionInformation *gc_context;
412    void *termination_semaphore;
413    signed_natural unwinding;
414    natural tlb_limit;
415    LispObj *tlb_pointer;
416    natural shutdown_count;
417    LispObj *next_tsp;
418    void *safe_ref_address;
419    sel_t ldt_selector;
420} TCR;
421
422#define nil_value (0x3000 + (fulltag_cons))
423#define t_value (0x3008 + (fulltag_misc))
424#define misc_header_offset -fulltag_misc
425#define misc_data_offset misc_header_offset + node_size
426
427#define heap_segment_size 0x00010000
428#define log2_heap_segment_size 16
Note: See TracBrowser for help on using the repository browser.