source: branches/working-0711/ccl/lisp-kernel/x86-constants32.h @ 12988

Last change on this file since 12988 was 12988, checked in by gz, 10 years ago

Cosmetic changes (r12644)

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