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 THREAD_STATE_NONE 7
50 * VALID_THREAD_STATE_FLAVOR is a platform specific macro that when passed
51 * an exception flavor will return whether that is a defined flavor for
53 * The macro must be manually updated to include all of the valid exception
54 * flavors as defined above.
56 #define VALID_THREAD_STATE_FLAVOR(x) \
57 ((x == PPC_THREAD_STATE) || \
58 (x == PPC_FLOAT_STATE) || \
59 (x == PPC_EXCEPTION_STATE) || \
60 (x == PPC_VECTOR_STATE) || \
61 (x == THREAD_STATE_NONE))
63 typedef struct ppc_thread_state
{
64 unsigned int srr0
; /* Instruction address register (PC) */
65 unsigned int srr1
; /* Machine state register (supervisor) */
99 unsigned int cr
; /* Condition register */
100 unsigned int xer
; /* User's integer exception register */
101 unsigned int lr
; /* Link register */
102 unsigned int ctr
; /* Count register */
103 unsigned int mq
; /* MQ register (601 only) */
105 unsigned int vrsave
; /* Vector Save Register */
106 } ppc_thread_state_t
;
108 /* This structure should be double-word aligned for performance */
110 typedef struct ppc_float_state
{
113 unsigned int fpscr_pad
; /* fpscr is 64 bits, 32 bits of rubbish */
114 unsigned int fpscr
; /* floating point status register */
117 typedef struct ppc_vector_state
{
118 unsigned long save_vr
[32][4];
119 unsigned long save_vscr
[4];
120 unsigned int save_pad5
[4];
121 unsigned int save_vrvalid
; /* VRs that have been saved */
122 unsigned int save_pad6
[7];
123 } ppc_vector_state_t
;
126 * saved state structure
128 * This structure corresponds to the saved state.
132 #if defined(__APPLE_API_PRIVATE) && defined(MACH_KERNEL_PRIVATE)
133 typedef struct savearea ppc_saved_state_t
;
135 typedef struct ppc_thread_state ppc_saved_state_t
;
136 #endif /* __APPLE_API_PRIVATE && MACH_KERNEL_PRIVATE */
139 * ppc_exception_state
141 * This structure corresponds to some additional state of the user
142 * registers as saved in the PCB upon kernel entry. They are only
143 * available if an exception is passed out of the kernel, and even
144 * then not all are guaranteed to be updated.
146 * Some padding is included in this structure which allows space for
147 * servers to store temporary values if need be, to maintain binary
151 typedef struct ppc_exception_state
{
152 unsigned long dar
; /* Fault registers for coredump */
154 unsigned long exception
;/* number of powerpc exception taken */
155 unsigned long pad0
; /* align to 16 bytes */
157 unsigned long pad1
[4]; /* space in PCB "just in case" */
158 } ppc_exception_state_t
;
164 #define PPC_THREAD_STATE_COUNT \
165 (sizeof(struct ppc_thread_state) / sizeof(int))
167 #define PPC_EXCEPTION_STATE_COUNT \
168 (sizeof(struct ppc_exception_state) / sizeof(int))
170 #define PPC_FLOAT_STATE_COUNT \
171 (sizeof(struct ppc_float_state) / sizeof(int))
173 #define PPC_VECTOR_STATE_COUNT \
174 (sizeof(struct ppc_vector_state) / sizeof(int))
177 * Machine-independent way for servers and Mach's exception mechanism to
178 * choose the most efficient state flavor for exception RPC's:
180 #define MACHINE_THREAD_STATE PPC_THREAD_STATE
181 #define MACHINE_THREAD_STATE_COUNT PPC_THREAD_STATE_COUNT
184 * Largest state on this machine:
186 #define THREAD_MACHINE_STATE_MAX PPC_VECTOR_STATE_COUNT
188 #endif /* _MACH_PPC_THREAD_STATUS_H_ */