2 * This is the IBM/Motorola/Apple/whoever Linux incarnation of
3 * arch-dependent OS-dependent routines. See also "linux-os.c". */
6 * This software is part of the SBCL system. See the README file for
9 * This software is derived from the CMU CL system, which was
10 * written at Carnegie Mellon University and released into the
11 * public domain. The software is in the public domain and is
12 * provided with absolutely no warranty. See the COPYING and CREDITS
13 * files for more information.
16 /* These header files were lifted wholesale from linux-os.c, some may
17 * be redundant. -- Dan Barlow ca. 2001-05-01 */
19 #include <sys/param.h>
26 #include "interrupt.h"
29 #include <sys/socket.h>
30 #include <sys/utsname.h>
32 #include <sys/types.h>
39 #include "ppc-linux-mcontext.h"
41 size_t os_vm_page_size
;
43 int arch_os_thread_init(struct thread
*thread
) {
44 return 1; /* success */
46 int arch_os_thread_cleanup(struct thread
*thread
) {
47 return 1; /* success */
50 os_context_register_t
*
51 os_context_register_addr(os_context_t
*context
, int offset
)
53 #if defined(GLIBC231_STYLE_UCONTEXT)
54 return &((context
->uc_mcontext
.regs
)->gpr
[offset
]);
55 #elif defined(GLIBC232_STYLE_UCONTEXT)
56 return &((context
->uc_mcontext
.uc_regs
->gregs
)[offset
]);
60 os_context_register_t
*
61 os_context_pc_addr(os_context_t
*context
)
63 #if defined(GLIBC231_STYLE_UCONTEXT)
64 return &((context
->uc_mcontext
.regs
)->nip
);
65 #elif defined(GLIBC232_STYLE_UCONTEXT)
66 return &((context
->uc_mcontext
.uc_regs
->gregs
)[PT_NIP
]);
70 os_context_register_t
*
71 os_context_lr_addr(os_context_t
*context
)
73 #if defined(GLIBC231_STYLE_UCONTEXT)
74 return &((context
->uc_mcontext
.regs
)->link
);
75 #elif defined(GLIBC232_STYLE_UCONTEXT)
76 return &((context
->uc_mcontext
.uc_regs
->gregs
)[PT_LNK
]);
81 os_context_sigmask_addr(os_context_t
*context
)
83 #if defined(GLIBC231_STYLE_UCONTEXT)
84 return &context
->uc_sigmask
;
85 #elif defined(GLIBC232_STYLE_UCONTEXT)
86 return &context
->uc_sigmask
;
91 os_context_fp_control(os_context_t
*context
)
93 /* So this may look like nice, well behaved code. However, closer
94 inspection reveals that gpr is simply the general purpose
95 registers, and PT_FPSCR is an offset that is larger than 32
96 (the number of ppc registers), but that happens to get the
97 right answer. -- CSR, 2002-07-11 */
98 #if defined(GLIBC231_STYLE_UCONTEXT)
99 return context
->uc_mcontext
.regs
->gpr
[PT_FPSCR
];
100 #elif defined(GLIBC232_STYLE_UCONTEXT)
101 return context
->uc_mcontext
.uc_regs
->gregs
[PT_FPSCR
];
106 os_restore_fp_control(os_context_t
*context
)
108 unsigned long control
;
111 control
= os_context_fp_control(context
) &
112 /* FIXME: Should we preserve the user's requested rounding mode?
116 ~(FLOAT_STICKY_BITS_MASK | FLOAT_EXCEPTIONS_BYTE_MASK)
118 here leads to infinite SIGFPE for invalid operations, as
119 there are bits in the control register that need to be
120 cleared that are let through by that mask. -- CSR, 2002-07-16 */
122 FLOAT_TRAPS_BYTE_MASK
;
124 d
= *((double *) &control
);
125 /* Hmp. Apparently the following doesn't work either:
127 asm volatile ("mtfsf 0xff,%0" : : "f" (d));
129 causing segfaults at the first GC.
134 os_flush_icache(os_vm_address_t address
, os_vm_size_t length
)
137 ppc_flush_icache(address
,length
);