source: release/1.9/source/lisp-kernel/arm-constants.h @ 16083

Last change on this file since 16083 was 15607, checked in by gb, 6 years ago

Bump image version for ARM.
Handle T/NIL operators in ARM backend.
No futexes on LinuxARM, either.
Bump image versions, including min version for ARM.
New ARM binaries. (Kernel was compiled on an ARMv7
for hard float ABI.)

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