Missing files...
[reactos.git] / reactos / include / ndk / asm.h
1 /*
2 * PROJECT: ReactOS Native Headers
3 * FILE: include/ndk/asm.h
4 * PURPOSE: Defintions for Structures used in Assembly Code
5 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
6 * UPDATE HISTORY:
7 * Created 07/19/05
8 */
9 #ifndef _ASM_H
10 #define _ASM_H
11
12 /* DEPENDENCIES **************************************************************/
13
14 /* EXPORTED DATA *************************************************************/
15
16 /* CONSTANTS *****************************************************************/
17
18 /*
19 * Definitions for the offsets of members in the KV86M_REGISTERS
20 */
21 #define KV86M_REGISTERS_EBP 0x0
22 #define KV86M_REGISTERS_EDI 0x4
23 #define KV86M_REGISTERS_ESI 0x8
24 #define KV86M_REGISTERS_EDX 0xC
25 #define KV86M_REGISTERS_ECX 0x10
26 #define KV86M_REGISTERS_EBX 0x14
27 #define KV86M_REGISTERS_EAX 0x18
28 #define KV86M_REGISTERS_DS 0x1C
29 #define KV86M_REGISTERS_ES 0x20
30 #define KV86M_REGISTERS_FS 0x24
31 #define KV86M_REGISTERS_GS 0x28
32 #define KV86M_REGISTERS_EIP 0x2C
33 #define KV86M_REGISTERS_CS 0x30
34 #define KV86M_REGISTERS_EFLAGS 0x34
35 #define KV86M_REGISTERS_ESP 0x38
36 #define KV86M_REGISTERS_SS 0x3C
37
38 #define TF_SAVED_EXCEPTION_STACK 0x8C
39 #define TF_REGS 0x90
40 #define TF_ORIG_EBP 0x94
41
42 /* TSS Offsets */
43 #define KTSS_ESP0 0x4
44 #define KTSS_CR3 0x1C
45 #define KTSS_EFLAGS 0x24
46 #define KTSS_IOMAPBASE 0x66
47
48 /*
49 * Defines for accessing KPCR and KTHREAD structure members
50 */
51 #define KTHREAD_DEBUG_ACTIVE 0x03
52 #define KTHREAD_INITIAL_STACK 0x18
53 #define KTHREAD_STACK_LIMIT 0x1C
54 #define KTHREAD_TEB 0x20
55 #define KTHREAD_KERNEL_STACK 0x28
56 #define KTHREAD_NPX_STATE 0x31
57 #define KTHREAD_STATE 0x2D
58 #define KTHREAD_ALERTED 0x2E
59 #define KTHREAD_APCSTATE_PROCESS 0x34 + 0x10
60 #define KTHREAD_PENDING_USER_APC 0x34 + 0x16
61 #define KTHREAD_PENDING_KERNEL_APC 0x34 + 0x15
62 #define KTHREAD_CONTEXT_SWITCHES 0x4C
63 #define KTHREAD_WAIT_IRQL 0x54
64 #define KTHREAD_SERVICE_TABLE 0xDC
65 #define KTHREAD_PREVIOUS_MODE 0x137
66 #define KTHREAD_TRAP_FRAME 0x128
67 #define KTHREAD_CALLBACK_STACK 0x120
68
69 #define KPROCESS_DIRECTORY_TABLE_BASE 0x18
70 #define KPROCESS_LDT_DESCRIPTOR0 0x20
71 #define KPROCESS_LDT_DESCRIPTOR1 0x24
72 #define KPROCESS_IOPM_OFFSET 0x30
73
74 #define KPCR_EXCEPTION_LIST 0x0
75 #define KPCR_INITIAL_STACK 0x4
76 #define KPCR_STACK_LIMIT 0x8
77 #define KPCR_TEB 0x18
78 #define KPCR_SELF 0x1C
79 #define KPCR_GDT 0x3C
80 #define KPCR_TSS 0x40
81 #define KPCR_CURRENT_THREAD 0x124
82 #define KPCR_NPX_THREAD 0x2F4
83
84 /* FPU Save Area Offsets */
85 #define FN_CONTROL_WORD 0x0
86 #define FN_STATUS_WORD 0x4
87 #define FN_TAG_WORD 0x8
88 #define FN_DATA_SELECTOR 0x18
89 #define FN_CR0_NPX_STATE 0x20C
90 #define SIZEOF_FX_SAVE_AREA 528
91
92 /* Trap Frame Offsets */
93 #define KTRAP_FRAME_DEBUGEBP 0x0
94 #define KTRAP_FRAME_DEBUGEIP 0x4
95 #define KTRAP_FRAME_DEBUGARGMARK 0x8
96 #define KTRAP_FRAME_DEBUGPOINTER 0xC
97 #define KTRAP_FRAME_TEMPCS 0x10
98 #define KTRAP_FRAME_TEMPESP 0x14
99 #define KTRAP_FRAME_DR0 0x18
100 #define KTRAP_FRAME_DR1 0x1C
101 #define KTRAP_FRAME_DR2 0x20
102 #define KTRAP_FRAME_DR3 0x24
103 #define KTRAP_FRAME_DR6 0x28
104 #define KTRAP_FRAME_DR7 0x2C
105 #define KTRAP_FRAME_GS 0x30
106 #define KTRAP_FRAME_RESERVED1 0x32
107 #define KTRAP_FRAME_ES 0x34
108 #define KTRAP_FRAME_RESERVED2 0x36
109 #define KTRAP_FRAME_DS 0x38
110 #define KTRAP_FRAME_RESERVED3 0x3A
111 #define KTRAP_FRAME_EDX 0x3C
112 #define KTRAP_FRAME_ECX 0x40
113 #define KTRAP_FRAME_EAX 0x44
114 #define KTRAP_FRAME_PREVIOUS_MODE 0x48
115 #define KTRAP_FRAME_EXCEPTION_LIST 0x4C
116 #define KTRAP_FRAME_FS 0x50
117 #define KTRAP_FRAME_RESERVED4 0x52
118 #define KTRAP_FRAME_EDI 0x54
119 #define KTRAP_FRAME_ESI 0x58
120 #define KTRAP_FRAME_EBX 0x5C
121 #define KTRAP_FRAME_EBP 0x60
122 #define KTRAP_FRAME_ERROR_CODE 0x64
123 #define KTRAP_FRAME_EIP 0x68
124 #define KTRAP_FRAME_CS 0x6C
125 #define KTRAP_FRAME_EFLAGS 0x70
126 #define KTRAP_FRAME_ESP 0x74
127 #define KTRAP_FRAME_SS 0x78
128 #define KTRAP_FRAME_RESERVED5 0x7A
129 #define KTRAP_FRAME_V86_ES 0x7C
130 #define KTRAP_FRAME_RESERVED6 0x7E
131 #define KTRAP_FRAME_V86_DS 0x80
132 #define KTRAP_FRAME_RESERVED7 0x82
133 #define KTRAP_FRAME_V86_FS 0x84
134 #define KTRAP_FRAME_RESERVED8 0x86
135 #define KTRAP_FRAME_V86_GS 0x88
136 #define KTRAP_FRAME_RESERVED9 0x8A
137 #define KTRAP_FRAME_SIZE 0x8C
138
139 /* User Shared Data */
140 #define KERNEL_USER_SHARED_DATA 0x7FFE0000
141 #define KUSER_SHARED_PROCESSOR_FEATURES KERNEL_USER_SHARED_DATA + 0x274
142 #define KUSER_SHARED_SYSCALL KERNEL_USER_SHARED_DATA + 0x300
143 #define KUSER_SHARED_SYSCALL_RET KERNEL_USER_SHARED_DATA + 0x304
144 #define PROCESSOR_FEATURE_FXSR KUSER_SHARED_PROCESSOR_FEATURES + 0x4
145
146 /* CONTEXT CONSTANTS */
147 #define CONTEXT_FLAGS 0x0
148 #define CONTEXT_DR6 0x14
149 #define CONTEXT_FLOAT_SAVE 0x1C
150 #define CONTEXT_SEGGS 0x8C
151 #define CONTEXT_SEGFS 0x90
152 #define CONTEXT_SEGES 0x94
153 #define CONTEXT_SEGDS 0x98
154 #define CONTEXT_EDI 0x9C
155 #define CONTEXT_ESI 0xA0
156 #define CONTEXT_EBX 0xA4
157 #define CONTEXT_EDX 0xA8
158 #define CONTEXT_ECX 0xAC
159 #define CONTEXT_EAX 0xB0
160 #define CONTEXT_EBP 0xB4
161 #define CONTEXT_EIP 0xB8
162 #define CONTEXT_SEGCS 0xBC
163 #define CONTEXT_EFLAGS 0xC0
164 #define CONTEXT_ESP 0xC4
165 #define CONTEXT_SEGSS 0xC8
166 #define CONTEXT_FLOAT_SAVE_CONTROL_WORD CONTEXT_FLOAT_SAVE + FN_CONTROL_WORD
167 #define CONTEXT_FLOAT_SAVE_STATUS_WORD CONTEXT_FLOAT_SAVE + FN_STATUS_WORD
168 #define CONTEXT_FLOAT_SAVE_TAG_WORD CONTEXT_FLOAT_SAVE + FN_TAG_WORD
169
170 /* EXCEPTION_RECORD Constants */
171 #define EXCEPTION_RECORD_EXCEPTION_CODE 0x0
172 #define EXCEPTION_RECORD_EXCEPTION_FLAGS 0x4
173 #define EXCEPTION_RECORD_EXCEPTION_RECORD 0x8
174 #define EXCEPTION_RECORD_EXCEPTION_ADDRESS 0xC
175 #define EXCEPTION_RECORD_NUMBER_PARAMETERS 0x10
176 #define SIZEOF_EXCEPTION_RECORD 0x14
177
178 /* TEB CONSTANTS */
179 #define TEB_EXCEPTION_LIST 0x0
180 #define TEB_STACK_BASE 0x4
181 #define TEB_STACK_LIMIT 0x8
182 #define TEB_FIBER_DATA 0x10
183 #define TEB_PEB 0x30
184 #define TEB_EXCEPTION_CODE 0x1A4
185 #define TEB_ACTIVATION_CONTEXT_STACK_POINTER 0x1A8
186 #define TEB_DEALLOCATION_STACK 0xE0C
187 #define TEB_GUARANTEED_STACK_BYTES 0xF78
188 #define TEB_FLS_DATA 0xFB4
189
190 /* PEB CONSTANTS */
191 #define PEB_KERNEL_CALLBACK_TABLE 0x2C
192
193 /* FIBER CONSTANTS */
194 #define FIBER_PARAMETER 0x0
195 #define FIBER_EXCEPTION_LIST 0x4
196 #define FIBER_STACK_BASE 0x8
197 #define FIBER_STACK_LIMIT 0xC
198 #define FIBER_DEALLOCATION_STACK 0x10
199 #define FIBER_CONTEXT 0x14
200 #define FIBER_GUARANTEED_STACK_BYTES 0x2E0
201 #define FIBER_FLS_DATA 0x2E4
202 #define FIBER_ACTIVATION_CONTEXT_STACK 0x2E8
203 #define FIBER_CONTEXT_FLAGS FIBER_CONTEXT + CONTEXT_FLAGS
204 #define FIBER_CONTEXT_EAX FIBER_CONTEXT + CONTEXT_EAX
205 #define FIBER_CONTEXT_EBX FIBER_CONTEXT + CONTEXT_EBX
206 #define FIBER_CONTEXT_ECX FIBER_CONTEXT + CONTEXT_ECX
207 #define FIBER_CONTEXT_EDX FIBER_CONTEXT + CONTEXT_EDX
208 #define FIBER_CONTEXT_ESI FIBER_CONTEXT + CONTEXT_ESI
209 #define FIBER_CONTEXT_EDI FIBER_CONTEXT + CONTEXT_EDI
210 #define FIBER_CONTEXT_EBP FIBER_CONTEXT + CONTEXT_EBP
211 #define FIBER_CONTEXT_ESP FIBER_CONTEXT + CONTEXT_ESP
212 #define FIBER_CONTEXT_DR6 FIBER_CONTEXT + CONTEXT_DR6
213 #define FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD FIBER_CONTEXT + CONTEXT_FLOAT_SAVE_STATUS_WORD
214 #define FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD FIBER_CONTEXT + CONTEXT_FLOAT_SAVE_CONTROL_WORD
215 #define FIBER_CONTEXT_FLOAT_SAVE_TAG_WORD FIBER_CONTEXT + CONTEXT_FLOAT_SAVE_TAG_WORD
216 #endif
217