2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
26 /* Miscellaneous constants and structures used by the exception
30 #ifndef _PPC_EXCEPTION_H_
31 #define _PPC_EXCEPTION_H_
33 #include <ppc/savearea.h>
40 #include <mach/machine/vm_types.h>
41 #include <mach/boolean.h>
43 #include <kern/cpu_data.h>
44 #include <pexpert/pexpert.h>
45 #include <IOKit/IOInterrupts.h>
46 #include <ppc/machine_routines.h>
48 /* Per processor CPU features */
49 #pragma pack(4) /* Make sure the structure stays as we defined it */
51 unsigned int Available
; /* 0x000 */
52 #define pfFloat 0x80000000
54 #define pfAltivec 0x40000000
56 #define pfAvJava 0x20000000
58 #define pfSMPcap 0x10000000
60 #define pfCanSleep 0x08000000
62 #define pfCanNap 0x04000000
64 #define pfCanDoze 0x02000000
66 #define pfSlowNap 0x00400000
68 #define pfNoMuMMCK 0x00200000
69 #define pfNoMuMMCKb 10
70 #define pfNoL2PFNap 0x00100000
71 #define pfNoL2PFNapb 11
72 #define pfSCOMFixUp 0x00080000
73 #define pfSCOMFixUpb 12
74 #define pfHasDcba 0x00040000
76 #define pfL1fa 0x00010000
78 #define pfL2 0x00008000
80 #define pfL2fa 0x00004000
82 #define pfL2i 0x00002000
84 #define pfLClck 0x00001000
86 #define pfWillNap 0x00000800
88 #define pfNoMSRir 0x00000400
90 #define pfL3pdet 0x00000200
92 #define pf128Byte 0x00000080
94 #define pf32Byte 0x00000020
96 #define pf64Bit 0x00000010
98 #define pfL3 0x00000004
100 #define pfL3fa 0x00000002
102 #define pfValid 0x00000001
104 unsigned short rptdProc
; /* 0x004 */
105 unsigned short lineSize
; /* 0x006 */
106 unsigned int l1iSize
; /* 0x008 */
107 unsigned int l1dSize
; /* 0x00C */
108 unsigned int l2cr
; /* 0x010 */
109 unsigned int l2Size
; /* 0x014 */
110 unsigned int l3cr
; /* 0x018 */
111 unsigned int l3Size
; /* 0x01C */
112 unsigned int pfMSSCR0
; /* 0x020 */
113 unsigned int pfMSSCR1
; /* 0x024 */
114 unsigned int pfICTRL
; /* 0x028 */
115 unsigned int pfLDSTCR
; /* 0x02C */
116 unsigned int pfLDSTDB
; /* 0x030 */
117 unsigned int pfMaxVAddr
; /* 0x034 */
118 unsigned int pfMaxPAddr
; /* 0x038 */
119 unsigned int pfPTEG
; /* 0x03C */
120 uint64_t pfHID0
; /* 0x040 */
121 uint64_t pfHID1
; /* 0x048 */
122 uint64_t pfHID2
; /* 0x050 */
123 uint64_t pfHID3
; /* 0x058 */
124 uint64_t pfHID4
; /* 0x060 */
125 uint64_t pfHID5
; /* 0x068 */
126 unsigned int l2crOriginal
; /* 0x070 */
127 unsigned int l3crOriginal
; /* 0x074 */
128 unsigned int pfBootConfig
; /* 0x078 */
129 unsigned int pfPowerModes
; /* 0x07C */
130 #define pmDPLLVmin 0x00010000
131 #define pmDPLLVminb 15
132 #define pmPowerTune 0x00000004
133 #define pmPowerTuneb 29
134 #define pmDFS 0x00000002
136 #define pmDualPLL 0x00000001
137 #define pmDualPLLb 31
138 unsigned int pfPowerTune0
; /* 0x080 */
139 unsigned int pfPowerTune1
; /* 0x084 */
140 unsigned int rsrvd88
[6]; /* 0x088 */
144 typedef struct procFeatures procFeatures
;
149 * Various performance counters
151 #pragma pack(4) /* Make sure the structure stays as we defined it */
154 unsigned int hwInVains
; /* In vain */
155 unsigned int hwResets
; /* Reset */
156 unsigned int hwMachineChecks
; /* Machine check */
157 unsigned int hwDSIs
; /* DSIs */
158 unsigned int hwISIs
; /* ISIs */
159 unsigned int hwExternals
; /* Externals */
160 unsigned int hwAlignments
; /* Alignment */
161 unsigned int hwPrograms
; /* Program */
162 unsigned int hwFloatPointUnavailable
; /* Floating point */
163 unsigned int hwDecrementers
; /* Decrementer */
164 unsigned int hwIOErrors
; /* I/O error */
165 unsigned int hwrsvd0
; /* Reserved */
166 unsigned int hwSystemCalls
; /* System call */
167 unsigned int hwTraces
; /* Trace */
168 unsigned int hwFloatingPointAssists
; /* Floating point assist */
169 unsigned int hwPerformanceMonitors
; /* Performance monitor */
170 unsigned int hwAltivecs
; /* VMX */
171 unsigned int hwrsvd1
; /* Reserved */
172 unsigned int hwrsvd2
; /* Reserved */
173 unsigned int hwrsvd3
; /* Reserved */
174 unsigned int hwInstBreakpoints
; /* Instruction breakpoint */
175 unsigned int hwSystemManagements
; /* System management */
176 unsigned int hwAltivecAssists
; /* Altivec Assist */
177 unsigned int hwThermal
; /* Thermals */
178 unsigned int hwrsvd5
; /* Reserved */
179 unsigned int hwrsvd6
; /* Reserved */
180 unsigned int hwrsvd7
; /* Reserved */
181 unsigned int hwrsvd8
; /* Reserved */
182 unsigned int hwrsvd9
; /* Reserved */
183 unsigned int hwrsvd10
; /* Reserved */
184 unsigned int hwrsvd11
; /* Reserved */
185 unsigned int hwrsvd12
; /* Reserved */
186 unsigned int hwrsvd13
; /* Reserved */
187 unsigned int hwTrace601
; /* Trace */
188 unsigned int hwSIGPs
; /* SIGP */
189 unsigned int hwPreemptions
; /* Preemption */
190 unsigned int hwContextSwitchs
; /* Context switch */
191 unsigned int hwShutdowns
; /* Shutdowns */
192 unsigned int hwChokes
; /* System ABENDs */
193 unsigned int hwDataSegments
; /* Data Segment Interruptions */
194 unsigned int hwInstructionSegments
; /* Instruction Segment Interruptions */
195 unsigned int hwSoftPatches
; /* Soft Patch interruptions */
196 unsigned int hwMaintenances
; /* Maintenance interruptions */
197 unsigned int hwInstrumentations
; /* Instrumentation interruptions */
198 unsigned int hwrsvd14
; /* Reserved */
199 unsigned int hwhdec
; /* 0B4 Hypervisor decrementer */
201 unsigned int hwspare0
[11]; /* 0B8 Reserved */
202 unsigned int hwspare0a
; /* 0E4 Reserved */
203 unsigned int hwspare0b
; /* 0E8 Reserved */
204 unsigned int hwspare0c
; /* 0EC Reserved */
205 unsigned int hwspare0d
; /* 0F0 Reserved */
206 unsigned int hwIgnored
; /* 0F4 Interruptions ignored */
207 unsigned int hwRedrives
; /* 0F8 Number of redriven interrupts */
208 unsigned int hwSteals
; /* 0FC Steals */
211 unsigned int hwMckHang
; /* ? */
212 unsigned int hwMckSLBPE
; /* ? */
213 unsigned int hwMckTLBPE
; /* ? */
214 unsigned int hwMckERCPE
; /* ? */
215 unsigned int hwMckL1DPE
; /* ? */
216 unsigned int hwMckL1TPE
; /* ? */
217 unsigned int hwMckUE
; /* ? */
218 unsigned int hwMckIUE
; /* ? */
219 unsigned int hwMckIUEr
; /* ? */
220 unsigned int hwMckDUE
; /* ? */
221 unsigned int hwMckDTW
; /* ? */
222 unsigned int hwMckUnk
; /* ? */
223 unsigned int hwMckExt
; /* ? */
224 unsigned int hwMckICachePE
; /* ? */
225 unsigned int hwMckITagPE
; /* ? */
226 unsigned int hwMckIEratPE
; /* ? */
227 unsigned int hwMckDEratPE
; /* ? */
228 unsigned int hwspare2
[15]; /* Pad to next 128 bndry */
231 unsigned int napStamp
[2]; /* Time base when we napped */
232 unsigned int napTotal
[2]; /* Total nap time in ticks */
233 unsigned int numSIGPast
; /* Number of SIGP asts recieved */
234 unsigned int numSIGPcpureq
; /* Number of SIGP cpu requests recieved */
235 unsigned int numSIGPdebug
; /* Number of SIGP debugs recieved */
236 unsigned int numSIGPwake
; /* Number of SIGP wakes recieved */
237 unsigned int numSIGPtimo
; /* Number of SIGP send timeouts */
238 unsigned int numSIGPmast
; /* Number of SIGPast messages merged */
239 unsigned int numSIGPmwake
; /* Number of SIGPwake messages merged */
241 unsigned int hwWalkPhys
; /* Number of entries to hw_walk_phys */
242 unsigned int hwWalkFull
; /* Full purge of connected PTE's */
243 unsigned int hwWalkMerge
; /* RC merge of connected PTE's */
244 unsigned int hwWalkQuick
; /* Quick scan of connected PTE's */
245 unsigned int numSIGPcall
; /* Number of SIGPcall messages received */
247 unsigned int hwspare3
[16]; /* Pad to 512 */
252 typedef struct hwCtrs hwCtrs
;
261 typedef struct patch_entry patch_entry_t
;
263 #define PATCH_INVALID 0
264 #define PATCH_PROCESSOR 1
265 #define PATCH_FEATURE 2
266 #define PATCH_END_OF_TABLE 3
268 #define PatchExt32 0x80000000
269 #define PatchExt32b 0
270 #define PatchLwsync 0x40000000
271 #define PatchLwsyncb 1
273 /* When an exception is taken, this info is accessed via sprg0 */
274 /* We should always have this one on a cache line boundary */
276 #pragma pack(4) /* Make sure the structure stays as we defined it */
277 struct per_proc_info
{
278 unsigned short cpu_number
;
279 unsigned short cpu_flags
; /* Various low-level flags */
280 vm_offset_t istackptr
;
281 vm_offset_t intstack_top_ss
;
283 vm_offset_t debstackptr
;
284 vm_offset_t debstack_top_ss
;
286 unsigned int spcFlags
; /* Special thread flags */
287 unsigned int old_thread
;
288 ast_t pending_ast
; /* mask of pending ast(s) */
290 /* PPC cache line boundary here - 020 */
296 * Note: the following two pairs of words need to stay in order and each pair must
297 * be in the same reservation (line) granule
299 struct facility_context
*FPU_owner
; /* Owner of the FPU on this cpu */
300 unsigned int liveVRSave
; /* VRSave assiciated with live vector registers */
301 struct facility_context
*VMX_owner
; /* Owner of the VMX on this cpu */
302 unsigned int spcTRc
; /* Special trace count */
303 unsigned int spcTRp
; /* Special trace buffer pointer */
305 /* PPC cache line boundary here - 040 */
306 addr64_t quickfret
; /* List of saveareas to release */
307 addr64_t lclfree
; /* Pointer to local savearea list */
308 unsigned int lclfreecnt
; /* Entries in local savearea list */
309 unsigned int holdQFret
; /* Hold off releasing quickfret list */
310 uint64_t rtcPop
; /* Real Time Clock pop */
312 /* PPC cache line boundary here - 060 */
313 boolean_t interrupts_enabled
;
314 IOInterruptHandler interrupt_handler
;
315 void * interrupt_nub
;
316 unsigned int interrupt_source
;
317 void * interrupt_target
;
318 void * interrupt_refCon
;
319 uint64_t next_savearea
; /* pointer to the next savearea */
321 /* PPC cache line boundary here - 080 */
322 unsigned int MPsigpStat
; /* Signal Processor status (interlocked update for this one) */
323 #define MPsigpMsgp 0xC0000000 /* Message pending (busy + pass ) */
324 #define MPsigpBusy 0x80000000 /* Processor area busy, i.e., locked */
325 #define MPsigpPass 0x40000000 /* Busy lock passed to receiving processor */
326 #define MPsigpAck 0x20000000 /* Ack Busy lock passed to receiving processor */
327 #define MPsigpSrc 0x000000FF /* Processor that owns busy, i.e., the ID of */
328 /* whomever set busy. When a busy is passed, */
329 /* this is the requestor of the function. */
330 #define MPsigpFunc 0x0000FF00 /* Current function */
331 #define MPsigpIdle 0x00 /* No function pending */
332 #define MPsigpSigp 0x04 /* Signal a processor */
333 unsigned int MPsigpParm0
; /* SIGP parm 0 */
334 unsigned int MPsigpParm1
; /* SIGP parm 1 */
335 unsigned int MPsigpParm2
; /* SIGP parm 2 */
337 vm_offset_t start_paddr
;
338 unsigned int ruptStamp
[2]; /* Timebase at last interruption */
340 /* PPC cache line boundary here - 0A0 */
341 procFeatures pf
; /* Processor features */
343 /* PPC cache line boundary here - 140 */
346 uint64_t rtclock_tick_deadline
;
347 struct rtclock_timer
{
350 /*boolean_t*/ is_set
:1,
354 unsigned int ppbbTaskEnv
; /* BlueBox Task Environment */
356 /* PPC cache line boundary here - 160 */
357 struct savearea
* db_saved_state
;
358 time_base_enable_t time_base_enable
;
361 int debugger_is_slave
;
363 int debugger_pending
;
364 int debugger_holdoff
;
366 /* PPC cache line boundary here - 180 */
367 uint64_t Uassist
; /* User Assist DoubleWord */
368 uint64_t validSegs
; /* Valid SR/STB slots */
369 addr64_t ppUserPmap
; /* Current user state pmap (physical address) */
370 unsigned int ppUserPmapVirt
; /* Current user state pmap (virtual address) */
371 unsigned int ppMapFlags
; /* Mapping flags */
373 /* PPC cache line boundary here - 1A0 */
374 unsigned short ppInvSeg
; /* Forces complete invalidate of SRs/SLB (this must stay with ppInvSeg) */
375 unsigned short ppCurSeg
; /* Set to 1 if user segments, 0 if kernel (this must stay with ppInvSeg) */
376 unsigned int ppSegSteal
; /* Count of segment slot steals */
377 ppnum_t VMMareaPhys
; /* vmm state page physical addr */
378 unsigned int VMMXAFlgs
; /* vmm extended flags */
379 unsigned int FAMintercept
; /* vmm FAM Exceptions to intercept */
380 unsigned int ppinfo_reserved1
;
384 /* PPC cache line boundary here - 1C0 */
385 unsigned int ppUMWmp
[16]; /* Linkage mapping for user memory window - 64 bytes */
387 /* PPC cache line boundary here - 200 */
388 uint64_t tempr0
; /* temporary savearea */
429 /* PPC cache line boundary here - 300 */
430 double emfp0
; /* Copies of floating point registers */
431 double emfp1
; /* Used for emulation purposes */
471 unsigned int emfpscr_pad
;
472 unsigned int emfpscr
;
473 unsigned int empadfp
[6];
476 unsigned int emvr0
[4]; /* Copies of vector registers used both */
477 unsigned int emvr1
[4]; /* for full vector emulation or */
478 unsigned int emvr2
[4]; /* as saveareas while assisting denorms */
479 unsigned int emvr3
[4];
480 unsigned int emvr4
[4];
481 unsigned int emvr5
[4];
482 unsigned int emvr6
[4];
483 unsigned int emvr7
[4];
484 unsigned int emvr8
[4];
485 unsigned int emvr9
[4];
486 unsigned int emvr10
[4];
487 unsigned int emvr11
[4];
488 unsigned int emvr12
[4];
489 unsigned int emvr13
[4];
490 unsigned int emvr14
[4];
491 unsigned int emvr15
[4];
492 unsigned int emvr16
[4];
493 unsigned int emvr17
[4];
494 unsigned int emvr18
[4];
495 unsigned int emvr19
[4];
496 unsigned int emvr20
[4];
497 unsigned int emvr21
[4];
498 unsigned int emvr22
[4];
499 unsigned int emvr23
[4];
500 unsigned int emvr24
[4];
501 unsigned int emvr25
[4];
502 unsigned int emvr26
[4];
503 unsigned int emvr27
[4];
504 unsigned int emvr28
[4];
505 unsigned int emvr29
[4];
506 unsigned int emvr30
[4];
507 unsigned int emvr31
[4];
508 unsigned int emvscr
[4];
509 unsigned int empadvr
[4];
511 /* note implicit dependence on kSkipListMaxLists, which must be <= 28 */
512 addr64_t skipListPrev
[28]; /* prev ptrs saved as side effect of calling mapSearchFull() */
516 unsigned int patcharea
[56];
519 hwCtrs hwCtr
; /* Hardware exception counters */
522 unsigned int processor
[384]; /* processor structure */
532 * Macro to conver a processor_t processor to its attached per_proc_info_t per_proc
534 #define PROCESSOR_TO_PER_PROC(x) \
535 ((struct per_proc_info*)((unsigned int)(x) \
536 - (unsigned int)(((struct per_proc_info *)0)->processor)))
538 extern struct per_proc_info BootProcInfo
;
542 struct per_proc_entry
{
544 unsigned int ppe_pad4
[1];
545 struct per_proc_info
*ppe_vaddr
;
548 extern struct per_proc_entry PerProcTable
[MAX_CPUS
-1];
551 extern char *trap_type
[];
553 #endif /* ndef ASSEMBLER */ /* with this savearea should be redriven */
556 #define SIGPactive 0x8000
557 #define needSRload 0x4000
558 #define turnEEon 0x2000
559 #define traceBE 0x1000 /* user mode BE tracing in enabled */
560 #define traceBEb 3 /* bit number for traceBE */
561 #define SleepState 0x0800
562 #define SleepStateb 4
563 #define mcountOff 0x0400
564 #define SignalReady 0x0200
565 #define BootDone 0x0100
566 #define loadMSR 0x7FF4
569 #define SignalReadyWait 0x00000001
571 #define T_VECTOR_SIZE 4 /* function pointer size */
573 /* Hardware exceptions */
575 #define T_IN_VAIN (0x00 * T_VECTOR_SIZE)
576 #define T_RESET (0x01 * T_VECTOR_SIZE)
577 #define T_MACHINE_CHECK (0x02 * T_VECTOR_SIZE)
578 #define T_DATA_ACCESS (0x03 * T_VECTOR_SIZE)
579 #define T_INSTRUCTION_ACCESS (0x04 * T_VECTOR_SIZE)
580 #define T_INTERRUPT (0x05 * T_VECTOR_SIZE)
581 #define T_ALIGNMENT (0x06 * T_VECTOR_SIZE)
582 #define T_PROGRAM (0x07 * T_VECTOR_SIZE)
583 #define T_FP_UNAVAILABLE (0x08 * T_VECTOR_SIZE)
584 #define T_DECREMENTER (0x09 * T_VECTOR_SIZE)
585 #define T_IO_ERROR (0x0a * T_VECTOR_SIZE)
586 #define T_RESERVED (0x0b * T_VECTOR_SIZE)
587 #define T_SYSTEM_CALL (0x0c * T_VECTOR_SIZE)
588 #define T_TRACE (0x0d * T_VECTOR_SIZE)
589 #define T_FP_ASSIST (0x0e * T_VECTOR_SIZE)
590 #define T_PERF_MON (0x0f * T_VECTOR_SIZE)
591 #define T_VMX (0x10 * T_VECTOR_SIZE)
592 #define T_INVALID_EXCP0 (0x11 * T_VECTOR_SIZE)
593 #define T_INVALID_EXCP1 (0x12 * T_VECTOR_SIZE)
594 #define T_INVALID_EXCP2 (0x13 * T_VECTOR_SIZE)
595 #define T_INSTRUCTION_BKPT (0x14 * T_VECTOR_SIZE)
596 #define T_SYSTEM_MANAGEMENT (0x15 * T_VECTOR_SIZE)
597 #define T_ALTIVEC_ASSIST (0x16 * T_VECTOR_SIZE)
598 #define T_THERMAL (0x17 * T_VECTOR_SIZE)
599 #define T_INVALID_EXCP5 (0x18 * T_VECTOR_SIZE)
600 #define T_INVALID_EXCP6 (0x19 * T_VECTOR_SIZE)
601 #define T_INVALID_EXCP7 (0x1A * T_VECTOR_SIZE)
602 #define T_INVALID_EXCP8 (0x1B * T_VECTOR_SIZE)
603 #define T_INVALID_EXCP9 (0x1C * T_VECTOR_SIZE)
604 #define T_INVALID_EXCP10 (0x1D * T_VECTOR_SIZE)
605 #define T_INVALID_EXCP11 (0x1E * T_VECTOR_SIZE)
606 #define T_INVALID_EXCP12 (0x1F * T_VECTOR_SIZE)
607 #define T_EMULATE (0x20 * T_VECTOR_SIZE)
609 #define T_RUNMODE_TRACE (0x21 * T_VECTOR_SIZE) /* 601 only */
611 #define T_SIGP (0x22 * T_VECTOR_SIZE)
612 #define T_PREEMPT (0x23 * T_VECTOR_SIZE)
613 #define T_CSWITCH (0x24 * T_VECTOR_SIZE)
614 #define T_SHUTDOWN (0x25 * T_VECTOR_SIZE)
615 #define T_CHOKE (0x26 * T_VECTOR_SIZE)
617 #define T_DATA_SEGMENT (0x27 * T_VECTOR_SIZE)
618 #define T_INSTRUCTION_SEGMENT (0x28 * T_VECTOR_SIZE)
620 #define T_SOFT_PATCH (0x29 * T_VECTOR_SIZE)
621 #define T_MAINTENANCE (0x2A * T_VECTOR_SIZE)
622 #define T_INSTRUMENTATION (0x2B * T_VECTOR_SIZE)
623 #define T_ARCHDEP0 (0x2C * T_VECTOR_SIZE)
624 #define T_HDEC (0x2D * T_VECTOR_SIZE)
626 #define T_AST (0x100 * T_VECTOR_SIZE)
627 #define T_MAX T_CHOKE /* Maximum exception no */
629 #define T_FAM 0x00004000
631 #define EXCEPTION_VECTOR(exception) (exception * 0x100 / T_VECTOR_SIZE )
634 * System choke (failure) codes
639 #define failMapping 2
640 #define failContext 3
641 #define failNoSavearea 4
642 #define failSaveareaCorr 5
643 #define failBadLiveContext 6
644 #define failSkipLists 7
645 #define failUnalignedStk 8
647 #define failTimeout 10
649 /* Always must be last - update failNames table in model_dep.c as well */
650 #define failUnknown 11
654 #pragma pack(4) /* Make sure the structure stays as we defined it */
655 typedef struct resethandler
{
657 vm_offset_t call_paddr
;
658 vm_offset_t arg__paddr
;
662 extern resethandler_t ResetHandler
;
666 #define RESET_HANDLER_NULL 0x0
667 #define RESET_HANDLER_START 0x1
668 #define RESET_HANDLER_BUPOR 0x2
669 #define RESET_HANDLER_IGNORE 0x3
671 #endif /* _PPC_EXCEPTION_H_ */