2 * This is the ARM BSD incarnation of arch-dependent OS-dependent
3 * routines. See also "bsd-os.c".
7 * This software is part of the SBCL system. See the README file for
10 * This software is derived from the CMU CL system, which was
11 * written at Carnegie Mellon University and released into the
12 * public domain. The software is in the public domain and is
13 * provided with absolutely no warranty. See the COPYING and CREDITS
14 * files for more information.
18 #include <sys/param.h>
25 #include "interrupt.h"
28 #include <sys/socket.h>
29 #include <sys/utsname.h>
30 #include <machine/sysarch.h>
32 #include <sys/types.h>
40 size_t os_vm_page_size
;
42 #ifdef LISP_FEATURE_SB_THREAD
43 #error "Define threading support functions"
45 int arch_os_thread_init(struct thread
*thread
) {
47 /* Signal handlers are normally run on the main stack, but we've
48 * swapped stacks, require that the control stack contain only
49 * boxed data, and expands upwards while the C stack expands
51 sigstack
.ss_sp
=((void *) thread
)+dynamic_values_bytes
;
53 sigstack
.ss_size
= 32*SIGSTKSZ
;
54 if(sigaltstack(&sigstack
,0)<0)
55 lose("Cannot sigaltstack: %s\n",strerror(errno
));
57 return 1; /* success */
59 int arch_os_thread_cleanup(struct thread
*thread
) {
60 return 1; /* success */
64 os_context_register_t
*
65 os_context_register_addr(os_context_t
*context
, int offset
)
67 /* KLUDGE: All of the context registers are stored in the
68 * structure consecutively, in order, as separately-named fields.
69 * Rather than do a big switch/case and all that, just take the
70 * address of the first one (R0) and treat it as the start of an
72 return &context
->uc_mcontext
.__gregs
[offset
];
75 os_context_register_t
*
76 os_context_pc_addr(os_context_t
*context
)
78 return os_context_register_addr(context
, reg_PC
);
81 os_context_register_t
*
82 os_context_lr_addr(os_context_t
*context
)
84 return os_context_register_addr(context
, reg_LR
);
88 os_restore_fp_control(os_context_t
*context
)
90 /* FIXME: Implement. */
94 os_flush_icache(os_vm_address_t address
, os_vm_size_t length
)
96 arm_sync_icache(address
, length
);
100 sigtrap_handler(int signal
, siginfo_t
*siginfo
, os_context_t
*context
)
102 unsigned int code
= *((unsigned char *)(4+*os_context_pc_addr(context
)));
103 u32 trap_instruction
= *((u32
*)*os_context_pc_addr(context
));
105 if (trap_instruction
!= 0xe7ffdefe) {
106 lose("Unrecognized trap instruction %08lx in sigtrap_handler()",
110 if (code
== trap_PendingInterrupt
) {
111 arch_skip_instruction(context
);
114 handle_trap(context
, code
);
117 void arch_install_interrupt_handlers()
119 undoably_install_low_level_interrupt_handler(SIGTRAP
, sigtrap_handler
);