0.9.2.42:
[sbcl.git] / src / runtime / mips-linux-os.c
1 /*
2  * This is the MIPS 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 "sbcl.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 <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 /* for cacheflush() */
38 #include <sys/cachectl.h>
39
40 #include "validate.h"
41
42 size_t os_vm_page_size;
43
44 int
45 arch_os_thread_init(struct thread *thread)
46 {
47 #ifdef LISP_FEATURE_SB_THREAD
48 #warning "Check threading support functions"
49 #endif
50     return 1;                  /* success */
51 }
52
53 int
54 arch_os_thread_cleanup(struct thread *thread)
55 {
56 #ifdef LISP_FEATURE_SB_THREAD
57 #warning "Check threading support functions"
58 #endif
59     return 1;                  /* success */
60 }
61
62 os_context_register_t *
63 os_context_register_addr(os_context_t *context, int offset)
64 {
65     return &(((struct sigcontext *)&(context->uc_mcontext))->sc_regs[offset]);
66 }
67
68 os_context_register_t *
69 os_context_pc_addr(os_context_t *context)
70 {
71     /* Why do I get all the silly ports? -- CSR, 2002-08-11 */
72     return &(((struct sigcontext *)&(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 int
82 os_context_fp_control(os_context_t *context)
83 {
84     /* FIXME: Probably do something. */
85 }
86
87 void
88 os_restore_fp_control(os_context_t *context)
89 {
90     /* FIXME: Probably do something. */
91 }
92
93 unsigned int
94 os_context_bd_cause(os_context_t *context)
95 {
96     /* We need to see if whatever happened, happened because of a
97        branch delay event */
98     /* FIXME: However, I'm not convinced that the values that Linux
99        puts in this slot are actually right; specifically, attempting
100        to compile sbcl with sbcl-0.7.7.7 lead to an "infinite SIGTRAP
101        loop" where a (BREAK 16) not in a branch delay slot would have
102        CAUSEF_BD filled. So, we comment
103
104         #include <asm/mipsregs.h>
105
106         return (((struct sigcontext *) &(context->uc_mcontext))->sc_cause
107                 & CAUSEF_BD);
108
109        out and return 0 always.  -- CSR, 2002-09-02 */
110     return 0;
111 }
112
113 void
114 os_flush_icache(os_vm_address_t address, os_vm_size_t length)
115 {
116     if (cacheflush(address, length, ICACHE) == -1)
117         perror("cacheflush");
118 }