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>
25 #include "interrupt.h"
28 #include <sys/socket.h>
29 #include <sys/utsname.h>
31 #include <sys/types.h>
39 size_t os_vm_page_size
;
41 #ifdef LISP_FEATURE_SB_THREAD
42 #error "Define threading support functions"
44 int arch_os_thread_init(struct thread
*thread
) {
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
50 sigstack
.ss_sp
=((void *) thread
)+dynamic_values_bytes
;
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 */
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
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
);
87 os_context_sigmask_addr(os_context_t
*context
)
89 return &(context
->uc_sigmask
);
93 os_restore_fp_control(os_context_t
*context
)
95 /* FIXME: Implement. */
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
);
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()",
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
);