]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/atomic_switch.h
bb2e6c0fe89fb59154a854860ab865cf43775daf
[apple/xnu.git] / osfmk / ppc / atomic_switch.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 typedef unsigned char UInt8;
24 typedef unsigned short UInt16;
25 typedef unsigned long UInt32;
26
27
28 /* Support firmware CallPseudoKernel architectural extension */
29
30 struct CallPseudoKernelDescriptor {
31 UInt32 pc;
32 UInt32 gpr0;
33 UInt32 intControlAddr;
34 UInt32 newState;
35 UInt32 intStateMask;
36 UInt32 intCR2Mask;
37 UInt32 intCR2Shift;
38 UInt32 sysContextState;
39 };
40 typedef struct CallPseudoKernelDescriptor CallPseudoKernelDescriptor;
41 typedef CallPseudoKernelDescriptor * CallPseudoKernelDescriptorPtr;
42 typedef CallPseudoKernelDescriptor CPKD_t;
43
44
45
46 /* Support firmware ExitPseudoKernel architectural extension */
47
48 struct ExitPseudoKernelDescriptor {
49 UInt32 pc;
50 UInt32 sp;
51 UInt32 gpr0;
52 UInt32 gpr3;
53 UInt32 cr;
54 UInt32 intControlAddr;
55 UInt32 newState;
56 UInt32 intStateMask;
57 UInt32 intCR2Mask;
58 UInt32 intCR2Shift;
59 UInt32 sysContextState;
60 UInt32 intPendingMask;
61 UInt32 intPendingPC;
62 UInt32 msrUpdate;
63 };
64 typedef struct ExitPseudoKernelDescriptor ExitPseudoKernelDescriptor;
65 typedef ExitPseudoKernelDescriptor * ExitPseudoKernelDescriptorPtr;
66 typedef ExitPseudoKernelDescriptor EPKD_t;
67
68
69 struct EmulatorDescriptor {
70 UInt8 regMap[16]; // table mapping 68K D0..D7, A0..A7 register to PowerPC registers
71 UInt32 bootstrapVersionOffset; // offset within emulator data page of the bootstrap version string
72 UInt32 ecbOffset; // offset within emulator data page of the ECB
73 UInt32 intModeLevelOffset; // offset within emulator data page of the interrupt mode level
74 UInt32 entryAddress; // offset within text of the emulator's main entry point
75 UInt32 kcallTrapTableOffset; // offset within text of the nanokernel(!) call trap table
76 UInt32 postIntMask; // post interrupt mask
77 UInt32 clearIntMask; // clear interrupt mask
78 UInt32 testIntMask; // test interrupt mask
79 UInt32 codeSize; // total size of emulator object code (interpretive + DR)
80 UInt32 hashTableSize; // size of DR emulator's hash table
81 UInt32 drCodeStartOffset; // offset within text of the DR emulator's object code
82 UInt32 drInitOffset; // offset within DR emulator of its initialization entry point
83 UInt32 drAllocateCache; // offset within DR emulator of its cache allocation entry point
84 UInt32 dispatchTableOffset; // offset within text of the encoded instruction dispatch table
85 };
86 typedef struct EmulatorDescriptor EmulatorDescriptor;
87 typedef EmulatorDescriptor *EmulatorDescriptorPtr;
88
89
90 enum {
91 // The following define the UInt32 gInterruptState
92 kInUninitialized = 0, // State not yet initialized
93 kInPseudoKernel = 1, // Currently executing within pseudo kernel
94 kInSystemContext = 2, // Currently executing within the system (emulator) context
95 kInAlternateContext = 3, // Currently executing within an alternate (native) context
96 kInExceptionHandler = 4, // Currently executing an exception handler
97 kOutsideMain = 5, // Currently executing outside of the main thread
98 kNotifyPending = 6, // Pending Notify Interrupt
99
100 kInterruptStateMask = 0x000F0000, // Mask to extract interrupt state from gInterruptState
101 kInterruptStateShift = 16, // Shift count to align interrupt state
102
103 kBackupCR2Mask = 0x0000000F, // Mask to extract backup CR2 from gInterruptState
104 kCR2ToBackupShift = 31-11, // Shift count to align CR2 into the backup CR2 of gInterruptState
105 // (and vice versa)
106 kCR2Mask = 0x00F00000 // Mask to extract CR2 from the PPC CR register
107 };
108
109
110 enum {
111 kcReturnFromException = 0,
112 kcRunAlternateContext = 1,
113 kcResetSystem = 2,
114 kcVMDispatch = 3,
115 kcPrioritizeInterrupts = 4,
116 kcPowerDispatch = 5,
117 kcRTASDispatch = 6,
118 kcGetAdapterProcPtrsPPC = 12,
119 kcGetAdapterProcPtrs = 13,
120 kcCallAdapterProc = 14,
121 kcSystemCrash = 15
122 };
123
124 #define bbMaxCode 16
125