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 kern_return_t
syscall_notify_interrupt(void);
51 struct BlueExceptionDataArea
{
52 UInt32 srr0
; // OUT PC at time of exception, IN return address
53 UInt32 srr1
; // OUT/IN msr FE0, BE, SE and FE1 bits to restore on exit
54 UInt32 sprg0
; // OUT R1 set to this value
55 UInt32 sprg1
; // OUT/IN R1 restored to this value
57 typedef struct BlueExceptionDataArea
* BlueExceptionDataAreaPtr
;
58 typedef struct BlueExceptionDataArea BEDA_t
;
61 The Blue Thread, which is running MacOS, needs to be able to handle Traps, SCs and interrupts.
63 struct BlueThreadTrapDescriptor
{
64 UInt32 TrapVector
; // 0=Trap
65 UInt32 SysCallVector
; // 1=SysCall
66 UInt32 InterruptVector
; // 2=Interrupt
67 UInt32 PendingIntVector
; // 3=Pending interrupt
68 BEDA_t exceptionInfo
; // Save registers at time of exception (trap/syscall)
69 UInt32 InterruptControlWord
; // Holds context state and backup CR2 bits
70 UInt32 NewExitState
; // New run state when exiting PseudoKernel
71 UInt32 testIntMask
; // Mask for a pending alternate context interrupt in backup CR2
72 UInt32 postIntMask
; // Mask to post an interrupt
74 typedef struct BlueThreadTrapDescriptor
* BlueThreadTrapDescriptorPtr
;
75 typedef struct BlueThreadTrapDescriptor BTTD_t
;
78 // The following define the UInt32 gInterruptState
79 kInUninitialized
= 0, // State not yet initialized
80 kInPseudoKernel
= 1, // Currently executing within pseudo kernel
81 kInSystemContext
= 2, // Currently executing within the system (emulator) context
82 kInAlternateContext
= 3, // Currently executing within an alternate (native) context
83 kInExceptionHandler
= 4, // Currently executing an exception handler
84 kOutsideBlue
= 5, // Currently executing outside of the Blue thread
85 kNotifyPending
= 6, // Pending Notify Interrupt
87 kInterruptStateMask
= 0x000F0000, // Mask to extract interrupt state from gInterruptState
88 kInterruptStateShift
= 16, // Shift count to align interrupt state
90 kBackupCR2Mask
= 0x0000000F, // Mask to extract backup CR2 from gInterruptState
91 kCR2ToBackupShift
= 31-11, // Shift count to align CR2 into the backup CR2 of gInterruptState
93 kCR2Mask
= 0x00F00000 // Mask to extract CR2 from the PPC CR register
97 struct ReturnHandler rh
; /* Return handler address */
99 typedef struct bbRupt bbRupt
;