2 * This is the ARM Linux incarnation of arch-dependent OS-dependent
3 * routines. See also "linux-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>
20 #include "genesis/sbcl.h"
24 #include "interrupt.h"
28 #include <sys/types.h>
37 #ifdef LISP_FEATURE_SB_THREAD
38 #error "Define threading support functions"
40 int arch_os_thread_init(struct thread
*thread
) {
42 /* Signal handlers are normally run on the main stack, but we've
43 * swapped stacks, require that the control stack contain only
44 * boxed data, and expands upwards while the C stack expands
46 sigstack
.ss_sp
= calc_altstack_base(thread
);
47 sigstack
.ss_flags
= 0;
48 sigstack
.ss_size
= calc_altstack_size(thread
);
49 if(sigaltstack(&sigstack
,0)<0)
50 lose("Cannot sigaltstack: %s",strerror(errno
));
52 return 1; /* success */
54 int arch_os_thread_cleanup(struct thread
*thread
) {
55 return 1; /* success */
59 os_context_register_t
*
60 os_context_register_addr(os_context_t
*context
, int offset
)
62 /* KLUDGE: All of the context registers are stored in the
63 * structure consecutively, in order, as separately-named fields.
64 * Rather than do a big switch/case and all that, just take the
65 * address of the first one (R0) and treat it as the start of an
67 return (os_context_register_t
*)&(&context
->uc_mcontext
.arm_r0
)[offset
];
70 os_context_register_t
*
71 os_context_lr_addr(os_context_t
*context
)
73 return os_context_register_addr(context
, reg_LR
);
77 os_context_sigmask_addr(os_context_t
*context
)
79 return &(context
->uc_sigmask
);
83 os_restore_fp_control(os_context_t
*context
)
85 /* FIXME: Implement. */
89 os_flush_icache(os_vm_address_t address
, os_vm_size_t length
)
91 os_vm_address_t end_address
92 = (os_vm_address_t
)(((uintptr_t) address
) + length
);
93 __clear_cache(address
, end_address
);
97 sigtrap_handler(int signal
, siginfo_t
*siginfo
, os_context_t
*context
)
99 unsigned int code
= *((unsigned char *)(4+OS_CONTEXT_PC(context
)));
100 uint32_t trap_instruction
= *(uint32_t *)OS_CONTEXT_PC(context
);
102 if (trap_instruction
!= 0xe7f001f0) {
103 lose("Unrecognized trap instruction %08lx in sigtrap_handler()",
107 if (code
== trap_PendingInterrupt
) {
108 arch_skip_instruction(context
);
111 handle_trap(context
, code
);
114 void arch_install_interrupt_handlers()
116 ll_install_handler(SIGTRAP
, sigtrap_handler
);