]> git.saurik.com Git - apple/xnu.git/blame - osfmk/mach/ppc/thread_status.h
xnu-344.21.73.tar.gz
[apple/xnu.git] / osfmk / mach / ppc / thread_status.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
d7e50217 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
d7e50217
A
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
d7e50217
A
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/*
26 * @OSF_COPYRIGHT@
27 */
28
29#ifndef _MACH_PPC_THREAD_STATUS_H_
30#define _MACH_PPC_THREAD_STATUS_H_
31
9bccf70c
A
32#include <sys/appleapiopts.h>
33
34#ifdef MACH_KERNEL_PRIVATE
35#include <ppc/savearea.h>
36#endif
1c79356b
A
37/*
38 * ppc_thread_state is the structure that is exported to user threads for
39 * use in status/mutate calls. This structure should never change.
40 *
41 */
42
43#define PPC_THREAD_STATE 1
44#define PPC_FLOAT_STATE 2
45#define PPC_EXCEPTION_STATE 3
46#define PPC_VECTOR_STATE 4
d7e50217
A
47#define PPC_THREAD_STATE64 5
48#define PPC_EXCEPTION_STATE64 6
1c79356b
A
49#define THREAD_STATE_NONE 7
50
51/*
52 * VALID_THREAD_STATE_FLAVOR is a platform specific macro that when passed
53 * an exception flavor will return whether that is a defined flavor for
54 * that platform.
55 * The macro must be manually updated to include all of the valid exception
56 * flavors as defined above.
57 */
58#define VALID_THREAD_STATE_FLAVOR(x) \
59 ((x == PPC_THREAD_STATE) || \
60 (x == PPC_FLOAT_STATE) || \
d7e50217 61 (x == PPC_EXCEPTION_STATE) || \
1c79356b 62 (x == PPC_VECTOR_STATE) || \
d7e50217
A
63 (x == PPC_THREAD_STATE64) || \
64 (x == PPC_EXCEPTION_STATE64) || \
1c79356b
A
65 (x == THREAD_STATE_NONE))
66
67typedef struct ppc_thread_state {
68 unsigned int srr0; /* Instruction address register (PC) */
69 unsigned int srr1; /* Machine state register (supervisor) */
70 unsigned int r0;
71 unsigned int r1;
72 unsigned int r2;
73 unsigned int r3;
74 unsigned int r4;
75 unsigned int r5;
76 unsigned int r6;
77 unsigned int r7;
78 unsigned int r8;
79 unsigned int r9;
80 unsigned int r10;
81 unsigned int r11;
82 unsigned int r12;
83 unsigned int r13;
84 unsigned int r14;
85 unsigned int r15;
86 unsigned int r16;
87 unsigned int r17;
88 unsigned int r18;
89 unsigned int r19;
90 unsigned int r20;
91 unsigned int r21;
92 unsigned int r22;
93 unsigned int r23;
94 unsigned int r24;
95 unsigned int r25;
96 unsigned int r26;
97 unsigned int r27;
98 unsigned int r28;
99 unsigned int r29;
100 unsigned int r30;
101 unsigned int r31;
102
103 unsigned int cr; /* Condition register */
104 unsigned int xer; /* User's integer exception register */
105 unsigned int lr; /* Link register */
106 unsigned int ctr; /* Count register */
107 unsigned int mq; /* MQ register (601 only) */
108
109 unsigned int vrsave; /* Vector Save Register */
110} ppc_thread_state_t;
111
d7e50217
A
112#pragma pack(4) /* Make sure the structure stays as we defined it */
113typedef struct ppc_thread_state64 {
114 unsigned long long srr0; /* Instruction address register (PC) */
115 unsigned long long srr1; /* Machine state register (supervisor) */
116 unsigned long long r0;
117 unsigned long long r1;
118 unsigned long long r2;
119 unsigned long long r3;
120 unsigned long long r4;
121 unsigned long long r5;
122 unsigned long long r6;
123 unsigned long long r7;
124 unsigned long long r8;
125 unsigned long long r9;
126 unsigned long long r10;
127 unsigned long long r11;
128 unsigned long long r12;
129 unsigned long long r13;
130 unsigned long long r14;
131 unsigned long long r15;
132 unsigned long long r16;
133 unsigned long long r17;
134 unsigned long long r18;
135 unsigned long long r19;
136 unsigned long long r20;
137 unsigned long long r21;
138 unsigned long long r22;
139 unsigned long long r23;
140 unsigned long long r24;
141 unsigned long long r25;
142 unsigned long long r26;
143 unsigned long long r27;
144 unsigned long long r28;
145 unsigned long long r29;
146 unsigned long long r30;
147 unsigned long long r31;
148
149 unsigned int cr; /* Condition register */
150 unsigned long long xer; /* User's integer exception register */
151 unsigned long long lr; /* Link register */
152 unsigned long long ctr; /* Count register */
153
154 unsigned int vrsave; /* Vector Save Register */
155} ppc_thread_state64_t;
156#pragma pack()
157
1c79356b
A
158/* This structure should be double-word aligned for performance */
159
160typedef struct ppc_float_state {
161 double fpregs[32];
162
163 unsigned int fpscr_pad; /* fpscr is 64 bits, 32 bits of rubbish */
164 unsigned int fpscr; /* floating point status register */
165} ppc_float_state_t;
166
167typedef struct ppc_vector_state {
168 unsigned long save_vr[32][4];
169 unsigned long save_vscr[4];
170 unsigned int save_pad5[4];
171 unsigned int save_vrvalid; /* VRs that have been saved */
172 unsigned int save_pad6[7];
173} ppc_vector_state_t;
174
175/*
176 * saved state structure
177 *
9bccf70c 178 * This structure corresponds to the saved state.
1c79356b
A
179 *
180 */
181
9bccf70c
A
182#if defined(__APPLE_API_PRIVATE) && defined(MACH_KERNEL_PRIVATE)
183typedef struct savearea ppc_saved_state_t;
184#else
185typedef struct ppc_thread_state ppc_saved_state_t;
186#endif /* __APPLE_API_PRIVATE && MACH_KERNEL_PRIVATE */
1c79356b
A
187
188/*
189 * ppc_exception_state
190 *
191 * This structure corresponds to some additional state of the user
192 * registers as saved in the PCB upon kernel entry. They are only
193 * available if an exception is passed out of the kernel, and even
194 * then not all are guaranteed to be updated.
195 *
196 * Some padding is included in this structure which allows space for
197 * servers to store temporary values if need be, to maintain binary
198 * compatiblity.
199 */
200
201typedef struct ppc_exception_state {
d7e50217 202 unsigned long dar; /* Fault registers for coredump */
1c79356b 203 unsigned long dsisr;
d7e50217
A
204 unsigned long exception; /* number of powerpc exception taken */
205 unsigned long pad0; /* align to 16 bytes */
1c79356b 206
d7e50217 207 unsigned long pad1[4]; /* space in PCB "just in case" */
1c79356b
A
208} ppc_exception_state_t;
209
d7e50217
A
210#pragma pack(4) /* Make sure the structure stays as we defined it */
211typedef struct ppc_exception_state64 {
212 unsigned long long dar; /* Fault registers for coredump */
213 unsigned long dsisr;
214 unsigned long exception; /* number of powerpc exception taken */
215
216 unsigned long pad1[4]; /* space in PCB "just in case" */
217} ppc_exception_state64_t;
218#pragma pack()
219
1c79356b
A
220/*
221 * Save State Flags
222 */
223
224#define PPC_THREAD_STATE_COUNT \
225 (sizeof(struct ppc_thread_state) / sizeof(int))
226
d7e50217
A
227#define PPC_THREAD_STATE64_COUNT \
228 (sizeof(struct ppc_thread_state64) / sizeof(int))
229
1c79356b
A
230#define PPC_EXCEPTION_STATE_COUNT \
231 (sizeof(struct ppc_exception_state) / sizeof(int))
232
d7e50217
A
233#define PPC_EXCEPTION_STATE64_COUNT \
234 (sizeof(struct ppc_exception_state64) / sizeof(int))
235
1c79356b
A
236#define PPC_FLOAT_STATE_COUNT \
237 (sizeof(struct ppc_float_state) / sizeof(int))
238
239#define PPC_VECTOR_STATE_COUNT \
240 (sizeof(struct ppc_vector_state) / sizeof(int))
241
242/*
243 * Machine-independent way for servers and Mach's exception mechanism to
244 * choose the most efficient state flavor for exception RPC's:
245 */
246#define MACHINE_THREAD_STATE PPC_THREAD_STATE
247#define MACHINE_THREAD_STATE_COUNT PPC_THREAD_STATE_COUNT
248
249/*
250 * Largest state on this machine:
251 */
252#define THREAD_MACHINE_STATE_MAX PPC_VECTOR_STATE_COUNT
253
254#endif /* _MACH_PPC_THREAD_STATUS_H_ */