%other-pointer-widetag derive-type: derive for simple-array.
[sbcl.git] / src / runtime / arm-linux-os.c
blob5fd39166318fc6aa94240e6c3fdd5ded889afbc8
1 /*
2 * This is the ARM Linux incarnation of arch-dependent OS-dependent
3 * routines. See also "linux-os.c".
4 */
6 /*
7 * This software is part of the SBCL system. See the README file for
8 * more information.
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.
17 #include <stdio.h>
18 #include <sys/param.h>
19 #include <sys/file.h>
20 #include "genesis/sbcl.h"
21 #include "os.h"
22 #include "arch.h"
23 #include "globals.h"
24 #include "interrupt.h"
25 #include "interr.h"
26 #include "lispregs.h"
28 #include <sys/types.h>
29 #include <signal.h>
30 #include <sys/time.h>
31 #include <sys/stat.h>
32 #include <unistd.h>
33 #include <errno.h>
35 #include "validate.h"
37 #ifdef LISP_FEATURE_SB_THREAD
38 #error "Define threading support functions"
39 #else
40 int arch_os_thread_init(struct thread *thread) {
41 stack_t sigstack;
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
45 * downwards. */
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 */
57 #endif
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
66 * array. */
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);
76 sigset_t *
77 os_context_sigmask_addr(os_context_t *context)
79 return &(context->uc_sigmask);
82 void
83 os_restore_fp_control(os_context_t *context)
85 /* FIXME: Implement. */
88 void
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);
96 static void
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()",
104 trap_instruction);
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);