VirtualBox

source: vbox/trunk/src/VBox/Disassembler/DisasmInternal-x86-amd64.h@ 100763

Last change on this file since 100763 was 99236, checked in by vboxsync, 21 months ago

Disassember: Continue separation of the common disassembler and x86 specific parts, bugref:10394

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.1 KB
Line 
1/* $Id: DisasmInternal-x86-amd64.h 99236 2023-03-30 15:30:26Z vboxsync $ */
2/** @file
3 * VBox disassembler - Internal header.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef VBOX_INCLUDED_SRC_DisasmInternal_x86_amd64_h
29#define VBOX_INCLUDED_SRC_DisasmInternal_x86_amd64_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <VBox/types.h>
35#include <VBox/err.h>
36#include <VBox/dis.h>
37#include <VBox/log.h>
38
39#include <iprt/param.h>
40#include "DisasmInternal.h"
41
42
43/** @addtogroup grp_dis_int Internals.
44 * @ingroup grp_dis
45 * @{
46 */
47
48/** @name Index into g_apfnCalcSize and g_apfnFullDisasm.
49 * @{ */
50enum IDX_Parse
51{
52 IDX_ParseNop = 0,
53 IDX_ParseModRM,
54 IDX_UseModRM,
55 IDX_ParseImmByte,
56 IDX_ParseImmBRel,
57 IDX_ParseImmUshort,
58 IDX_ParseImmV,
59 IDX_ParseImmVRel,
60 IDX_ParseImmAddr,
61 IDX_ParseFixedReg,
62 IDX_ParseImmUlong,
63 IDX_ParseImmQword,
64 IDX_ParseTwoByteEsc,
65 IDX_ParseGrp1,
66 IDX_ParseShiftGrp2,
67 IDX_ParseGrp3,
68 IDX_ParseGrp4,
69 IDX_ParseGrp5,
70 IDX_Parse3DNow,
71 IDX_ParseGrp6,
72 IDX_ParseGrp7,
73 IDX_ParseGrp8,
74 IDX_ParseGrp9,
75 IDX_ParseGrp10,
76 IDX_ParseGrp12,
77 IDX_ParseGrp13,
78 IDX_ParseGrp14,
79 IDX_ParseGrp15,
80 IDX_ParseGrp16,
81 IDX_ParseGrp17,
82 IDX_ParseModFence,
83 IDX_ParseYv,
84 IDX_ParseYb,
85 IDX_ParseXv,
86 IDX_ParseXb,
87 IDX_ParseEscFP,
88 IDX_ParseNopPause,
89 IDX_ParseImmByteSX,
90 IDX_ParseImmZ,
91 IDX_ParseThreeByteEsc4,
92 IDX_ParseThreeByteEsc5,
93 IDX_ParseImmAddrF,
94 IDX_ParseInvOpModRM,
95 IDX_ParseVex2b,
96 IDX_ParseVex3b,
97 IDX_ParseVexDest,
98 IDX_ParseMax
99};
100AssertCompile(IDX_ParseMax < 64 /* Packed DISOPCODE assumption. */);
101/** @} */
102
103/**
104 * Opcode map descriptor.
105 *
106 * This is used a number of places to save storage space where there are lots of
107 * invalid instructions and the beginning or end of the map.
108 */
109typedef struct DISOPMAPDESC
110{
111 /** Pointer to the opcodes described by this structure. */
112 PCDISOPCODE papOpcodes;
113#if ARCH_BITS <= 32
114 uint16_t
115#else
116 uint32_t
117#endif
118 /** The map index corresponding to the first papOpcodes entry. */
119 idxFirst,
120 /** Number of opcodes in the map. */
121 cOpcodes;
122} DISOPMAPDESC;
123/** Pointer to a const opcode map descriptor. */
124typedef DISOPMAPDESC const *PCDISOPMAPDESC;
125
126/** @name Opcode maps.
127 * @{ */
128extern const DISOPCODE g_InvalidOpcode[1];
129
130extern const DISOPCODE g_aOneByteMapX86[256];
131extern const DISOPCODE g_aOneByteMapX64[256];
132extern const DISOPCODE g_aTwoByteMapX86[256];
133
134/** Two byte opcode map with prefix 0x66 */
135extern const DISOPCODE g_aTwoByteMapX86_PF66[256];
136
137/** Two byte opcode map with prefix 0xF2 */
138extern const DISOPCODE g_aTwoByteMapX86_PFF2[256];
139
140/** Two byte opcode map with prefix 0xF3 */
141extern const DISOPCODE g_aTwoByteMapX86_PFF3[256];
142
143/** Three byte opcode map (0xF 0x38) */
144extern PCDISOPCODE const g_apThreeByteMapX86_0F38[16];
145
146/** Three byte opcode map with prefix 0x66 (0xF 0x38) */
147extern PCDISOPCODE const g_apThreeByteMapX86_660F38[16];
148
149/** Three byte opcode map with prefix 0xF2 (0xF 0x38) */
150extern PCDISOPCODE const g_apThreeByteMapX86_F20F38[16];
151
152/** Three byte opcode map with prefix 0xF3 (0xF 0x38) */
153extern PCDISOPCODE const g_apThreeByteMapX86_F30F38[16];
154
155extern PCDISOPCODE const g_apThreeByteMapX86_0F3A[16];
156
157/** Three byte opcode map with prefix 0x66 (0xF 0x3A) */
158extern PCDISOPCODE const g_apThreeByteMapX86_660F3A[16];
159
160/** Three byte opcode map with prefixes 0x66 0xF2 (0xF 0x38) */
161extern PCDISOPCODE const g_apThreeByteMapX86_66F20F38[16];
162
163/** VEX opcodes table defined by [VEX.m-mmmm - 1].
164 * 0Fh, 0F38h, 0F3Ah correspondingly, VEX.pp = 00b */
165extern PCDISOPMAPDESC const g_apVexOpcodesMapRanges_None[3];
166
167/** VEX opcodes table defined by [VEX.m-mmmm - 1].
168 * 0Fh, 0F38h, 0F3Ah correspondingly, VEX.pp = 01b (66h) */
169extern PCDISOPMAPDESC const g_apVexOpcodesMapRanges_66H[3];
170
171/** 0Fh, 0F38h, 0F3Ah correspondingly, VEX.pp = 10b (F3h) */
172extern PCDISOPMAPDESC const g_apVexOpcodesMapRanges_F3H[3];
173
174/** 0Fh, 0F38h, 0F3Ah correspondingly, VEX.pp = 11b (F2h) */
175extern PCDISOPMAPDESC const g_apVexOpcodesMapRanges_F2H[3];
176
177/** Two dimmentional map descriptor array: first index is by VEX.pp (prefix),
178 * second by the VEX.mmmm (map).
179 * The latter has to be bounced checked as we only have the first 4 maps. */
180extern PCDISOPMAPDESC const g_aapVexOpcodesMapRanges[4][4];
181/** @} */
182
183/** @name Opcode extensions (Group tables)
184 * @{ */
185extern const DISOPCODE g_aMapX86_Group1[8*4];
186extern const DISOPCODE g_aMapX86_Group2[8*6];
187extern const DISOPCODE g_aMapX86_Group3[8*2];
188extern const DISOPCODE g_aMapX86_Group4[8];
189extern const DISOPCODE g_aMapX86_Group5[8];
190extern const DISOPCODE g_aMapX86_Group6[8];
191extern const DISOPCODE g_aMapX86_Group7_mem[8];
192extern const DISOPCODE g_aMapX86_Group7_mod11_rm000[8];
193extern const DISOPCODE g_aMapX86_Group7_mod11_rm001[8];
194extern const DISOPCODE g_aMapX86_Group8[8];
195extern const DISOPCODE g_aMapX86_Group9[8];
196extern const DISOPCODE g_aMapX86_Group10[8];
197extern const DISOPCODE g_aMapX86_Group11[8*2];
198extern const DISOPCODE g_aMapX86_Group12[8*2];
199extern const DISOPCODE g_aMapX86_Group13[8*2];
200extern const DISOPCODE g_aMapX86_Group14[8*2];
201extern const DISOPCODE g_aMapX86_Group15_mem[8];
202extern const DISOPCODE g_aMapX86_Group15_mod11_rm000[8];
203extern const DISOPCODE g_aMapX86_Group16[8];
204extern const DISOPCODE g_aMapX86_Group17[8*2];
205extern const DISOPCODE g_aMapX86_NopPause[2];
206/** @} */
207
208/** 3DNow! map (0x0F 0x0F prefix) */
209extern const DISOPCODE g_aTwoByteMapX86_3DNow[256];
210
211/** Floating point opcodes starting with escape byte 0xDF
212 * @{ */
213extern const DISOPCODE g_aMapX86_EscF0_Low[8];
214extern const DISOPCODE g_aMapX86_EscF0_High[16*4];
215extern const DISOPCODE g_aMapX86_EscF1_Low[8];
216extern const DISOPCODE g_aMapX86_EscF1_High[16*4];
217extern const DISOPCODE g_aMapX86_EscF2_Low[8];
218extern const DISOPCODE g_aMapX86_EscF2_High[16*4];
219extern const DISOPCODE g_aMapX86_EscF3_Low[8];
220extern const DISOPCODE g_aMapX86_EscF3_High[16*4];
221extern const DISOPCODE g_aMapX86_EscF4_Low[8];
222extern const DISOPCODE g_aMapX86_EscF4_High[16*4];
223extern const DISOPCODE g_aMapX86_EscF5_Low[8];
224extern const DISOPCODE g_aMapX86_EscF5_High[16*4];
225extern const DISOPCODE g_aMapX86_EscF6_Low[8];
226extern const DISOPCODE g_aMapX86_EscF6_High[16*4];
227extern const DISOPCODE g_aMapX86_EscF7_Low[8];
228extern const DISOPCODE g_aMapX86_EscF7_High[16*4];
229
230extern const PCDISOPCODE g_apMapX86_FP_Low[8];
231extern const PCDISOPCODE g_apMapX86_FP_High[8];
232/** @} */
233
234
235/** @} */
236#endif /* !VBOX_INCLUDED_SRC_DisasmInternal_x86_amd64_h */
237
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette