]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/PseudoKernel.h
xnu-1228.tar.gz
[apple/xnu.git] / osfmk / ppc / PseudoKernel.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
2d21ac55
A
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.
8f6c56a5 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/*
29 File: PseudoKernelPriv.h
30
31 Contains: Interfaces for Classic environment's PseudoKernel
32
33 Copyright: (c) 2000 Apple Computer, Inc. All rights reserved.
34*/
35
0b4e3aa0
A
36#include <libkern/OSTypes.h>
37
1c79356b
A
38#include <ppc/exception.h>
39
40/* Support firmware PseudoKernel FastTrap architectural extension */
41
42#define bbMaxTrap (16 * sizeof(long))
43#define bbRFITrap bbMaxTrap
44
45extern int bb_enable_bluebox(struct savearea *);
46extern int bb_disable_bluebox(struct savearea *);
47extern int bb_settaskenv(struct savearea *);
48
2d21ac55
A
49kern_return_t syscall_notify_interrupt(void);
50
1c79356b
A
51struct 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
56};
57typedef struct BlueExceptionDataArea * BlueExceptionDataAreaPtr;
58typedef struct BlueExceptionDataArea BEDA_t;
59
60/*
61 The Blue Thread, which is running MacOS, needs to be able to handle Traps, SCs and interrupts.
62*/
63struct 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
73};
74typedef struct BlueThreadTrapDescriptor * BlueThreadTrapDescriptorPtr;
75typedef struct BlueThreadTrapDescriptor BTTD_t;
76
77enum {
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
86
87 kInterruptStateMask = 0x000F0000, // Mask to extract interrupt state from gInterruptState
88 kInterruptStateShift = 16, // Shift count to align interrupt state
89
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
92 // (and vice versa)
93 kCR2Mask = 0x00F00000 // Mask to extract CR2 from the PPC CR register
94};
95
96struct bbRupt {
97 struct ReturnHandler rh; /* Return handler address */
98};
99typedef struct bbRupt bbRupt;