2f345309e0ae8b0be1b7271f3685d2b90f57a3da
[reactos.git] / reactos / include / ndk / 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
13 Author:
14
15 Alex Ionescu (alex.ionescu@reactos.com) 06-Oct-2004
16
17 --*/
18
19 #ifndef _ASM_H
20 #define _ASM_H
21
22 //
23 // Selector Names
24 //
25 #define RPL_MASK 0x0003
26 #define MODE_MASK 0x0001
27 #define KGDT_R0_CODE (0x8)
28 #define KGDT_R0_DATA (0x10)
29 #define KGDT_R3_CODE (0x18)
30 #define KGDT_R3_DATA (0x20)
31 #define KGDT_TSS (0x28)
32 #define KGDT_R0_PCR (0x30)
33 #define KGDT_R3_TEB (0x38)
34 #define KGDT_LDT (0x48)
35 #define KGDT_DF_TSS (0x50)
36
37 //
38 // KV86M_REGISTERS Offsets
39 //
40 #define KV86M_REGISTERS_EBP 0x0
41 #define KV86M_REGISTERS_EDI 0x4
42 #define KV86M_REGISTERS_ESI 0x8
43 #define KV86M_REGISTERS_EDX 0xC
44 #define KV86M_REGISTERS_ECX 0x10
45 #define KV86M_REGISTERS_EBX 0x14
46 #define KV86M_REGISTERS_EAX 0x18
47 #define KV86M_REGISTERS_DS 0x1C
48 #define KV86M_REGISTERS_ES 0x20
49 #define KV86M_REGISTERS_FS 0x24
50 #define KV86M_REGISTERS_GS 0x28
51 #define KV86M_REGISTERS_EIP 0x2C
52 #define KV86M_REGISTERS_CS 0x30
53 #define KV86M_REGISTERS_EFLAGS 0x34
54 #define KV86M_REGISTERS_ESP 0x38
55 #define KV86M_REGISTERS_SS 0x3C
56 #define TF_SAVED_EXCEPTION_STACK 0x8C
57 #define TF_REGS 0x90
58 #define TF_ORIG_EBP 0x94
59
60 //
61 // TSS Offsets
62 //
63 #define KTSS_ESP0 0x4
64 #define KTSS_CR3 0x1C
65 #define KTSS_EFLAGS 0x24
66 #define KTSS_IOMAPBASE 0x66
67 #define KTSS_IO_MAPS 0x68
68
69 //
70 // KTHREAD Offsets
71 //
72 #define KTHREAD_DEBUG_ACTIVE 0x03
73 #define KTHREAD_INITIAL_STACK 0x18
74 #define KTHREAD_STACK_LIMIT 0x1C
75 #define KTHREAD_TEB 0x74
76 #define KTHREAD_KERNEL_STACK 0x20
77 #define KTHREAD_NPX_STATE 0x4D
78 #define KTHREAD_STATE 0x4C
79 #define KTHREAD_ALERTED 0x5E
80 #define KTHREAD_APCSTATE_PROCESS 0x28 + 0x10
81 #define KTHREAD_PENDING_USER_APC 0x28 + 0x16
82 #define KTHREAD_PENDING_KERNEL_APC 0x28 + 0x15
83 #define KTHREAD_CONTEXT_SWITCHES 0x48
84 #define KTHREAD_WAIT_IRQL 0x4E
85 #define KTHREAD_SERVICE_TABLE 0x118
86 #define KTHREAD_PREVIOUS_MODE 0xD7
87 #define KTHREAD_TRAP_FRAME 0x110
88 #define KTHREAD_CALLBACK_STACK 0x114
89
90 //
91 // KPROCESS Offsets
92 //
93 #define KPROCESS_DIRECTORY_TABLE_BASE 0x18
94 #define KPROCESS_LDT_DESCRIPTOR0 0x20
95 #define KPROCESS_LDT_DESCRIPTOR1 0x24
96 #define KPROCESS_IOPM_OFFSET 0x30
97
98 //
99 // KPCR Offsets
100 //
101 #define KPCR_EXCEPTION_LIST 0x0
102 #define KPCR_INITIAL_STACK 0x4
103 #define KPCR_STACK_LIMIT 0x8
104 #define KPCR_TEB 0x18
105 #define KPCR_SELF 0x1C
106 #define KPCR_GDT 0x3C
107 #define KPCR_TSS 0x40
108 #define KPCR_CURRENT_THREAD 0x124
109 #define KPCR_NPX_THREAD 0x2F4
110
111 //
112 // FPU Save Area Offsets
113 //
114 #define FN_CONTROL_WORD 0x0
115 #define FN_STATUS_WORD 0x4
116 #define FN_TAG_WORD 0x8
117 #define FN_DATA_SELECTOR 0x18
118 #define FN_CR0_NPX_STATE 0x20C
119 #define SIZEOF_FX_SAVE_AREA 528
120
121 //
122 // Trap Frame Offsets
123 //
124 #define KTRAP_FRAME_DEBUGEBP 0x0
125 #define KTRAP_FRAME_DEBUGEIP 0x4
126 #define KTRAP_FRAME_DEBUGARGMARK 0x8
127 #define KTRAP_FRAME_DEBUGPOINTER 0xC
128 #define KTRAP_FRAME_TEMPCS 0x10
129 #define KTRAP_FRAME_TEMPESP 0x14
130 #define KTRAP_FRAME_DR0 0x18
131 #define KTRAP_FRAME_DR1 0x1C
132 #define KTRAP_FRAME_DR2 0x20
133 #define KTRAP_FRAME_DR3 0x24
134 #define KTRAP_FRAME_DR6 0x28
135 #define KTRAP_FRAME_DR7 0x2C
136 #define KTRAP_FRAME_GS 0x30
137 #define KTRAP_FRAME_RESERVED1 0x32
138 #define KTRAP_FRAME_ES 0x34
139 #define KTRAP_FRAME_RESERVED2 0x36
140 #define KTRAP_FRAME_DS 0x38
141 #define KTRAP_FRAME_RESERVED3 0x3A
142 #define KTRAP_FRAME_EDX 0x3C
143 #define KTRAP_FRAME_ECX 0x40
144 #define KTRAP_FRAME_EAX 0x44
145 #define KTRAP_FRAME_PREVIOUS_MODE 0x48
146 #define KTRAP_FRAME_EXCEPTION_LIST 0x4C
147 #define KTRAP_FRAME_FS 0x50
148 #define KTRAP_FRAME_RESERVED4 0x52
149 #define KTRAP_FRAME_EDI 0x54
150 #define KTRAP_FRAME_ESI 0x58
151 #define KTRAP_FRAME_EBX 0x5C
152 #define KTRAP_FRAME_EBP 0x60
153 #define KTRAP_FRAME_ERROR_CODE 0x64
154 #define KTRAP_FRAME_EIP 0x68
155 #define KTRAP_FRAME_CS 0x6C
156 #define KTRAP_FRAME_EFLAGS 0x70
157 #define KTRAP_FRAME_ESP 0x74
158 #define KTRAP_FRAME_SS 0x78
159 #define KTRAP_FRAME_RESERVED5 0x7A
160 #define KTRAP_FRAME_V86_ES 0x7C
161 #define KTRAP_FRAME_RESERVED6 0x7E
162 #define KTRAP_FRAME_V86_DS 0x80
163 #define KTRAP_FRAME_RESERVED7 0x82
164 #define KTRAP_FRAME_V86_FS 0x84
165 #define KTRAP_FRAME_RESERVED8 0x86
166 #define KTRAP_FRAME_V86_GS 0x88
167 #define KTRAP_FRAME_RESERVED9 0x8A
168 #define KTRAP_FRAME_SIZE 0x8C
169
170 //
171 // KUSER_SHARED_DATA Offsets
172 //
173 #define KERNEL_USER_SHARED_DATA 0x7FFE0000
174 #define KUSER_SHARED_PROCESSOR_FEATURES KERNEL_USER_SHARED_DATA + 0x274
175 #define KUSER_SHARED_SYSCALL KERNEL_USER_SHARED_DATA + 0x300
176 #define KUSER_SHARED_SYSCALL_RET KERNEL_USER_SHARED_DATA + 0x304
177 #define PROCESSOR_FEATURE_FXSR KUSER_SHARED_PROCESSOR_FEATURES + 0x4
178
179 //
180 // CONTEXT Offsets
181 //
182 #define CONTEXT_FLAGS 0x0
183 #define CONTEXT_DR6 0x14
184 #define CONTEXT_FLOAT_SAVE 0x1C
185 #define CONTEXT_SEGGS 0x8C
186 #define CONTEXT_SEGFS 0x90
187 #define CONTEXT_SEGES 0x94
188 #define CONTEXT_SEGDS 0x98
189 #define CONTEXT_EDI 0x9C
190 #define CONTEXT_ESI 0xA0
191 #define CONTEXT_EBX 0xA4
192 #define CONTEXT_EDX 0xA8
193 #define CONTEXT_ECX 0xAC
194 #define CONTEXT_EAX 0xB0
195 #define CONTEXT_EBP 0xB4
196 #define CONTEXT_EIP 0xB8
197 #define CONTEXT_SEGCS 0xBC
198 #define CONTEXT_EFLAGS 0xC0
199 #define CONTEXT_ESP 0xC4
200 #define CONTEXT_SEGSS 0xC8
201 #define CONTEXT_FLOAT_SAVE_CONTROL_WORD CONTEXT_FLOAT_SAVE + FN_CONTROL_WORD
202 #define CONTEXT_FLOAT_SAVE_STATUS_WORD CONTEXT_FLOAT_SAVE + FN_STATUS_WORD
203 #define CONTEXT_FLOAT_SAVE_TAG_WORD CONTEXT_FLOAT_SAVE + FN_TAG_WORD
204
205 //
206 // EXCEPTION_RECORD Offsets
207 //
208 #define EXCEPTION_RECORD_EXCEPTION_CODE 0x0
209 #define EXCEPTION_RECORD_EXCEPTION_FLAGS 0x4
210 #define EXCEPTION_RECORD_EXCEPTION_RECORD 0x8
211 #define EXCEPTION_RECORD_EXCEPTION_ADDRESS 0xC
212 #define EXCEPTION_RECORD_NUMBER_PARAMETERS 0x10
213 #define SIZEOF_EXCEPTION_RECORD 0x14
214
215 //
216 // TEB Offsets
217 //
218 #define TEB_EXCEPTION_LIST 0x0
219 #define TEB_STACK_BASE 0x4
220 #define TEB_STACK_LIMIT 0x8
221 #define TEB_FIBER_DATA 0x10
222 #define TEB_PEB 0x30
223 #define TEB_EXCEPTION_CODE 0x1A4
224 #define TEB_ACTIVATION_CONTEXT_STACK_POINTER 0x1A8
225 #define TEB_DEALLOCATION_STACK 0xE0C
226 #define TEB_GUARANTEED_STACK_BYTES 0xF78
227 #define TEB_FLS_DATA 0xFB4
228
229 //
230 // PEB Offsets
231 //
232 #define PEB_KERNEL_CALLBACK_TABLE 0x2C
233
234 //
235 // FIBER Offsets
236 //
237 #define FIBER_PARAMETER 0x0
238 #define FIBER_EXCEPTION_LIST 0x4
239 #define FIBER_STACK_BASE 0x8
240 #define FIBER_STACK_LIMIT 0xC
241 #define FIBER_DEALLOCATION_STACK 0x10
242 #define FIBER_CONTEXT 0x14
243 #define FIBER_GUARANTEED_STACK_BYTES 0x2E0
244 #define FIBER_FLS_DATA 0x2E4
245 #define FIBER_ACTIVATION_CONTEXT_STACK 0x2E8
246 #define FIBER_CONTEXT_FLAGS FIBER_CONTEXT + CONTEXT_FLAGS
247 #define FIBER_CONTEXT_EAX FIBER_CONTEXT + CONTEXT_EAX
248 #define FIBER_CONTEXT_EBX FIBER_CONTEXT + CONTEXT_EBX
249 #define FIBER_CONTEXT_ECX FIBER_CONTEXT + CONTEXT_ECX
250 #define FIBER_CONTEXT_EDX FIBER_CONTEXT + CONTEXT_EDX
251 #define FIBER_CONTEXT_ESI FIBER_CONTEXT + CONTEXT_ESI
252 #define FIBER_CONTEXT_EDI FIBER_CONTEXT + CONTEXT_EDI
253 #define FIBER_CONTEXT_EBP FIBER_CONTEXT + CONTEXT_EBP
254 #define FIBER_CONTEXT_ESP FIBER_CONTEXT + CONTEXT_ESP
255 #define FIBER_CONTEXT_DR6 FIBER_CONTEXT + CONTEXT_DR6
256 #define FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD FIBER_CONTEXT + CONTEXT_FLOAT_SAVE_STATUS_WORD
257 #define FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD FIBER_CONTEXT + CONTEXT_FLOAT_SAVE_CONTROL_WORD
258 #define FIBER_CONTEXT_FLOAT_SAVE_TAG_WORD FIBER_CONTEXT + CONTEXT_FLOAT_SAVE_TAG_WORD
259
260 #endif // !_ASM_H
261