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