1 ;;; This file contains the ARM specific runtime stuff.
5 ;;; See x86-vm.lisp for a description of this.
6 ;;; FIXME: Why is this present in every ARCH-vm.lisp with the the same definition. Is there something like common-vm?
7 (define-alien-type os-context-t
(struct os-context-t-struct
))
11 "Return a string describing the type of the local machine."
14 ;;;; FIXUP-CODE-OBJECT
16 (defun fixup-code-object (code offset fixup kind
)
17 (declare (type index offset
))
18 (unless (zerop (rem offset
4))
19 (error "Unaligned instruction? offset=#x~X." offset
))
21 (let ((sap (%primitive code-instructions code
)))
24 (setf (sap-ref-word sap offset
) fixup
))
26 (setf (ldb (byte 19 5) (sap-ref-32 sap offset
))
27 (ash (- fixup
(+ (sap-int sap
) offset
)) -
2)))
29 (setf (ldb (byte 26 0) (sap-ref-32 sap offset
))
30 (ash (- fixup
(+ (sap-int sap
) offset
)) -
2)))))))
32 ;;;; "Sigcontext" access functions, cut & pasted from sparc-vm.lisp,
33 ;;;; then modified for ARM.
35 ;;;; See also x86-vm for commentary on signed vs unsigned.
37 (define-alien-routine ("os_context_register_addr" context-register-addr
)
39 (context (* os-context-t
))
42 (define-alien-routine ("os_context_pc_addr" context-register-pc-addr
)
44 (context (* os-context-t
)))
45 (define-alien-routine ("os_context_float_register_addr" context-float-register-addr
)
46 (* unsigned
) (context (* os-context-t
)) (index int
))
48 ;;; FIXME: Should this and CONTEXT-PC be INLINE to reduce consing?
49 ;;; (Are they used in anything time-critical, or just the debugger?)
50 (defun context-register (context index
)
51 (declare (type (alien (* os-context-t
)) context
))
52 (deref (context-register-addr context index
)))
54 (defun %set-context-register
(context index new
)
55 (declare (type (alien (* os-context-t
)) context
))
56 (setf (deref (context-register-addr context index
))
59 (defun context-float-register (context index format
)
60 (let ((sap (alien-sap (context-float-register-addr context index
))))
63 (sap-ref-single sap
0))
65 (sap-ref-double sap
0))
67 (complex (sap-ref-single sap
0)
68 (sap-ref-single sap
4)))
70 (complex (sap-ref-double sap
0)
71 (sap-ref-double sap
8))))))
73 (defun %set-context-float-register
(context index format value
)
74 (let ((sap (alien-sap (context-float-register-addr context index
))))
77 (setf (sap-ref-single sap
0) value
))
79 (setf (sap-ref-double sap
0) value
))
82 (declare (type (complex single-float
) value
))
83 (setf (sap-ref-single sap
0) (realpart value
)
84 (sap-ref-single sap
4) (imagpart value
))))
87 (declare (type (complex double-float
) value
))
88 (setf (sap-ref-double sap
0) (realpart value
)
89 (sap-ref-double sap
8) (imagpart value
)))))))
91 (defun context-pc (context)
92 (declare (type (alien (* os-context-t
)) context
))
93 (int-sap (deref (context-register-pc-addr context
))))
95 ;;;; INTERNAL-ERROR-ARGS.
97 ;;; Given a (POSIX) signal context, extract the internal error
98 ;;; arguments from the instruction stream.
99 (defun internal-error-args (context)
100 (declare (type (alien (* os-context-t
)) context
))
101 (let* ((pc (context-pc context
))
102 (instruction (sap-ref-32 pc
0))
103 (error-number (ldb (byte 8 13) instruction
)))
104 (declare (type system-area-pointer pc
))
105 (if (= (ldb (byte 8 5) instruction
) invalid-arg-count-trap
)
106 (values error-number
'(#.arg-count-sc
))
107 (let* ((length (sap-ref-8 pc
4))
108 (vector (make-array length
:element-type
'(unsigned-byte 8)))
110 (declare (type (unsigned-byte 8) length
)
111 (type (simple-array (unsigned-byte 8) (*)) vector
))
112 (copy-ub8-from-system-area pc
5 vector
0 length
)
113 (collect ((sc-offsets))
115 (when (>= index length
)
117 (sc-offsets (sb!c
:read-var-integer vector index
)))
118 (values error-number
(sc-offsets)))))))