2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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.
23 * @APPLE_LICENSE_HEADER_END@
29 /* Miscellaneous constants and structures used by the exception
33 #ifndef _PPC_EXCEPTION_H_
34 #define _PPC_EXCEPTION_H_
36 #include <ppc/savearea.h>
44 #include <mach/machine/vm_types.h>
45 #include <mach/boolean.h>
46 #include <kern/cpu_data.h>
47 #include <pexpert/pexpert.h>
48 #include <IOKit/IOInterrupts.h>
49 #include <ppc/machine_routines.h>
51 /* Per processor CPU features */
53 unsigned int Available
;
54 #define pfFloat 0x80000000
56 #define pfAltivec 0x40000000
58 #define pfAvJava 0x20000000
60 #define pfSMPcap 0x10000000
62 #define pfCanSleep 0x08000000
64 #define pfCanNap 0x04000000
66 #define pfCanDoze 0x02000000
68 #define pfThermal 0x01000000
70 #define pfThermInt 0x00800000
72 #define pfNoL2PFNap 0x00008000
73 #define pfNoL2PFNapb 16
74 #define pfSlowNap 0x00004000
76 #define pfNoMuMMCK 0x00002000
77 #define pfNoMuMMCKb 18
78 #define pfLClck 0x00001000
80 #define pfWillNap 0x00000800
82 #define pfNoMSRir 0x00000400
84 #define pfL3pdet 0x00000200
86 #define pfL1i 0x00000100
88 #define pfL1d 0x00000080
90 #define pfL1fa 0x00000040
92 #define pfL2 0x00000020
94 #define pfL2fa 0x00000010
96 #define pfL2i 0x00000008
98 #define pfL3 0x00000004
100 #define pfL3fa 0x00000002
102 #define pfValid 0x00000001
104 unsigned short rptdProc
;
105 unsigned short lineSize
;
106 unsigned int l1iSize
;
107 unsigned int l1dSize
;
116 unsigned int pfMSSCR0
;
117 unsigned int pfMSSCR1
;
118 unsigned int pfICTRL
;
119 unsigned int pfLDSTCR
;
120 unsigned int pfLDSTDB
;
121 unsigned int l2crOriginal
;
122 unsigned int l3crOriginal
;
123 unsigned int pfBootConfig
;
124 unsigned int reserved
[4];
127 typedef struct procFeatures procFeatures
;
130 unsigned int maxTemp
; /* Maximum temprature before damage */
131 unsigned int throttleTemp
; /* Temprature at which to throttle down */
132 unsigned int lowTemp
; /* Interrupt when temprature drops below */
133 unsigned int highTemp
; /* Interrupt when temprature exceeds this */
134 unsigned int thrm3val
; /* Value for thrm3 register */
135 unsigned int rsvd
[3]; /* Pad to cache line */
138 typedef struct thrmControl thrmControl
;
140 /* When an exception is taken, this info is accessed via sprg0 */
141 /* We should always have this one on a cache line boundary */
142 struct per_proc_info
{
143 unsigned short cpu_number
;
144 unsigned short cpu_flags
; /* Various low-level flags */
145 vm_offset_t istackptr
;
146 vm_offset_t intstack_top_ss
;
148 vm_offset_t debstackptr
;
149 vm_offset_t debstack_top_ss
;
151 unsigned int tempwork1
; /* Temp work area - monitor use carefully */
152 unsigned int save_exception_type
;
153 unsigned int old_thread
;
155 /* PPC cache line boundary here - 020 */
157 unsigned int active_kloaded
; /* pointer to active_kloaded[CPU_NO] */
158 unsigned int active_stacks
; /* pointer to active_stacks[CPU_NO] */
159 unsigned int need_ast
; /* pointer to need_ast[CPU_NO] */
161 * Note: the following two pairs of words need to stay in order and each pair must
162 * be in the same reservation (line) granule
164 struct facility_context
*FPU_owner
; /* Owner of the FPU on this cpu */
166 struct facility_context
*VMX_owner
; /* Owner of the VMX on this cpu */
168 unsigned int next_savearea
; /* pointer to the next savearea */
170 /* PPC cache line boundary here - 040 */
171 unsigned int quickfret
; /* List of saveareas to release */
172 unsigned int lclfree
; /* Pointer to local savearea list */
173 unsigned int lclfreecnt
; /* Entries in local savearea list */
174 unsigned int Lastpmap
; /* Last user pmap loaded */
175 unsigned int userspace
; /* Last loaded user memory space ID */
176 unsigned int userpmap
; /* User pmap - real address */
177 unsigned int liveVRSave
; /* VRSave assiciated with live vector registers */
178 unsigned int spcFlags
; /* Special thread flags */
180 /* PPC cache line boundary here - 060 */
181 boolean_t interrupts_enabled
;
182 unsigned int ppbbTaskEnv
; /* BlueBox Task Environment */
183 IOInterruptHandler interrupt_handler
;
184 void * interrupt_nub
;
185 unsigned int interrupt_source
;
186 void * interrupt_target
;
187 void * interrupt_refCon
;
188 time_base_enable_t time_base_enable
;
190 /* PPC cache line boundary here - 080 */
191 unsigned int MPsigpStat
; /* Signal Processor status (interlocked update for this one) */
192 #define MPsigpMsgp 0xC0000000 /* Message pending (busy + pass ) */
193 #define MPsigpBusy 0x80000000 /* Processor area busy, i.e., locked */
194 #define MPsigpPass 0x40000000 /* Busy lock passed to receiving processor */
195 #define MPsigpAck 0x20000000 /* Ack Busy lock passed to receiving processor */
196 #define MPsigpSrc 0x000000FF /* Processor that owns busy, i.e., the ID of */
197 /* whomever set busy. When a busy is passed, */
198 /* this is the requestor of the function. */
199 #define MPsigpFunc 0x0000FF00 /* Current function */
200 #define MPsigpIdle 0x00 /* No function pending */
201 #define MPsigpSigp 0x04 /* Signal a processor */
202 #define SIGPast 0 /* Requests an ast on target processor */
203 #define SIGPcpureq 1 /* Requests CPU specific function */
204 #define SIGPdebug 2 /* Requests a debugger entry */
205 #define SIGPwake 3 /* Wake up a sleeping processor */
206 #define CPRQtemp 0 /* Get temprature of processor */
207 #define CPRQtimebase 1 /* Get timebase of processor */
208 unsigned int MPsigpParm0
; /* SIGP parm 0 */
209 unsigned int MPsigpParm1
; /* SIGP parm 1 */
210 unsigned int MPsigpParm2
; /* SIGP parm 2 */
212 vm_offset_t start_paddr
;
213 unsigned int ruptStamp
[2]; /* Timebase at last interruption */
215 /* PPC cache line boundary here - 0A0 */
216 procFeatures pf
; /* Processor features */
218 /* PPC cache line boundary here - 100 */
219 thrmControl thrm
; /* Thermal controls */
221 /* PPC cache line boundary here - 120 */
222 unsigned int napStamp
[2]; /* Time base when we napped */
223 unsigned int napTotal
[2]; /* Total nap time in ticks */
224 unsigned int numSIGPast
; /* Number of SIGP asts recieved */
225 unsigned int numSIGPcpureq
; /* Number of SIGP cpu requests recieved */
226 unsigned int numSIGPdebug
; /* Number of SIGP debugs recieved */
227 unsigned int numSIGPwake
; /* Number of SIGP wakes recieved */
229 /* PPC cache line boundary here - 140 */
230 unsigned int numSIGPtimo
; /* Number of SIGP send timeouts */
231 unsigned int numSIGPmast
; /* Number of SIGPast messages merged */
232 unsigned int numSIGPmwake
; /* Number of SIGPwake messages merged */
233 unsigned int spcTRc
; /* Special trace count */
234 unsigned int spcTRp
; /* Special trace buffer pointer */
235 unsigned int Uassist
; /* User Assist Word */
236 vm_offset_t VMMareaPhys
; /* vmm state page physical addr */
237 unsigned int FAMintercept
; /* vmm FAM Exceptions to intercept */
239 /* PPC cache line boundary here - 160 */
240 cpu_data_t pp_cpu_data
; /* cpu data info */
241 unsigned int rsrvd170
[4]; /* Reserved slots */
243 /* PPC cache line boundary here - 180 */
244 unsigned int rsrvd180
[8]; /* Reserved slots */
246 /* PPC cache line boundary here - 1A0 */
247 unsigned int rsrvd1A0
[8]; /* Reserved slots */
249 /* PPC cache line boundary here - 1C0 */
250 unsigned int rsrvd1C0
[8]; /* Reserved slots */
252 /* PPC cache line boundary here - 1E0 */
253 double emfp0
; /* Copies of floating point registers */
254 double emfp1
; /* Used for emulation purposes */
294 unsigned int emfpscr_pad
;
295 unsigned int emfpscr
;
296 unsigned int empadfp
[6];
299 unsigned int emvr0
[4]; /* Copies of vector registers used both */
300 unsigned int emvr1
[4]; /* for full vector emulation or */
301 unsigned int emvr2
[4]; /* as saveareas while assisting denorms */
302 unsigned int emvr3
[4];
303 unsigned int emvr4
[4];
304 unsigned int emvr5
[4];
305 unsigned int emvr6
[4];
306 unsigned int emvr7
[4];
307 unsigned int emvr8
[4];
308 unsigned int emvr9
[4];
309 unsigned int emvr10
[4];
310 unsigned int emvr11
[4];
311 unsigned int emvr12
[4];
312 unsigned int emvr13
[4];
313 unsigned int emvr14
[4];
314 unsigned int emvr15
[4];
315 unsigned int emvr16
[4];
316 unsigned int emvr17
[4];
317 unsigned int emvr18
[4];
318 unsigned int emvr19
[4];
319 unsigned int emvr20
[4];
320 unsigned int emvr21
[4];
321 unsigned int emvr22
[4];
322 unsigned int emvr23
[4];
323 unsigned int emvr24
[4];
324 unsigned int emvr25
[4];
325 unsigned int emvr26
[4];
326 unsigned int emvr27
[4];
327 unsigned int emvr28
[4];
328 unsigned int emvr29
[4];
329 unsigned int emvr30
[4];
330 unsigned int emvr31
[4];
331 unsigned int emvscr
[4];
332 unsigned int empadvr
[4];
335 unsigned int patcharea
[56];
340 #define pp_active_thread pp_cpu_data.active_thread
341 #define pp_preemption_count pp_cpu_data.preemption_level
342 #define pp_simple_lock_count pp_cpu_data.simple_lock_count
343 #define pp_interrupt_level pp_cpu_data.interrupt_level
346 extern struct per_proc_info per_proc_info
[NCPUS
];
348 extern char *trap_type
[];
350 #endif /* ndef ASSEMBLER */
351 /* with this savearea should be redriven */
354 #define SIGPactive 0x8000
355 #define needSRload 0x4000
356 #define turnEEon 0x2000
357 #define traceBE 0x1000 /* user mode BE tracing in enabled */
358 #define traceBEb 3 /* bit number for traceBE */
359 #define BootDone 0x0100
360 #define SignalReady 0x0200
361 #define loadMSR 0x7FF4
363 #define T_VECTOR_SIZE 4 /* function pointer size */
365 /* Hardware exceptions */
367 #define T_IN_VAIN (0x00 * T_VECTOR_SIZE)
368 #define T_RESET (0x01 * T_VECTOR_SIZE)
369 #define T_MACHINE_CHECK (0x02 * T_VECTOR_SIZE)
370 #define T_DATA_ACCESS (0x03 * T_VECTOR_SIZE)
371 #define T_INSTRUCTION_ACCESS (0x04 * T_VECTOR_SIZE)
372 #define T_INTERRUPT (0x05 * T_VECTOR_SIZE)
373 #define T_ALIGNMENT (0x06 * T_VECTOR_SIZE)
374 #define T_PROGRAM (0x07 * T_VECTOR_SIZE)
375 #define T_FP_UNAVAILABLE (0x08 * T_VECTOR_SIZE)
376 #define T_DECREMENTER (0x09 * T_VECTOR_SIZE)
377 #define T_IO_ERROR (0x0a * T_VECTOR_SIZE)
378 #define T_RESERVED (0x0b * T_VECTOR_SIZE)
379 #define T_SYSTEM_CALL (0x0c * T_VECTOR_SIZE)
380 #define T_TRACE (0x0d * T_VECTOR_SIZE)
381 #define T_FP_ASSIST (0x0e * T_VECTOR_SIZE)
382 #define T_PERF_MON (0x0f * T_VECTOR_SIZE)
383 #define T_VMX (0x10 * T_VECTOR_SIZE)
384 #define T_INVALID_EXCP0 (0x11 * T_VECTOR_SIZE)
385 #define T_INVALID_EXCP1 (0x12 * T_VECTOR_SIZE)
386 #define T_INVALID_EXCP2 (0x13 * T_VECTOR_SIZE)
387 #define T_INSTRUCTION_BKPT (0x14 * T_VECTOR_SIZE)
388 #define T_SYSTEM_MANAGEMENT (0x15 * T_VECTOR_SIZE)
389 #define T_ALTIVEC_ASSIST (0x16 * T_VECTOR_SIZE)
390 #define T_THERMAL (0x17 * T_VECTOR_SIZE)
391 #define T_INVALID_EXCP5 (0x18 * T_VECTOR_SIZE)
392 #define T_INVALID_EXCP6 (0x19 * T_VECTOR_SIZE)
393 #define T_INVALID_EXCP7 (0x1A * T_VECTOR_SIZE)
394 #define T_INVALID_EXCP8 (0x1B * T_VECTOR_SIZE)
395 #define T_INVALID_EXCP9 (0x1C * T_VECTOR_SIZE)
396 #define T_INVALID_EXCP10 (0x1D * T_VECTOR_SIZE)
397 #define T_INVALID_EXCP11 (0x1E * T_VECTOR_SIZE)
398 #define T_INVALID_EXCP12 (0x1F * T_VECTOR_SIZE)
399 #define T_INVALID_EXCP13 (0x20 * T_VECTOR_SIZE)
401 #define T_RUNMODE_TRACE (0x21 * T_VECTOR_SIZE) /* 601 only */
403 #define T_SIGP (0x22 * T_VECTOR_SIZE)
404 #define T_PREEMPT (0x23 * T_VECTOR_SIZE)
405 #define T_CSWITCH (0x24 * T_VECTOR_SIZE)
406 #define T_SHUTDOWN (0x25 * T_VECTOR_SIZE)
407 #define T_CHOKE (0x26 * T_VECTOR_SIZE)
409 #define T_AST (0x100 * T_VECTOR_SIZE)
410 #define T_MAX T_CHOKE /* Maximum exception no */
412 #define T_FAM 0x00004000
414 #define EXCEPTION_VECTOR(exception) (exception * 0x100 /T_VECTOR_SIZE )
417 * System choke (failure) codes
422 #define failMapping 2
423 #define failContext 3
424 #define failNoSavearea 4
425 #define failSaveareaCorr 5
426 #define failBadLiveContext 6
428 /* Always must be last - update failNames table in model_dep.c as well */
429 #define failUnknown 7
433 typedef struct resethandler
{
435 vm_offset_t call_paddr
;
436 vm_offset_t arg__paddr
;
439 extern resethandler_t ResetHandler
;
443 #define RESET_HANDLER_NULL 0x0
444 #define RESET_HANDLER_START 0x1
446 #endif /* _PPC_EXCEPTION_H_ */