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@
26 File: PseudoKernelPriv.h
28 Contains: Interfaces for Classic environment's PseudoKernel
30 Copyright: (c) 2000 Apple Computer, Inc. All rights reserved.
33 #include <libkern/OSTypes.h>
35 #include <ppc/exception.h>
37 /* Support firmware PseudoKernel FastTrap architectural extension */
39 #define bbMaxTrap (16 * sizeof(long))
40 #define bbRFITrap bbMaxTrap
42 extern int bb_enable_bluebox(struct savearea
*);
43 extern int bb_disable_bluebox(struct savearea
*);
44 extern int bb_settaskenv(struct savearea
*);
46 struct BlueExceptionDataArea
{
47 UInt32 srr0
; // OUT PC at time of exception, IN return address
48 UInt32 srr1
; // OUT/IN msr FE0, BE, SE and FE1 bits to restore on exit
49 UInt32 sprg0
; // OUT R1 set to this value
50 UInt32 sprg1
; // OUT/IN R1 restored to this value
52 typedef struct BlueExceptionDataArea
* BlueExceptionDataAreaPtr
;
53 typedef struct BlueExceptionDataArea BEDA_t
;
56 The Blue Thread, which is running MacOS, needs to be able to handle Traps, SCs and interrupts.
58 struct BlueThreadTrapDescriptor
{
59 UInt32 TrapVector
; // 0=Trap
60 UInt32 SysCallVector
; // 1=SysCall
61 UInt32 InterruptVector
; // 2=Interrupt
62 UInt32 PendingIntVector
; // 3=Pending interrupt
63 BEDA_t exceptionInfo
; // Save registers at time of exception (trap/syscall)
64 UInt32 InterruptControlWord
; // Holds context state and backup CR2 bits
65 UInt32 NewExitState
; // New run state when exiting PseudoKernel
66 UInt32 testIntMask
; // Mask for a pending alternate context interrupt in backup CR2
67 UInt32 postIntMask
; // Mask to post an interrupt
69 typedef struct BlueThreadTrapDescriptor
* BlueThreadTrapDescriptorPtr
;
70 typedef struct BlueThreadTrapDescriptor BTTD_t
;
73 // The following define the UInt32 gInterruptState
74 kInUninitialized
= 0, // State not yet initialized
75 kInPseudoKernel
= 1, // Currently executing within pseudo kernel
76 kInSystemContext
= 2, // Currently executing within the system (emulator) context
77 kInAlternateContext
= 3, // Currently executing within an alternate (native) context
78 kInExceptionHandler
= 4, // Currently executing an exception handler
79 kOutsideBlue
= 5, // Currently executing outside of the Blue thread
80 kNotifyPending
= 6, // Pending Notify Interrupt
82 kInterruptStateMask
= 0x000F0000, // Mask to extract interrupt state from gInterruptState
83 kInterruptStateShift
= 16, // Shift count to align interrupt state
85 kBackupCR2Mask
= 0x0000000F, // Mask to extract backup CR2 from gInterruptState
86 kCR2ToBackupShift
= 31-11, // Shift count to align CR2 into the backup CR2 of gInterruptState
88 kCR2Mask
= 0x00F00000 // Mask to extract CR2 from the PPC CR register
92 struct ReturnHandler rh
; /* Return handler address */
94 typedef struct bbRupt bbRupt
;