1 | /** @file
|
---|
2 | Instruction parsing support definitions.
|
---|
3 |
|
---|
4 | Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.<BR>
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #ifndef __INSTRUCTION_PARSING_H__
|
---|
10 | #define __INSTRUCTION_PARSING_H__
|
---|
11 |
|
---|
12 | #include <Base.h>
|
---|
13 | #include <Uefi.h>
|
---|
14 |
|
---|
15 | //
|
---|
16 | // Instruction REX prefix definition
|
---|
17 | //
|
---|
18 | typedef union {
|
---|
19 | struct {
|
---|
20 | UINT8 BitB : 1;
|
---|
21 | UINT8 BitX : 1;
|
---|
22 | UINT8 BitR : 1;
|
---|
23 | UINT8 BitW : 1;
|
---|
24 | UINT8 Rex : 4;
|
---|
25 | } Bits;
|
---|
26 |
|
---|
27 | UINT8 Uint8;
|
---|
28 | } INSTRUCTION_REX_PREFIX;
|
---|
29 |
|
---|
30 | //
|
---|
31 | // Instruction ModRM definition
|
---|
32 | //
|
---|
33 | typedef union {
|
---|
34 | struct {
|
---|
35 | UINT8 Rm : 3;
|
---|
36 | UINT8 Reg : 3;
|
---|
37 | UINT8 Mod : 2;
|
---|
38 | } Bits;
|
---|
39 |
|
---|
40 | UINT8 Uint8;
|
---|
41 | } INSTRUCTION_MODRM;
|
---|
42 |
|
---|
43 | //
|
---|
44 | // Instruction SIB definition
|
---|
45 | //
|
---|
46 | typedef union {
|
---|
47 | struct {
|
---|
48 | UINT8 Base : 3;
|
---|
49 | UINT8 Index : 3;
|
---|
50 | UINT8 Scale : 2;
|
---|
51 | } Bits;
|
---|
52 |
|
---|
53 | UINT8 Uint8;
|
---|
54 | } INSTRUCTION_SIB;
|
---|
55 |
|
---|
56 | //
|
---|
57 | // Legacy Instruction Prefixes
|
---|
58 | //
|
---|
59 | #define OVERRIDE_SEGMENT_CS 0x2E
|
---|
60 | #define OVERRIDE_SEGMENT_DS 0x3E
|
---|
61 | #define OVERRIDE_SEGMENT_ES 0x26
|
---|
62 | #define OVERRIDE_SEGMENT_SS 0x36
|
---|
63 | #define OVERRIDE_SEGMENT_FS 0x64
|
---|
64 | #define OVERRIDE_SEGMENT_GS 0x65
|
---|
65 | #define OVERRIDE_OPERAND_SIZE 0x66
|
---|
66 | #define OVERRIDE_ADDRESS_SIZE 0x67
|
---|
67 | #define LOCK_PREFIX 0xF0
|
---|
68 | #define REPNZ_PREFIX 0xF2
|
---|
69 | #define REPZ_PREFIX 0xF3
|
---|
70 |
|
---|
71 | //
|
---|
72 | // REX Prefixes
|
---|
73 | //
|
---|
74 | #define REX_PREFIX_START 0x40
|
---|
75 | #define REX_PREFIX_STOP 0x4F
|
---|
76 | #define REX_64BIT_OPERAND_SIZE_MASK 0x08
|
---|
77 |
|
---|
78 | //
|
---|
79 | // Two-byte Opcode Flag
|
---|
80 | //
|
---|
81 | #define TWO_BYTE_OPCODE_ESCAPE 0x0F
|
---|
82 |
|
---|
83 | #endif
|
---|