]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
91447636 | 2 | * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. |
1c79356b | 3 | * |
8ad349bb | 4 | * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ |
1c79356b | 5 | * |
8ad349bb A |
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 | |
10 | * License may not be used to create, or enable the creation or | |
11 | * redistribution of, unlawful or unlicensed copies of an Apple operating | |
12 | * system, or to circumvent, violate, or enable the circumvention or | |
13 | * violation of, any terms of an Apple operating system software license | |
14 | * agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
18 | * file. | |
19 | * | |
20 | * The Original Code and all software distributed under the License are | |
21 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
22 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
23 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
24 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
25 | * Please see the License for the specific language governing rights and | |
26 | * limitations under the License. | |
27 | * | |
28 | * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ | |
1c79356b A |
29 | */ |
30 | /* | |
31 | * @OSF_COPYRIGHT@ | |
32 | */ | |
33 | ||
34 | /* | |
35 | * File: machine/thread.h | |
36 | * | |
37 | * This file contains the structure definitions for the thread | |
38 | * state as applied to PPC processors. | |
39 | */ | |
40 | ||
41 | #ifndef _PPC_THREAD_H_ | |
42 | #define _PPC_THREAD_H_ | |
43 | ||
91447636 A |
44 | #include <mach/boolean.h> |
45 | #include <mach/ppc/vm_types.h> | |
46 | #include <mach/thread_status.h> | |
47 | #include <kern/lock.h> | |
48 | #include <kern/clock.h> | |
49 | #include <ppc/savearea.h> | |
50 | ||
51 | /* | |
52 | * Kernel state structure | |
53 | * | |
54 | * This holds the kernel state that is saved and restored across context | |
55 | * switches. | |
56 | */ | |
57 | ||
58 | /* | |
59 | * PPC process control block | |
60 | * | |
61 | * The PCB holds normal context. It does not contain vector or floating point | |
62 | * registers. | |
63 | * | |
64 | */ | |
65 | ||
66 | typedef struct savearea pcb; | |
67 | typedef struct savearea *pcb_t; | |
68 | ||
69 | struct facility_context { | |
70 | ||
71 | savearea_fpu *FPUsave; /* The floating point savearea */ | |
72 | savearea *FPUlevel; /* The floating point context level */ | |
73 | unsigned int FPUcpu; /* The last processor to enable floating point */ | |
74 | unsigned int FPUsync; /* Sync lock */ | |
75 | savearea_vec *VMXsave; /* The VMX savearea */ | |
76 | savearea *VMXlevel; /* The VMX context level */ | |
77 | unsigned int VMXcpu; /* The last processor to enable vector */ | |
78 | unsigned int VMXsync; /* Sync lock */ | |
79 | struct thread *facAct; | |
80 | }; | |
81 | ||
82 | typedef struct facility_context facility_context; | |
83 | ||
84 | /* | |
85 | * Maps state flavor to number of words in the state: | |
86 | */ | |
87 | __private_extern__ unsigned int _MachineStateCount[]; | |
88 | ||
89 | #define USER_REGS(ThrAct) ((ThrAct)->machine.pcb) | |
90 | ||
91 | #define user_pc(ThrAct) ((ThrAct)->machine.pcb->save_srr0) | |
92 | ||
93 | #define act_machine_state_ptr(ThrAct) (thread_state_t)USER_REGS(ThrAct) | |
94 | ||
95 | struct machine_thread { | |
96 | /* | |
97 | * pointer to process control block control blocks. Potentially | |
98 | * one for each active facility context. They may point to the | |
99 | * same saveareas. | |
100 | */ | |
101 | savearea *pcb; /* The "normal" savearea */ | |
102 | savearea *upcb; /* The "normal" user savearea */ | |
103 | facility_context *curctx; /* Current facility context */ | |
104 | facility_context *deferctx; /* Deferred facility context */ | |
105 | facility_context facctx; /* "Normal" facility context */ | |
106 | struct vmmCntrlEntry *vmmCEntry; /* Pointer current emulation context or 0 */ | |
107 | struct vmmCntrlTable *vmmControl; /* Pointer to virtual machine monitor control table */ | |
108 | uint64_t qactTimer; /* Time thread needs to interrupt. This is a single-shot timer. Zero is unset */ | |
109 | unsigned int umwSpace; /* Address space ID for user memory window */ | |
110 | #define umwSwitchAway 0x80000000 /* Context switched away from thread since MapUserAddressWindow */ | |
111 | #define umwSwitchAwayb 0 | |
112 | addr64_t umwRelo; /* Relocation value for user memory window */ | |
113 | unsigned int ksp; /* points to TOP OF STACK or zero */ | |
114 | unsigned int preemption_count; /* preemption count */ | |
115 | struct per_proc_info *PerProc; /* current per processor data */ | |
116 | unsigned int bbDescAddr; /* Points to Blue Box Trap descriptor area in kernel (page aligned) */ | |
117 | unsigned int bbUserDA; /* Points to Blue Box Trap descriptor area in user (page aligned) */ | |
118 | unsigned int bbTableStart; /* Points to Blue Box Trap dispatch area in user */ | |
119 | unsigned int emPendRupts; /* Number of pending emulated interruptions */ | |
120 | unsigned int bbTaskID; /* Opaque task ID for Blue Box threads */ | |
121 | unsigned int bbTaskEnv; /* Opaque task data reference for Blue Box threads */ | |
122 | unsigned int specFlags; /* Special flags */ | |
123 | unsigned int pmcovfl[8]; /* PMC overflow count */ | |
124 | unsigned int perfmonFlags; /* Perfmon facility flags */ | |
125 | unsigned int bbTrap; /* Blue Box trap vector */ | |
126 | unsigned int bbSysCall; /* Blue Box syscall vector */ | |
127 | unsigned int bbInterrupt; /* Blue Box interrupt vector */ | |
128 | unsigned int bbPending; /* Blue Box pending interrupt vector */ | |
129 | ||
130 | /* special flags bits */ | |
131 | ||
132 | #define ignoreZeroFaultbit 0 | |
133 | #define floatUsedbit 1 | |
134 | #define vectorUsedbit 2 | |
135 | #define runningVMbit 4 | |
136 | #define floatCngbit 5 | |
137 | #define vectorCngbit 6 | |
138 | #define timerPopbit 7 | |
139 | #define userProtKeybit 8 | |
140 | #define FamVMenabit 11 | |
141 | #define FamVMmodebit 12 | |
142 | #define perfMonitorbit 13 | |
143 | #define OnProcbit 14 | |
144 | /* NOTE: Do not move or assign bit 31 without changing exception vector ultra fast path code */ | |
145 | #define bbThreadbit 28 | |
146 | #define bbNoMachSCbit 29 | |
147 | #define bbPreemptivebit 30 | |
148 | #define spfReserved1 31 /* See note above */ | |
149 | ||
150 | #define ignoreZeroFault 0x80000000 /* (1<<(31-ignoreZeroFaultbit)) */ | |
151 | #define floatUsed 0x40000000 /* (1<<(31-floatUsedbit)) */ | |
152 | #define vectorUsed 0x20000000 /* (1<<(31-vectorUsedbit)) */ | |
153 | ||
154 | #define runningVM 0x08000000 /* (1<<(31-runningVMbit)) */ | |
155 | #define floatCng 0x04000000 /* (1<<(31-floatCngbit)) */ | |
156 | #define vectorCng 0x02000000 /* (1<<(31-vectorCngbit)) */ | |
157 | #define timerPop 0x01000000 /* (1<<(31-timerPopbit)) */ | |
158 | ||
159 | #define userProtKey 0x00800000 /* (1<<(31-userProtKeybit)) */ | |
160 | ||
161 | #define FamVMena 0x00100000 /* (1<<(31-FamVMenabit)) */ | |
162 | #define FamVMmode 0x00080000 /* (1<<(31-FamVMmodebit)) */ | |
163 | #define perfMonitor 0x00040000 /* (1<<(31-perfMonitorbit)) */ | |
164 | #define OnProc 0x00020000 /* (1<<(31-OnProcbit)) */ | |
165 | ||
166 | #define bbThread 0x00000008 /* (1<<(31-bbThreadbit)) */ | |
167 | #define bbNoMachSC 0x00000004 /* (1<<(31-bbNoMachSCbit)) */ | |
168 | #define bbPreemptive 0x00000002 /* (1<<(31-bbPreemptivebit)) */ | |
169 | ||
170 | #define fvChkb 0 | |
171 | #define fvChk 0x80000000 | |
172 | ||
173 | #ifdef MACH_BSD | |
174 | uint64_t cthread_self; /* for use of cthread package */ | |
175 | #endif | |
176 | ||
177 | }; | |
178 | ||
179 | extern struct savearea *find_user_regs(thread_t); | |
180 | extern struct savearea *get_user_regs(thread_t); | |
181 | extern struct savearea_fpu *find_user_fpu(thread_t); | |
182 | extern struct savearea_vec *find_user_vec(thread_t); | |
183 | extern struct savearea_vec *find_user_vec_curr(void); | |
184 | extern int thread_enable_fpe(thread_t act, int onoff); | |
185 | ||
186 | extern struct savearea *find_kern_regs(thread_t); | |
187 | ||
188 | extern void *act_thread_csave(void); | |
189 | extern void act_thread_catt(void *ctx); | |
190 | extern void act_thread_cfree(void *ctx); | |
1c79356b A |
191 | |
192 | /* | |
193 | * Return address of the function that called current function, given | |
194 | * address of the first parameter of current function. We can't | |
195 | * do it this way, since parameter was copied from a register | |
196 | * into a local variable. Call an assembly sub-function to | |
197 | * return this. | |
198 | */ | |
199 | ||
200 | extern vm_offset_t getrpc(void); | |
201 | #define GET_RETURN_PC(addr) getrpc() | |
202 | ||
203 | #define STACK_IKS(stack) \ | |
204 | ((vm_offset_t)(((vm_offset_t)stack)+KERNEL_STACK_SIZE)-FM_SIZE) | |
205 | ||
1c79356b A |
206 | /* |
207 | * Defining this indicates that MD code will supply an exception() | |
208 | * routine, conformant with kern/exception.c (dependency alert!) | |
209 | * but which does wonderfully fast, machine-dependent magic. | |
210 | */ | |
211 | ||
212 | #define MACHINE_FAST_EXCEPTION 1 | |
213 | ||
214 | #endif /* _PPC_THREAD_H_ */ |