]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/thread_act.h
30bf02c8e7158839861f33b11d573203022be9f1
[apple/xnu.git] / osfmk / ppc / thread_act.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 * @OSF_COPYRIGHT@
24 *
25 */
26
27 #ifndef _PPC_THREAD_ACT_H_
28 #define _PPC_THREAD_ACT_H_
29
30 #include <mach_kgdb.h>
31 #include <mach/boolean.h>
32 #include <mach/ppc/vm_types.h>
33 #include <mach/thread_status.h>
34 #include <kern/lock.h>
35 #include <kern/clock.h>
36
37
38 /*
39 * Kernel state structure
40 *
41 * This holds the kernel state that is saved and restored across context
42 * switches. This is kept at the top of the kernel stack.
43 *
44 * XXX Some state is saved only because it is not saved on entry to the
45 * kernel from user mode. This needs to be straightened out.
46 */
47
48 /*
49 * PPC process control block
50 *
51 * In the continuation model, the PCB holds the user context. It is used
52 * on entry to the kernel from user mode, either by system call or trap,
53 * to store the necessary user registers and other state.
54 *
55 * Note that this structure overlays a savearea. Make sure that these
56 * guys are updated in concert with that.
57 */
58 struct pcb
59 {
60 struct ppc_saved_state ss;
61 struct ppc_exception_state es;
62 struct ppc_float_state fs;
63 unsigned int gas1[6]; /* Force alignment with savearea */
64 struct ppc_vector_state vec;
65
66 };
67
68 typedef struct pcb *pcb_t;
69
70 /*
71 * Maps state flavor to number of words in the state:
72 */
73 extern unsigned int state_count[];
74
75 #define USER_REGS(ThrAct) (&(ThrAct)->mact.pcb->ss)
76
77 #define user_pc(ThrAct) ((ThrAct)->mact.pcb->ss.srr0)
78
79 #define act_machine_state_ptr(ThrAct) (thread_state_t)USER_REGS(ThrAct)
80
81 typedef struct MachineThrAct {
82 /*
83 * pointer to process control block control blocks. Potentially
84 * one for each active facility context. They may point to the
85 * same saveareas.
86 */
87 pcb_t pcb; /* The "normal" savearea */
88 pcb_t FPU_pcb; /* The floating point savearea */
89 pcb_t FPU_lvl; /* The floating point context level */
90 unsigned int FPU_cpu; /* The last processor to enable floating point */
91 pcb_t VMX_pcb; /* The VMX savearea */
92 pcb_t VMX_lvl; /* The VMX context level */
93 unsigned int VMX_cpu; /* The last processor to enable vector */
94 struct vmmCntrlEntry *vmmCEntry; /* Pointer current emulation context or 0 */
95 struct vmmCntrlTable *vmmControl; /* Pointer to virtual machine monitor control table */
96 AbsoluteTime qactTimer; /* Time thread needs to interrupt. This is a single-shot timer. Zero is unset */
97 unsigned int ksp; /* points to TOP OF STACK or zero */
98 unsigned int bbDescAddr; /* Points to Blue Box Trap descriptor area in kernel (page aligned) */
99 unsigned int bbUserDA; /* Points to Blue Box Trap descriptor area in user (page aligned) */
100 unsigned int bbTableStart; /* Points to Blue Box Trap dispatch area in user */
101 unsigned int bbPendRupt; /* Number of pending Blue Box interruptions */
102 unsigned int bbTaskID; /* Opaque task ID for Blue Box threads */
103 unsigned int bbTaskEnv; /* Opaque task data reference for Blue Box threads */
104 unsigned int specFlags; /* Special flags */
105
106 /* special flags bits */
107
108 #define ignoreZeroFaultbit 0
109 #define floatUsedbit 1
110 #define vectorUsedbit 2
111 #define bbNoMachSCbit 3
112 #define runningVMbit 4
113 #define floatCngbit 5
114 #define vectorCngbit 6
115 #define timerPopbit 7
116
117 #define ignoreZeroFault (1<<(31-ignoreZeroFaultbit))
118 #define floatUsed (1<<(31-floatUsedbit))
119 #define vectorUsed (1<<(31-vectorUsedbit))
120 #define bbNoMachSC (1<<(31-bbNoMachSCbit))
121 #define runningVM (1<<(31-runningVMbit))
122 #define floatCng (1<<(31-floatCngbit))
123 #define vectorCng (1<<(31-vectorCngbit))
124 #define timerPop (1<<(31-timerPopbit))
125
126 #ifdef MACH_BSD
127 unsigned long cthread_self; /* for use of cthread package */
128 #endif
129
130 } MachineThrAct, *MachineThrAct_t;
131
132 extern struct ppc_saved_state * find_user_regs(thread_act_t act);
133 extern struct ppc_float_state * find_user_fpu(thread_act_t act);
134
135 #endif /* _PPC_THREAD_ACT_H_ */