don't tell the user the device is working properly when the drivers aren't even installed
[reactos.git] / reactos / include / ndk / i386 / ketypes.h
1 /*++ NDK Version: 0095
2
3 Copyright (c) Alex Ionescu. All rights reserved.
4
5 Header Name:
6
7 ketypes.h (X86)
8
9 Abstract:
10
11 i386 Type definitions for the Kernel services.
12
13 Author:
14
15 Alex Ionescu (alex.ionescu@reactos.com) 06-Oct-2004
16
17 --*/
18
19 #ifndef _I386_KETYPES_H
20 #define _I386_KETYPES_H
21
22 //
23 // Dependencies
24 //
25
26 //
27 // X86 80386 Segment Types
28 //
29 #define I386_TSS 0x9
30 #define I386_ACTIVE_TSS 0xB
31 #define I386_CALL_GATE 0xC
32 #define I386_INTERRUPT_GATE 0xE
33 #define I386_TRAP_GATE 0xF
34
35 //
36 // IPI Types
37 //
38 #define IPI_APC 1
39 #define IPI_DPC 2
40 #define IPI_FREEZE 3
41 #define IPI_PACKET_READY 4
42 #define IPI_SYNCH_REQUEST 10
43
44 //
45 // FN/FX (FPU) Save Area Structures
46 //
47 typedef struct _FNSAVE_FORMAT
48 {
49 ULONG ControlWord;
50 ULONG StatusWord;
51 ULONG TagWord;
52 ULONG ErrorOffset;
53 ULONG ErrorSelector;
54 ULONG DataOffset;
55 ULONG DataSelector;
56 UCHAR RegisterArea[80];
57 } FNSAVE_FORMAT, *PFNSAVE_FORMAT;
58
59 typedef struct _FXSAVE_FORMAT
60 {
61 USHORT ControlWord;
62 USHORT StatusWord;
63 USHORT TagWord;
64 USHORT ErrorOpcode;
65 ULONG ErrorOffset;
66 ULONG ErrorSelector;
67 ULONG DataOffset;
68 ULONG DataSelector;
69 ULONG MXCsr;
70 ULONG MXCsrMask;
71 UCHAR RegisterArea[128];
72 UCHAR Reserved3[128];
73 UCHAR Reserved4[224];
74 UCHAR Align16Byte[8];
75 } FXSAVE_FORMAT, *PFXSAVE_FORMAT;
76
77 typedef struct _FX_SAVE_AREA
78 {
79 union
80 {
81 FNSAVE_FORMAT FnArea;
82 FXSAVE_FORMAT FxArea;
83 } U;
84 ULONG NpxSavedCpu;
85 ULONG Cr0NpxState;
86 } FX_SAVE_AREA, *PFX_SAVE_AREA;
87
88 //
89 // Trap Frame Definition
90 //
91 typedef struct _KTRAP_FRAME
92 {
93 ULONG DbgEbp;
94 ULONG DbgEip;
95 ULONG DbgArgMark;
96 ULONG DbgArgPointer;
97 ULONG TempSegCs;
98 ULONG TempEsp;
99 ULONG Dr0;
100 ULONG Dr1;
101 ULONG Dr2;
102 ULONG Dr3;
103 ULONG Dr6;
104 ULONG Dr7;
105 ULONG SegGs;
106 ULONG SegEs;
107 ULONG SegDs;
108 ULONG Edx;
109 ULONG Ecx;
110 ULONG Eax;
111 ULONG PreviousPreviousMode;
112 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
113 ULONG SegFs;
114 ULONG Edi;
115 ULONG Esi;
116 ULONG Ebx;
117 ULONG Ebp;
118 ULONG ErrCode;
119 ULONG Eip;
120 ULONG SegCs;
121 ULONG EFlags;
122 ULONG HardwareEsp;
123 ULONG HardwareSegSs;
124 ULONG V86Es;
125 ULONG V86Ds;
126 ULONG V86Fs;
127 ULONG V86Gs;
128 } KTRAP_FRAME, *PKTRAP_FRAME;
129
130 //
131 // LDT Entry Definition
132 //
133 typedef struct _LDT_ENTRY
134 {
135 USHORT LimitLow;
136 USHORT BaseLow;
137 union
138 {
139 struct
140 {
141 UCHAR BaseMid;
142 UCHAR Flags1;
143 UCHAR Flags2;
144 UCHAR BaseHi;
145 } Bytes;
146 struct
147 {
148 ULONG BaseMid : 8;
149 ULONG Type : 5;
150 ULONG Dpl : 2;
151 ULONG Pres : 1;
152 ULONG LimitHi : 4;
153 ULONG Sys : 1;
154 ULONG Reserved_0 : 1;
155 ULONG Default_Big : 1;
156 ULONG Granularity : 1;
157 ULONG BaseHi : 8;
158 } Bits;
159 } HighWord;
160 } LDT_ENTRY, *PLDT_ENTRY, *LPLDT_ENTRY;
161
162 //
163 // GDT Entry Definition
164 //
165 typedef struct _KGDTENTRY
166 {
167 USHORT LimitLow;
168 USHORT BaseLow;
169 union
170 {
171 struct
172 {
173 UCHAR BaseMid;
174 UCHAR Flags1;
175 UCHAR Flags2;
176 UCHAR BaseHi;
177 } Bytes;
178 struct
179 {
180 ULONG BaseMid : 8;
181 ULONG Type : 5;
182 ULONG Dpl : 2;
183 ULONG Pres : 1;
184 ULONG LimitHi : 4;
185 ULONG Sys : 1;
186 ULONG Reserved_0 : 1;
187 ULONG Default_Big : 1;
188 ULONG Granularity : 1;
189 ULONG BaseHi : 8;
190 } Bits;
191 } HighWord;
192 } KGDTENTRY, *PKGDTENTRY;
193
194 //
195 // IDT Entry Access Definition
196 //
197 typedef struct _KIDT_ACCESS
198 {
199 union
200 {
201 struct
202 {
203 UCHAR Reserved;
204 UCHAR SegmentType:4;
205 UCHAR SystemSegmentFlag:1;
206 UCHAR Dpl:2;
207 UCHAR Present:1;
208 };
209 USHORT Value;
210 };
211 } KIDT_ACCESS, *PKIDT_ACCESS;
212
213 //
214 // IDT Entry Definition
215 //
216 typedef struct _KIDTENTRY
217 {
218 USHORT Offset;
219 USHORT Selector;
220 USHORT Access;
221 USHORT ExtendedOffset;
222 } KIDTENTRY, *PKIDTENTRY;
223
224 //
225 // Page Table Entry Definition
226 //
227 typedef struct _HARDWARE_PTE_X86
228 {
229 ULONG Valid : 1;
230 ULONG Write : 1;
231 ULONG Owner : 1;
232 ULONG WriteThrough : 1;
233 ULONG CacheDisable : 1;
234 ULONG Accessed : 1;
235 ULONG Dirty : 1;
236 ULONG LargePage : 1;
237 ULONG Global : 1;
238 ULONG CopyOnWrite : 1;
239 ULONG Prototype : 1;
240 ULONG reserved : 1;
241 ULONG PageFrameNumber : 20;
242 } HARDWARE_PTE_X86, *PHARDWARE_PTE_X86;
243
244 typedef struct _DESCRIPTOR
245 {
246 USHORT Pad;
247 USHORT Limit;
248 ULONG Base;
249 } KDESCRIPTOR, *PKDESCRIPTOR;
250
251 //
252 // Special Registers Structure (outside of CONTEXT)
253 //
254 typedef struct _KSPECIAL_REGISTERS
255 {
256 ULONG Cr0;
257 ULONG Cr2;
258 ULONG Cr3;
259 ULONG Cr4;
260 ULONG KernelDr0;
261 ULONG KernelDr1;
262 ULONG KernelDr2;
263 ULONG KernelDr3;
264 ULONG KernelDr6;
265 ULONG KernelDr7;
266 KDESCRIPTOR Gdtr;
267 KDESCRIPTOR Idtr;
268 USHORT Tr;
269 USHORT Ldtr;
270 ULONG Reserved[6];
271 } KSPECIAL_REGISTERS, *PKSPECIAL_REGISTERS;
272
273 //
274 // Processor State Data
275 //
276 #pragma pack(push,4)
277 typedef struct _KPROCESSOR_STATE
278 {
279 PCONTEXT ContextFrame;
280 KSPECIAL_REGISTERS SpecialRegisters;
281 } KPROCESSOR_STATE;
282
283 //
284 // Processor Region Control Block
285 //
286 typedef struct _KPRCB
287 {
288 USHORT MinorVersion;
289 USHORT MajorVersion;
290 struct _KTHREAD *CurrentThread;
291 struct _KTHREAD *NextThread;
292 struct _KTHREAD *IdleThread;
293 UCHAR Number;
294 UCHAR Reserved;
295 USHORT BuildType;
296 KAFFINITY SetMember;
297 UCHAR CpuType;
298 UCHAR CpuID;
299 USHORT CpuStep;
300 KPROCESSOR_STATE ProcessorState;
301 ULONG KernelReserved[16];
302 ULONG HalReserved[16];
303 UCHAR PrcbPad0[92];
304 PVOID LockQueue[33]; // Used for Queued Spinlocks
305 struct _KTHREAD *NpxThread;
306 ULONG InterruptCount;
307 ULONG KernelTime;
308 ULONG UserTime;
309 ULONG DpcTime;
310 ULONG DebugDpcTime;
311 ULONG InterruptTime;
312 ULONG AdjustDpcThreshold;
313 ULONG PageColor;
314 UCHAR SkipTick;
315 UCHAR DebuggerSavedIRQL;
316 UCHAR Spare1[6];
317 struct _KNODE *ParentNode;
318 ULONG MultiThreadProcessorSet;
319 struct _KPRCB *MultiThreadSetMaster;
320 ULONG ThreadStartCount[2];
321 ULONG CcFastReadNoWait;
322 ULONG CcFastReadWait;
323 ULONG CcFastReadNotPossible;
324 ULONG CcCopyReadNoWait;
325 ULONG CcCopyReadWait;
326 ULONG CcCopyReadNoWaitMiss;
327 ULONG KeAlignmentFixupCount;
328 ULONG KeContextSwitches;
329 ULONG KeDcacheFlushCount;
330 ULONG KeExceptionDispatchCount;
331 ULONG KeFirstLevelTbFills;
332 ULONG KeFloatingEmulationCount;
333 ULONG KeIcacheFlushCount;
334 ULONG KeSecondLevelTbFills;
335 ULONG KeSystemCalls;
336 ULONG IoReadOperationCount;
337 ULONG IoWriteOperationCount;
338 ULONG IoOtherOperationCount;
339 LARGE_INTEGER IoReadTransferCount;
340 LARGE_INTEGER IoWriteTransferCount;
341 LARGE_INTEGER IoOtherTransferCount;
342 ULONG SpareCounter1[8];
343 PP_LOOKASIDE_LIST PPLookasideList[16];
344 PP_LOOKASIDE_LIST PPNPagedLookasideList[32];
345 PP_LOOKASIDE_LIST PPPagedLookasideList[32];
346 ULONG PacketBarrier;
347 ULONG ReverseStall;
348 PVOID IpiFrame;
349 UCHAR PrcbPad2[52];
350 PVOID CurrentPacket[3];
351 ULONG TargetSet;
352 ULONG_PTR WorkerRoutine;
353 ULONG IpiFrozen;
354 UCHAR PrcbPad3[40];
355 ULONG RequestSummary;
356 struct _KPRCB *SignalDone;
357 UCHAR PrcbPad4[56];
358 struct _KDPC_DATA DpcData[2];
359 PVOID DpcStack;
360 ULONG MaximumDpcQueueDepth;
361 ULONG DpcRequestRate;
362 ULONG MinimumDpcRate;
363 UCHAR DpcInterruptRequested;
364 UCHAR DpcThreadRequested;
365 UCHAR DpcRoutineActive;
366 UCHAR DpcThreadActive;
367 ULONG PrcbLock;
368 ULONG DpcLastCount;
369 ULONG TimerHand;
370 ULONG TimerRequest;
371 PVOID DpcThread;
372 struct _KEVENT *DpcEvent;
373 UCHAR ThreadDpcEnable;
374 BOOLEAN QuantumEnd;
375 UCHAR PrcbPad50;
376 UCHAR IdleSchedule;
377 ULONG DpcSetEventRequest;
378 UCHAR PrcbPad5[18];
379 LONG TickOffset;
380 struct _KDPC* CallDpc;
381 ULONG PrcbPad7[8];
382 LIST_ENTRY WaitListHead;
383 ULONG ReadySummary;
384 ULONG SelectNextLast;
385 LIST_ENTRY DispatcherReadyListHead[32];
386 SINGLE_LIST_ENTRY DeferredReadyListHead;
387 ULONG PrcbPad72[11];
388 PVOID ChainedInterruptList;
389 LONG LookasideIrpFloat;
390 LONG MmPageFaultCount;
391 LONG MmCopyOnWriteCount;
392 LONG MmTransitionCount;
393 LONG MmCacheTransitionCount;
394 LONG MmDemandZeroCount;
395 LONG MmPageReadCount;
396 LONG MmPageReadIoCount;
397 LONG MmCacheReadCount;
398 LONG MmCacheIoCount;
399 LONG MmDirtyPagesWriteCount;
400 LONG MmDirtyWriteIoCount;
401 LONG MmMappedPagesWriteCount;
402 LONG MmMappedWriteIoCount;
403 ULONG SpareFields0[1];
404 CHAR VendorString[13];
405 UCHAR InitialApicId;
406 UCHAR LogicalProcessorsPerPhysicalProcessor;
407 ULONG MHz;
408 ULONG FeatureBits;
409 LARGE_INTEGER UpdateSignature;
410 LARGE_INTEGER IsrTime;
411 LARGE_INTEGER SpareField1;
412 FX_SAVE_AREA NpxSaveArea;
413 PROCESSOR_POWER_STATE PowerState;
414 } KPRCB, *PKPRCB;
415
416 //
417 // Processor Control Region
418 //
419 typedef struct _KIPCR
420 {
421 union
422 {
423 NT_TIB NtTib;
424 struct
425 {
426 struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList;
427 PVOID Used_StackBase;
428 PVOID PerfGlobalGroupMask;
429 PVOID TssCopy;
430 ULONG ContextSwitches;
431 KAFFINITY SetMemberCopy;
432 PVOID Used_Self;
433 };
434 };
435 struct _KPCR *Self; /* 1C */
436 struct _KPRCB *Prcb; /* 20 */
437 KIRQL Irql; /* 24 */
438 ULONG IRR; /* 28 */
439 ULONG IrrActive; /* 2C */
440 ULONG IDR; /* 30 */
441 PVOID KdVersionBlock; /* 34 */
442 PUSHORT IDT; /* 38 */
443 PUSHORT GDT; /* 3C */
444 struct _KTSS *TSS; /* 40 */
445 USHORT MajorVersion; /* 44 */
446 USHORT MinorVersion; /* 46 */
447 KAFFINITY SetMember; /* 48 */
448 ULONG StallScaleFactor; /* 4C */
449 UCHAR SparedUnused; /* 50 */
450 UCHAR Number; /* 51 */
451 UCHAR Reserved; /* 52 */
452 UCHAR L2CacheAssociativity; /* 53 */
453 ULONG VdmAlert; /* 54 */
454 ULONG KernelReserved[14]; /* 58 */
455 ULONG L2CacheSize; /* 90 */
456 ULONG HalReserved[16]; /* 94 */
457 ULONG InterruptMode; /* D4 */
458 UCHAR KernelReserved2[0x48]; /* D8 */
459 KPRCB PrcbData; /* 120 */
460 } KIPCR, *PKIPCR;
461 #pragma pack(pop)
462
463 //
464 // TSS Definition
465 //
466 typedef struct _KiIoAccessMap
467 {
468 UCHAR DirectionMap[32];
469 UCHAR IoMap[8196];
470 } KIIO_ACCESS_MAP;
471
472 #include <pshpack1.h>
473 typedef struct _KTSS
474 {
475 USHORT Backlink;
476 USHORT Reserved0;
477 ULONG Esp0;
478 USHORT Ss0;
479 USHORT Reserved1;
480 ULONG NotUsed1[4];
481 ULONG CR3;
482 ULONG Eip;
483 ULONG NotUsed2[9];
484 USHORT Es;
485 USHORT Reserved2;
486 USHORT Cs;
487 USHORT Reserved3;
488 USHORT Ss;
489 USHORT Reserved4;
490 USHORT Ds;
491 USHORT Reserved5;
492 USHORT Fs;
493 USHORT Reserved6;
494 USHORT Gs;
495 USHORT Reserved7;
496 USHORT LDT;
497 USHORT Reserved8;
498 USHORT Flags;
499 USHORT IoMapBase;
500 KIIO_ACCESS_MAP IoMaps[1];
501 UCHAR IntDirectionMap[32];
502 } KTSS, *PKTSS;
503 #include <poppack.h>
504
505 //
506 // i386 CPUs don't have exception frames
507 //
508 typedef struct _KEXCEPTION_FRAME KEXCEPTION_FRAME, *PKEXCEPTION_FRAME;
509
510 #endif