1.0.12.40: NetBSD/Sparc port by Robert Swindells
[sbcl.git] / src / runtime / sparc-bsd.c
1 /*
2  * This is the SPARC BSD 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 #include "validate.h"
38
39 #ifdef LISP_FEATURE_SB_THREAD
40 #error "Define threading support functions"
41 #else
42 int arch_os_thread_init(struct thread *thread) {
43    return 1;                   /* success */
44 }
45 int arch_os_thread_cleanup(struct thread *thread) {
46    return 1;                   /* success */
47 }
48 #endif
49
50 os_context_register_t   *
51 os_context_register_addr(os_context_t *context, int offset)
52 {
53    if (offset == 0) {
54        static int zero;
55        zero = 0;
56        return &zero;
57    } else if (offset < 16) {
58        return &context->uc_mcontext.__gregs[offset+3];
59    } else if (offset < 32) {
60        /* FIXME: You know, this (int *) stuff looks decidedly
61           dubious */
62        int *sp = (int*) _UC_MACHINE_SP(context);
63        return &(sp[offset-16]);
64    } else {
65        return 0;
66    }
67 }
68
69 os_context_register_t *
70 os_context_pc_addr(os_context_t *context)
71 {
72    return &(context->uc_mcontext.__gregs[_REG_PC]);
73 }
74
75 os_context_register_t *
76 os_context_npc_addr(os_context_t *context)
77 {
78    return &(context->uc_mcontext.__gregs[_REG_nPC]);
79 }
80
81 #ifdef SOLARIS
82 sigset_t *
83 os_context_sigmask_addr(os_context_t *context)
84 {
85    return &(context->uc_sigmask);
86 }
87 #endif
88
89 unsigned long
90 os_context_fp_control(os_context_t *context)
91 {
92    return (context->uc_mcontext.__fpregs.__fpu_fsr);
93 }
94
95 void os_flush_icache(os_vm_address_t address, os_vm_size_t length)
96 {
97    /* see sparc-assem.S */
98    sparc_flush_icache(address, length);
99 }