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