0.8.2.35
[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 #ifdef LISP_FEATURE_SB_THREAD
41 #error "Define threading support functions"
42 #else
43 struct thread *arch_os_get_current_thread() {
44     return all_threads;
45 }
46 int arch_os_thread_init(struct thread *thread) {
47     return 1;                   /* success */
48 }
49 int arch_os_thread_cleanup(struct thread *thread) {
50     return 1;                   /* success */
51 }
52 #endif
53
54 os_context_register_t   *
55 os_context_register_addr(os_context_t *context, int offset)
56 {
57     if (offset == 0) {
58         static int zero;
59         zero = 0;
60         return &zero;
61     } else if (offset < 16) {
62         return &context->si_regs.u_regs[offset];
63     } else if (offset < 32) {
64         int *sp = (int*) context->si_regs.u_regs[14]; /* Stack Pointer */
65         return &(sp[offset-16]);
66     } else
67         return 0;
68 }
69
70 os_context_register_t *
71 os_context_pc_addr(os_context_t *context)
72 {
73     return &(context->si_regs.pc);
74 }
75
76 os_context_register_t *
77 os_context_npc_addr(os_context_t *context)
78 {
79     return &(context->si_regs.npc);
80 }
81
82 sigset_t *
83 os_context_sigmask_addr(os_context_t *context)
84 {
85     return &(context->si_mask);
86 }
87
88 void 
89 os_restore_fp_control(os_context_t *context)
90 {
91     /* Included here, for reference, is an attempt at the PPC
92        variant. If it weren't the case that SPARC/Linux gave a Bus
93        Error on floating point exceptions, something like this would
94        have to be done. -- CSR, 2002-07-13
95
96     asm ("msfsf $255, %0" : : "m" 
97          (os_context_fp_control(context) & 
98           ~ (FLOAT_STICKY_BITS_MASK | FLOAT_EXCEPTIONS_BYTE_MASK)));
99     */
100 }
101
102 void 
103 os_flush_icache(os_vm_address_t address, os_vm_size_t length)
104 {
105     /* This is the same for linux and solaris, so see sparc-assem.S */
106     sparc_flush_icache(address,length);
107 }