File: x86extra.mac

package info (click to toggle)
virtualbox 7.2.4-dfsg-3
  • links: PTS, VCS
  • area: contrib
  • in suites: sid
  • size: 619,504 kB
  • sloc: cpp: 2,386,220; ansic: 2,351,736; asm: 380,287; python: 235,275; xml: 89,706; sh: 25,715; makefile: 8,169; perl: 5,697; java: 5,337; cs: 4,872; pascal: 1,785; javascript: 1,692; objc: 1,131; lex: 931; sed: 921; php: 906; yacc: 707
file content (414 lines) | stat: -rw-r--r-- 13,430 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
;; @file
; IPRT - X86 and AMD64 Structures and Definitions that are not automatically
;        converted from the C header file.
;

;
; Copyright (C) 2012-2025 Oracle and/or its affiliates.
;
; This file is part of VirtualBox base platform packages, as
; available from https://www.virtualbox.org.
;
; This program is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License
; as published by the Free Software Foundation, in version 3 of the
; License.
;
; This program is distributed in the hope that it will be useful, but
; WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
; General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, see <https://www.gnu.org/licenses>.
;
; The contents of this file may alternatively be used under the terms
; of the Common Development and Distribution License Version 1.0
; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
; in the VirtualBox distribution, in which case the provisions of the
; CDDL are applicable instead of those of the GPL.
;
; You may elect to license modified versions of this file under the
; terms and conditions of either the GPL or the CDDL or both.
;
; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
;

%ifndef ___iprt_x86extra_mac
%define ___iprt_x86extra_mac


%define X86_XCPT_DE             0x00
%define X86_XCPT_DB             0x01
%define X86_XCPT_NMI            0x02
%define X86_XCPT_BP             0x03
%define X86_XCPT_OF             0x04
%define X86_XCPT_BR             0x05
%define X86_XCPT_UD             0x06
%define X86_XCPT_NM             0x07
%define X86_XCPT_DF             0x08
%define X86_XCPT_CO_SEG_OVERRUN 0x09
%define X86_XCPT_TS             0x0a
%define X86_XCPT_NP             0x0b
%define X86_XCPT_SS             0x0c
%define X86_XCPT_GP             0x0d
%define X86_XCPT_PF             0x0e
%define X86_XCPT_MF             0x10
%define X86_XCPT_AC             0x11
%define X86_XCPT_MC             0x12
%define X86_XCPT_XF             0x13
%define X86_XCPT_VE             0x14
%define X86_XCPT_SX             0x1f

%define PAGE_SIZE               0x1000

;; Same a ~(X86_CR0_PE | X86_CR0_PG) except it won't cause assembler warnings.
%define X86_CR0_NO_PE_NO_PG 0x7ffffffe



;;
; 32-bit protected mode fstenv image.
;
struc X86FSTENV32P
        .FCW            resw 1
        .padding1       resw 1
        .FSW            resw 1
        .padding2       resw 1
        .FTW            resw 1
        .padding3       resw 1
        .FPUIP          resd 1
        .FPUCS          resw 1
        .FOP            resw 1
        .FPUDP          resd 1
        .FPUDS          resw 1
        .padding4       resw 1
endstruc


;;
; The image saved by FXSAVE.
;
struc X86FXSTATE
        .FCW            resw 1
        .FSW            resw 1
        .FTW            resw 1
        .FOP            resw 1
        .FPUIP          resd 1
        .FPUCS          resw 1
        .Rsrvd1         resw 1
        .FPUDP          resd 1
        .FPUDS          resw 1
        .Rsrvd2         resw 1
        .MXCSR          resd 1
        .MXCSR_MASK     resd 1
        .st0            resd 4
        .st1            resd 4
        .st2            resd 4
        .st3            resd 4
        .st4            resd 4
        .st5            resd 4
        .st6            resd 4
        .st7            resd 4
        .xmm0           resd 4
        .xmm1           resd 4
        .xmm2           resd 4
        .xmm3           resd 4
        .xmm4           resd 4
        .xmm5           resd 4
        .xmm6           resd 4
        .xmm7           resd 4
        .xmm8           resd 4
        .xmm9           resd 4
        .xmm10          resd 4
        .xmm11          resd 4
        .xmm12          resd 4
        .xmm13          resd 4
        .xmm14          resd 4
        .xmm15          resd 4
        .au32RsrvdRest  resd 24
endstruc


struc X86TSS16
        .selPrev        resw 1
        .sp0            resw 1
        .ss0            resw 1
        .sp1            resw 1
        .ss1            resw 1
        .sp2            resw 1
        .ss2            resw 1
        .ip             resw 1
        .flags          resw 1
        .ax             resw 1
        .cx             resw 1
        .dx             resw 1
        .bx             resw 1
        .sp             resw 1
        .bp             resw 1
        .si             resw 1
        .di             resw 1
        .es             resw 1
        .cs             resw 1
        .ss             resw 1
        .ds             resw 1
        .selLdt         resw 1
endstruc
AssertCompileSize(X86TSS16, 44)


struc X86TSS32
        .selPrev        resw 1
        .padding1       resw 1
        .esp0           resd 1
        .ss0            resw 1
        .padding_ss0    resw 1
        .esp1           resd 1
        .ss1            resw 1
        .padding_ss1    resw 1
        .esp2           resd 1
        .ss2            resw 1
        .padding_ss2    resw 1
        .cr3            resd 1
        .eip            resd 1
        .eflags         resd 1
        .eax            resd 1
        .ecx            resd 1
        .edx            resd 1
        .ebx            resd 1
        .esp            resd 1
        .ebp            resd 1
        .esi            resd 1
        .edi            resd 1
        .es             resw 1
        .padding_es     resw 1
        .cs             resw 1
        .padding_cs     resw 1
        .ss             resw 1
        .padding_ss     resw 1
        .ds             resw 1
        .padding_ds     resw 1
        .fs             resw 1
        .padding_fs     resw 1
        .gs             resw 1
        .padding_gs     resw 1
        .selLdt         resw 1
        .padding_ldt    resw 1
        .fDebugTrap     resw 1
        .offIoBitmap    resw 1
        ;.IntRedirBitmap resb 32 - this is optional.
endstruc
AssertCompileSize(X86TSS32,104)


struc X86TSS64
        .u32Reserved    resd 1
        .rsp0           resq 1
        .rsp1           resq 1
        .rsp2           resq 1
        .u32Reserved2   resd 2
        .ist1           resq 1
        .ist2           resq 1
        .ist3           resq 1
        .ist4           resq 1
        .ist5           resq 1
        .ist6           resq 1
        .ist7           resq 1
        .u16Reserved    resw 5
        .offIoBitmap    resw 1
        ;.IntRedirBitmap resb 32 - this isn't really there!! VBox addition for x86TSS32 structure compatibility in x86.h.
endstruc
AssertCompileSize(X86TSS64, 104)


;; @name Helper values for the X86_MKOP_XXX macros.
;; @{
%define X86_MKOP_GREG8_al     0
%define X86_MKOP_GREG8_cl     1
%define X86_MKOP_GREG8_dl     2
%define X86_MKOP_GREG8_bl     3
%define X86_MKOP_GREG8_ah     4
%define X86_MKOP_GREG8_ch     5
%define X86_MKOP_GREG8_dh     6
%define X86_MKOP_GREG8_bh     7
%define X86_MKOP_GREG8_spl   20
%define X86_MKOP_GREG8_bpl   21
%define X86_MKOP_GREG8_sil   22
%define X86_MKOP_GREG8_dil   23
%define X86_MKOP_GREG8_r8b    8
%define X86_MKOP_GREG8_r9b    9
%define X86_MKOP_GREG8_r10b  10
%define X86_MKOP_GREG8_r11b  11
%define X86_MKOP_GREG8_r12b  12
%define X86_MKOP_GREG8_r13b  13
%define X86_MKOP_GREG8_r14b  14
%define X86_MKOP_GREG8_r15b  15

%define X86_MKOP_GREG16_ax    0
%define X86_MKOP_GREG16_cx    1
%define X86_MKOP_GREG16_dx    2
%define X86_MKOP_GREG16_bx    3
%define X86_MKOP_GREG16_sp    4
%define X86_MKOP_GREG16_bp    5
%define X86_MKOP_GREG16_si    6
%define X86_MKOP_GREG16_di    7
%define X86_MKOP_GREG16_r8w   8
%define X86_MKOP_GREG16_r9w   9
%define X86_MKOP_GREG16_r10w 10
%define X86_MKOP_GREG16_r11w 11
%define X86_MKOP_GREG16_r12w 12
%define X86_MKOP_GREG16_r13w 13
%define X86_MKOP_GREG16_r14w 14
%define X86_MKOP_GREG16_r15w 15

%define X86_MKOP_GREG32_eax   0
%define X86_MKOP_GREG32_ecx   1
%define X86_MKOP_GREG32_edx   2
%define X86_MKOP_GREG32_ebx   3
%define X86_MKOP_GREG32_esp   4
%define X86_MKOP_GREG32_ebp   5
%define X86_MKOP_GREG32_esi   6
%define X86_MKOP_GREG32_edi   7
%define X86_MKOP_GREG32_r8d   8
%define X86_MKOP_GREG32_r9d   9
%define X86_MKOP_GREG32_r10d 10
%define X86_MKOP_GREG32_r11d 11
%define X86_MKOP_GREG32_r12d 12
%define X86_MKOP_GREG32_r13d 13
%define X86_MKOP_GREG32_r14d 14
%define X86_MKOP_GREG32_r15d 15

%define X86_MKOP_GREG64_rax   0
%define X86_MKOP_GREG64_rcx   1
%define X86_MKOP_GREG64_rdx   2
%define X86_MKOP_GREG64_rbx   3
%define X86_MKOP_GREG64_rsp   4
%define X86_MKOP_GREG64_rbp   5
%define X86_MKOP_GREG64_rsi   6
%define X86_MKOP_GREG64_rdi   7
%define X86_MKOP_GREG64_r8    8
%define X86_MKOP_GREG64_r9    9
%define X86_MKOP_GREG64_r10  10
%define X86_MKOP_GREG64_r11  11
%define X86_MKOP_GREG64_r12  12
%define X86_MKOP_GREG64_r13  13
%define X86_MKOP_GREG64_r14  14
%define X86_MKOP_GREG64_r15  15
;; @}

;;
; Encodes the MODRM byte for an instruction with 8-bit operand size.
; @param 1     The MODRM.MOD value (X86_MOD_REG, X86_MOD_MEM0, X86_MOD_MEM1, X86_MOD_MEM4).
; @param 2     The MODRM.REG register mnemonic.
; @param 3     The MODRM.RM register mnemonic.
%macro X86_MKOP_MODRM8 3
 %assign x86_mkop_modrm8_iReg  X86_MKOP_GREG8_ %+ %2
 %assign x86_mkop_modrm8_iRm   X86_MKOP_GREG8_ %+ %3
        db      X86_MODRM_MAKE(%1, x86_mkop_modrm8_iReg & 7, x86_mkop_modrm8_iRm & 7)
%endmacro

;;
; Encodes the optional REX prefix for an instruction with 8-bit operand size.
; @param 1     The MODRM.REG register mnemonic.
; @param 2     The MODRM.RM register mnemonic.
%macro X86_MKOP_REX8 2
 %assign x86_mkop_rex8_iReg     X86_MKOP_GREG8_ %+ %1
 %assign x86_mkop_rex8_iRm      X86_MKOP_GREG8_ %+ %2
 %if x86_mkop_rex8_iReg >= 8 || x86_mkop_rex8_iRm >= 8
  %if __BITS__ == 64
   %if (x86_mkop_rex8_iReg < 4 || x86_mkop_rex8_iReg >= 8) && (x86_mkop_rex8_iRm < 4 || x86_mkop_rex8_iRm >= 8)
        db      X86_OP_REX | (((x86_mkop_rex8_iReg >> 3) & 1) * X86_OP_REX_R) | (((x86_mkop_rex8_iRm >> 3) & 1) * X86_OP_REX_B)
   %else
    %error X86_MKOP_REX8: Invalid operand mix: %1, %2
   %endif
  %else
   %error X86_MKOP_REX8: not in 64-bit code: %1, %2
  %endif
 %endif
%endmacro


;;
; Encodes the MODRM byte for an instruction with 16-bit operand size.
; @param 1     The MODRM.MOD value (X86_MOD_REG, X86_MOD_MEM0, X86_MOD_MEM1, X86_MOD_MEM4).
; @param 2     The MODRM.REG register mnemonic.
; @param 3     The MODRM.RM register mnemonic.
%macro X86_MKOP_MODRM16 3
 %assign x86_mkop_modrm16_iReg  X86_MKOP_GREG16_ %+ %2
 %assign x86_mkop_modrm16_iRm   X86_MKOP_GREG16_ %+ %3
        db      X86_MODRM_MAKE(%1, x86_mkop_modrm16_iReg & 7, x86_mkop_modrm16_iRm & 7)
%endmacro

;;
; Encodes the optional REX prefix for an instruction with 16-bit operand size.
; @param 1     The MODRM.REG register mnemonic.
; @param 2     The MODRM.RM register mnemonic.
%macro X86_MKOP_REX16 2
 %assign x86_mkop_rex16_iReg    X86_MKOP_GREG16_ %+ %1
 %assign x86_mkop_rex16_iRm     X86_MKOP_GREG16_ %+ %2
 %if x86_mkop_rex16_iReg >= 8 || x86_mkop_rex16_iRm >= 8
  %if __BITS__ == 64
        db      X86_OP_REX | ((x86_mkop_rex16_iReg >> 3) * X86_OP_REX_R) | ((x86_mkop_rex16_iRm >> 3) * X86_OP_REX_B)
  %else
   %error X86_MKOP_REX16: not in 64-bit code: %1, %2
  %endif
 %endif
%endmacro


;;
; Encodes the MODRM byte for an instruction with 32-bit operand size.
; @param 1     The MODRM.MOD value (X86_MOD_REG, X86_MOD_MEM0, X86_MOD_MEM1, X86_MOD_MEM4).
; @param 2     The MODRM.REG register mnemonic.
; @param 3     The MODRM.RM register mnemonic.
%macro X86_MKOP_MODRM32 3
 %assign x86_mkop_modrm32_iReg  X86_MKOP_GREG32_ %+ %2
 %assign x86_mkop_modrm32_iRm   X86_MKOP_GREG32_ %+ %3
        db      X86_MODRM_MAKE(%1, x86_mkop_modrm32_iReg & 7, x86_mkop_modrm32_iRm & 7)
%endmacro

;;
; Encodes the optional REX prefix for an instruction with 32-bit operand size.
; @param 1     The MODRM.REG register mnemonic.
; @param 2     The MODRM.RM register mnemonic.
%macro X86_MKOP_REX32 2
 %assign x86_mkop_rex32_iReg    X86_MKOP_GREG32_ %+ %1
 %assign x86_mkop_rex32_iRm     X86_MKOP_GREG32_ %+ %2
 %if x86_mkop_rex32_iReg >= 8 || x86_mkop_rex32_iRm >= 8
  %if __BITS__ == 64
        db      X86_OP_REX | ((x86_mkop_rex32_iReg >> 3) * X86_OP_REX_R) | ((x86_mkop_rex32_iRm >> 3) * X86_OP_REX_B)
  %else
   %error X86_MKOP_REX32: not in 64-bit code: %1, %2
  %endif
 %endif
%endmacro


;;
; Encodes the MODRM byte for an instruction with 64-bit operand size.
; @param 1     The MODRM.MOD value (X86_MOD_REG, X86_MOD_MEM0, X86_MOD_MEM1, X86_MOD_MEM4).
; @param 2     The MODRM.REG register mnemonic.
; @param 3     The MODRM.RM register mnemonic.
%macro X86_MKOP_MODRM64 3
 %assign x86_mkop_modrm64_iReg  X86_MKOP_GREG64_ %+ %2
 %assign x86_mkop_modrm64_iRm   X86_MKOP_GREG64_ %+ %3
        db      X86_MODRM_MAKE(%1, x86_mkop_modrm64_iReg & 7, x86_mkop_modrm64_iRm & 7)
%endmacro

;;
; Encodes the REX prefix for an instruction with 64-bit operand size.
; @param 1     The MODRM.REG register mnemonic.
; @param 2     The MODRM.RM register mnemonic.
%macro X86_MKOP_REX64 2
 %assign x86_mkop_rex64_iReg    X86_MKOP_GREG64_ %+ %1
 %assign x86_mkop_rex64_iRm     X86_MKOP_GREG64_ %+ %2
 %if __BITS__ == 64
        db      X86_OP_REX_W | ((x86_mkop_rex64_iReg >> 3) * X86_OP_REX_R) | ((x86_mkop_rex64_iRm >> 3) * X86_OP_REX_B)
 %else
  %error X86_MKOP_REX64: not in 64-bit code: %1, %2
 %endif
%endmacro


%endif