Speed up vector extension in VECTOR-PUSH-EXTEND.
[sbcl.git] / src / runtime / arm-bsd-os.c
blob368f97418da0d31f85a3d7f0516af3f3214eb7d4
1 /*
2 * This is the ARM BSD incarnation of arch-dependent OS-dependent
3 * routines. See also "bsd-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>
30 #include <machine/sysarch.h>
32 #include <sys/types.h>
33 #include <signal.h>
34 #include <sys/time.h>
35 #include <sys/stat.h>
36 #include <unistd.h>
37 #include <errno.h>
39 #include "validate.h"
40 size_t os_vm_page_size;
42 #ifdef LISP_FEATURE_SB_THREAD
43 #error "Define threading support functions"
44 #else
45 int arch_os_thread_init(struct thread *thread) {
46 stack_t sigstack;
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
50 * downwards. */
51 sigstack.ss_sp=((void *) thread)+dynamic_values_bytes;
52 sigstack.ss_flags=0;
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 */
62 #endif
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
71 * array. */
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);
87 void
88 os_restore_fp_control(os_context_t *context)
90 /* FIXME: Implement. */
93 void
94 os_flush_icache(os_vm_address_t address, os_vm_size_t length)
96 arm_sync_icache(address, length);
99 static void
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()",
107 trap_instruction);
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);