2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
26 #ifndef _MACH_PPC_THREAD_STATUS_H_
27 #define _MACH_PPC_THREAD_STATUS_H_
29 #include <sys/appleapiopts.h>
31 #ifdef MACH_KERNEL_PRIVATE
32 #include <ppc/savearea.h>
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.
40 #define PPC_THREAD_STATE 1
41 #define PPC_FLOAT_STATE 2
42 #define PPC_EXCEPTION_STATE 3
43 #define PPC_VECTOR_STATE 4
44 #define PPC_THREAD_STATE64 5
45 #define PPC_EXCEPTION_STATE64 6
46 #define THREAD_STATE_NONE 7
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
52 * The macro must be manually updated to include all of the valid exception
53 * flavors as defined above.
55 #define VALID_THREAD_STATE_FLAVOR(x) \
56 ((x == PPC_THREAD_STATE) || \
57 (x == PPC_FLOAT_STATE) || \
58 (x == PPC_EXCEPTION_STATE) || \
59 (x == PPC_VECTOR_STATE) || \
60 (x == PPC_THREAD_STATE64) || \
61 (x == PPC_EXCEPTION_STATE64) || \
62 (x == THREAD_STATE_NONE))
64 typedef struct ppc_thread_state
{
65 unsigned int srr0
; /* Instruction address register (PC) */
66 unsigned int srr1
; /* Machine state register (supervisor) */
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) */
106 unsigned int vrsave
; /* Vector Save Register */
107 } ppc_thread_state_t
;
109 #pragma pack(4) /* Make sure the structure stays as we defined it */
110 typedef 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
;
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 */
151 unsigned int vrsave
; /* Vector Save Register */
152 } ppc_thread_state64_t
;
155 /* This structure should be double-word aligned for performance */
157 typedef struct ppc_float_state
{
160 unsigned int fpscr_pad
; /* fpscr is 64 bits, 32 bits of rubbish */
161 unsigned int fpscr
; /* floating point status register */
164 typedef 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
;
173 * saved state structure
175 * This structure corresponds to the saved state.
179 #if defined(__APPLE_API_PRIVATE) && defined(MACH_KERNEL_PRIVATE)
180 typedef struct savearea ppc_saved_state_t
;
182 typedef struct ppc_thread_state ppc_saved_state_t
;
183 #endif /* __APPLE_API_PRIVATE && MACH_KERNEL_PRIVATE */
186 * ppc_exception_state
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.
193 * Some padding is included in this structure which allows space for
194 * servers to store temporary values if need be, to maintain binary
198 typedef struct ppc_exception_state
{
199 unsigned long dar
; /* Fault registers for coredump */
201 unsigned long exception
; /* number of powerpc exception taken */
202 unsigned long pad0
; /* align to 16 bytes */
204 unsigned long pad1
[4]; /* space in PCB "just in case" */
205 } ppc_exception_state_t
;
207 #pragma pack(4) /* Make sure the structure stays as we defined it */
208 typedef struct ppc_exception_state64
{
209 unsigned long long dar
; /* Fault registers for coredump */
211 unsigned long exception
; /* number of powerpc exception taken */
213 unsigned long pad1
[4]; /* space in PCB "just in case" */
214 } ppc_exception_state64_t
;
221 #define PPC_THREAD_STATE_COUNT \
222 (sizeof(struct ppc_thread_state) / sizeof(int))
224 #define PPC_THREAD_STATE64_COUNT \
225 (sizeof(struct ppc_thread_state64) / sizeof(int))
227 #define PPC_EXCEPTION_STATE_COUNT \
228 (sizeof(struct ppc_exception_state) / sizeof(int))
230 #define PPC_EXCEPTION_STATE64_COUNT \
231 (sizeof(struct ppc_exception_state64) / sizeof(int))
233 #define PPC_FLOAT_STATE_COUNT \
234 (sizeof(struct ppc_float_state) / sizeof(int))
236 #define PPC_VECTOR_STATE_COUNT \
237 (sizeof(struct ppc_vector_state) / sizeof(int))
240 * Machine-independent way for servers and Mach's exception mechanism to
241 * choose the most efficient state flavor for exception RPC's:
243 #define MACHINE_THREAD_STATE PPC_THREAD_STATE
244 #define MACHINE_THREAD_STATE_COUNT PPC_THREAD_STATE_COUNT
247 * Largest state on this machine:
249 #define THREAD_MACHINE_STATE_MAX THREAD_STATE_MAX
251 #endif /* _MACH_PPC_THREAD_STATUS_H_ */