The Pedigree Project
0.1
src
system
include
pedigree
kernel
debugger
libudis86
opcmap.h
1
/*
2
* Copyright (c) 2008-2014, Pedigree Developers
3
*
4
* Please see the CONTRIB file in the root of the source tree for a full
5
* list of contributors.
6
*
7
* Permission to use, copy, modify, and distribute this software for any
8
* purpose with or without fee is hereby granted, provided that the above
9
* copyright notice and this permission notice appear in all copies.
10
*
11
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
*/
19
20
#ifndef UD_OPCMAP_H
21
#define UD_OPCMAP_H
22
23
#include "pedigree/kernel/debugger/libudis86/types.h"
24
25
/* Prefixes/Macros */
26
27
#define Pnone 0x00
28
#define Pa32 0x01
29
#define P_A32(n) ((n) & 0x01)
30
#define Po32 0x04
31
#define P_O32(n) ((n) & 0x04)
32
#define Pdef64 0x08
33
#define P_DEF64(n) ((n) & 0x08)
34
#define Pinv64 0x10
35
#define P_INV64(n) ((n) & 0x10)
36
#define Pc1 0x20
37
#define P_C1(n) ((n) & 0x20)
38
#define Pc2 0x40
39
#define P_C2(n) ((n) & 0x40)
40
#define Pc3 0x80
41
#define P_C3(n) ((n) & 0x80)
42
#define PdepM 0x100
43
#define P_DEPM(n) ((n) & 0x100)
44
#define REX(c) ((0x40 | c) << 16)
45
#define P_REX(c) (c & 0xFF0000)
46
#define P_REX_MASK(n) (0x40 | (0xF & ((n) >> 16)))
47
#define _W 8
48
#define _R 4
49
#define _X 2
50
#define _B 1
51
#define P_REX_W(r) ((0xF & (r)) >> 3)
52
#define P_REX_R(r) ((0x7 & (r)) >> 2)
53
#define P_REX_X(r) ((0x3 & (r)) >> 1)
54
#define P_REX_B(r) ((0x1 & (r)) >> 0)
55
#define SIB_S(b) ((b) >> 6)
56
#define SIB_I(b) (((b) >> 3) & 7)
57
#define SIB_B(b) ((b) & 7)
58
#define MODRM_REG(b) (((b) >> 3) & 7)
59
#define MODRM_NNN(b) (((b) >> 3) & 7)
60
#define MODRM_MOD(b) (((b) >> 6) & 3)
61
#define MODRM_RM(b) ((b) & 7)
62
63
#define SZ_Z 1
64
#define SZ_V 2
65
#define SZ_P 3
66
#define SZ_WP 4
67
#define SZ_DP 5
68
#define SZ_MDQ 6
69
#define SZ_RDQ 7
70
#define SZ_B 8
71
#define SZ_W 16
72
#define SZ_D 32
73
#define SZ_Q 64
74
#define SZ_T 80
75
76
/* -----------------------------------------------------------------------------
77
* Enumeration of types of the operands in the opcode map. The naming was
78
* inspired by the AMD manuals. To understand the specifics, read the manuals.
79
* -----------------------------------------------------------------------------
80
*/
81
enum
map_operand_type {
82
OP_NONE = 0,
83
OP_A,
84
OP_E,
85
OP_M,
86
OP_G,
87
OP_I,
88
OP_AL,
89
OP_CL,
90
OP_DL,
91
OP_BL,
92
OP_AH,
93
OP_CH,
94
OP_DH,
95
OP_BH,
96
OP_ALr8b,
97
OP_CLr9b,
98
OP_DLr10b,
99
OP_BLr11b,
100
OP_AHr12b,
101
OP_CHr13b,
102
OP_DHr14b,
103
OP_BHr15b,
104
OP_AX,
105
OP_CX,
106
OP_DX,
107
OP_BX,
108
OP_SI,
109
OP_DI,
110
OP_SP,
111
OP_BP,
112
OP_rAX,
113
OP_rCX,
114
OP_rDX,
115
OP_rBX,
116
OP_rSP,
117
OP_rBP,
118
OP_rSI,
119
OP_rDI,
120
OP_rAXr8,
121
OP_rCXr9,
122
OP_rDXr10,
123
OP_rBXr11,
124
OP_rSPr12,
125
OP_rBPr13,
126
OP_rSIr14,
127
OP_rDIr15,
128
OP_eAX,
129
OP_eCX,
130
OP_eDX,
131
OP_eBX,
132
OP_eSP,
133
OP_eBP,
134
OP_eSI,
135
OP_eDI,
136
OP_ES,
137
OP_CS,
138
OP_SS,
139
OP_DS,
140
OP_FS,
141
OP_GS,
142
OP_ST0,
143
OP_ST1,
144
OP_ST2,
145
OP_ST3,
146
OP_ST4,
147
OP_ST5,
148
OP_ST6,
149
OP_ST7,
150
OP_J,
151
OP_S,
152
OP_O,
153
OP_I1,
154
OP_I3,
155
OP_V,
156
OP_W,
157
OP_Q,
158
OP_P,
159
OP_R,
160
OP_C,
161
OP_D,
162
OP_VR,
163
OP_PR
164
};
165
166
struct
map_operand
{
167
enum
map_operand_type type;
168
uint8_t size;
169
};
170
171
struct
map_entry
{
172
enum
ud_mnemonic_code mnemonic;
173
struct
map_operand
operand1;
174
struct
map_operand
operand2;
175
struct
map_operand
operand3;
176
uint32_t prefix;
177
};
178
179
int
ud_search_map(
struct
ud
*);
180
enum
ud_mnemonic_code ud_map_get_3dnow(uint8_t);
181
182
#endif
map_entry
Definition
opcmap.h:171
map_operand
Definition
opcmap.h:166
ud
Definition
system/include/pedigree/kernel/debugger/libudis86/types.h:257
Generated on Thu Sep 24 2026 06:24:01 for The Pedigree Project by
1.9.8