source: trunk/source/lisp-kernel/x86-constants32.h @ 14347

Last change on this file since 14347 was 14295, checked in by rme, 9 years ago

Eliminate some (but not all) warnings produced when building with
"-Wall -Wno-format". Also a couple of minor changes that enable
clang to build the lisp kernel (at least on x8632 and x8664).

File size: 10.8 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#include "x86-constants.h"
19
20/* offsets into uc_mcontext.ss */
21#ifdef DARWIN
22#define REG_EAX 0
23#define REG_EBX 1
24#define REG_ECX 2
25#define REG_EDX 3
26#define REG_EDI 4
27#define REG_ESI 5
28#define REG_EBP 6
29#define REG_ESP 7
30#define REG_EFL 9
31#define REG_EIP 10
32#endif
33
34#ifdef WINDOWS
35/* Offsets relative to _CONTEXT.Edi */
36#define REG_EDI 0
37#define REG_ESI 1
38#define REG_EBX 2
39#define REG_EDX 3
40#define REG_ECX 4
41#define REG_EAX 5
42#define REG_EBP 6
43#define REG_EIP 7
44#define REG_EFL 9
45#define REG_ESP 10
46#endif
47
48#ifdef FREEBSD
49#define REG_EDI 5
50#define REG_ESI 6
51#define REG_EBP 7
52#define REG_ISP 8
53#define REG_EBX 9
54#define REG_EDX 10
55#define REG_ECX 11
56#define REG_EAX 12
57#define REG_EIP 15
58#define REG_EFL 17
59#define REG_ESP 18
60#endif
61
62#ifdef SOLARIS
63#include <sys/regset.h>
64#include <limits.h>
65#define REG_EAX EAX
66#define REG_EBX EBX
67#define REG_ECX ECX
68#define REG_EDX EDX
69#define REG_ESI ESI
70#define REG_EDI EDI
71#define REG_EBP EBP
72#define REG_ESP UESP    /* Maybe ... ESP is often 0, but who knows why ? */
73#define REG_EFL EFL
74#define REG_EIP EIP
75#endif
76
77/* Indicies of GPRs in the mcontext component of a ucontext */
78#define Iimm0  REG_EAX
79#define Iarg_z REG_EBX
80#define Itemp0 REG_ECX
81#define Itemp1 REG_EDX
82#define Ifn    REG_EDI
83#define Iarg_y REG_ESI
84#define Iesp   REG_ESP
85#define Iebp   REG_EBP
86#define Ieip   REG_EIP
87#define Iflags REG_EFL
88
89#define Isp Iesp
90#define Iip Ieip
91#define Iallocptr Itemp0
92#define Ira0 Itemp0
93#define Inargs Itemp1
94#define Ixfn Itemp1
95#define Ifp Iebp
96
97/* MMX register offsets from where mm0 is found in uc_mcontext.fs */
98#define Imm0 0
99#define Imm1 1
100
101#define nbits_in_word 32
102#define log2_nbits_in_word 5
103#define nbits_in_byte 8
104#define ntagbits 3
105#define nlisptagbits 2
106#define nfixnumtagbits 2
107#define num_subtag_bits 8
108#define fixnumshift 2
109#define fixnum_shift 2
110#define fulltagmask 7
111#define tagmask  3
112#define fixnummask 3
113#define subtagmask ((1<<num_subtag_bits)-1)
114#define ncharcodebits 8
115#define charcode_shift 8
116#define node_size 4
117#define node_shift 2
118#define nargregs 2
119
120#define tag_fixnum 0
121#define tag_list 1
122#define tag_misc 2
123#define tag_imm 3
124
125#define fulltag_even_fixnum 0
126#define fulltag_cons 1
127#define fulltag_nodeheader 2
128#define fulltag_imm 3
129#define fulltag_odd_fixnum 4
130#define fulltag_tra 5
131#define fulltag_misc 6
132#define fulltag_immheader 7
133
134#define SUBTAG(tag,subtag) ((tag) | ((subtag) << ntagbits))
135#define IMM_SUBTAG(subtag) SUBTAG(fulltag_immheader,(subtag))
136#define NODE_SUBTAG(subtag) SUBTAG(fulltag_nodeheader,(subtag))
137
138#define subtag_bignum IMM_SUBTAG(0)
139#define min_numeric_subtag subtag_bignum
140#define subtag_ratio NODE_SUBTAG(1)
141#define max_rational_subtag subtag_ratio
142#define subtag_single_float IMM_SUBTAG(1)
143#define subtag_double_float IMM_SUBTAG(2)
144#define min_float_subtag subtag_single_float
145#define max_float_subtag subtag_double_float
146#define max_real_subtag subtag_double_float
147#define subtag_complex NODE_SUBTAG(3)
148#define max_numeric_subtag subtag_complex
149
150#define subtag_bit_vector IMM_SUBTAG(31)
151#define subtag_double_float_vector IMM_SUBTAG(30)
152#define subtag_s16_vector IMM_SUBTAG(29)
153#define subtag_u16_vector IMM_SUBTAG(28)
154#define min_16_bit_ivector_subtag subtag_u16_vector
155#define max_16_bit_ivector_subtag subtag_s16_vector
156
157/* subtag 27 unused*/
158#define subtag_s8_vector IMM_SUBTAG(26)
159#define subtag_u8_vector IMM_SUBTAG(25)
160#define min_8_bit_ivector_subtag subtag_u8_vector
161#define max_8_bit_ivector_subtag IMM_SUBTAG(27)
162
163#define subtag_simple_base_string IMM_SUBTAG(24)
164#define subtag_fixnum_vector IMM_SUBTAG(23)
165#define subtag_s32_vector IMM_SUBTAG(22)
166#define subtag_u32_vector IMM_SUBTAG(21)
167#define subtag_single_float_vector IMM_SUBTAG(20)
168#define max_32_bit_ivector_subtag IMM_SUBTAG(24)
169#define min_cl_ivector_subtag subtag_single_float_vector
170
171#define subtag_vectorH NODE_SUBTAG(20)
172#define subtag_arrayH NODE_SUBTAG(19)
173#define subtag_simple_vector NODE_SUBTAG(21)    /*  Only one such subtag */
174#define min_vector_subtag subtag_vectorH
175#define min_array_subtag subtag_arrayH
176
177#define subtag_macptr IMM_SUBTAG(3)
178#define min_non_numeric_imm_subtag subtag_macptr
179
180#define subtag_dead_macptr IMM_SUBTAG(4)
181#define subtag_code_vector IMM_SUBTAG(5)
182#define subtag_creole IMM_SUBTAG(6)
183
184#define max_non_array_imm_subtag ((19<<ntagbits)|fulltag_immheader)
185
186#define subtag_catch_frame NODE_SUBTAG(4)
187#define subtag_function NODE_SUBTAG(5)
188#define subtag_basic_stream NODE_SUBTAG(6)
189#define subtag_symbol NODE_SUBTAG(7)
190#define subtag_lock NODE_SUBTAG(8)
191#define subtag_hash_vector NODE_SUBTAG(9)
192#define subtag_pool NODE_SUBTAG(10)
193#define subtag_weak NODE_SUBTAG(11)
194#define subtag_package NODE_SUBTAG(12)
195#define subtag_slot_vector NODE_SUBTAG(13)
196#define subtag_instance NODE_SUBTAG(14)
197#define subtag_struct NODE_SUBTAG(15)
198#define subtag_istruct NODE_SUBTAG(16)
199#define max_non_array_node_subtag ((19<<ntagbits)|fulltag_immheader)
200
201#define subtag_unbound SUBTAG(fulltag_imm, 6)
202#define unbound_marker subtag_unbound
203#define undefined subtag_unbound
204#define unbound subtag_unbound
205#define subtag_character SUBTAG(fulltag_imm, 9)
206#define slot_unbound SUBTAG(fulltag_imm, 10)
207#define slot_unbound_marker slot_unbound
208#define subtag_illegal SUBTAG(fulltag_imm,11)
209#define illegal_marker subtag_illegal
210#define subtag_forward_marker SUBTAG(fulltag_imm,28)
211#define subtag_reserved_frame  SUBTAG(fulltag_imm,29)
212#define reserved_frame_marker subtag_reserved_frame
213#define subtag_no_thread_local_binding SUBTAG(fulltag_imm,30)
214#define no_thread_local_binding_marker subtag_no_thread_local_binding
215#define subtag_function_boundary_marker SUBTAG(fulltag_imm,31)
216#define function_boundary_marker subtag_function_boundary_marker
217
218
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
232
233typedef struct lisp_frame {
234    struct lisp_frame *backlink;
235    LispObj tra;
236    LispObj xtra;               /* if tra is nvalretn */
237} lisp_frame;
238
239typedef struct exception_callback_frame {
240    struct lisp_frame *backlink;
241    LispObj tra;                /* ALWAYS 0 FOR AN XCF */
242    LispObj nominal_function;   /* the current function at the time of the exception */
243    LispObj relative_pc;        /* Boxed byte offset within actual function or absolute address */
244    LispObj containing_uvector; /* the uvector that contains the relative PC or NIL */
245    LispObj xp;                 /* exception context */
246    LispObj ra0;                /* value of ra0 from context */
247    LispObj foreign_sp;         /* foreign sp at the time that exception occurred */
248    LispObj prev_xframe;        /* so %apply-in-frame can unwind it */
249} xcf;
250
251
252typedef struct catch_frame {
253    LispObj header;
254    LispObj catch_tag;
255    LispObj link;
256    LispObj mvflag;
257    LispObj esp;
258    LispObj ebp;
259    LispObj foreign_sp;
260    LispObj db_link;
261    LispObj xframe;
262    LispObj pc;
263} catch_frame;
264
265#define catch_frame_element_count ((sizeof(catch_frame)/sizeof(LispObj))-1)
266#define catch_frame_header make_header(subtag_catch_frame,catch_frame_element_count)
267
268/*
269   All exception frames in a thread are linked together
270 */
271typedef struct xframe_list {
272  ExceptionInformation *curr;
273  natural node_regs_mask;
274  struct xframe_list *prev;
275} xframe_list;
276
277#define fixnum_bitmask(n)  (1<<((n)+fixnumshift))
278
279
280
281
282
283
284#include "lisp-errors.h"
285
286#ifdef DARWIN
287#include <architecture/i386/sel.h>
288#else
289typedef unsigned short sel_t;   /* for now */
290#endif
291
292#define TCR_BIAS 0
293
294/*
295 * bits correspond to reg encoding used in instructions
296 *   7   6   5   4   3   2   1   0
297 *  edi esi ebp esp ebx edx ecx eax
298 */
299
300#define X8632_DEFAULT_NODE_REGS_MASK 0xce
301
302typedef struct tcr {
303  struct tcr *next;
304  struct tcr *prev;
305  natural node_regs_mask; /* bit set means correspnding reg contains node */
306  struct tcr *linear;
307  /* this spill area must be 16-byte aligned */
308  LispObj save0;                /* spill area for node registers */
309  LispObj save1;
310  LispObj save2;
311  LispObj save3;
312  LispObj *save_fp;             /* EBP when in foreign code */
313  u32_t lisp_mxcsr;
314  u32_t foreign_mxcsr;
315  special_binding *db_link;     /* special binding chain head */
316  LispObj catch_top;            /* top catch frame */
317  LispObj *save_vsp;              /* VSP when in foreign code */
318  LispObj *save_tsp;              /* TSP when in foreign code */
319  LispObj *foreign_sp;
320  struct area *cs_area;         /* cstack area pointer */
321  struct area *vs_area;         /* vstack area pointer */
322  struct area *ts_area;         /* tstack area pointer */
323  LispObj cs_limit;                     /* stack overflow limit */
324  natural bytes_allocated;
325  natural bytes_consed_high;
326  natural log2_allocation_quantum;      /* for per-thread consing */
327  signed_natural interrupt_pending;     /* pending interrupt flag */
328  xframe_list *xframe;    /* exception-frame linked list */
329  int *errno_loc;               /* per-thread (?) errno location */
330  LispObj ffi_exception;        /* fpscr bits from ff-call */
331  LispObj osid;                 /* OS thread id */
332  signed_natural valence;         /* odd when in foreign code */
333  signed_natural foreign_exception_status; /* non-zero -> call lisp_exit_hook */
334  void *native_thread_info;                  /* platform-dependent */
335  void *native_thread_id;       /* mach_thread_t, pid_t, etc. */
336  char *last_allocptr;
337  char *save_allocptr;
338  char *save_allocbase;
339  void *reset_completion;
340  void *activate;
341  signed_natural suspend_count;
342  ExceptionInformation *suspend_context;
343  ExceptionInformation *pending_exception_context;
344  void *suspend;                /* suspension semaphore */
345  void *resume;                 /* resumption semaphore */
346  natural flags;
347  ExceptionInformation *gc_context;
348  void *termination_semaphore;
349  signed_natural unwinding;
350  natural tlb_limit;
351  LispObj *tlb_pointer;
352  natural shutdown_count;
353  LispObj *next_tsp;
354  void *safe_ref_address;
355  sel_t ldt_selector;
356  natural scratch_mxcsr;
357  natural unboxed0;
358  natural unboxed1;
359  LispObj next_method_context; /* used in lieu of register */
360  natural save_eflags;
361  void *allocated;
362  void *pending_io_info;
363  void *io_datum;
364} TCR;
365
366#define nil_value ((0x13000 + (fulltag_cons))+(LOWMEM_BIAS))
367#define t_value ((0x13008 + (fulltag_misc))+(LOWMEM_BIAS))
368#define t_offset (t_value-nil_value)
369#define misc_header_offset -fulltag_misc
370#define misc_data_offset misc_header_offset + node_size
371
372typedef struct {
373  natural Eip;
374  natural Cs;                   /* in low 16 bits */
375  natural EFlags;
376} ia32_iret_frame;
377
378#define heap_segment_size 0x00010000
379#define log2_heap_segment_size 16
380
381#ifndef EFL_DF
382#define EFL_DF 1024
383#endif
384
Note: See TracBrowser for help on using the repository browser.