]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/PseudoKernel.h
xnu-344.21.74.tar.gz
[apple/xnu.git] / osfmk / ppc / PseudoKernel.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
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
13 * file.
14 *
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.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 File: PseudoKernelPriv.h
27
28 Contains: Interfaces for Classic environment's PseudoKernel
29
30 Copyright: (c) 2000 Apple Computer, Inc. All rights reserved.
31 */
32
33 #include <libkern/OSTypes.h>
34
35 #include <ppc/exception.h>
36
37 /* Support firmware PseudoKernel FastTrap architectural extension */
38
39 #define bbMaxTrap (16 * sizeof(long))
40 #define bbRFITrap bbMaxTrap
41
42 extern int bb_enable_bluebox(struct savearea *);
43 extern int bb_disable_bluebox(struct savearea *);
44 extern int bb_settaskenv(struct savearea *);
45
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
51 };
52 typedef struct BlueExceptionDataArea * BlueExceptionDataAreaPtr;
53 typedef struct BlueExceptionDataArea BEDA_t;
54
55 /*
56 The Blue Thread, which is running MacOS, needs to be able to handle Traps, SCs and interrupts.
57 */
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
68 };
69 typedef struct BlueThreadTrapDescriptor * BlueThreadTrapDescriptorPtr;
70 typedef struct BlueThreadTrapDescriptor BTTD_t;
71
72 enum {
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
81
82 kInterruptStateMask = 0x000F0000, // Mask to extract interrupt state from gInterruptState
83 kInterruptStateShift = 16, // Shift count to align interrupt state
84
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
87 // (and vice versa)
88 kCR2Mask = 0x00F00000 // Mask to extract CR2 from the PPC CR register
89 };
90
91 struct bbRupt {
92 struct ReturnHandler rh; /* Return handler address */
93 };
94 typedef struct bbRupt bbRupt;