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