5e25e80de081003e84366a273b9cbdee2be03247
[sbcl.git] / src / runtime / alpha-linux-os.c
1 /*
2  * This is the Compaq/Digital Alpha Linux incarnation of
3  * arch-dependent OS-dependent routines. See also "linux-os.c".  */
4
5 /*
6  * This software is part of the SBCL system. See the README file for
7  * more information.
8  *
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.
14  */
15
16 /* These header files were lifted wholesale from linux-os.c, some may
17  * be redundant. -- Dan Barlow ca. 2001-05-01 */
18 #include <stdio.h>
19 #include <sys/param.h>
20 #include <sys/file.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 "sbcl.h"
29 #include <sys/socket.h>
30 #include <sys/utsname.h>
31
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 <asm/fpu.h>
38
39 #include "validate.h"
40 size_t os_vm_page_size;
41
42 #ifdef LISP_FEATURE_SB_THREAD
43 #error "Define threading support functions"
44 #else
45 struct thread *arch_os_get_current_thread() {
46     return all_threads;
47 }
48 int arch_os_thread_init(struct thread *thread) {
49     return 1;                   /* success */
50 }
51 int arch_os_thread_cleanup(struct thread *thread) {
52     return 1;                   /* success */
53 }
54 #endif
55
56
57 os_context_register_t   *
58 os_context_register_addr(os_context_t *context, int offset)
59 {
60     return &context->uc_mcontext.sc_regs[offset];
61 }
62
63 os_context_register_t *
64 os_context_float_register_addr(os_context_t *context, int offset)
65 {
66     return &context->uc_mcontext.sc_fpregs[offset];
67 }
68
69 os_context_register_t *
70 os_context_pc_addr(os_context_t *context)
71 {
72     return &((context->uc_mcontext).sc_pc);
73 }
74
75 sigset_t *
76 os_context_sigmask_addr(os_context_t *context)
77 {
78     return &context->uc_sigmask;
79 }
80
81 unsigned long
82 os_context_fp_control(os_context_t *context)
83 {
84     return ieee_fpcr_to_swcr((context->uc_mcontext).sc_fpcr);
85 }
86
87 void
88 os_restore_fp_control(os_context_t *context)
89 {
90     /* FIXME: 0x7E0000 is defined as something useful in constants.h,
91        but without the L, which would probably lead to 32/64-bit
92        errors if we simply used it here.  Ugh.  CSR, 2003-09-15 */
93     arch_set_fp_control(os_context_fp_control(context) & ~(0x7e0000L));
94 }
95
96 void os_flush_icache(os_vm_address_t address, os_vm_size_t length)
97 {
98     asm volatile ("imb" : : : "memory" );
99 }