1 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; This software is derived from the CMU CL system, which was
5 ;;;; written at Carnegie Mellon University and released into the
6 ;;;; public domain. The software is in the public domain and is
7 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
8 ;;;; files for more information.
12 (eval-when (:compile-toplevel :load-toplevel :execute)
14 (defconstant word-bits 32
16 "Number of bits per word where a word holds one lisp descriptor.")
18 (defconstant byte-bits 8
20 "Number of bits per byte where a byte is the smallest addressable object.")
22 (defconstant word-shift (1- (integer-length (/ word-bits byte-bits)))
24 "Number of bits to shift between word addresses and byte addresses.")
26 (defconstant word-bytes (/ word-bits byte-bits)
28 "Number of bytes in a word.")
30 (defconstant float-sign-shift 31)
32 (defconstant single-float-bias 126)
33 (defconstant-eqx single-float-exponent-byte (byte 8 23) #'equalp)
34 (defconstant-eqx single-float-significand-byte (byte 23 0) #'equalp)
35 (defconstant single-float-normal-exponent-min 1)
36 (defconstant single-float-normal-exponent-max 254)
37 (defconstant single-float-hidden-bit (ash 1 23))
38 (defconstant single-float-trapping-nan-bit (ash 1 22))
40 (defconstant double-float-bias 1022)
41 (defconstant-eqx double-float-exponent-byte (byte 11 20) #'equalp)
42 (defconstant-eqx double-float-significand-byte (byte 20 0) #'equalp)
43 (defconstant double-float-normal-exponent-min 1)
44 (defconstant double-float-normal-exponent-max #x7FE)
45 (defconstant double-float-hidden-bit (ash 1 20))
46 (defconstant double-float-trapping-nan-bit (ash 1 19))
48 (defconstant single-float-digits
49 (+ (byte-size single-float-significand-byte) 1))
51 (defconstant double-float-digits
52 (+ (byte-size double-float-significand-byte) word-bits 1))
54 ;; Values in 17f code seem to be same as HPPA. These values are from
55 ;; DEC Assembly Language Programmers guide. The active bits are
56 ;; actually in (byte 12 52) of the fpcr. (byte 6 52) contain the
57 ;; exception flags. Bit 63 is the bitwise logor of all exceptions.
58 ;; The enable and exception bytes are in a software control word
59 ;; manipulated via OS functions and the bits in the SCP match those
60 ;; defs. This mapping follows <machine/fpu.h>
61 (defconstant float-inexact-trap-bit (ash 1 4)) ; rw
62 (defconstant float-underflow-trap-bit (ash 1 3)) ; rw
63 (defconstant float-overflow-trap-bit (ash 1 2)) ; ro
64 (defconstant float-divide-by-zero-trap-bit (ash 1 1)) ; ro
65 (defconstant float-invalid-trap-bit (ash 1 0)) ; ro
67 (defconstant float-round-to-zero 0)
68 (defconstant float-round-to-negative 1)
69 (defconstant float-round-to-nearest 2)
70 (defconstant float-round-to-positive 3)
72 ;; These aren't quite correct yet. Work in progress.
73 (defconstant-eqx float-rounding-mode (byte 2 58) #'equalp) ; hardware fpcr
74 (defconstant-eqx float-exceptions-byte (byte 6 52) #'equalp) ; hardware fpcr
75 (defconstant-eqx float-sticky-bits (byte 6 17) #'equalp) ; software (clear only)
76 (defconstant-eqx float-traps-byte (byte 6 1) #'equalp) ; software fp control word
77 (defconstant float-condition-bit (ash 1 63)) ; summary - not used?? XXX
78 (defconstant float-fast-bit 0)
84 ;;;; Description of the target address space.
86 ;;; Where to put the different spaces.
91 (defconstant read-only-space-start #x20000000)
92 (defconstant read-only-space-end #x24000000)
94 (defconstant static-space-start #x28000000)
95 (defconstant static-space-end #x2c000000)
97 ;; this is used in PURIFY as part of a sloppy check to see if a pointer
98 ;; is in dynamic space. Chocolate brownie for the first person to fix it
100 (defconstant dynamic-space-start #x30000000)
101 (defconstant dynamic-space-end #x38000000)
103 (defconstant dynamic-0-space-start #x30000000)
104 (defconstant dynamic-0-space-end #x38000000)
106 (defconstant dynamic-1-space-start #x40000000)
107 (defconstant dynamic-1-space-end #x48000000)
109 (defconstant control-stack-start #x50000000)
110 (defconstant control-stack-end #x51000000)
112 (defconstant binding-stack-start #x70000000)
113 (defconstant binding-stack-end #x71000000))
117 (defparameter read-only-space-start #x10000000)
118 (defparameter static-space-start #x28000000)
119 (defparameter dynamic-space-start #x30000000))
122 ;;; FIXME nothing refers to either of these in alpha or x86 cmucl
123 ;;; backend, so they could probably be removed.
125 ;; The space-register holding the lisp heap.
126 (defconstant lisp-heap-space 4)
128 ;; The space-register holding the C text segment.
129 (defconstant c-text-space 4)
131 ;;; the X86 port defines *nil-value* as (+ *target-static-space-start* #xB)
132 ;;; here, but it seems to be the only port that needs to know the
133 ;;; location of NIL from lisp.
135 ;;;; other miscellaneous constants
137 (defenum (:suffix -trap :start 8)
143 function-end-breakpoint
144 single-step-breakpoint)
146 (defenum (:prefix trace-table-)
154 ;;; These symbols are loaded into static space directly after NIL so
155 ;;; that the system can compute their address by adding a constant
158 ;;; The fdefn objects for the static functions are loaded into static
159 ;;; space directly after the static symbols. That way, the raw-addr
160 ;;; can be loaded directly out of them by indirecting relative to NIL.
162 (defparameter *static-symbols*
165 ;; The C startup code must fill these in.
167 ;;lisp::lisp-environment-list
168 ;;lisp::lisp-command-line-list
169 sb!impl::*!initial-fdefn-objects*
171 ;; Functions that the C code needs to call
173 sb!kernel::internal-error
174 sb!di::handle-breakpoint
175 sb!di::handle-function-end-breakpoint
179 *read-only-space-free-pointer*
180 *static-space-free-pointer*
181 *initial-dynamic-space-free-pointer*
183 ;; things needed for non-local exit
184 *current-catch-block*
185 *current-unwind-protect-block*
188 ;; interrupt handling
189 *free-interrupt-context-index*
190 sb!unix::*interrupts-enabled*
191 sb!unix::*interrupt-pending*))
193 (defparameter *static-functions*
203 ;; probably need the following as they are defined in
204 ;; arith.lisp: two-arg-<= two-arg->= two-arg-/=
205 ;; a comment from old CMU CL or old old CMU CL or
206 ;; the SBCL alpha port or what? Do we need to worry about it,
207 ;; or can we delete it?
210 sb!kernel:two-arg-and
211 sb!kernel:two-arg-ior
212 sb!kernel:two-arg-xor
213 sb!kernel:two-arg-gcd
214 sb!kernel:two-arg-lcm))