- INITIAL_STALL_COUNT makes more sense in decimal (100) than hex (0x64) so define...
[reactos.git] / reactos / include / ndk / i386 / asm.h
1 /*++ NDK Version: 0095
2
3 Copyright (c) Alex Ionescu. All rights reserved.
4
5 Header Name:
6
7 asm.h
8
9 Abstract:
10
11 ASM Offsets for dealing with de-referencing structures in registers.
12 C-compatible version of the file ks386.inc present in the newest WDK.
13
14 Author:
15
16 Alex Ionescu (alex.ionescu@reactos.com) 06-Oct-2004
17
18 --*/
19
20 #ifndef _ASM_X86_H
21 #define _ASM_X86_H
22
23 //
24 // PCR Access
25 //
26 #ifdef __ASM__
27 #ifdef CONFIG_SMP
28 #define PCR fs:
29 #else
30 #define PCR ds:[0xFFDFF000]
31 #endif
32 #endif
33
34 //
35 // CPU Modes
36 //
37 #define KernelMode 0x0
38 #define UserMode 0x1
39
40 //
41 // CPU Types
42 //
43 #define CPU_NONE 0x0
44 #define CPU_INTEL 0x1
45 #define CPU_AMD 0x2
46 #define CPU_CYRIX 0x3
47 #define CPU_TRANSMETA 0x4
48 #define CPU_CENTAUR 0x5
49 #define CPU_RISE 0x6
50 #define CPU_UNKNOWN 0x7
51
52 //
53 // Selector Names
54 //
55 #ifdef __ASM__
56 #define RPL_MASK 0x0003
57 #define MODE_MASK 0x0001
58 #define KGDT_R0_CODE (0x8)
59 #define KGDT_R0_DATA (0x10)
60 #define KGDT_R3_CODE (0x18)
61 #define KGDT_R3_DATA (0x20)
62 #define KGDT_TSS (0x28)
63 #define KGDT_R0_PCR (0x30)
64 #define KGDT_R3_TEB (0x38)
65 #define KGDT_LDT (0x48)
66 #define KGDT_DF_TSS (0x50)
67 #define KGDT_NMI_TSS (0x58)
68 #endif
69
70 //
71 // KV86M_REGISTERS Offsets
72 //
73 #define KV86M_REGISTERS_EBP 0x0
74 #define KV86M_REGISTERS_EDI 0x4
75 #define KV86M_REGISTERS_ESI 0x8
76 #define KV86M_REGISTERS_EDX 0xC
77 #define KV86M_REGISTERS_ECX 0x10
78 #define KV86M_REGISTERS_EBX 0x14
79 #define KV86M_REGISTERS_EAX 0x18
80 #define KV86M_REGISTERS_DS 0x1C
81 #define KV86M_REGISTERS_ES 0x20
82 #define KV86M_REGISTERS_FS 0x24
83 #define KV86M_REGISTERS_GS 0x28
84 #define KV86M_REGISTERS_EIP 0x2C
85 #define KV86M_REGISTERS_CS 0x30
86 #define KV86M_REGISTERS_EFLAGS 0x34
87 #define KV86M_REGISTERS_ESP 0x38
88 #define KV86M_REGISTERS_SS 0x3C
89 #define TF_SAVED_EXCEPTION_STACK 0x8C
90 #define TF_REGS 0x90
91 #define TF_ORIG_EBP 0x94
92
93 //
94 // TSS Offsets
95 //
96 #define KTSS_ESP0 0x4
97 #define KTSS_CR3 0x1C
98 #define KTSS_EFLAGS 0x24
99 #define KTSS_IOMAPBASE 0x66
100 #define KTSS_IO_MAPS 0x68
101
102 //
103 // KTHREAD Offsets
104 //
105 #define KTHREAD_DEBUG_ACTIVE 0x03
106 #define KTHREAD_INITIAL_STACK 0x18
107 #define KTHREAD_STACK_LIMIT 0x1C
108 #define KTHREAD_TEB 0x74
109 #define KTHREAD_KERNEL_STACK 0x20
110 #define KTHREAD_ALERTED 0x5E
111 #define KTHREAD_APCSTATE_PROCESS 0x28 + 0x10
112 #define KTHREAD_PENDING_USER_APC 0x28 + 0x16
113 #define KTHREAD_PENDING_KERNEL_APC 0x28 + 0x15
114 #define KTHREAD_CONTEXT_SWITCHES 0x48
115 #define KTHREAD_STATE_ 0x4C
116 #define KTHREAD_NPX_STATE 0x4D
117 #define KTHREAD_WAIT_IRQL 0x4E
118 #define KTHREAD_NEXT_PROCESSOR 0x40
119 #define KTHREAD_WAIT_REASON 0x5A
120 #define KTHREAD_PRIORITY 0x5B
121 #define KTHREAD_SWAP_BUSY 0x5D
122 #define KTHREAD_SERVICE_TABLE 0x118
123 #define KTHREAD_PREVIOUS_MODE 0xD7
124 #define KTHREAD_COMBINED_APC_DISABLE 0x70
125 #define KTHREAD_SPECIAL_APC_DISABLE 0x72
126 #define KTHREAD_LARGE_STACK 0x107
127 #define KTHREAD_TRAP_FRAME 0x110
128 #define KTHREAD_CALLBACK_STACK 0x114
129 #define KTHREAD_APC_STATE_INDEX 0x11C
130 #define KTHREAD_STACK_BASE 0x158
131 #define KTHREAD_QUANTUM 0x15D
132 #define KTHREAD_KERNEL_TIME 0x160
133 #define KTHREAD_USER_TIME 0x18C
134
135 //
136 // KPROCESS Offsets
137 //
138 #define KPROCESS_DIRECTORY_TABLE_BASE 0x18
139 #define KPROCESS_LDT_DESCRIPTOR0 0x20
140 #define KPROCESS_LDT_DESCRIPTOR1 0x24
141 #define KPROCESS_INT21_DESCRIPTOR0 0x28
142 #define KPROCESS_INT21_DESCRIPTOR1 0x2C
143 #define KPROCESS_IOPM_OFFSET 0x30
144 #define KPROCESS_ACTIVE_PROCESSORS 0x34
145 #define EPROCESS_VDM_OBJECTS 0x144
146
147 //
148 // KTIMER_TABLE Offsets
149 //
150 #ifdef __ASM__
151 #define KTIMER_TABLE_ENTRY 0x00
152 #define KTIMER_TABLE_TIME 0x08
153 #define TIMER_ENTRY_SIZE 0x10
154 #define TIMER_TABLE_SIZE 0x200
155 #endif
156
157 //
158 // KPRCB Offsets
159 //
160 #define KPRCB_DR0 0x2F8
161 #define KPRCB_DR1 0x2FC
162 #define KPRCB_DR2 0x300
163 #define KPRCB_DR3 0x304
164 #define KPRCB_DR6 0x308
165 #define KPRCB_DR7 0x30C
166 #define KPRCB_TIMER_HAND 0x964
167 #define KPRCB_TIMER_REQUEST 0x968
168
169 //
170 // KPCR Offsets
171 //
172 #define KPCR_EXCEPTION_LIST 0x0
173 #define KPCR_INITIAL_STACK 0x4
174 #define KPCR_STACK_LIMIT 0x8
175 #define KPCR_PERF_GLOBAL_GROUP_MASK 0x8
176 #define KPCR_CONTEXT_SWITCHES 0x10
177 #define KPCR_SET_MEMBER_COPY 0x14
178 #define KPCR_TEB 0x18
179 #define KPCR_SELF 0x1C
180 #define KPCR_PRCB 0x20
181 #define KPCR_IRQL 0x24
182 #define KPCR_IRR 0x28
183 #define KPCR_IRR_ACTIVE 0x2C
184 #define KPCR_IDR 0x30
185 #define KPCR_KD_VERSION_BLOCK 0x34
186 #define KPCR_IDT 0x38
187 #define KPCR_GDT 0x3C
188 #define KPCR_TSS 0x40
189 #define KPCR_STALL_SCALE_FACTOR 0x4C
190 #define KPCR_SET_MEMBER 0x48
191 #define KPCR_NUMBER 0x51
192 #define KPCR_VDM_ALERT 0x54
193 #define KPCR_PRCB_DATA 0x120
194 #define KPCR_CURRENT_THREAD 0x124
195 #define KPCR_PRCB_NEXT_THREAD 0x128
196 #define KPCR_PRCB_IDLE_THREAD 0x12C
197 #define KPCR_PROCESSOR_NUMBER 0x130
198 #define KPCR_PRCB_SET_MEMBER 0x134
199 #define KPCR_PRCB_CPU_TYPE 0x138
200 #define KPCR_PRCB_PRCB_LOCK 0xA7C
201 #define KPCR_NPX_THREAD 0x640
202 #define KPCR_DR6 0x428
203 #define KPCR_DR7 0x42C
204 #define KPCR_PRCB_INTERRUPT_COUNT 0x644
205 #define KPCR_PRCB_KERNEL_TIME 0x648
206 #define KPCR_PRCB_USER_TIME 0x64C
207 #define KPCR_PRCB_DPC_TIME 0x650
208 #define KPCR_PRCB_DEBUG_DPC_TIME 0x654
209 #define KPCR_PRCB_INTERRUPT_TIME 0x658
210 #define KPCR_PRCB_ADJUST_DPC_THRESHOLD 0x65C
211 #define KPCR_PRCB_SKIP_TICK 0x664
212 #define KPCR_SYSTEM_CALLS 0x6B8
213 #define KPCR_PRCB_DPC_QUEUE_DEPTH 0xA4C
214 #define KPCR_PRCB_DPC_COUNT 0xA50
215 #define KPCR_PRCB_DPC_STACK 0xA68
216 #define KPCR_PRCB_MAXIMUM_DPC_QUEUE_DEPTH 0xA6C
217 #define KPCR_PRCB_DPC_REQUEST_RATE 0xA70
218 #define KPCR_PRCB_DPC_INTERRUPT_REQUESTED 0xA78
219 #define KPCR_PRCB_DPC_ROUTINE_ACTIVE 0xA7A
220 #define KPCR_PRCB_DPC_LAST_COUNT 0xA80
221 #define KPCR_PRCB_TIMER_REQUEST 0xA88
222 #define KPCR_PRCB_QUANTUM_END 0xAA1
223 #define KPCR_PRCB_IDLE_SCHEDULE 0xAA3
224 #define KPCR_PRCB_DEFERRED_READY_LIST_HEAD 0xC10
225 #define KPCR_PRCB_POWER_STATE_IDLE_FUNCTION 0xEC0
226
227 //
228 // KINTERRUPT Offsets
229 //
230 #define KINTERRUPT_INTERRUPT_LIST_HEAD 0x04
231 #define KINTERRUPT_SERVICE_ROUTINE 0x0C
232 #define KINTERRUPT_SERVICE_CONTEXT 0x10
233 #define KINTERRUPT_TICK_COUNT 0x18
234 #define KINTERRUPT_ACTUAL_LOCK 0x1C
235 #define KINTERRUPT_VECTOR 0x24
236 #define KINTERRUPT_IRQL 0x28
237 #define KINTERRUPT_SYNCHRONIZE_IRQL 0x29
238 #define KINTERRUPT_DISPATCH_COUNT 0x38
239
240 //
241 // KGDTENTRY Offsets
242 //
243 #define KGDT_BASE_LOW 0x2
244 #define KGDT_BASE_MID 0x4
245 #define KGDT_BASE_HI 0x7
246 #define KGDT_LIMIT_HI 0x6
247 #define KGDT_LIMIT_LOW 0x0
248
249 //
250 // FPU Save Area Offsets
251 //
252 #define FP_CONTROL_WORD 0x0
253 #define FP_STATUS_WORD 0x4
254 #define FP_TAG_WORD 0x8
255 #define FP_ERROR_OFFSET 0xC
256 #define FP_ERROR_SELECTOR 0x10
257 #define FP_DATA_OFFSET 0x14
258 #define FP_DATA_SELECTOR 0x18
259 #define FN_CR0_NPX_STATE 0x20C
260 #define SIZEOF_FX_SAVE_AREA 528
261 #define NPX_FRAME_LENGTH 0x210
262
263 //
264 // FX Save Area Offsets
265 //
266 #define FX_CONTROL_WORD 0x0
267 #define FX_STATUS_WORD 0x2
268 #define FX_TAG_WORD 0x4
269 #define FX_ERROR_OPCODE 0x6
270 #define FX_ERROR_OFFSET 0x8
271 #define FX_ERROR_SELECTOR 0xC
272 #define FX_DATA_OFFSET 0x10
273 #define FX_DATA_SELECTOR 0x14
274 #define FX_MXCSR 0x18
275
276 //
277 // NPX States
278 //
279 #define NPX_STATE_NOT_LOADED 0xA
280 #define NPX_STATE_LOADED 0x0
281
282 //
283 // Trap Frame Offsets
284 //
285 #define KTRAP_FRAME_DEBUGEBP 0x0
286 #define KTRAP_FRAME_DEBUGEIP 0x4
287 #define KTRAP_FRAME_DEBUGARGMARK 0x8
288 #define KTRAP_FRAME_DEBUGPOINTER 0xC
289 #define KTRAP_FRAME_TEMPCS 0x10
290 #define KTRAP_FRAME_TEMPESP 0x14
291 #define KTRAP_FRAME_DR0 0x18
292 #define KTRAP_FRAME_DR1 0x1C
293 #define KTRAP_FRAME_DR2 0x20
294 #define KTRAP_FRAME_DR3 0x24
295 #define KTRAP_FRAME_DR6 0x28
296 #define KTRAP_FRAME_DR7 0x2C
297 #define KTRAP_FRAME_GS 0x30
298 #define KTRAP_FRAME_RESERVED1 0x32
299 #define KTRAP_FRAME_ES 0x34
300 #define KTRAP_FRAME_RESERVED2 0x36
301 #define KTRAP_FRAME_DS 0x38
302 #define KTRAP_FRAME_RESERVED3 0x3A
303 #define KTRAP_FRAME_EDX 0x3C
304 #define KTRAP_FRAME_ECX 0x40
305 #define KTRAP_FRAME_EAX 0x44
306 #define KTRAP_FRAME_PREVIOUS_MODE 0x48
307 #define KTRAP_FRAME_EXCEPTION_LIST 0x4C
308 #define KTRAP_FRAME_FS 0x50
309 #define KTRAP_FRAME_RESERVED4 0x52
310 #define KTRAP_FRAME_EDI 0x54
311 #define KTRAP_FRAME_ESI 0x58
312 #define KTRAP_FRAME_EBX 0x5C
313 #define KTRAP_FRAME_EBP 0x60
314 #define KTRAP_FRAME_ERROR_CODE 0x64
315 #define KTRAP_FRAME_EIP 0x68
316 #define KTRAP_FRAME_CS 0x6C
317 #define KTRAP_FRAME_EFLAGS 0x70
318 #define KTRAP_FRAME_ESP 0x74
319 #define KTRAP_FRAME_SS 0x78
320 #define KTRAP_FRAME_RESERVED5 0x7A
321 #define KTRAP_FRAME_V86_ES 0x7C
322 #define KTRAP_FRAME_RESERVED6 0x7E
323 #define KTRAP_FRAME_V86_DS 0x80
324 #define KTRAP_FRAME_RESERVED7 0x82
325 #define KTRAP_FRAME_V86_FS 0x84
326 #define KTRAP_FRAME_RESERVED8 0x86
327 #define KTRAP_FRAME_V86_GS 0x88
328 #define KTRAP_FRAME_RESERVED9 0x8A
329 #define KTRAP_FRAME_SIZE 0x8C
330 #define KTRAP_FRAME_LENGTH 0x8C
331 #define KTRAP_FRAME_ALIGN 0x04
332 #define FRAME_EDITED 0xFFF8
333
334 //
335 // KUSER_SHARED_DATA Offsets
336 //
337 #ifdef __ASM__
338 #define USER_SHARED_DATA 0xFFDF0000
339 #endif
340 #define USER_SHARED_DATA_INTERRUPT_TIME 0x8
341 #define USER_SHARED_DATA_SYSTEM_TIME 0x14
342 #define USER_SHARED_DATA_TICK_COUNT 0x320
343
344 //
345 // KUSER_SHARED_DATA Offsets (this stuff is trash)
346 //
347 #define KERNEL_USER_SHARED_DATA 0x7FFE0000
348 #define KUSER_SHARED_PROCESSOR_FEATURES KERNEL_USER_SHARED_DATA + 0x274
349 #define KUSER_SHARED_SYSCALL KERNEL_USER_SHARED_DATA + 0x300
350 #define KUSER_SHARED_SYSCALL_RET KERNEL_USER_SHARED_DATA + 0x304
351 #define PROCESSOR_FEATURE_FXSR KUSER_SHARED_PROCESSOR_FEATURES + 0x4
352
353 //
354 // CONTEXT Offsets
355 //
356 #define CONTEXT_FLAGS 0x0
357 #define CONTEXT_DR6 0x14
358 #define CONTEXT_FLOAT_SAVE 0x1C
359 #define CONTEXT_SEGGS 0x8C
360 #define CONTEXT_SEGFS 0x90
361 #define CONTEXT_SEGES 0x94
362 #define CONTEXT_SEGDS 0x98
363 #define CONTEXT_EDI 0x9C
364 #define CONTEXT_ESI 0xA0
365 #define CONTEXT_EBX 0xA4
366 #define CONTEXT_EDX 0xA8
367 #define CONTEXT_ECX 0xAC
368 #define CONTEXT_EAX 0xB0
369 #define CONTEXT_EBP 0xB4
370 #define CONTEXT_EIP 0xB8
371 #define CONTEXT_SEGCS 0xBC
372 #define CONTEXT_EFLAGS 0xC0
373 #define CONTEXT_ESP 0xC4
374 #define CONTEXT_SEGSS 0xC8
375 #define CONTEXT_FLOAT_SAVE_CONTROL_WORD CONTEXT_FLOAT_SAVE + FP_CONTROL_WORD
376 #define CONTEXT_FLOAT_SAVE_STATUS_WORD CONTEXT_FLOAT_SAVE + FP_STATUS_WORD
377 #define CONTEXT_FLOAT_SAVE_TAG_WORD CONTEXT_FLOAT_SAVE + FP_TAG_WORD
378 #define CONTEXT_ALIGNED_SIZE 0x2CC
379 #define CONTEXT_FRAME_LENGTH 0x2D0
380
381 //
382 // CONTEXT Flags
383 //
384 #ifdef __ASM__
385 #define CONTEXT_CONTROL 0x10001
386 #define CONTEXT_INTEGER 0x10002
387 #define CONTEXT_SEGMENTS 0x10004
388 #define CONTEXT_FLOATING_POINT 0x10008
389 #define CONTEXT_DEBUG_REGISTERS 0x10010
390 #define CONTEXT_FULL 0x10007
391 #endif
392
393 //
394 // EXCEPTION_RECORD Offsets
395 //
396 #define EXCEPTION_RECORD_EXCEPTION_CODE 0x0
397 #define EXCEPTION_RECORD_EXCEPTION_FLAGS 0x4
398 #define EXCEPTION_RECORD_EXCEPTION_RECORD 0x8
399 #define EXCEPTION_RECORD_EXCEPTION_ADDRESS 0xC
400 #define EXCEPTION_RECORD_NUMBER_PARAMETERS 0x10
401 #define SIZEOF_EXCEPTION_RECORD 0x14
402 #define EXCEPTION_RECORD_LENGTH 0x50
403
404 //
405 // Exception types
406 //
407 #ifdef __ASM__
408 #define EXCEPTION_NONCONTINUABLE 0x0001
409 #define EXCEPTION_UNWINDING 0x0002
410 #define EXCEPTION_EXIT_UNWIND 0x0004
411 #define EXCEPTION_STACK_INVALID 0x0008
412 #define EXCEPTION_NESTED_CALL 0x00010
413 #define EXCEPTION_TARGET_UNWIND 0x00020
414 #define EXCEPTION_COLLIDED_UNWIND 0x00040
415 #define EXCEPTION_UNWIND 0x00066
416 #define EXCEPTION_EXECUTE_HANDLER 0x00001
417 #define EXCEPTION_CONTINUE_SEARCH 0x00000
418 #define EXCEPTION_CONTINUE_EXECUTION 0xFFFFFFFF
419 #define EXCEPTION_CHAIN_END 0xFFFFFFFF
420 #endif
421
422 //
423 // TEB Offsets
424 //
425 #define TEB_EXCEPTION_LIST 0x0
426 #define TEB_STACK_BASE 0x4
427 #define TEB_STACK_LIMIT 0x8
428 #define TEB_FIBER_DATA 0x10
429 #define TEB_SELF 0x18
430 #define TEB_PEB 0x30
431 #define TEB_EXCEPTION_CODE 0x1A4
432 #define TEB_ACTIVATION_CONTEXT_STACK_POINTER 0x1A8
433 #define TEB_DEALLOCATION_STACK 0xE0C
434 #define TEB_GDI_BATCH_COUNT 0xF70
435 #define TEB_GUARANTEED_STACK_BYTES 0xF78
436 #define TEB_FLS_DATA 0xFB4
437
438 //
439 // PEB Offsets
440 //
441 #define PEB_KERNEL_CALLBACK_TABLE 0x2C
442
443 //
444 // FIBER Offsets
445 //
446 #define FIBER_PARAMETER 0x0
447 #define FIBER_EXCEPTION_LIST 0x4
448 #define FIBER_STACK_BASE 0x8
449 #define FIBER_STACK_LIMIT 0xC
450 #define FIBER_DEALLOCATION_STACK 0x10
451 #define FIBER_CONTEXT 0x14
452 #define FIBER_GUARANTEED_STACK_BYTES 0x2E0
453 #define FIBER_FLS_DATA 0x2E4
454 #define FIBER_ACTIVATION_CONTEXT_STACK 0x2E8
455 #define FIBER_CONTEXT_FLAGS FIBER_CONTEXT + CONTEXT_FLAGS
456 #define FIBER_CONTEXT_EAX FIBER_CONTEXT + CONTEXT_EAX
457 #define FIBER_CONTEXT_EBX FIBER_CONTEXT + CONTEXT_EBX
458 #define FIBER_CONTEXT_ECX FIBER_CONTEXT + CONTEXT_ECX
459 #define FIBER_CONTEXT_EDX FIBER_CONTEXT + CONTEXT_EDX
460 #define FIBER_CONTEXT_ESI FIBER_CONTEXT + CONTEXT_ESI
461 #define FIBER_CONTEXT_EDI FIBER_CONTEXT + CONTEXT_EDI
462 #define FIBER_CONTEXT_EBP FIBER_CONTEXT + CONTEXT_EBP
463 #define FIBER_CONTEXT_ESP FIBER_CONTEXT + CONTEXT_ESP
464 #define FIBER_CONTEXT_DR6 FIBER_CONTEXT + CONTEXT_DR6
465 #define FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD FIBER_CONTEXT + CONTEXT_FLOAT_SAVE_STATUS_WORD
466 #define FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD FIBER_CONTEXT + CONTEXT_FLOAT_SAVE_CONTROL_WORD
467 #define FIBER_CONTEXT_FLOAT_SAVE_TAG_WORD FIBER_CONTEXT + CONTEXT_FLOAT_SAVE_TAG_WORD
468
469 //
470 // EFLAGS
471 //
472 #ifdef __ASM__
473 #define EFLAGS_TF 0x100
474 #define EFLAGS_INTERRUPT_MASK 0x200
475 #define EFLAGS_IOPL 0x3000
476 #define EFLAGS_NESTED_TASK 0x4000
477 #define EFLAGS_V86_MASK 0x20000
478 #define EFLAGS_ALIGN_CHECK 0x40000
479 #define EFLAGS_VIF 0x80000
480 #define EFLAGS_VIP 0x100000
481 #define EFLAG_SIGN 0x8000
482 #define EFLAG_ZERO 0x4000
483 #define EFLAG_SELECT (EFLAG_SIGN + EFLAG_ZERO)
484 #endif
485 #define EFLAGS_USER_SANITIZE 0x3F4DD7
486
487 //
488 // CR0
489 //
490 #define CR0_PE 0x1
491 #define CR0_MP 0x2
492 #define CR0_EM 0x4
493 #define CR0_TS 0x8
494 #define CR0_ET 0x10
495 #define CR0_NE 0x20
496 #define CR0_WP 0x10000
497 #define CR0_AM 0x40000
498 #define CR0_NW 0x20000000
499 #define CR0_CD 0x40000000
500 #define CR0_PG 0x80000000
501
502 //
503 // CR4
504 //
505 #ifdef __ASM__
506 #define CR4_VME 0x1
507 #define CR4_PVI 0x2
508 #define CR4_TSD 0x4
509 #define CR4_DE 0x8
510 #define CR4_PSE 0x10
511 #define CR4_PAE 0x20
512 #define CR4_MCE 0x40
513 #define CR4_PGE 0x80
514 #define CR4_FXSR 0x200
515 #define CR4_XMMEXCPT 0x400
516 #endif
517
518 //
519 // DR6 and 7 Masks
520 //
521 #define DR6_LEGAL 0xE00F
522 #define DR7_LEGAL 0xFFFF0155
523 #define DR7_ACTIVE 0x55
524 #define DR7_OVERRIDE_V 0x04
525 #define DR7_RESERVED_MASK 0xDC00
526 #define DR7_OVERRIDE_MASK 0xF0000
527
528 //
529 // Usermode callout frame definitions
530 //
531 #define CBSTACK_STACK 0x0
532 #define CBSTACK_TRAP_FRAME 0x4
533 #define CBSTACK_CALLBACK_STACK 0x8
534 #define CBSTACK_EBP 0x18
535 #define CBSTACK_RESULT 0x20
536 #define CBSTACK_RESULT_LENGTH 0x24
537 #define CBSTACK_FRAME_POINTER CBSTACK_EBP
538
539 //
540 // NTSTATUS, Bugcheck Codes and Debug Codes
541 //
542 #ifdef __ASM__
543 #define STATUS_ACCESS_VIOLATION 0xC0000005
544 #define STATUS_IN_PAGE_ERROR 0xC0000006
545 #define STATUS_GUARD_PAGE_VIOLATION 0x80000001
546 #define STATUS_PRIVILEGED_INSTRUCTION 0xC0000096
547 #define STATUS_STACK_OVERFLOW 0xC00000FD
548 #define KI_EXCEPTION_ACCESS_VIOLATION 0x10000004
549 #define STATUS_INVALID_SYSTEM_SERVICE 0xC000001C
550 #define STATUS_NO_CALLBACK_ACTIVE 0xC0000258
551 #define STATUS_CALLBACK_POP_STACK 0xC0000423
552 #define STATUS_ARRAY_BOUNDS_EXCEEDED 0xC000008C
553 #define STATUS_ILLEGAL_INSTRUCTION 0xC000001D
554 #define STATUS_INVALID_LOCK_SEQUENCE 0xC000001E
555 #define STATUS_BREAKPOINT 0x80000003
556 #define STATUS_SINGLE_STEP 0x80000004
557 #define STATUS_INTEGER_DIVIDE_BY_ZERO 0xC0000094
558 #define STATUS_INTEGER_OVERFLOW 0xC0000095
559 #define STATUS_FLOAT_DENORMAL_OPERAND 0xC000008D
560 #define STATUS_FLOAT_DIVIDE_BY_ZERO 0xC000008E
561 #define STATUS_FLOAT_INEXACT_RESULT 0xC000008F
562 #define STATUS_FLOAT_INVALID_OPERATION 0xC0000090
563 #define STATUS_FLOAT_OVERFLOW 0xC0000091
564 #define STATUS_FLOAT_STACK_CHECK 0xC0000092
565 #define STATUS_FLOAT_UNDERFLOW 0xC0000093
566 #define STATUS_FLOAT_MULTIPLE_FAULTS 0xC00002B4
567 #define STATUS_FLOAT_MULTIPLE_TRAPS 0xC00002B5
568 #define STATUS_ASSERTION_FAILURE 0xC0000420
569 #define APC_INDEX_MISMATCH 0x01
570 #define IRQL_NOT_GREATER_OR_EQUAL 0x09
571 #define IRQL_NOT_LESS_OR_EQUAL 0x0A
572 #define TRAP_CAUSE_UNKNOWN 0x12
573 #define KMODE_EXCEPTION_NOT_HANDLED 0x13
574 #define IRQL_GT_ZERO_AT_SYSTEM_SERVICE 0x4A
575 #define UNEXPECTED_KERNEL_MODE_TRAP 0x7F
576 #define ATTEMPTED_SWITCH_FROM_DPC 0xB8
577 #define HARDWARE_INTERRUPT_STORM 0xF2
578 #define DBG_STATUS_CONTROL_C 0x01
579
580 //
581 // DebugService Control Types
582 //
583 #define BREAKPOINT_BREAK 0x0
584
585 //
586 // IRQL Levels
587 //
588 #define PASSIVE_LEVEL 0x0
589 #define APC_LEVEL 0x1
590 #define DISPATCH_LEVEL 0x2
591 #define PROFILE_LEVEL 0x1B
592 #define CLOCK2_LEVEL 0x1C
593 #define IPI_LEVEL 0x1D
594 #define HIGH_LEVEL 0x1F
595
596 //
597 // Synchronization-level IRQL
598 //
599 #ifndef CONFIG_SMP
600 #define SYNCH_LEVEL DISPATCH_LEVEL
601 #else
602 #if (NTDDI_VERSION < NTDDI_WS03)
603 #define SYNCH_LEVEL (IPI_LEVEL - 0x1)
604 #else
605 #define SYNCH_LEVEL (IPI_LEVEL - 0x2)
606 #endif
607 #endif
608
609 //
610 // Quantum Decrements
611 //
612 #define CLOCK_QUANTUM_DECREMENT 0x3
613 #endif
614
615 //
616 // System Call Table definitions
617 //
618 #define NUMBER_SERVICE_TABLES 0x0002
619 #define SERVICE_NUMBER_MASK 0x0FFF
620 #define SERVICE_TABLE_SHIFT 0x0008
621 #define SERVICE_TABLE_MASK 0x0010
622 #define SERVICE_TABLE_TEST 0x0010
623 #define SERVICE_DESCRIPTOR_BASE 0x0000
624 #define SERVICE_DESCRIPTOR_COUNT 0x0004
625 #define SERVICE_DESCRIPTOR_LIMIT 0x0008
626 #define SERVICE_DESCRIPTOR_NUMBER 0x000C
627 #define SERVICE_DESCRIPTOR_LENGTH 0x0010
628
629 //
630 // VDM State Pointer
631 //
632 #define FIXED_NTVDMSTATE_LINEAR_PC_AT 0x714
633
634 //
635 // Machine types
636 //
637 #ifdef __ASM__
638 #define MACHINE_TYPE_ISA 0x0000
639 #define MACHINE_TYPE_EISA 0x0001
640 #define MACHINE_TYPE_MCA 0x0002
641
642 //
643 // Kernel Feature Bits
644 //
645 #define KF_RDTSC 0x00000002
646
647 //
648 // Kernel Stack Size
649 //
650 #define KERNEL_STACK_SIZE 0x3000
651 #endif
652
653 //
654 // Generic Definitions
655 //
656 #define PRIMARY_VECTOR_BASE 0x30 // FIXME: HACK
657 #define MAXIMUM_IDTVECTOR 0xFF
658 #endif // !_ASM_X86_H