2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
23 * @APPLE_LICENSE_HEADER_END@
29 #ifndef _MACH_PPC_THREAD_STATUS_H_
30 #define _MACH_PPC_THREAD_STATUS_H_
32 #include <sys/appleapiopts.h>
34 #ifdef MACH_KERNEL_PRIVATE
35 #include <ppc/savearea.h>
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.
43 #define PPC_THREAD_STATE 1
44 #define PPC_FLOAT_STATE 2
45 #define PPC_EXCEPTION_STATE 3
46 #define PPC_VECTOR_STATE 4
47 #define PPC_THREAD_STATE64 5
48 #define PPC_EXCEPTION_STATE64 6
49 #define THREAD_STATE_NONE 7
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
55 * The macro must be manually updated to include all of the valid exception
56 * flavors as defined above.
58 #define VALID_THREAD_STATE_FLAVOR(x) \
59 ((x == PPC_THREAD_STATE) || \
60 (x == PPC_FLOAT_STATE) || \
61 (x == PPC_EXCEPTION_STATE) || \
62 (x == PPC_VECTOR_STATE) || \
63 (x == PPC_THREAD_STATE64) || \
64 (x == PPC_EXCEPTION_STATE64) || \
65 (x == THREAD_STATE_NONE))
67 typedef struct ppc_thread_state
{
68 unsigned int srr0
; /* Instruction address register (PC) */
69 unsigned int srr1
; /* Machine state register (supervisor) */
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) */
109 unsigned int vrsave
; /* Vector Save Register */
110 } ppc_thread_state_t
;
112 #pragma pack(4) /* Make sure the structure stays as we defined it */
113 typedef 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
;
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 */
154 unsigned int vrsave
; /* Vector Save Register */
155 } ppc_thread_state64_t
;
158 /* This structure should be double-word aligned for performance */
160 typedef struct ppc_float_state
{
163 unsigned int fpscr_pad
; /* fpscr is 64 bits, 32 bits of rubbish */
164 unsigned int fpscr
; /* floating point status register */
167 typedef 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
;
176 * saved state structure
178 * This structure corresponds to the saved state.
182 #if defined(__APPLE_API_PRIVATE) && defined(MACH_KERNEL_PRIVATE)
183 typedef struct savearea ppc_saved_state_t
;
185 typedef struct ppc_thread_state ppc_saved_state_t
;
186 #endif /* __APPLE_API_PRIVATE && MACH_KERNEL_PRIVATE */
189 * ppc_exception_state
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.
196 * Some padding is included in this structure which allows space for
197 * servers to store temporary values if need be, to maintain binary
201 typedef struct ppc_exception_state
{
202 unsigned long dar
; /* Fault registers for coredump */
204 unsigned long exception
; /* number of powerpc exception taken */
205 unsigned long pad0
; /* align to 16 bytes */
207 unsigned long pad1
[4]; /* space in PCB "just in case" */
208 } ppc_exception_state_t
;
210 #pragma pack(4) /* Make sure the structure stays as we defined it */
211 typedef struct ppc_exception_state64
{
212 unsigned long long dar
; /* Fault registers for coredump */
214 unsigned long exception
; /* number of powerpc exception taken */
216 unsigned long pad1
[4]; /* space in PCB "just in case" */
217 } ppc_exception_state64_t
;
224 #define PPC_THREAD_STATE_COUNT \
225 (sizeof(struct ppc_thread_state) / sizeof(int))
227 #define PPC_THREAD_STATE64_COUNT \
228 (sizeof(struct ppc_thread_state64) / sizeof(int))
230 #define PPC_EXCEPTION_STATE_COUNT \
231 (sizeof(struct ppc_exception_state) / sizeof(int))
233 #define PPC_EXCEPTION_STATE64_COUNT \
234 (sizeof(struct ppc_exception_state64) / sizeof(int))
236 #define PPC_FLOAT_STATE_COUNT \
237 (sizeof(struct ppc_float_state) / sizeof(int))
239 #define PPC_VECTOR_STATE_COUNT \
240 (sizeof(struct ppc_vector_state) / sizeof(int))
243 * Machine-independent way for servers and Mach's exception mechanism to
244 * choose the most efficient state flavor for exception RPC's:
246 #define MACHINE_THREAD_STATE PPC_THREAD_STATE
247 #define MACHINE_THREAD_STATE_COUNT PPC_THREAD_STATE_COUNT
250 * Largest state on this machine:
252 #define THREAD_MACHINE_STATE_MAX THREAD_STATE_MAX
254 #endif /* _MACH_PPC_THREAD_STATUS_H_ */