]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
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 | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
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. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * @OSF_COPYRIGHT@ | |
27 | * | |
28 | */ | |
29 | ||
30 | #ifndef _PPC_THREAD_ACT_H_ | |
31 | #define _PPC_THREAD_ACT_H_ | |
32 | ||
33 | #include <mach_kgdb.h> | |
34 | #include <mach/boolean.h> | |
35 | #include <mach/ppc/vm_types.h> | |
36 | #include <mach/thread_status.h> | |
37 | #include <kern/lock.h> | |
38 | #include <kern/clock.h> | |
9bccf70c | 39 | #include <ppc/savearea.h> |
1c79356b | 40 | |
1c79356b A |
41 | /* |
42 | * Kernel state structure | |
43 | * | |
44 | * This holds the kernel state that is saved and restored across context | |
0b4e3aa0 | 45 | * switches. |
1c79356b A |
46 | */ |
47 | ||
48 | /* | |
49 | * PPC process control block | |
50 | * | |
9bccf70c A |
51 | * The PCB holds normal context. It does not contain vector or floating point |
52 | * registers. | |
1c79356b | 53 | * |
1c79356b | 54 | */ |
1c79356b | 55 | |
9bccf70c A |
56 | typedef struct savearea pcb; |
57 | typedef struct savearea *pcb_t; | |
58 | ||
59 | struct facility_context { | |
60 | ||
61 | savearea_fpu *FPUsave; /* The floating point savearea */ | |
62 | savearea *FPUlevel; /* The floating point context level */ | |
63 | unsigned int FPUcpu; /* The last processor to enable floating point */ | |
55e303ae | 64 | unsigned int FPUsync; /* Sync lock */ |
9bccf70c A |
65 | savearea_vec *VMXsave; /* The VMX savearea */ |
66 | savearea *VMXlevel; /* The VMX context level */ | |
67 | unsigned int VMXcpu; /* The last processor to enable vector */ | |
55e303ae | 68 | unsigned int VMXsync; /* Sync lock */ |
9bccf70c | 69 | struct thread_activation *facAct; /* Activation associated with context */ |
1c79356b A |
70 | }; |
71 | ||
9bccf70c | 72 | typedef struct facility_context facility_context; |
1c79356b A |
73 | |
74 | /* | |
75 | * Maps state flavor to number of words in the state: | |
76 | */ | |
77 | extern unsigned int state_count[]; | |
78 | ||
9bccf70c | 79 | #define USER_REGS(ThrAct) ((ThrAct)->mact.pcb) |
1c79356b | 80 | |
9bccf70c | 81 | #define user_pc(ThrAct) ((ThrAct)->mact.pcb->save_srr0) |
1c79356b A |
82 | |
83 | #define act_machine_state_ptr(ThrAct) (thread_state_t)USER_REGS(ThrAct) | |
84 | ||
85 | typedef struct MachineThrAct { | |
86 | /* | |
87 | * pointer to process control block control blocks. Potentially | |
88 | * one for each active facility context. They may point to the | |
89 | * same saveareas. | |
90 | */ | |
9bccf70c | 91 | savearea *pcb; /* The "normal" savearea */ |
55e303ae | 92 | savearea *upcb; /* The "normal" user savearea */ |
9bccf70c A |
93 | facility_context *curctx; /* Current facility context */ |
94 | facility_context *deferctx; /* Deferred facility context */ | |
95 | facility_context facctx; /* "Normal" facility context */ | |
1c79356b A |
96 | struct vmmCntrlEntry *vmmCEntry; /* Pointer current emulation context or 0 */ |
97 | struct vmmCntrlTable *vmmControl; /* Pointer to virtual machine monitor control table */ | |
0b4e3aa0 | 98 | uint64_t qactTimer; /* Time thread needs to interrupt. This is a single-shot timer. Zero is unset */ |
55e303ae A |
99 | unsigned int cioSpace; /* Address space ID for in progress copyin/out */ |
100 | #define cioSwitchAway 0x80000000 /* Context switched away from thread since MapUserAddressSpace */ | |
101 | #define cioSwitchAwayb 0 | |
102 | addr64_t cioRelo; /* Relocation value for in progress copyin/out */ | |
1c79356b | 103 | unsigned int ksp; /* points to TOP OF STACK or zero */ |
55e303ae | 104 | unsigned int preemption_count; /* preemption count */ |
1c79356b A |
105 | unsigned int bbDescAddr; /* Points to Blue Box Trap descriptor area in kernel (page aligned) */ |
106 | unsigned int bbUserDA; /* Points to Blue Box Trap descriptor area in user (page aligned) */ | |
107 | unsigned int bbTableStart; /* Points to Blue Box Trap dispatch area in user */ | |
0b4e3aa0 | 108 | unsigned int emPendRupts; /* Number of pending emulated interruptions */ |
1c79356b A |
109 | unsigned int bbTaskID; /* Opaque task ID for Blue Box threads */ |
110 | unsigned int bbTaskEnv; /* Opaque task data reference for Blue Box threads */ | |
111 | unsigned int specFlags; /* Special flags */ | |
55e303ae A |
112 | unsigned int pmcovfl[8]; /* PMC overflow count */ |
113 | unsigned int perfmonFlags; /* Perfmon facility flags */ | |
114 | unsigned int bbTrap; /* Blue Box trap vector */ | |
115 | unsigned int bbSysCall; /* Blue Box syscall vector */ | |
116 | unsigned int bbInterrupt; /* Blue Box interrupt vector */ | |
117 | unsigned int bbPending; /* Blue Box pending interrupt vector */ | |
1c79356b A |
118 | |
119 | /* special flags bits */ | |
120 | ||
121 | #define ignoreZeroFaultbit 0 | |
122 | #define floatUsedbit 1 | |
123 | #define vectorUsedbit 2 | |
1c79356b A |
124 | #define runningVMbit 4 |
125 | #define floatCngbit 5 | |
126 | #define vectorCngbit 6 | |
127 | #define timerPopbit 7 | |
0b4e3aa0 | 128 | #define userProtKeybit 8 |
55e303ae | 129 | #define FamVMenabit 11 |
d7e50217 | 130 | #define FamVMmodebit 12 |
55e303ae | 131 | #define perfMonitorbit 13 |
0b4e3aa0 A |
132 | /* NOTE: Do not move or assign bit 31 without changing exception vector ultra fast path code */ |
133 | #define bbThreadbit 28 | |
134 | #define bbNoMachSCbit 29 | |
135 | #define bbPreemptivebit 30 | |
136 | #define spfReserved1 31 /* See note above */ | |
1c79356b | 137 | |
55e303ae A |
138 | #define ignoreZeroFault 0x80000000 /* (1<<(31-ignoreZeroFaultbit)) */ |
139 | #define floatUsed 0x40000000 /* (1<<(31-floatUsedbit)) */ | |
140 | #define vectorUsed 0x20000000 /* (1<<(31-vectorUsedbit)) */ | |
141 | ||
142 | #define runningVM 0x08000000 /* (1<<(31-runningVMbit)) */ | |
143 | #define floatCng 0x04000000 /* (1<<(31-floatCngbit)) */ | |
144 | #define vectorCng 0x02000000 /* (1<<(31-vectorCngbit)) */ | |
145 | #define timerPop 0x01000000 /* (1<<(31-timerPopbit)) */ | |
146 | ||
147 | #define userProtKey 0x00800000 /* (1<<(31-userProtKeybit)) */ | |
148 | ||
149 | #define FamVMena 0x00100000 /* (1<<(31-FamVMenabit)) */ | |
150 | #define FamVMmode 0x00080000 /* (1<<(31-FamVMmodebit)) */ | |
151 | #define perfMonitor 0x00040000 /* (1<<(31-perfMonitorbit)) */ | |
152 | ||
153 | #define bbThread 0x00000008 /* (1<<(31-bbThreadbit)) */ | |
154 | #define bbNoMachSC 0x00000004 /* (1<<(31-bbNoMachSCbit)) */ | |
155 | #define bbPreemptive 0x00000002 /* (1<<(31-bbPreemptivebit)) */ | |
0b4e3aa0 A |
156 | |
157 | #define fvChkb 0 | |
158 | #define fvChk 0x80000000 | |
1c79356b A |
159 | |
160 | #ifdef MACH_BSD | |
161 | unsigned long cthread_self; /* for use of cthread package */ | |
162 | #endif | |
163 | ||
164 | } MachineThrAct, *MachineThrAct_t; | |
165 | ||
9bccf70c A |
166 | extern struct savearea *find_user_regs(thread_act_t act); |
167 | extern struct savearea *get_user_regs(thread_act_t); | |
168 | extern struct savearea_fpu *find_user_fpu(thread_act_t act); | |
169 | extern struct savearea_vec *find_user_vec(thread_act_t act); | |
55e303ae | 170 | extern struct savearea_vec *find_user_vec_curr(void); |
9bccf70c | 171 | extern int thread_enable_fpe(thread_act_t act, int onoff); |
1c79356b | 172 | |
55e303ae A |
173 | extern struct savearea *find_kern_regs(thread_act_t act); |
174 | ||
0b4e3aa0 A |
175 | extern void *act_thread_csave(void); |
176 | extern void act_thread_catt(void *ctx); | |
177 | extern void act_thread_cfree(void *ctx); | |
178 | ||
9bccf70c A |
179 | #define current_act_fast() current_act() |
180 | ||
1c79356b | 181 | #endif /* _PPC_THREAD_ACT_H_ */ |