4ddd07451726c0960ec5bc7f67f99f41c43b0642
[reactos.git] / reactos / include / ndk / arm / ketypes.h
1 /*++ NDK Version: 0098
2
3 Copyright (c) Alex Ionescu. All rights reserved.
4
5 Header Name:
6
7 ketypes.h (ARM)
8
9 Abstract:
10
11 ARM Type definitions for the Kernel services.
12
13 Author:
14
15 Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
16
17 --*/
18
19 #ifndef _ARM_KETYPES_H
20 #define _ARM_KETYPES_H
21
22 //
23 // Dependencies
24 //
25
26 //
27 // IRQLs
28 //
29 #define PASSIVE_LEVEL 0
30 #define LOW_LEVEL 0
31 #define APC_LEVEL 1
32 #define DISPATCH_LEVEL 2
33 #define IPI_LEVEL 7
34 #define POWER_LEVEL 7
35 #define PROFILE_LEVEL 8
36 #define HIGH_LEVEL 8
37 #define SYNCH_LEVEL (IPI_LEVEL - 1)
38
39 //
40 // IPI Types
41 //
42 #define IPI_APC 1
43 #define IPI_DPC 2
44 #define IPI_FREEZE 4
45 #define IPI_PACKET_READY 8
46 #define IPI_SYNCH_REQUEST 16
47
48 //
49 // PRCB Flags
50 //
51 #define PRCB_MAJOR_VERSION 1
52 #define PRCB_BUILD_DEBUG 1
53 #define PRCB_BUILD_UNIPROCESSOR 2
54
55 //
56 // HAL Variables
57 //
58 #define INITIAL_STALL_COUNT 0x64
59
60 //
61 // Static Kernel-Mode Address start (use MM_KSEG0_BASE for actual)
62 //
63 #define KSEG0_BASE 0x80000000
64
65 //
66 // FIXME: mmtypes.h?
67 //
68 #define KIPCR 0xFFFFF000
69 #define USPCR 0x7FFF0000
70 #define PCR ((volatile KPCR * const)USPCR)
71 #define USERPCR ((volatile KPCR * const)KIPCR)
72
73 //
74 // Synchronization-level IRQL
75 //
76 #define SYNCH_LEVEL DISPATCH_LEVEL
77
78 //
79 // Trap Frame Definition
80 //
81 typedef struct _KTRAP_FRAME
82 {
83 ULONG R0;
84 ULONG R1;
85 ULONG R2;
86 ULONG R3;
87 ULONG R4;
88 ULONG R5;
89 ULONG R6;
90 ULONG R7;
91 ULONG R8;
92 ULONG R9;
93 ULONG R10;
94 ULONG R11;
95 ULONG R12;
96 ULONG Sp;
97 ULONG Lr;
98 ULONG Pc;
99 ULONG Psr;
100 UCHAR ExceptionRecord[(sizeof(EXCEPTION_RECORD) + 7) & (~7)];
101 UCHAR OldIrql;
102 UCHAR PreviousMode;
103 ULONG Fpscr;
104 ULONG FpExc;
105 ULONG S[33];
106 ULONG FpExtra[8];
107 } KTRAP_FRAME, *PKTRAP_FRAME;
108
109 //
110 // Processor Control Region
111 // On ARM, it's actually readable from user-mode, much like KUSER_SHARED_DATA
112 //
113 #ifdef NTOS_MODE_USER
114 #define PKINTERRUPT_ROUTINE PVOID // Hack!
115 #endif
116 typedef struct _KPCR
117 {
118 ULONG MinorVersion;
119 ULONG MajorVersion;
120 PKINTERRUPT_ROUTINE InterruptRoutine[64];
121 PVOID XcodeDispatch;
122 ULONG FirstLevelDcacheSize;
123 ULONG FirstLevelDcacheFillSize;
124 ULONG FirstLevelIcacheSize;
125 ULONG FirstLevelIcacheFillSize;
126 ULONG SecondLevelDcacheSize;
127 ULONG SecondLevelDcacheFillSize;
128 ULONG SecondLevelIcacheSize;
129 ULONG SecondLevelIcacheFillSize;
130 struct _KPRCB *Prcb;
131 struct _TEB *Teb;
132 PVOID TlsArray;
133 ULONG DcacheFillSize;
134 ULONG IcacheAlignment;
135 ULONG IcacheFillSize;
136 ULONG ProcessorId;
137 ULONG ProfileInterval;
138 ULONG ProfileCount;
139 ULONG StallExecutionCount;
140 ULONG StallScaleFactor;
141 CCHAR Number;
142 PVOID DataBusError;
143 PVOID InstructionBusError;
144 ULONG CachePolicy;
145 UCHAR IrqlMask[64];
146 UCHAR IrqlTable[64];
147 UCHAR CurrentIrql;
148 KAFFINITY SetMember;
149 struct _KTHREAD *CurrentThread;
150 KAFFINITY NotMember;
151 ULONG SystemReserved[6];
152 ULONG DcacheAlignment;
153 ULONG HalReserved[64];
154 BOOLEAN FirstLevelActive;
155 BOOLEAN DpcRoutineActive;
156 ULONG CurrentPid;
157 BOOLEAN OnInterruptStack;
158 PVOID SavedInitialStack;
159 PVOID SavedStackLimit;
160 PVOID SystemServiceDispatchStart;
161 PVOID SystemServiceDispatchEnd;
162 PVOID InterruptStack;
163 PVOID PanicStack;
164 PVOID BadVaddr;
165 PVOID InitialStack;
166 PVOID StackLimit;
167 ULONG QuantumEnd;
168 } KPCR, *PKPCR;
169
170 #ifndef NTOS_MODE_USER
171 //
172 // Stub
173 //
174 typedef struct _KFLOATING_SAVE
175 {
176 ULONG Reserved;
177 } KFLOATING_SAVE, *PKFLOATING_SAVE;
178
179 //
180 // Processor Region Control Block
181 //
182 typedef struct _KPRCB
183 {
184 USHORT MinorVersion;
185 USHORT MajorVersion;
186 struct _KTHREAD *CurrentThread;
187 struct _KTHREAD *NextThread;
188 struct _KTHREAD *IdleThread;
189 UCHAR Number;
190 //
191 // TODO
192 //
193 } KPRCB, *PKPRCB;
194
195 //
196 // Macro to get current KPRCB
197 //
198 FORCEINLINE
199 struct _KPRCB *
200 KeGetCurrentPrcb(VOID)
201 {
202 return PCR->Prcb;
203 }
204
205 //
206 // Macro to get current CPU
207 //
208 FORCEINLINE
209 ULONG
210 DDKAPI
211 KeGetCurrentProcessorNumber(VOID)
212 {
213 return PCR->Number;
214 }
215
216 #endif
217 #endif