0.9.13.27:
[sbcl.git] / src / runtime / ppc-darwin-os.c
1 /*
2  * This is the PowerPC/Darwin incarnation of arch-dependent
3  * OS-dependent routines. See also "bsdos.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 "sbcl.h"
18 #include "globals.h"
19 #include "runtime.h"
20 #include <signal.h>
21 #include <ucontext.h>
22 #include <limits.h>
23 #include <mach-o/dyld.h>
24 #include "bsd-os.h"
25
26 #ifdef LISP_FEATURE_SB_THREAD
27 #error "Define threading support functions"
28 #else
29 int arch_os_thread_init(struct thread *thread) {
30     return 1;                   /* success */
31 }
32 int arch_os_thread_cleanup(struct thread *thread) {
33     return 1;                   /* success */
34 }
35 #endif
36
37 os_context_register_t   *
38 os_context_register_addr(os_context_t *context, int offset)
39 {
40     ppc_saved_state_t *state = &context->uc_mcontext->ss;
41     switch(offset) {
42     case 0:
43         return &state->r0;
44     case 1:
45         return &state->r1;
46     case 2:
47         return &state->r2;
48     case 3:
49         return &state->r3;
50     case 4:
51         return &state->r4;
52     case 5:
53         return &state->r5;
54     case 6:
55         return &state->r6;
56     case 7:
57         return &state->r7;
58     case 8:
59         return &state->r8;
60     case 9:
61         return &state->r9;
62     case 10:
63         return &state->r10;
64     case 11:
65         return &state->r11;
66     case 12:
67         return &state->r12;
68     case 13:
69         return &state->r13;
70     case 14:
71         return &state->r14;
72     case 15:
73         return &state->r15;
74     case 16:
75         return &state->r16;
76     case 17:
77         return &state->r17;
78     case 18:
79         return &state->r18;
80     case 19:
81         return &state->r19;
82     case 20:
83         return &state->r20;
84     case 21:
85         return &state->r21;
86     case 22:
87         return &state->r22;
88     case 23:
89         return &state->r23;
90     case 24:
91         return &state->r24;
92     case 25:
93         return &state->r25;
94     case 26:
95         return &state->r26;
96     case 27:
97         return &state->r27;
98     case 28:
99         return &state->r28;
100     case 29:
101         return &state->r29;
102     case 30:
103         return &state->r30;
104     case 31:
105         return &state->r31;
106     case 41:
107         /* PT_DAR */
108         return &context->uc_mcontext->es.dar;
109     case 42:
110         /* PT_DSISR */
111         return &context->uc_mcontext->es.dsisr;
112     }
113 }
114
115 os_context_register_t *
116 os_context_lr_addr(os_context_t *context)
117 {
118     return &context->uc_mcontext->ss.lr;
119 }
120
121 void
122 os_flush_icache(os_vm_address_t address, os_vm_size_t length)
123 {
124     /* see ppc-arch.c */
125     ppc_flush_icache(address,length);
126 }
127