1 ;;; This file contains the MIPS specific runtime stuff.
6 (define-alien-type os-context-t
(struct os-context-t-struct
))
7 (define-alien-type os-context-register-t unsigned-long-long
)
12 (defun machine-type ()
13 "Returns a string describing the type of the local machine."
16 ;;;; FIXUP-CODE-OBJECT
18 (defun fixup-code-object (code offset value kind
)
19 (declare (type index offset
))
20 (unless (zerop (rem offset n-word-bytes
))
21 (error "Unaligned instruction? offset=#x~X." offset
))
23 (let ((sap (%primitive sb
!c
::code-instructions code
)))
26 (aver (zerop (ash value -
28)))
27 (setf (ldb (byte 26 0) (sap-ref-32 sap offset
))
30 (setf (ldb (byte 16 0) (sap-ref-32 sap offset
))
31 (ash (1+ (ash value -
15)) -
1)))
33 (setf (ldb (byte 16 0) (sap-ref-32 sap offset
))
34 (ldb (byte 16 0) value
)))))))
37 (define-alien-routine ("os_context_pc_addr" context-pc-addr
)
38 (* os-context-register-t
)
39 (context (* os-context-t
) :in
))
41 (defun context-pc (context)
42 (declare (type (alien (* os-context-t
)) context
))
43 (int-sap (deref (context-pc-addr context
))))
45 (define-alien-routine ("os_context_register_addr" context-register-addr
)
46 (* os-context-register-t
)
47 (context (* os-context-t
) :in
)
50 (define-alien-routine ("os_context_bd_cause" context-bd-cause-int
)
52 (context (* os-context-t
) :in
))
54 ;;; FIXME: Should this and CONTEXT-PC be INLINE to reduce consing?
55 ;;; (Are they used in anything time-critical, or just the debugger?)
56 (defun context-register (context index
)
57 (declare (type (alien (* os-context-t
)) context
))
58 (let ((addr (context-register-addr context index
)))
59 (declare (type (alien (* os-context-register-t
)) addr
))
62 (defun %set-context-register
(context index new
)
63 (declare (type (alien (* os-context-t
)) context
))
64 (let ((addr (context-register-addr context index
)))
65 (declare (type (alien (* os-context-register-t
)) addr
))
66 (setf (deref addr
) new
)))
68 ;;; This is like CONTEXT-REGISTER, but returns the value of a float
69 ;;; register. FORMAT is the type of float to return.
71 ;;; FIXME: Whether COERCE actually knows how to make a float out of a
72 ;;; long is another question. This stuff still needs testing.
73 (define-alien-routine ("os_context_fpregister_addr" context-float-register-addr
)
74 (* os-context-register-t
)
75 (context (* os-context-t
) :in
)
78 (defun context-float-register (context index format
)
79 (declare (type (alien (* os-context-t
)) context
))
80 (let ((addr (context-float-register-addr context index
)))
81 (declare (type (alien (* os-context-register-t
)) addr
))
82 (coerce (deref addr
) format
)))
84 (defun %set-context-float-register
(context index format new
)
85 (declare (type (alien (* os-context-t
)) context
))
86 (let ((addr (context-float-register-addr context index
)))
87 (declare (type (alien (* os-context-register-t
)) addr
))
88 (setf (deref addr
) (coerce new format
))))
91 ("arch_get_fp_control" floating-point-modes
) unsigned-int
)
94 ("arch_set_fp_control" %floating-point-modes-setter
) void
(fp unsigned-int
:in
))
96 (defun (setf floating-point-modes
) (val) (%floating-point-modes-setter val
))
98 ;;; Given a signal context, return the floating point modes word in
99 ;;; the same format as returned by FLOATING-POINT-MODES.
100 (define-alien-routine ("os_context_fp_control" context-floating-point-modes
)
102 (context (* os-context-t
) :in
))
104 ;;;; Internal-error-arguments.
106 ;;; INTERNAL-ERROR-ARGUMENTS -- interface.
108 ;;; Given the sigcontext, extract the internal error arguments from the
109 ;;; instruction stream. This is e.g.
110 ;;; 4 23 254 206 1 0 0 0
111 ;;; | ~~~~~~~~~~~~~~~~~~~~~~~~~
112 ;;; length data (everything is an octet)
114 (defun internal-error-args (context)
115 (declare (type (alien (* os-context-t
)) context
))
116 (/show0
"entering INTERNAL-ERROR-ARGS, CONTEXT=..")
118 (let ((pc (context-pc context
))
119 (cause (context-bd-cause-int context
)))
120 (declare (type system-area-pointer pc
))
121 (multiple-value-bind (error-number length sc-offsets
)
122 ;; KLUDGE: This exposure of the branch delay mechanism hurts.
123 (snarf-error-junk pc
(if (logbitp 31 cause
) 8 4))
124 (declare (ignore length
))
125 (values error-number sc-offsets
))))