9d4d683e4d17316f451206b9344a8b58176bc5ce
[sbcl.git] / src / runtime / sparc-linux-os.c
1 /*
2  * This is the SPARC Linux incarnation of arch-dependent OS-dependent
3  * routines. See also "linux-os.c".
4  */
5
6 /*
7  * This software is part of the SBCL system. See the README file for
8  * more information.
9  *
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.
15  */
16
17 #include <stdio.h>
18 #include <sys/param.h>
19 #include <sys/file.h>
20 #include "./signal.h"
21 #include "os.h"
22 #include "arch.h"
23 #include "globals.h"
24 #include "interrupt.h"
25 #include "interr.h"
26 #include "lispregs.h"
27 #include "sbcl.h"
28 #include <sys/socket.h>
29 #include <sys/utsname.h>
30
31 #include <sys/types.h>
32 #include <signal.h>
33 #include <sys/time.h>
34 #include <sys/stat.h>
35 #include <unistd.h>
36
37 #include "validate.h"
38 size_t os_vm_page_size;
39
40 #if defined GENCGC              /* unlikely ... */
41 #include "gencgc.h"
42 #endif
43
44 os_context_register_t   *
45 os_context_register_addr(os_context_t *context, int offset)
46 {
47     if (offset == 0) {
48         static int zero;
49         zero = 0;
50         return &zero;
51     } else if (offset < 16) {
52         return &context->si_regs.u_regs[offset];
53     } else if (offset < 32) {
54         int *sp = (int*) context->si_regs.u_regs[14]; /* Stack Pointer */
55         return &(sp[offset-16]);
56     } else
57         return 0;
58 }
59
60 os_context_register_t *
61 os_context_pc_addr(os_context_t *context)
62 {
63     return &(context->si_regs.pc);
64 }
65
66 os_context_register_t *
67 os_context_npc_addr(os_context_t *context)
68 {
69     return &(context->si_regs.npc);
70 }
71
72 sigset_t *
73 os_context_sigmask_addr(os_context_t *context)
74 {
75     return &(context->si_mask);
76 }
77
78 void 
79 os_restore_fp_control(os_context_t *context)
80 {
81     /* Included here, for reference, is an attempt at the PPC
82        variant. If it weren't the case that SPARC/Linux gave a Bus
83        Error on floating point exceptions, something like this would
84        have to be done. -- CSR, 2002-07-13
85
86     asm ("msfsf $255, %0" : : "m" 
87          (os_context_fp_control(context) & 
88           ~ (FLOAT_STICKY_BITS_MASK | FLOAT_EXCEPTIONS_BYTE_MASK)));
89     */
90 }
91
92 void 
93 os_flush_icache(os_vm_address_t address, os_vm_size_t length)
94 {
95     /* This is the same for linux and solaris, so see sparc-assem.S */
96     sparc_flush_icache(address,length);
97 }