2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 File: PseudoKernelPriv.h
31 Contains: Interfaces for Classic environment's PseudoKernel
33 Copyright: (c) 2000 Apple Computer, Inc. All rights reserved.
36 #include <libkern/OSTypes.h>
38 #include <ppc/exception.h>
40 /* Support firmware PseudoKernel FastTrap architectural extension */
42 #define bbMaxTrap (16 * sizeof(long))
43 #define bbRFITrap bbMaxTrap
45 extern int bb_enable_bluebox(struct savearea
*);
46 extern int bb_disable_bluebox(struct savearea
*);
47 extern int bb_settaskenv(struct savearea
*);
49 struct BlueExceptionDataArea
{
50 UInt32 srr0
; // OUT PC at time of exception, IN return address
51 UInt32 srr1
; // OUT/IN msr FE0, BE, SE and FE1 bits to restore on exit
52 UInt32 sprg0
; // OUT R1 set to this value
53 UInt32 sprg1
; // OUT/IN R1 restored to this value
55 typedef struct BlueExceptionDataArea
* BlueExceptionDataAreaPtr
;
56 typedef struct BlueExceptionDataArea BEDA_t
;
59 The Blue Thread, which is running MacOS, needs to be able to handle Traps, SCs and interrupts.
61 struct BlueThreadTrapDescriptor
{
62 UInt32 TrapVector
; // 0=Trap
63 UInt32 SysCallVector
; // 1=SysCall
64 UInt32 InterruptVector
; // 2=Interrupt
65 UInt32 PendingIntVector
; // 3=Pending interrupt
66 BEDA_t exceptionInfo
; // Save registers at time of exception (trap/syscall)
67 UInt32 InterruptControlWord
; // Holds context state and backup CR2 bits
68 UInt32 NewExitState
; // New run state when exiting PseudoKernel
69 UInt32 testIntMask
; // Mask for a pending alternate context interrupt in backup CR2
70 UInt32 postIntMask
; // Mask to post an interrupt
72 typedef struct BlueThreadTrapDescriptor
* BlueThreadTrapDescriptorPtr
;
73 typedef struct BlueThreadTrapDescriptor BTTD_t
;
76 // The following define the UInt32 gInterruptState
77 kInUninitialized
= 0, // State not yet initialized
78 kInPseudoKernel
= 1, // Currently executing within pseudo kernel
79 kInSystemContext
= 2, // Currently executing within the system (emulator) context
80 kInAlternateContext
= 3, // Currently executing within an alternate (native) context
81 kInExceptionHandler
= 4, // Currently executing an exception handler
82 kOutsideBlue
= 5, // Currently executing outside of the Blue thread
83 kNotifyPending
= 6, // Pending Notify Interrupt
85 kInterruptStateMask
= 0x000F0000, // Mask to extract interrupt state from gInterruptState
86 kInterruptStateShift
= 16, // Shift count to align interrupt state
88 kBackupCR2Mask
= 0x0000000F, // Mask to extract backup CR2 from gInterruptState
89 kCR2ToBackupShift
= 31-11, // Shift count to align CR2 into the backup CR2 of gInterruptState
91 kCR2Mask
= 0x00F00000 // Mask to extract CR2 from the PPC CR register
95 struct ReturnHandler rh
; /* Return handler address */
97 typedef struct bbRupt bbRupt
;