1/*
2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28/*
29 * @OSF_COPYRIGHT@
30 */
31
32#ifndef	_MACH_PPC_THREAD_STATUS_H_
33#define _MACH_PPC_THREAD_STATUS_H_
34
35#include <mach/ppc/_structs.h>
36#include <mach/message.h>
37
38/*
39 * ppc_thread_state is the structure that is exported to user threads for
40 * use in status/mutate calls.  This structure should never change.
41 *
42 */
43
44#define PPC_THREAD_STATE        1
45#define PPC_FLOAT_STATE         2
46#define PPC_EXCEPTION_STATE		3
47#define PPC_VECTOR_STATE		4
48#define PPC_THREAD_STATE64		5
49#define PPC_EXCEPTION_STATE64	6
50/*
51#define THREAD_STATE_NONE		7
52*/
53
54/*
55 * VALID_THREAD_STATE_FLAVOR is a platform specific macro that when passed
56 * an exception flavor will return whether that is a defined flavor for
57 * that platform.
58 * The macro must be manually updated to include all of the valid exception
59 * flavors as defined above.
60 */
61/*
62#define VALID_THREAD_STATE_FLAVOR(x)       \
63        ((x == PPC_THREAD_STATE)        || \
64         (x == PPC_FLOAT_STATE)         || \
65	 (x == PPC_EXCEPTION_STATE)     	|| \
66         (x == PPC_VECTOR_STATE)        || \
67         (x == PPC_THREAD_STATE64)      || \
68         (x == PPC_EXCEPTION_STATE64)   || \
69         (x == THREAD_STATE_NONE))
70*/
71
72typedef _STRUCT_PPC_THREAD_STATE	ppc_thread_state_t;
73#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
74typedef _STRUCT_PPC_THREAD_STATE64	ppc_thread_state64_t;
75#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
76typedef _STRUCT_PPC_FLOAT_STATE		ppc_float_state_t;
77typedef _STRUCT_PPC_VECTOR_STATE	ppc_vector_state_t;
78
79/*
80 * saved state structure
81 *
82 * This structure corresponds to the saved state.
83 *
84 */
85
86#ifdef	MACH__POSIX_C_SOURCE_PRIVATE
87
88#include <ppc/savearea.h>
89
90typedef struct savearea				ppc_saved_state_t;
91
92#else	/* MACH__POSIX_C_SOURCE_PRIVATE */
93
94typedef struct ppc_thread_state			ppc_saved_state_t;
95
96#endif	/* MACH__POSIX_C_SOURCE_PRIVATE */
97
98/*
99 * ppc_exception_state
100 *
101 * This structure corresponds to some additional state of the user
102 * registers as saved in the PCB upon kernel entry. They are only
103 * available if an exception is passed out of the kernel, and even
104 * then not all are guaranteed to be updated.
105 *
106 * Some padding is included in this structure which allows space for
107 * servers to store temporary values if need be, to maintain binary
108 * compatiblity.
109 */
110
111/* Exception state for 32-bit thread (on 32-bit processor) */
112/* Still available on 64-bit processors, but may fall short */
113/* of covering the full potential state (hi half available). */
114
115typedef _STRUCT_PPC_EXCEPTION_STATE	ppc_exception_state_t;
116#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
117typedef _STRUCT_PPC_EXCEPTION_STATE64	ppc_exception_state64_t;
118#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
119
120/*
121 * Save State Flags
122 */
123
124#define PPC_THREAD_STATE_COUNT ((mach_msg_type_number_t) \
125   (sizeof(ppc_thread_state_t) / sizeof(int)))
126
127#define PPC_THREAD_STATE64_COUNT ((mach_msg_type_number_t) \
128   (sizeof(ppc_thread_state64_t) / sizeof(int)))
129
130#define PPC_EXCEPTION_STATE_COUNT ((mach_msg_type_number_t) \
131   (sizeof(ppc_exception_state_t) / sizeof(int)))
132
133#define PPC_EXCEPTION_STATE64_COUNT ((mach_msg_type_number_t) \
134   (sizeof(ppc_exception_state64_t) / sizeof(int)))
135
136#define PPC_FLOAT_STATE_COUNT ((mach_msg_type_number_t) \
137   (sizeof(ppc_float_state_t) / sizeof(int)))
138
139#define PPC_VECTOR_STATE_COUNT ((mach_msg_type_number_t) \
140   (sizeof(ppc_vector_state_t) / sizeof(int)))
141
142/*
143 * Machine-independent way for servers and Mach's exception mechanism to
144 * choose the most efficient state flavor for exception RPC's:
145 */
146/*
147#define MACHINE_THREAD_STATE		PPC_THREAD_STATE
148#define MACHINE_THREAD_STATE_COUNT	PPC_THREAD_STATE_COUNT
149*/
150
151/*
152 * Largest state on this machine:
153 */
154#define THREAD_MACHINE_STATE_MAX	THREAD_STATE_MAX
155
156#endif /* _MACH_PPC_THREAD_STATUS_H_ */
157