- Move asm.h to NDK.
[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_INITIAL_STACK 0x18
52 #define KTHREAD_STACK_LIMIT 0x1C
53 #define KTHREAD_TEB 0x20
54 #define KTHREAD_KERNEL_STACK 0x28
55 #define KTHREAD_NPX_STATE 0x31
56 #define KTHREAD_STATE 0x2D
57 #define KTHREAD_APCSTATE_PROCESS 0x34 + 0x10
58 #define KTHREAD_PENDING_USER_APC 0x34 + 0x16
59 #define KTHREAD_PENDING_KERNEL_APC 0x34 + 0x15
60 #define KTHREAD_CONTEXT_SWITCHES 0x4C
61 #define KTHREAD_WAIT_IRQL 0x54
62 #define KTHREAD_SERVICE_TABLE 0xDC
63 #define KTHREAD_PREVIOUS_MODE 0x137
64 #define KTHREAD_TRAP_FRAME 0x128
65 #define KTHREAD_CALLBACK_STACK 0x120
66
67 #define KPROCESS_DIRECTORY_TABLE_BASE 0x18
68 #define KPROCESS_LDT_DESCRIPTOR0 0x20
69 #define KPROCESS_LDT_DESCRIPTOR1 0x24
70 #define KPROCESS_IOPM_OFFSET 0x30
71
72 #define KPCR_EXCEPTION_LIST 0x0
73 #define KPCR_INITIAL_STACK 0x4
74 #define KPCR_STACK_LIMIT 0x8
75 #define KPCR_SELF 0x1C
76 #define KPCR_GDT 0x3C
77 #define KPCR_TSS 0x40
78 #define KPCR_CURRENT_THREAD 0x124
79 #define KPCR_NPX_THREAD 0x2F4
80
81 /* FPU Save Area Offsets */
82 #define FN_CONTROL_WORD 0x0
83 #define FN_STATUS_WORD 0x4
84 #define FN_TAG_WORD 0x8
85 #define FN_DATA_SELECTOR 0x18
86 #define FN_CR0_NPX_STATE 0x20C
87 #define SIZEOF_FX_SAVE_AREA 528
88
89 /* Trap Frame Offsets */
90 #define KTRAP_FRAME_DEBUGEBP 0x0
91 #define KTRAP_FRAME_DEBUGEIP 0x4
92 #define KTRAP_FRAME_DEBUGARGMARK 0x8
93 #define KTRAP_FRAME_DEBUGPOINTER 0xC
94 #define KTRAP_FRAME_TEMPSS 0x10
95 #define KTRAP_FRAME_TEMPESP 0x14
96 #define KTRAP_FRAME_DR0 0x18
97 #define KTRAP_FRAME_DR1 0x1C
98 #define KTRAP_FRAME_DR2 0x20
99 #define KTRAP_FRAME_DR3 0x24
100 #define KTRAP_FRAME_DR6 0x28
101 #define KTRAP_FRAME_DR7 0x2C
102 #define KTRAP_FRAME_GS 0x30
103 #define KTRAP_FRAME_RESERVED1 0x32
104 #define KTRAP_FRAME_ES 0x34
105 #define KTRAP_FRAME_RESERVED2 0x36
106 #define KTRAP_FRAME_DS 0x38
107 #define KTRAP_FRAME_RESERVED3 0x3A
108 #define KTRAP_FRAME_EDX 0x3C
109 #define KTRAP_FRAME_ECX 0x40
110 #define KTRAP_FRAME_EAX 0x44
111 #define KTRAP_FRAME_PREVIOUS_MODE 0x48
112 #define KTRAP_FRAME_EXCEPTION_LIST 0x4C
113 #define KTRAP_FRAME_FS 0x50
114 #define KTRAP_FRAME_RESERVED4 0x52
115 #define KTRAP_FRAME_EDI 0x54
116 #define KTRAP_FRAME_ESI 0x58
117 #define KTRAP_FRAME_EBX 0x5C
118 #define KTRAP_FRAME_EBP 0x60
119 #define KTRAP_FRAME_ERROR_CODE 0x64
120 #define KTRAP_FRAME_EIP 0x68
121 #define KTRAP_FRAME_CS 0x6C
122 #define KTRAP_FRAME_EFLAGS 0x70
123 #define KTRAP_FRAME_ESP 0x74
124 #define KTRAP_FRAME_SS 0x78
125 #define KTRAP_FRAME_RESERVED5 0x7A
126 #define KTRAP_FRAME_V86_ES 0x7C
127 #define KTRAP_FRAME_RESERVED6 0x7E
128 #define KTRAP_FRAME_V86_DS 0x80
129 #define KTRAP_FRAME_RESERVED7 0x82
130 #define KTRAP_FRAME_V86_FS 0x84
131 #define KTRAP_FRAME_RESERVED8 0x86
132 #define KTRAP_FRAME_V86_GS 0x88
133 #define KTRAP_FRAME_RESERVED9 0x8A
134 #define KTRAP_FRAME_SIZE 0x8C
135
136 /* User Shared Data */
137 #define KERNEL_USER_SHARED_DATA 0x7FFE0000
138 #define KUSER_SHARED_PROCESSOR_FEATURES KERNEL_USER_SHARED_DATA + 0x274
139 #define KUSER_SHARED_SYSCALL KERNEL_USER_SHARED_DATA + 0x300
140 #define KUSER_SHARED_SYSCALL_RET KERNEL_USER_SHARED_DATA + 0x304
141 #define PROCESSOR_FEATURE_FXSR KUSER_SHARED_PROCESSOR_FEATURES + 0x4
142
143 /* CONTEXT CONSTANTS */
144 #define CONTEXT_FLAGS 0x0
145 #define CONTEXT_DR6 0x14
146 #define CONTEXT_FLOAT_SAVE 0x1C
147 #define CONTEXT_EDI 0x9C
148 #define CONTEXT_ESI 0xA0
149 #define CONTEXT_EBX 0xA4
150 #define CONTEXT_EDX 0xA8
151 #define CONTEXT_ECX 0xAC
152 #define CONTEXT_EAX 0xB0
153 #define CONTEXT_EBP 0xB4
154 #define CONTEXT_EIP 0xB8
155 #define CONTEXT_ESP 0xC4
156 #define CONTEXT_FLOAT_SAVE_CONTROL_WORD CONTEXT_FLOAT_SAVE + FN_CONTROL_WORD
157 #define CONTEXT_FLOAT_SAVE_STATUS_WORD CONTEXT_FLOAT_SAVE + FN_STATUS_WORD
158 #define CONTEXT_FLOAT_SAVE_TAG_WORD CONTEXT_FLOAT_SAVE + FN_TAG_WORD
159
160 /* TEB CONSTANTS */
161 #define TEB_EXCEPTION_LIST 0x0
162 #define TEB_STACK_BASE 0x4
163 #define TEB_STACK_LIMIT 0x8
164 #define TEB_FIBER_DATA 0x10
165 #define TEB_ACTIVATION_CONTEXT_STACK_POINTER 0x1A8
166 #define TEB_DEALLOCATION_STACK 0xE0C
167 #define TEB_GUARANTEED_STACK_BYTES 0xF78
168 #define TEB_FLS_DATA 0xFB4
169
170 /* FIBER CONSTANTS */
171 #define FIBER_PARAMETER 0x0
172 #define FIBER_EXCEPTION_LIST 0x4
173 #define FIBER_STACK_BASE 0x8
174 #define FIBER_STACK_LIMIT 0xC
175 #define FIBER_DEALLOCATION_STACK 0x10
176 #define FIBER_CONTEXT 0x14
177 #define FIBER_GUARANTEED_STACK_BYTES 0x2E0
178 #define FIBER_FLS_DATA 0x2E4
179 #define FIBER_ACTIVATION_CONTEXT_STACK 0x2E8
180 #define FIBER_CONTEXT_FLAGS FIBER_CONTEXT + CONTEXT_FLAGS
181 #define FIBER_CONTEXT_EAX FIBER_CONTEXT + CONTEXT_EAX
182 #define FIBER_CONTEXT_EBX FIBER_CONTEXT + CONTEXT_EBX
183 #define FIBER_CONTEXT_ECX FIBER_CONTEXT + CONTEXT_ECX
184 #define FIBER_CONTEXT_EDX FIBER_CONTEXT + CONTEXT_EDX
185 #define FIBER_CONTEXT_ESI FIBER_CONTEXT + CONTEXT_ESI
186 #define FIBER_CONTEXT_EDI FIBER_CONTEXT + CONTEXT_EDI
187 #define FIBER_CONTEXT_EBP FIBER_CONTEXT + CONTEXT_EBP
188 #define FIBER_CONTEXT_ESP FIBER_CONTEXT + CONTEXT_ESP
189 #define FIBER_CONTEXT_DR6 FIBER_CONTEXT + CONTEXT_DR6
190 #define FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD FIBER_CONTEXT + CONTEXT_FLOAT_SAVE_STATUS_WORD
191 #define FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD FIBER_CONTEXT + CONTEXT_FLOAT_SAVE_CONTROL_WORD
192 #define FIBER_CONTEXT_FLOAT_SAVE_TAG_WORD FIBER_CONTEXT + CONTEXT_FLOAT_SAVE_TAG_WORD
193 #endif
194