Remove more disassembler bogosity
[sbcl.git] / src / runtime / arm-linux-os.c
blob8e66b0cb65e89ac05ab263f8e2449efa1bda4e5a
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 "sbcl.h"
21 #include "./signal.h"
22 #include "os.h"
23 #include "arch.h"
24 #include "globals.h"
25 #include "interrupt.h"
26 #include "interr.h"
27 #include "lispregs.h"
28 #include <sys/socket.h>
29 #include <sys/utsname.h>
31 #include <sys/types.h>
32 #include <signal.h>
33 #include <sys/time.h>
34 #include <sys/stat.h>
35 #include <unistd.h>
36 #include <errno.h>
38 #include "validate.h"
39 size_t os_vm_page_size;
41 #ifdef LISP_FEATURE_SB_THREAD
42 #error "Define threading support functions"
43 #else
44 int arch_os_thread_init(struct thread *thread) {
45 stack_t sigstack;
46 /* Signal handlers are normally run on the main stack, but we've
47 * swapped stacks, require that the control stack contain only
48 * boxed data, and expands upwards while the C stack expands
49 * downwards. */
50 sigstack.ss_sp=((void *) thread)+dynamic_values_bytes;
51 sigstack.ss_flags=0;
52 sigstack.ss_size = 32*SIGSTKSZ;
53 if(sigaltstack(&sigstack,0)<0)
54 lose("Cannot sigaltstack: %s\n",strerror(errno));
56 return 1; /* success */
58 int arch_os_thread_cleanup(struct thread *thread) {
59 return 1; /* success */
61 #endif
63 os_context_register_t *
64 os_context_register_addr(os_context_t *context, int offset)
66 /* KLUDGE: All of the context registers are stored in the
67 * structure consecutively, in order, as separately-named fields.
68 * Rather than do a big switch/case and all that, just take the
69 * address of the first one (R0) and treat it as the start of an
70 * array. */
71 return &(&context->uc_mcontext.arm_r0)[offset];
74 os_context_register_t *
75 os_context_pc_addr(os_context_t *context)
77 return os_context_register_addr(context, reg_PC);
80 os_context_register_t *
81 os_context_lr_addr(os_context_t *context)
83 return os_context_register_addr(context, reg_LR);
86 sigset_t *
87 os_context_sigmask_addr(os_context_t *context)
89 return &(context->uc_sigmask);
92 void
93 os_restore_fp_control(os_context_t *context)
95 /* FIXME: Implement. */
98 void
99 os_flush_icache(os_vm_address_t address, os_vm_size_t length)
101 os_vm_address_t end_address
102 = (os_vm_address_t)(((pointer_sized_uint_t) address) + length);
103 __clear_cache(address, end_address);
106 static void
107 sigtrap_handler(int signal, siginfo_t *siginfo, os_context_t *context)
109 unsigned int code = *((unsigned char *)(4+*os_context_pc_addr(context)));
110 u32 trap_instruction = *((u32 *)*os_context_pc_addr(context));
112 if (trap_instruction != 0xe7f001f0) {
113 lose("Unrecognized trap instruction %08lx in sigtrap_handler()",
114 trap_instruction);
117 if (code == trap_PendingInterrupt) {
118 arch_skip_instruction(context);
121 handle_trap(context, code);
124 void arch_install_interrupt_handlers()
126 undoably_install_low_level_interrupt_handler(SIGTRAP, sigtrap_handler);