2 * The x86 Linux incarnation of arch-dependent OS-dependent routines.
3 * 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>
24 #include "interrupt.h"
28 #include <sys/socket.h>
29 #include <sys/utsname.h>
31 #include <sys/types.h>
33 /* #include <sys/sysinfo.h> */
39 size_t os_vm_page_size;
42 /* KLUDGE: As of kernel 2.2.14 on Red Hat 6.2, there's code in the
43 * <sys/ucontext.h> file to define symbolic names for offsets into
44 * gregs[], but it's conditional on __USE_GNU and not defined, so
45 * we need to do this nasty absolute index magic number thing
47 os_context_register_t *
48 os_context_register_addr(os_context_t *context, int offset)
51 case 0: return &context->uc_mcontext.gregs[11]; /* EAX */
52 case 2: return &context->uc_mcontext.gregs[10]; /* ECX */
53 case 4: return &context->uc_mcontext.gregs[9]; /* EDX */
54 case 6: return &context->uc_mcontext.gregs[8]; /* EBX */
55 case 8: return &context->uc_mcontext.gregs[7]; /* ESP */
56 case 10: return &context->uc_mcontext.gregs[6]; /* EBP */
57 case 12: return &context->uc_mcontext.gregs[5]; /* ESI */
58 case 14: return &context->uc_mcontext.gregs[4]; /* EDI */
61 return &context->uc_mcontext.gregs[offset];
64 os_context_register_t *
65 os_context_pc_addr(os_context_t *context)
67 return &context->uc_mcontext.gregs[14]; /* REG_EIP */
70 os_context_register_t *
71 os_context_sp_addr(os_context_t *context)
73 return &context->uc_mcontext.gregs[17]; /* REG_UESP */
76 os_context_register_t *
77 os_context_fp_addr(os_context_t *context)
79 return &context->uc_mcontext.gregs[6]; /* REG_EBP */
83 os_context_fp_control(os_context_t *context)
85 return ((((context->uc_mcontext.fpregs->cw) & 0xffff) ^ 0x3f) |
86 (((context->uc_mcontext.fpregs->sw) & 0xffff) << 16));
90 os_context_sigmask_addr(os_context_t *context)
92 return &context->uc_sigmask;
96 os_restore_fp_control(os_context_t *context)
98 asm ("fldcw %0" : : "m" (context->uc_mcontext.fpregs->cw));
102 os_flush_icache(os_vm_address_t address, os_vm_size_t length)