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