source: branches/arm/lisp-kernel/ppc-constants32.h @ 13923

Last change on this file since 13923 was 13717, checked in by gb, 9 years ago

Try to move platform-independent definitions to constants.h, to
lessen redundancy a bit. (Should do this on trunk, too.)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.6 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#ifndef __constants32__
19#define __constants32__ 1
20
21#include "ppc-constants.h"
22
23
24#define rcontext 13
25
26#define nbits_in_word 32
27#define log2_nbits_in_word 5
28#define nbits_in_byte 8
29#define ntagbits 3      /* But only 2 are significant to lisp */
30#define nlisptagbits 2
31#define nfixnumtagbits 2
32#define num_subtag_bits 8
33#define fixnumshift 2
34#define fixnum_shift 2
35#define fulltagmask 7
36#define tagmask  3
37#define fixnummask 3
38#define subtagmask ((1<<num_subtag_bits)-1)
39#define ncharcodebits 24        /* Only the low 8 are used currently */
40#define charcode_shift (nbits_in_word-ncharcodebits)
41#define node_size 4
42#define node_shift 2
43
44/*  Tags. */
45/*  There are two-bit tags and three-bit tags. */
46/*  A FULLTAG is the value of the low three bits of a tagged object. */
47/*  A TAG is the value of the low two bits of a tagged object. */
48/*  A TYPECODE is either a TAG or the value of a "tag-misc" object's header-byte. */
49
50/*  There are 4 primary TAG values.  Any object which lisp can "see" can be classified  */
51/*  by its TAG.  (Some headers have FULLTAGS that are congruent modulo 4 with the */
52/*  TAGS of other objects, but lisp can't "see" headers.) */
53
54
55#define tag_fixnum 0    /*  All fixnums, whether odd or even */
56#define tag_list 1      /*  Conses and NIL */
57#define tag_misc 2      /*  Heap-consed objects other than lists: vectors, symbols, functions, floats ... */
58#define tag_imm  3      /*  Immediate-objects: characters, UNBOUND, other markers. */
59
60/*  And there are 8 FULLTAG values.  Note that NIL has its own FULLTAG (congruent mod 4 to tag-list), */
61/*  that FULLTAG-MISC is > 4 (so that code-vector entry-points can be branched to, since the low */
62/*  two bits of the PC are ignored) and that both FULLTAG-MISC and FULLTAG-IMM have header fulltags */
63/*  that share the same TAG. */
64/*  Things that walk memory (and the stack) have to be careful to look at the FULLTAG of each */
65/*  object that they see. */
66
67#define fulltag_even_fixnum 0   /*  I suppose EVENP/ODDP might care; nothing else does. */
68#define fulltag_cons     1      /*  a real (non_null) cons.  Shares TAG with fulltag_nil. */
69#define fulltag_nodeheader 2    /*  Header of heap_allocated object that contains lisp_object pointers */
70#define fulltag_imm      3      /*  a "real" immediate object.  Shares TAG with fulltag_immheader. */
71#define fulltag_odd_fixnum 4    /*   */
72#define fulltag_nil      5      /*  NIL and nothing but.  (Note that there's still a hidden NILSYM.) */
73#define fulltag_misc     6      /*  Pointer "real" tag_misc object.  Shares TAG with fulltag_nodeheader. */
74#define fulltag_immheader 7     /*  Header of heap-allocated object that contains unboxed data. */
75
76
77
78/*  Order of CAR and CDR doesn't seem to matter much - there aren't */
79/*  too many tricks to be played with predecrement/preincrement addressing. */
80/*  Keep them in the confusing MCL 3.0 order, to avoid confusion. */
81
82typedef struct cons {
83  LispObj cdr;
84  LispObj car;
85} cons;
86
87
88#define misc_header_offset -fulltag_misc
89#define misc_subtag_offset misc_header_offset+3         /*  low byte of header */
90#define misc_data_offset misc_header_offset+4           /*  first word of data */
91#define misc_dfloat_offset misc_header_offset+8         /*  double-floats are doubleword-aligned */
92
93#define max_64_bit_constant_index ((0x7fff + misc_dfloat_offset)>>3)
94#define max_32_bit_constant_index ((0x7fff + misc_data_offset)>>2)
95#define max_16_bit_constant_index ((0x7fff + misc_data_offset)>>1)
96#define max_8_bit_constant_index (0x7fff + misc_data_offset)
97#define max_1_bit_constant_index ((0x7fff + misc_data_offset)<<5)
98
99/*  T is almost adjacent to NIL: since NIL is a misaligned CONS, it spans */
100/*  two doublewords.  The arithmetic difference between T and NIL is */
101/*  such that the least-significant bit and exactly one other bit is */
102/*  set in the result. */
103
104#define t_offset (8+(8-fulltag_nil)+fulltag_misc)
105#define t_value (lisp_nil+t_offset)
106
107/*  The order in which various header values are defined is significant in several ways: */
108/*  1) Numeric subtags precede non-numeric ones; there are further orderings among numeric subtags. */
109/*  2) All subtags which denote CL arrays are preceded by those that don't, */
110/*     with a further ordering which requires that (< header-arrayH header-vectorH ,@all-other-CL-vector-types) */
111/*  3) The element-size of ivectors is determined by the ordering of ivector subtags. */
112/*  4) All subtags are >= fulltag-immheader . */
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       
119/* Numeric subtags. */
120
121#define subtag_bignum IMM_SUBTAG(0)
122#define min_numeric_subtag subtag_bignum
123
124#define subtag_ratio NODE_SUBTAG(1)
125#define max_rational_subtag subtag_ratio
126
127#define subtag_single_float IMM_SUBTAG(1)
128#define subtag_double_float IMM_SUBTAG(2)
129#define min_float_subtag subtag_single_float
130#define max_float_subtag subtag_double_float
131#define max_real_subtag subtag_double_float
132
133#define subtag_complex NODE_SUBTAG(3)
134#define max_numeric_subtag subtag_complex
135
136
137/*  CL array types.  There are more immediate types than node types; all CL array subtags must be > than */
138/*  all non-CL-array subtags.  So we start by defining the immediate subtags in decreasing order, starting */
139/*  with that subtag whose element size isn't an integral number of bits and ending with those whose */
140/*  element size - like all non-CL-array fulltag-immheader types - is 32 bits. */
141
142#define subtag_bit_vector IMM_SUBTAG(31)
143#define subtag_double_float_vector IMM_SUBTAG(30)
144#define subtag_s16_vector IMM_SUBTAG(29)
145#define subtag_u16_vector IMM_SUBTAG(28)
146#define min_16_bit_ivector_subtag subtag_u16_vector
147#define max_16_bit_ivector_subtag subtag_s16_vector
148
149#define subtag_s8_vector IMM_SUBTAG(26)
150#define subtag_u8_vector IMM_SUBTAG(25)
151#define min_8_bit_ivector_subtag subtag_u8_vector
152#define max_8_bit_ivector_subtag IMM_SUBTAG(27)
153
154#define subtag_simple_base_string IMM_SUBTAG(24)
155#define subtag_fixnum_vector IMM_SUBTAG(23)
156#define subtag_s32_vector IMM_SUBTAG(22)
157#define subtag_u32_vector IMM_SUBTAG(21)
158#define subtag_single_float_vector IMM_SUBTAG(20)
159#define max_32_bit_ivector_subtag IMM_SUBTAG(24)
160#define min_cl_ivector_subtag subtag_single_float_vector
161
162
163#define subtag_vectorH NODE_SUBTAG(20)
164#define subtag_arrayH NODE_SUBTAG(19)
165#define subtag_simple_vector NODE_SUBTAG(21)    /*  Only one such subtag) */
166#define min_vector_subtag subtag_vectorH
167#define min_array_subtag subtag_arrayH
168
169/*  So, we get the remaining subtags (n: (n > max-numeric-subtag) & (n < min-array-subtag)) */
170/*  for various immediate/node object types. */
171
172#define subtag_macptr IMM_SUBTAG(3)
173#define min_non_numeric_imm_subtag subtag_macptr
174
175#define subtag_dead_macptr IMM_SUBTAG(4)
176#define subtag_code_vector IMM_SUBTAG(5)
177#define subtag_creole IMM_SUBTAG(6)
178
179#define max_non_array_imm_subtag ((19<<ntagbits)|fulltag_immheader)
180
181#define subtag_catch_frame NODE_SUBTAG(4)
182#define subtag_function NODE_SUBTAG(5)
183#define subtag_basic_stream NODE_SUBTAG(6)
184#define subtag_symbol NODE_SUBTAG(7)
185#define subtag_lock NODE_SUBTAG(8)
186#define subtag_hash_vector NODE_SUBTAG(9)
187#define subtag_pool NODE_SUBTAG(10)
188#define subtag_weak NODE_SUBTAG(11)
189#define subtag_package NODE_SUBTAG(12)
190#define subtag_slot_vector NODE_SUBTAG(13)
191#define subtag_instance NODE_SUBTAG(14)
192#define subtag_struct NODE_SUBTAG(15)
193#define subtag_istruct NODE_SUBTAG(16)
194#define max_non_array_node_subtag ((19<<ntagbits)|fulltag_immheader)
195       
196/*  The objects themselves look something like this: */
197
198typedef struct double_float {
199  LispObj header;
200  LispObj pad;
201  LispObj value_high;
202  LispObj value_low;
203} double_float;
204
205typedef struct single_float {
206  LispObj header;
207  LispObj value;
208} single_float;
209
210 
211
212typedef struct eabi_c_frame {
213  struct eabi_c_frame *backlink;
214  unsigned savelr;
215  unsigned params[8];
216} eabi_c_frame;
217
218/* PowerOpen ABI C frame */
219
220typedef struct c_frame {
221  struct c_frame *backlink;
222  unsigned crsave;
223  unsigned savelr;
224  unsigned unused[2];
225  unsigned savetoc;             /* Used with CFM */
226  unsigned params[8];           /* Space for callee to save r3-r10 */
227} c_frame;
228
229typedef struct lisp_frame {
230  struct lisp_frame *backlink;
231  LispObj savefn;
232  LispObj savelr;
233  LispObj savevsp;
234} lisp_frame;
235
236
237/*
238  The GC also needs to know what a catch_frame looks like.
239*/
240
241typedef struct catch_frame {
242  LispObj header;
243  LispObj catch_tag;
244  LispObj link;
245  LispObj mvflag;
246  LispObj csp;
247  LispObj db_link;
248  LispObj regs[8];
249  LispObj xframe;
250  LispObj tsp_segment;
251} catch_frame;
252
253#define catch_frame_element_count ((sizeof(catch_frame)/sizeof(LispObj))-1)
254#define catch_frame_header make_header(subtag_catch_frame,catch_frame_element_count)
255
256#define unbound SUBTAG(fulltag_imm, 6)
257#define undefined unbound
258#define unbound_marker unbound
259#define subtag_character SUBTAG(fulltag_imm, 9)
260#define slot_unbound SUBTAG(fulltag_imm, 10)
261#define slot_unbound_marker slot_unbound
262#define no_thread_local_binding_marker SUBTAG(fulltag_imm,30)
263
264/*
265  All exception frames in a thread are linked together
266  */
267typedef struct xframe_list {
268  ExceptionInformation *curr;
269  struct xframe_list *prev;
270} xframe_list;
271
272#define fixnum_bitmask(n)  (1<<((n)+fixnumshift))
273
274
275#include "lisp-errors.h"
276
277
278
279
280#define nil_value (0x00003015+(LOWMEM_BIAS))
281
282#define TCR_BIAS (0)
283
284typedef struct tcr {
285  struct tcr *next;
286  struct tcr *prev;
287  union {
288    double d;
289    struct {unsigned h, l;} words;
290  } lisp_fpscr;                 /* lisp thread's fpscr (in low word) */
291  special_binding *db_link;     /* special binding chain head */
292  LispObj catch_top;            /* top catch frame */
293  LispObj *save_vsp;            /* VSP when in foreign code */
294  LispObj *save_tsp;            /* TSP when in foreign code */
295  struct area *cs_area;         /* cstack area pointer */
296  struct area *vs_area;         /* vstack area pointer */
297  struct area *ts_area;         /* tstack area pointer */
298  LispObj cs_limit;             /* stack overflow limit */
299  unsigned long long bytes_allocated;
300  natural log2_allocation_quantum;  /* for per-thread consing */
301  int interrupt_pending;        /* deferred-interrupt pending */
302  xframe_list *xframe;          /* exception-frame linked list */
303  int *errno_loc;               /* per-thread (?) errno location */
304  LispObj ffi_exception;        /* fpscr bits from ff-call */
305  LispObj osid;                 /* OS thread id */
306  int valence;                  /* odd when in foreign code */
307  int foreign_exception_status; /* non-zero -> call lisp_exit_hook */
308  void *native_thread_info;     /* platform-dependent */
309  void *native_thread_id;       /* mach_thread_t, pid_t, etc. */
310  void *last_allocptr;
311  void *save_allocptr;
312  void *save_allocbase;
313  void *reset_completion;
314  void *activate;
315  int suspend_count;
316  ExceptionInformation *suspend_context;
317  ExceptionInformation *pending_exception_context;
318  void *suspend;                /* suspension semaphore */
319  void *resume;                 /* resumption semaphore */
320  natural flags;
321  ExceptionInformation *gc_context;
322  void *termination_semaphore;
323  int unwinding;
324  unsigned tlb_limit;
325  LispObj *tlb_pointer;
326  unsigned shutdown_count;
327  void *safe_ref_address;
328} TCR;
329
330/*
331  These were previously global variables.  There are lots of implicit
332  assumptions about the size of a heap segment, so they might as well
333  be constants.
334*/
335
336#define heap_segment_size 0x00010000
337#define log2_heap_segment_size 16
338
339
340#endif
341
Note: See TracBrowser for help on using the repository browser.