source: release/1.7/source/lisp-kernel/arm-constants.h @ 15267

Last change on this file since 15267 was 14270, checked in by gb, 9 years ago

Some Android conditionalization. (Use 'Rfn' for r11, not 'fn').

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