]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/ppc/thread_status.h
xnu-344.49.tar.gz
[apple/xnu.git] / osfmk / mach / ppc / thread_status.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
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
13 * file.
14 *
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.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * @OSF_COPYRIGHT@
27 */
28
29 #ifndef _MACH_PPC_THREAD_STATUS_H_
30 #define _MACH_PPC_THREAD_STATUS_H_
31
32 #include <sys/appleapiopts.h>
33
34 #ifdef MACH_KERNEL_PRIVATE
35 #include <ppc/savearea.h>
36 #endif
37 /*
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.
40 *
41 */
42
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
48
49 /*
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
52 * that platform.
53 * The macro must be manually updated to include all of the valid exception
54 * flavors as defined above.
55 */
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))
62
63 typedef struct ppc_thread_state {
64 unsigned int srr0; /* Instruction address register (PC) */
65 unsigned int srr1; /* Machine state register (supervisor) */
66 unsigned int r0;
67 unsigned int r1;
68 unsigned int r2;
69 unsigned int r3;
70 unsigned int r4;
71 unsigned int r5;
72 unsigned int r6;
73 unsigned int r7;
74 unsigned int r8;
75 unsigned int r9;
76 unsigned int r10;
77 unsigned int r11;
78 unsigned int r12;
79 unsigned int r13;
80 unsigned int r14;
81 unsigned int r15;
82 unsigned int r16;
83 unsigned int r17;
84 unsigned int r18;
85 unsigned int r19;
86 unsigned int r20;
87 unsigned int r21;
88 unsigned int r22;
89 unsigned int r23;
90 unsigned int r24;
91 unsigned int r25;
92 unsigned int r26;
93 unsigned int r27;
94 unsigned int r28;
95 unsigned int r29;
96 unsigned int r30;
97 unsigned int r31;
98
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) */
104
105 unsigned int vrsave; /* Vector Save Register */
106 } ppc_thread_state_t;
107
108 /* This structure should be double-word aligned for performance */
109
110 typedef struct ppc_float_state {
111 double fpregs[32];
112
113 unsigned int fpscr_pad; /* fpscr is 64 bits, 32 bits of rubbish */
114 unsigned int fpscr; /* floating point status register */
115 } ppc_float_state_t;
116
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;
124
125 /*
126 * saved state structure
127 *
128 * This structure corresponds to the saved state.
129 *
130 */
131
132 #if defined(__APPLE_API_PRIVATE) && defined(MACH_KERNEL_PRIVATE)
133 typedef struct savearea ppc_saved_state_t;
134 #else
135 typedef struct ppc_thread_state ppc_saved_state_t;
136 #endif /* __APPLE_API_PRIVATE && MACH_KERNEL_PRIVATE */
137
138 /*
139 * ppc_exception_state
140 *
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.
145 *
146 * Some padding is included in this structure which allows space for
147 * servers to store temporary values if need be, to maintain binary
148 * compatiblity.
149 */
150
151 typedef struct ppc_exception_state {
152 unsigned long dar; /* Fault registers for coredump */
153 unsigned long dsisr;
154 unsigned long exception;/* number of powerpc exception taken */
155 unsigned long pad0; /* align to 16 bytes */
156
157 unsigned long pad1[4]; /* space in PCB "just in case" */
158 } ppc_exception_state_t;
159
160 /*
161 * Save State Flags
162 */
163
164 #define PPC_THREAD_STATE_COUNT \
165 (sizeof(struct ppc_thread_state) / sizeof(int))
166
167 #define PPC_EXCEPTION_STATE_COUNT \
168 (sizeof(struct ppc_exception_state) / sizeof(int))
169
170 #define PPC_FLOAT_STATE_COUNT \
171 (sizeof(struct ppc_float_state) / sizeof(int))
172
173 #define PPC_VECTOR_STATE_COUNT \
174 (sizeof(struct ppc_vector_state) / sizeof(int))
175
176 /*
177 * Machine-independent way for servers and Mach's exception mechanism to
178 * choose the most efficient state flavor for exception RPC's:
179 */
180 #define MACHINE_THREAD_STATE PPC_THREAD_STATE
181 #define MACHINE_THREAD_STATE_COUNT PPC_THREAD_STATE_COUNT
182
183 /*
184 * Largest state on this machine:
185 */
186 #define THREAD_MACHINE_STATE_MAX PPC_VECTOR_STATE_COUNT
187
188 #endif /* _MACH_PPC_THREAD_STATUS_H_ */