1 ;;; This file contains the ARM specific runtime stuff.
6 ;;; See x86-vm.lisp for a description of this.
7 ;;; FIXME: Why is this present in every ARCH-vm.lisp with the the same definition. Is there something like common-vm?
8 (define-alien-type os-context-t
(struct os-context-t-struct
))
10 (defun machine-type ()
11 "Return a string describing the type of the local machine."
15 ;;;; FIXUP-CODE-OBJECT
18 (defun fixup-code-object (code offset fixup kind
)
19 (declare (type index offset
))
20 (unless (zerop (rem offset
4))
21 (error "Unaligned instruction? offset=#x~X." offset
))
23 (let ((sap (code-instructions code
)))
26 (setf (sap-ref-word sap offset
) fixup
))
28 (setf (ldb (byte 19 5) (sap-ref-32 sap offset
))
29 (ash (- fixup
(+ (sap-int sap
) offset
)) -
2)))
31 (setf (ldb (byte 26 0) (sap-ref-32 sap offset
))
32 (ash (- fixup
(+ (sap-int sap
) offset
)) -
2))))))))
34 ;;;; "Sigcontext" access functions, cut & pasted from sparc-vm.lisp,
35 ;;;; then modified for ARM.
37 ;;;; See also x86-vm for commentary on signed vs unsigned.
40 (define-alien-routine ("os_context_register_addr" context-register-addr
)
42 (context (* os-context-t
))
45 (define-alien-routine ("os_context_pc_addr" context-register-pc-addr
)
47 (context (* os-context-t
)))
48 (define-alien-routine ("os_context_float_register_addr" context-float-register-addr
)
49 (* unsigned
) (context (* os-context-t
)) (index int
))
51 ;;; FIXME: Should this and CONTEXT-PC be INLINE to reduce consing?
52 ;;; (Are they used in anything time-critical, or just the debugger?)
53 (defun context-register (context index
)
54 (declare (type (alien (* os-context-t
)) context
))
55 (deref (context-register-addr context index
)))
57 (defun %set-context-register
(context index new
)
58 (declare (type (alien (* os-context-t
)) context
))
59 (setf (deref (context-register-addr context index
))
62 (defun context-float-register (context index format
)
63 (let ((sap (alien-sap (context-float-register-addr context index
))))
66 (sap-ref-single sap
0))
68 (sap-ref-double sap
0))
70 (complex (sap-ref-single sap
0)
71 (sap-ref-single sap
4)))
73 (complex (sap-ref-double sap
0)
74 (sap-ref-double sap
8))))))
76 (defun %set-context-float-register
(context index format value
)
77 (let ((sap (alien-sap (context-float-register-addr context index
))))
80 (setf (sap-ref-single sap
0) value
))
82 (setf (sap-ref-double sap
0) value
))
85 (declare (type (complex single-float
) value
))
86 (setf (sap-ref-single sap
0) (realpart value
)
87 (sap-ref-single sap
4) (imagpart value
))))
90 (declare (type (complex double-float
) value
))
91 (setf (sap-ref-double sap
0) (realpart value
)
92 (sap-ref-double sap
8) (imagpart value
)))))))
94 (defun context-pc (context)
95 (declare (type (alien (* os-context-t
)) context
))
96 (int-sap (deref (context-register-pc-addr context
))))
98 ;;;; INTERNAL-ERROR-ARGS.
100 ;;; Given a (POSIX) signal context, extract the internal error
101 ;;; arguments from the instruction stream.
102 (defun internal-error-args (context)
103 (declare (type (alien (* os-context-t
)) context
))
104 (let* ((pc (context-pc context
))
105 (instruction (sap-ref-32 pc
0))
106 (error-number (ldb (byte 8 13) instruction
)))
107 (declare (type system-area-pointer pc
))
109 (if (= (ldb (byte 8 5) instruction
) invalid-arg-count-trap
)
111 (sb!kernel
::decode-internal-error-args
(sap+ pc
4) error-number
)))))