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;
45 /* KLUDGE: As of kernel 2.2.14 on Red Hat 6.2, there's code in the
46 * <sys/ucontext.h> file to define symbolic names for offsets into
47 * gregs[], but it's conditional on __USE_GNU and not defined, so
48 * we need to do this nasty absolute index magic number thing
50 os_context_register_t *
51 os_context_register_addr(os_context_t *context, int offset)
54 case 0: return &context->uc_mcontext.gregs[11]; /* EAX */
55 case 2: return &context->uc_mcontext.gregs[10]; /* ECX */
56 case 4: return &context->uc_mcontext.gregs[9]; /* EDX */
57 case 6: return &context->uc_mcontext.gregs[8]; /* EBX */
58 case 8: return &context->uc_mcontext.gregs[7]; /* ESP */
59 case 10: return &context->uc_mcontext.gregs[6]; /* EBP */
60 case 12: return &context->uc_mcontext.gregs[5]; /* ESI */
61 case 14: return &context->uc_mcontext.gregs[4]; /* EDI */
64 return &context->uc_mcontext.gregs[offset];
67 os_context_register_t *
68 os_context_pc_addr(os_context_t *context)
70 return &context->uc_mcontext.gregs[14];
73 os_context_register_t *
74 os_context_sp_addr(os_context_t *context)
76 return &context->uc_mcontext.gregs[17];
80 os_context_fp_control(os_context_t *context)
82 return ((((context->uc_mcontext.fpregs->cw) & 0xffff) ^ 0x3f) |
83 (((context->uc_mcontext.fpregs->sw) & 0xffff) << 16));
87 os_context_sigmask_addr(os_context_t *context)
89 return &context->uc_sigmask;
93 os_restore_fp_control(os_context_t *context)
95 asm ("fldcw %0" : : "m" (context->uc_mcontext.fpregs->cw));
99 os_flush_icache(os_vm_address_t address, os_vm_size_t length)