feb0c16c6dce67e5a12f61ef790a29404c038306
[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 Ignored:6;
201 ULONG UnalignedAccess:1;
202 ULONG ExtendedPageTables:1;
203 ULONG Sbz1:1;
204 ULONG ExceptionBit:1;
205 ULONG Sbz2:1;
206 ULONG Nmif:1;
207 ULONG TexRemap:1;
208 ULONG ForceAp:1;
209 ULONG Reserved:2;
210 };
211 ULONG AsUlong;
212 } ARM_CONTROL_REGISTER, *PARM_CONTROL_REGISTER;
213
214 C_ASSERT(sizeof(ARM_CONTROL_REGISTER) == sizeof(ULONG));
215
216 typedef union _ARM_ID_CODE_REGISTER
217 {
218 struct
219 {
220 ULONG Revision:4;
221 ULONG PartNumber:12;
222 ULONG Architecture:4;
223 ULONG Variant:4;
224 ULONG Identifier:8;
225 };
226 ULONG AsUlong;
227 } ARM_ID_CODE_REGISTER, *PARM_ID_CODE_REGISTER;
228
229 typedef union _ARM_CACHE_REGISTER
230 {
231 struct
232 {
233 ULONG ILength:2;
234 ULONG IMultipler:1;
235 ULONG IAssociativty:3;
236 ULONG ISize:4;
237 ULONG IReserved:2;
238 ULONG DLength:2;
239 ULONG DMultipler:1;
240 ULONG DAssociativty:3;
241 ULONG DSize:4;
242 ULONG DReserved:2;
243 ULONG Separate:1;
244 ULONG CType:4;
245 ULONG Reserved:3;
246 };
247 ULONG AsUlong;
248 } ARM_CACHE_REGISTER, *PARM_CACHE_REGISTER;
249
250 typedef union _ARM_LOCKDOWN_REGISTER
251 {
252 struct
253 {
254 ULONG Preserve:1;
255 ULONG Ignored:25;
256 ULONG Victim:3;
257 ULONG Reserved:3;
258 };
259 ULONG AsUlong;
260 } ARM_LOCKDOWN_REGISTER, *PARM_LOCKDOWN_REGISTER;
261
262 //
263 // ARM Domains
264 //
265 typedef enum _ARM_DOMAINS
266 {
267 Domain0,
268 Domain1,
269 Domain2,
270 Domain3,
271 Domain4,
272 Domain5,
273 Domain6,
274 Domain7,
275 Domain8,
276 Domain9,
277 Domain10,
278 Domain11,
279 Domain12,
280 Domain13,
281 Domain14,
282 Domain15
283 } ARM_DOMAINS;
284
285 //
286 // Special Registers Structure (outside of CONTEXT)
287 //
288 typedef struct _KSPECIAL_REGISTERS
289 {
290 ARM_CONTROL_REGISTER ControlRegister;
291 ARM_LOCKDOWN_REGISTER LockdownRegister;
292 ARM_CACHE_REGISTER CacheRegister;
293 ARM_STATUS_REGISTER StatusRegister;
294 } KSPECIAL_REGISTERS, *PKSPECIAL_REGISTERS;
295
296 //
297 // Processor State
298 //
299 typedef struct _KPROCESSOR_STATE
300 {
301 struct _CONTEXT ContextFrame;
302 struct _KSPECIAL_REGISTERS SpecialRegisters;
303 } KPROCESSOR_STATE, *PKPROCESSOR_STATE;
304
305 //
306 // Processor Region Control Block
307 //
308 typedef struct _KPRCB
309 {
310 USHORT MinorVersion;
311 USHORT MajorVersion;
312 struct _KTHREAD *CurrentThread;
313 struct _KTHREAD *NextThread;
314 struct _KTHREAD *IdleThread;
315 UCHAR Number;
316 UCHAR Reserved;
317 USHORT BuildType;
318 KAFFINITY SetMember;
319 UCHAR CpuType;
320 UCHAR CpuID;
321 USHORT CpuStep;
322 KPROCESSOR_STATE ProcessorState;
323 ULONG KernelReserved[16];
324 ULONG HalReserved[16];
325 UCHAR PrcbPad0[92];
326 KSPIN_LOCK_QUEUE LockQueue[LockQueueMaximumLock];
327 struct _KTHREAD *NpxThread;
328 ULONG InterruptCount;
329 ULONG KernelTime;
330 ULONG UserTime;
331 ULONG DpcTime;
332 ULONG DebugDpcTime;
333 ULONG InterruptTime;
334 ULONG AdjustDpcThreshold;
335 ULONG PageColor;
336 UCHAR SkipTick;
337 UCHAR DebuggerSavedIRQL;
338 UCHAR NodeColor;
339 UCHAR Spare1;
340 ULONG NodeShiftedColor;
341 struct _KNODE *ParentNode;
342 ULONG MultiThreadProcessorSet;
343 struct _KPRCB *MultiThreadSetMaster;
344 ULONG SecondaryColorMask;
345 LONG Sleeping;
346 ULONG CcFastReadNoWait;
347 ULONG CcFastReadWait;
348 ULONG CcFastReadNotPossible;
349 ULONG CcCopyReadNoWait;
350 ULONG CcCopyReadWait;
351 ULONG CcCopyReadNoWaitMiss;
352 ULONG KeAlignmentFixupCount;
353 ULONG SpareCounter0;
354 ULONG KeDcacheFlushCount;
355 ULONG KeExceptionDispatchCount;
356 ULONG KeFirstLevelTbFills;
357 ULONG KeFloatingEmulationCount;
358 ULONG KeIcacheFlushCount;
359 ULONG KeSecondLevelTbFills;
360 ULONG KeSystemCalls;
361 volatile ULONG IoReadOperationCount;
362 volatile ULONG IoWriteOperationCount;
363 volatile ULONG IoOtherOperationCount;
364 LARGE_INTEGER IoReadTransferCount;
365 LARGE_INTEGER IoWriteTransferCount;
366 LARGE_INTEGER IoOtherTransferCount;
367 ULONG SpareCounter1[8];
368 PP_LOOKASIDE_LIST PPLookasideList[16];
369 PP_LOOKASIDE_LIST PPNPagedLookasideList[32];
370 PP_LOOKASIDE_LIST PPPagedLookasideList[32];
371 volatile ULONG PacketBarrier;
372 volatile ULONG ReverseStall;
373 PVOID IpiFrame;
374 UCHAR PrcbPad2[52];
375 volatile PVOID CurrentPacket[3];
376 volatile ULONG TargetSet;
377 volatile PKIPI_WORKER WorkerRoutine;
378 volatile ULONG IpiFrozen;
379 UCHAR PrcbPad3[40];
380 volatile ULONG RequestSummary;
381 volatile struct _KPRCB *SignalDone;
382 UCHAR PrcbPad4[56];
383 struct _KDPC_DATA DpcData[2];
384 PVOID DpcStack;
385 ULONG MaximumDpcQueueDepth;
386 ULONG DpcRequestRate;
387 ULONG MinimumDpcRate;
388 volatile UCHAR DpcInterruptRequested;
389 volatile UCHAR DpcThreadRequested;
390 volatile UCHAR DpcRoutineActive;
391 volatile UCHAR DpcThreadActive;
392 ULONG PrcbLock;
393 ULONG DpcLastCount;
394 volatile ULONG TimerHand;
395 volatile ULONG TimerRequest;
396 PVOID DpcThread;
397 KEVENT DpcEvent;
398 UCHAR ThreadDpcEnable;
399 volatile BOOLEAN QuantumEnd;
400 UCHAR PrcbPad50;
401 volatile UCHAR IdleSchedule;
402 LONG DpcSetEventRequest;
403 UCHAR PrcbPad5[18];
404 LONG TickOffset;
405 KDPC CallDpc;
406 ULONG PrcbPad7[8];
407 LIST_ENTRY WaitListHead;
408 ULONG ReadySummary;
409 ULONG QueueIndex;
410 LIST_ENTRY DispatcherReadyListHead[32];
411 SINGLE_LIST_ENTRY DeferredReadyListHead;
412 ULONG PrcbPad72[11];
413 PVOID ChainedInterruptList;
414 LONG LookasideIrpFloat;
415 volatile LONG MmPageFaultCount;
416 volatile LONG MmCopyOnWriteCount;
417 volatile LONG MmTransitionCount;
418 volatile LONG MmCacheTransitionCount;
419 volatile LONG MmDemandZeroCount;
420 volatile LONG MmPageReadCount;
421 volatile LONG MmPageReadIoCount;
422 volatile LONG MmCacheReadCount;
423 volatile LONG MmCacheIoCount;
424 volatile LONG MmDirtyPagesWriteCount;
425 volatile LONG MmDirtyWriteIoCount;
426 volatile LONG MmMappedPagesWriteCount;
427 volatile LONG MmMappedWriteIoCount;
428 ULONG SpareFields0[1];
429 CHAR VendorString[13];
430 UCHAR InitialApicId;
431 UCHAR LogicalProcessorsPerPhysicalProcessor;
432 ULONG MHz;
433 ULONG FeatureBits;
434 LARGE_INTEGER UpdateSignature;
435 volatile LARGE_INTEGER IsrTime;
436 LARGE_INTEGER SpareField1;
437 //FX_SAVE_AREA NpxSaveArea;
438 PROCESSOR_POWER_STATE PowerState;
439 } KPRCB, *PKPRCB;
440
441 //
442 // Processor Control Region
443 //
444 typedef struct _KIPCR
445 {
446 union
447 {
448 NT_TIB NtTib;
449 struct
450 {
451 struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList; // Unused
452 PVOID Used_StackBase; // Unused
453 PVOID PerfGlobalGroupMask;
454 PVOID TssCopy; // Unused
455 ULONG ContextSwitches;
456 KAFFINITY SetMemberCopy; // Unused
457 PVOID Used_Self;
458 };
459 };
460 struct _KPCR *Self;
461 struct _KPRCB *Prcb;
462 KIRQL Irql;
463 ULONG IRR; // Unused
464 ULONG IrrActive; // Unused
465 ULONG IDR; // Unused
466 PVOID KdVersionBlock;
467 PVOID IDT; // Unused
468 PVOID GDT; // Unused
469 PVOID TSS; // Unused
470 USHORT MajorVersion;
471 USHORT MinorVersion;
472 KAFFINITY SetMember;
473 ULONG StallScaleFactor;
474 UCHAR SpareUnused;
475 UCHAR Number;
476 UCHAR Spare0;
477 UCHAR SecondLevelCacheAssociativity;
478 ULONG VdmAlert;
479 ULONG KernelReserved[14];
480 ULONG SecondLevelCacheSize;
481 ULONG HalReserved[16];
482 // arm part
483 UCHAR IrqlMask[32];
484 ULONG IrqlTable[32];
485 PKINTERRUPT_ROUTINE InterruptRoutine[32];
486 ULONG ReservedVectors;
487 ULONG FirstLevelDcacheSize;
488 ULONG FirstLevelDcacheFillSize;
489 ULONG FirstLevelIcacheSize;
490 ULONG FirstLevelIcacheFillSize;
491 ULONG SecondLevelDcacheSize;
492 ULONG SecondLevelDcacheFillSize;
493 ULONG SecondLevelIcacheSize;
494 ULONG SecondLevelIcacheFillSize;
495 ULONG DcacheFillSize;
496 ULONG DcacheAlignment;
497 ULONG IcacheAlignment;
498 ULONG IcacheFillSize;
499 ULONG ProcessorId;
500 PVOID InterruptStack;
501 PVOID PanicStack;
502 PVOID InitialStack;
503 KPRCB PrcbData;
504 } KIPCR, *PKIPCR;
505
506 //
507 // Macro to get current KPRCB
508 //
509 FORCEINLINE
510 struct _KPRCB *
511 KeGetCurrentPrcb(VOID)
512 {
513 return PCR->Prcb;
514 }
515
516 //
517 // Just read it from the PCR
518 //
519 #define KeGetCurrentProcessorNumber() (int)PCR->Number
520 #define KeGetCurrentIrql() PCR->Irql
521 #define _KeGetCurrentThread() KeGetCurrentPrcb()->CurrentThread
522 #define _KeGetPreviousMode() KeGetCurrentPrcb()->CurrentThread->PreviousMode
523 #define _KeIsExecutingDpc() (KeGetCurrentPrcb()->DpcRoutineActive != 0)
524 #define KeGetCurrentThread() _KeGetCurrentThread()
525 #define KeGetPreviousMode() _KeGetPreviousMode()
526 #define KeGetDcacheFillSize() PCR->DcacheFillSize
527
528 #endif
529 #endif