[NTOSKRNL]
[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 // IPI Types
28 //
29 #define IPI_APC 1
30 #define IPI_DPC 2
31 #define IPI_FREEZE 4
32 #define IPI_PACKET_READY 8
33 #define IPI_SYNCH_REQUEST 16
34
35 //
36 // PRCB Flags
37 //
38 #define PRCB_MAJOR_VERSION 1
39 #define PRCB_BUILD_DEBUG 1
40 #define PRCB_BUILD_UNIPROCESSOR 2
41
42 //
43 // No LDTs on ARM
44 //
45 #define LDT_ENTRY ULONG
46
47 //
48 // HAL Variables
49 //
50 #define INITIAL_STALL_COUNT 100
51
52 //
53 // Static Kernel-Mode Address start (use MM_KSEG0_BASE for actual)
54 //
55 #define KSEG0_BASE 0x80000000
56
57 //
58 // Trap Frame Definition
59 //
60 typedef struct _KTRAP_FRAME
61 {
62 ULONG DbgArgMark;
63 ULONG R0;
64 ULONG R1;
65 ULONG R2;
66 ULONG R3;
67 ULONG R4;
68 ULONG R5;
69 ULONG R6;
70 ULONG R7;
71 ULONG R8;
72 ULONG R9;
73 ULONG R10;
74 ULONG R11;
75 ULONG R12;
76 ULONG UserSp;
77 ULONG UserLr;
78 ULONG SvcSp;
79 ULONG SvcLr;
80 ULONG Pc;
81 ULONG Spsr;
82 ULONG OldIrql;
83 ULONG PreviousMode;
84 ULONG PreviousTrapFrame;
85 } KTRAP_FRAME, *PKTRAP_FRAME;
86
87 //
88 // Defines the Callback Stack Layout for User Mode Callbacks
89 //
90 // Just a stub with some required members for now
91 //
92 typedef struct _KCALLOUT_FRAME
93 {
94 ULONG CallbackStack;
95 ULONG DummyFramePointer;
96 } KCALLOUT_FRAME, *PKCALLOUT_FRAME;
97
98 #ifndef NTOS_MODE_USER
99
100 //
101 // Exception Frame Definition
102 //
103 typedef struct _KEXCEPTION_FRAME
104 {
105 // ULONG R0;
106 // ULONG R1;
107 // ULONG R2;
108 // ULONG R3;
109 ULONG R4;
110 ULONG R5;
111 ULONG R6;
112 ULONG R7;
113 ULONG R8;
114 ULONG R9;
115 ULONG R10;
116 ULONG R11;
117 // ULONG R12;
118 ULONG Lr;
119 ULONG Psr;
120 } KEXCEPTION_FRAME, *PKEXCEPTION_FRAME;
121
122 //
123 // ARM Internal Registers
124 //
125 typedef union _ARM_TTB_REGISTER
126 {
127 struct
128 {
129 ULONG Reserved:14;
130 ULONG BaseAddress:18;
131 };
132 ULONG AsUlong;
133 } ARM_TTB_REGISTER;
134
135 typedef union _ARM_STATUS_REGISTER
136 {
137
138 struct
139 {
140 ULONG Mode:5;
141 ULONG State:1;
142 ULONG FiqDisable:1;
143 ULONG IrqDisable:1;
144 ULONG ImpreciseAbort:1;
145 ULONG Endianness:1;
146 ULONG Sbz:6;
147 ULONG GreaterEqual:4;
148 ULONG Sbz1:4;
149 ULONG Java:1;
150 ULONG Sbz2:2;
151 ULONG StickyOverflow:1;
152 ULONG Overflow:1;
153 ULONG CarryBorrowExtend:1;
154 ULONG Zero:1;
155 ULONG NegativeLessThan:1;
156 };
157 ULONG AsUlong;
158 } ARM_STATUS_REGISTER;
159
160 typedef union _ARM_DOMAIN_REGISTER
161 {
162 struct
163 {
164 ULONG Domain0:2;
165 ULONG Domain1:2;
166 ULONG Domain2:2;
167 ULONG Domain3:2;
168 ULONG Domain4:2;
169 ULONG Domain5:2;
170 ULONG Domain6:2;
171 ULONG Domain7:2;
172 ULONG Domain8:2;
173 ULONG Domain9:2;
174 ULONG Domain10:2;
175 ULONG Domain11:2;
176 ULONG Domain12:2;
177 ULONG Domain13:2;
178 ULONG Domain14:2;
179 ULONG Domain15:2;
180 };
181 ULONG AsUlong;
182 } ARM_DOMAIN_REGISTER;
183
184 typedef union _ARM_CONTROL_REGISTER
185 {
186 struct
187 {
188 ULONG MmuEnabled:1;
189 ULONG AlignmentFaultsEnabled:1;
190 ULONG DCacheEnabled:1;
191 ULONG Sbo:4;
192 ULONG BigEndianEnabled:1;
193 ULONG System:1;
194 ULONG Rom:1;
195 ULONG Sbz:2;
196 ULONG ICacheEnabled:1;
197 ULONG HighVectors:1;
198 ULONG RoundRobinReplacementEnabled:1;
199 ULONG Armv4Compat:1;
200 ULONG Sbo1:1;
201 ULONG Sbz1:1;
202 ULONG Sbo2:1;
203 ULONG Reserved:14;
204 };
205 ULONG AsUlong;
206 } ARM_CONTROL_REGISTER, *PARM_CONTROL_REGISTER;
207
208 typedef union _ARM_ID_CODE_REGISTER
209 {
210 struct
211 {
212 ULONG Revision:4;
213 ULONG PartNumber:12;
214 ULONG Architecture:4;
215 ULONG Variant:4;
216 ULONG Identifier:8;
217 };
218 ULONG AsUlong;
219 } ARM_ID_CODE_REGISTER, *PARM_ID_CODE_REGISTER;
220
221 typedef union _ARM_CACHE_REGISTER
222 {
223 struct
224 {
225 ULONG ILength:2;
226 ULONG IMultipler:1;
227 ULONG IAssociativty:3;
228 ULONG ISize:4;
229 ULONG IReserved:2;
230 ULONG DLength:2;
231 ULONG DMultipler:1;
232 ULONG DAssociativty:3;
233 ULONG DSize:4;
234 ULONG DReserved:2;
235 ULONG Separate:1;
236 ULONG CType:4;
237 ULONG Reserved:3;
238 };
239 ULONG AsUlong;
240 } ARM_CACHE_REGISTER, *PARM_CACHE_REGISTER;
241
242 typedef union _ARM_LOCKDOWN_REGISTER
243 {
244 struct
245 {
246 ULONG Preserve:1;
247 ULONG Ignored:25;
248 ULONG Victim:3;
249 ULONG Reserved:3;
250 };
251 ULONG AsUlong;
252 } ARM_LOCKDOWN_REGISTER, *PARM_LOCKDOWN_REGISTER;
253
254 //
255 // ARM Domains
256 //
257 typedef enum _ARM_DOMAINS
258 {
259 Domain0,
260 Domain1,
261 Domain2,
262 Domain3,
263 Domain4,
264 Domain5,
265 Domain6,
266 Domain7,
267 Domain8,
268 Domain9,
269 Domain10,
270 Domain11,
271 Domain12,
272 Domain13,
273 Domain14,
274 Domain15
275 } ARM_DOMAINS;
276
277 //
278 // Special Registers Structure (outside of CONTEXT)
279 //
280 typedef struct _KSPECIAL_REGISTERS
281 {
282 ARM_CONTROL_REGISTER ControlRegister;
283 ARM_LOCKDOWN_REGISTER LockdownRegister;
284 ARM_CACHE_REGISTER CacheRegister;
285 ARM_STATUS_REGISTER StatusRegister;
286 } KSPECIAL_REGISTERS, *PKSPECIAL_REGISTERS;
287
288 //
289 // Processor State
290 //
291 typedef struct _KPROCESSOR_STATE
292 {
293 struct _CONTEXT ContextFrame;
294 struct _KSPECIAL_REGISTERS SpecialRegisters;
295 } KPROCESSOR_STATE, *PKPROCESSOR_STATE;
296
297 //
298 // Processor Region Control Block
299 //
300 typedef struct _KPRCB
301 {
302 USHORT MinorVersion;
303 USHORT MajorVersion;
304 struct _KTHREAD *CurrentThread;
305 struct _KTHREAD *NextThread;
306 struct _KTHREAD *IdleThread;
307 UCHAR Number;
308 UCHAR Reserved;
309 USHORT BuildType;
310 KAFFINITY SetMember;
311 KPROCESSOR_STATE ProcessorState;
312 ULONG KernelReserved[16];
313 ULONG HalReserved[16];
314 KSPIN_LOCK_QUEUE LockQueue[LockQueueMaximumLock];
315 struct _KTHREAD *NpxThread;
316 ULONG InterruptCount;
317 ULONG KernelTime;
318 ULONG UserTime;
319 ULONG DpcTime;
320 ULONG DebugDpcTime;
321 ULONG InterruptTime;
322 ULONG AdjustDpcThreshold;
323 ULONG PageColor;
324 UCHAR SkipTick;
325 UCHAR DebuggerSavedIRQL;
326 UCHAR NodeColor;
327 UCHAR Spare1;
328 ULONG NodeShiftedColor;
329 ULONG PcrPage;
330 struct _KNODE *ParentNode;
331 ULONG MultiThreadProcessorSet;
332 struct _KPRCB *MultiThreadSetMaster;
333 ULONG SecondaryColorMask;
334 LONG Sleeping;
335 ULONG CcFastReadNoWait;
336 ULONG CcFastReadWait;
337 ULONG CcFastReadNotPossible;
338 ULONG CcCopyReadNoWait;
339 ULONG CcCopyReadWait;
340 ULONG CcCopyReadNoWaitMiss;
341 ULONG KeAlignmentFixupCount;
342 ULONG SpareCounter0;
343 ULONG KeDcacheFlushCount;
344 ULONG KeExceptionDispatchCount;
345 ULONG KeFirstLevelTbFills;
346 ULONG KeIcacheFlushCount;
347 ULONG KeSecondLevelTbFills;
348 ULONG KeSystemCalls;
349 volatile ULONG IoReadOperationCount;
350 volatile ULONG IoWriteOperationCount;
351 volatile ULONG IoOtherOperationCount;
352 LARGE_INTEGER IoReadTransferCount;
353 LARGE_INTEGER IoWriteTransferCount;
354 LARGE_INTEGER IoOtherTransferCount;
355 PP_LOOKASIDE_LIST PPLookasideList[16];
356 PP_LOOKASIDE_LIST PPNPagedLookasideList[32];
357 PP_LOOKASIDE_LIST PPPagedLookasideList[32];
358 volatile ULONG PacketBarrier;
359 volatile ULONG ReverseStall;
360 PVOID IpiFrame;
361 volatile PVOID CurrentPacket[3];
362 volatile ULONG TargetSet;
363 volatile PKIPI_WORKER WorkerRoutine;
364 volatile ULONG IpiFrozen;
365 volatile ULONG RequestSummary;
366 volatile struct _KPRCB *SignalDone;
367 struct _KDPC_DATA DpcData[2];
368 PVOID DpcStack;
369 ULONG MaximumDpcQueueDepth;
370 ULONG DpcRequestRate;
371 ULONG MinimumDpcRate;
372 volatile UCHAR DpcInterruptRequested;
373 volatile UCHAR DpcThreadRequested;
374 volatile UCHAR DpcRoutineActive;
375 volatile UCHAR DpcThreadActive;
376 ULONG PrcbLock;
377 ULONG DpcLastCount;
378 volatile ULONG TimerHand;
379 volatile ULONG TimerRequest;
380 PVOID DpcThread;
381 KEVENT DpcEvent;
382 UCHAR ThreadDpcEnable;
383 volatile BOOLEAN QuantumEnd;
384 volatile UCHAR IdleSchedule;
385 LONG DpcSetEventRequest;
386 LONG TickOffset;
387 KDPC CallDpc;
388 LIST_ENTRY WaitListHead;
389 ULONG ReadySummary;
390 ULONG QueueIndex;
391 LIST_ENTRY DispatcherReadyListHead[32];
392 SINGLE_LIST_ENTRY DeferredReadyListHead;
393 PVOID ChainedInterruptList;
394 LONG LookasideIrpFloat;
395 volatile LONG MmPageFaultCount;
396 volatile LONG MmCopyOnWriteCount;
397 volatile LONG MmTransitionCount;
398 volatile LONG MmCacheTransitionCount;
399 volatile LONG MmDemandZeroCount;
400 volatile LONG MmPageReadCount;
401 volatile LONG MmPageReadIoCount;
402 volatile LONG MmCacheReadCount;
403 volatile LONG MmCacheIoCount;
404 volatile LONG MmDirtyPagesWriteCount;
405 volatile LONG MmDirtyWriteIoCount;
406 volatile LONG MmMappedPagesWriteCount;
407 volatile LONG MmMappedWriteIoCount;
408 CHAR VendorString[13];
409 ULONG MHz;
410 ULONG FeatureBits;
411 volatile LARGE_INTEGER IsrTime;
412 PROCESSOR_POWER_STATE PowerState;
413 } KPRCB, *PKPRCB;
414
415 //
416 // Macro to get current KPRCB
417 //
418 FORCEINLINE
419 struct _KPRCB *
420 KeGetCurrentPrcb(VOID)
421 {
422 return PCR->Prcb;
423 }
424
425 #endif
426 #endif