]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/atomic_switch.h
xnu-792.21.3.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 *
8f6c56a5 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
8f6c56a5
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.
14 *
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
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
8ad349bb 24 * limitations under the License.
8f6c56a5
A
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28typedef unsigned char UInt8;
29typedef unsigned short UInt16;
30typedef unsigned long UInt32;
31
32
33/* Support firmware CallPseudoKernel architectural extension */
34
35struct CallPseudoKernelDescriptor {
36 UInt32 pc;
37 UInt32 gpr0;
38 UInt32 intControlAddr;
39 UInt32 newState;
40 UInt32 intStateMask;
41 UInt32 intCR2Mask;
42 UInt32 intCR2Shift;
43 UInt32 sysContextState;
44};
45typedef struct CallPseudoKernelDescriptor CallPseudoKernelDescriptor;
46typedef CallPseudoKernelDescriptor * CallPseudoKernelDescriptorPtr;
47typedef CallPseudoKernelDescriptor CPKD_t;
48
49
50
51/* Support firmware ExitPseudoKernel architectural extension */
52
53struct ExitPseudoKernelDescriptor {
54 UInt32 pc;
55 UInt32 sp;
56 UInt32 gpr0;
57 UInt32 gpr3;
58 UInt32 cr;
59 UInt32 intControlAddr;
60 UInt32 newState;
61 UInt32 intStateMask;
62 UInt32 intCR2Mask;
63 UInt32 intCR2Shift;
64 UInt32 sysContextState;
65 UInt32 intPendingMask;
66 UInt32 intPendingPC;
67 UInt32 msrUpdate;
68};
69typedef struct ExitPseudoKernelDescriptor ExitPseudoKernelDescriptor;
70typedef ExitPseudoKernelDescriptor * ExitPseudoKernelDescriptorPtr;
71typedef ExitPseudoKernelDescriptor EPKD_t;
72
73
74struct EmulatorDescriptor {
75 UInt8 regMap[16]; // table mapping 68K D0..D7, A0..A7 register to PowerPC registers
76 UInt32 bootstrapVersionOffset; // offset within emulator data page of the bootstrap version string
77 UInt32 ecbOffset; // offset within emulator data page of the ECB
78 UInt32 intModeLevelOffset; // offset within emulator data page of the interrupt mode level
79 UInt32 entryAddress; // offset within text of the emulator's main entry point
80 UInt32 kcallTrapTableOffset; // offset within text of the nanokernel(!) call trap table
81 UInt32 postIntMask; // post interrupt mask
82 UInt32 clearIntMask; // clear interrupt mask
83 UInt32 testIntMask; // test interrupt mask
84 UInt32 codeSize; // total size of emulator object code (interpretive + DR)
85 UInt32 hashTableSize; // size of DR emulator's hash table
86 UInt32 drCodeStartOffset; // offset within text of the DR emulator's object code
87 UInt32 drInitOffset; // offset within DR emulator of its initialization entry point
88 UInt32 drAllocateCache; // offset within DR emulator of its cache allocation entry point
89 UInt32 dispatchTableOffset; // offset within text of the encoded instruction dispatch table
90};
91typedef struct EmulatorDescriptor EmulatorDescriptor;
92typedef EmulatorDescriptor *EmulatorDescriptorPtr;
93
94
95enum {
96 // The following define the UInt32 gInterruptState
97 kInUninitialized = 0, // State not yet initialized
98 kInPseudoKernel = 1, // Currently executing within pseudo kernel
99 kInSystemContext = 2, // Currently executing within the system (emulator) context
100 kInAlternateContext = 3, // Currently executing within an alternate (native) context
101 kInExceptionHandler = 4, // Currently executing an exception handler
102 kOutsideMain = 5, // Currently executing outside of the main thread
103 kNotifyPending = 6, // Pending Notify Interrupt
104
105 kInterruptStateMask = 0x000F0000, // Mask to extract interrupt state from gInterruptState
106 kInterruptStateShift = 16, // Shift count to align interrupt state
107
108 kBackupCR2Mask = 0x0000000F, // Mask to extract backup CR2 from gInterruptState
109 kCR2ToBackupShift = 31-11, // Shift count to align CR2 into the backup CR2 of gInterruptState
110 // (and vice versa)
111 kCR2Mask = 0x00F00000 // Mask to extract CR2 from the PPC CR register
112};
113
114
115enum {
116 kcReturnFromException = 0,
117 kcRunAlternateContext = 1,
118 kcResetSystem = 2,
119 kcVMDispatch = 3,
120 kcPrioritizeInterrupts = 4,
121 kcPowerDispatch = 5,
122 kcRTASDispatch = 6,
123 kcGetAdapterProcPtrsPPC = 12,
124 kcGetAdapterProcPtrs = 13,
125 kcCallAdapterProc = 14,
126 kcSystemCrash = 15
127};
128
129#define bbMaxCode 16
130