0.7.7.9:
[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 "./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 /* for cacheflush() */
39 #include <asm/cachectl.h>
40
41 /* FIXME: For CAUSEF_BD */
42 #include <asm/mipsregs.h>
43 size_t os_vm_page_size;
44
45
46 os_context_register_t *
47 os_context_register_addr(os_context_t *context, int offset)
48 {
49     if (offset == 0) {
50         /* KLUDGE: I'm not sure, but it's possible that Linux puts the
51            contents of the Processor Status Word in the (wired-zero)
52            slot in the mcontext. In any case, the following is
53            unlikely to do any harm: */
54         static unsigned long long zero;
55         zero = 0;
56         return &zero;
57     } else {
58         return &(((struct sigcontext *) &(context->uc_mcontext))->sc_regs[offset]);
59     }
60 }
61
62 os_context_register_t *
63 os_context_pc_addr(os_context_t *context)
64 {
65     /* Why do I get all the silly ports? -- CSR, 2002-08-11 */
66     return &(((struct sigcontext *) &(context->uc_mcontext))->sc_pc);
67 }
68
69 sigset_t *
70 os_context_sigmask_addr(os_context_t *context)
71 {
72     return &(context->uc_sigmask);
73 }
74
75 void 
76 os_restore_fp_control(os_context_t *context)
77 {
78     /* FIXME: Probably do something. */
79 }
80
81 unsigned int
82 os_context_bd_cause(os_context_t *context)
83 {
84     /* We need to see if whatever happened, happened because of a
85        branch delay event */
86     return (((struct sigcontext *) &(context->uc_mcontext))->sc_cause 
87             & CAUSEF_BD);
88 }
89
90 void 
91 os_flush_icache(os_vm_address_t address, os_vm_size_t length)
92 {
93     if (cacheflush(address, length, ICACHE) == -1)
94         perror("cacheflush");
95 }