TianoCore EDK2 master
Loading...
Searching...
No Matches
CcInstruction.h
Go to the documentation of this file.
1
10#ifndef CC_INSTRUCTION_H_
11#define CC_INSTRUCTION_H_
12
13#include <Base.h>
14#include <Uefi.h>
15#include <Register/Amd/Ghcb.h>
18
19//
20// Instruction execution mode definition
21//
22typedef enum {
23 LongMode64Bit = 0,
24 LongModeCompat32Bit,
25 LongModeCompat16Bit,
26} CC_INSTRUCTION_MODE;
27
28//
29// Instruction size definition (for operand and address)
30//
31typedef enum {
32 Size8Bits = 0,
33 Size16Bits,
34 Size32Bits,
35 Size64Bits,
36} CC_INSTRUCTION_SIZE;
37
38//
39// Intruction segment definition
40//
41typedef enum {
42 SegmentEs = 0,
43 SegmentCs,
44 SegmentSs,
45 SegmentDs,
46 SegmentFs,
47 SegmentGs,
48} CC_INSTRUCTION_SEGMENT;
49
50//
51// Instruction rep function definition
52//
53typedef enum {
54 RepNone = 0,
55 RepZ,
56 RepNZ,
57} CC_INSTRUCTION_REP;
58
59typedef struct {
60 UINT8 Rm;
61 UINT8 Reg;
62 UINT8 Mod;
64
65typedef struct {
66 UINT8 Base;
67 UINT8 Index;
68 UINT8 Scale;
70
71//
72// Instruction opcode definition
73//
74typedef struct {
76
78
79 UINTN RegData;
80 UINTN RmData;
82
83//
84// Instruction parsing context definition
85//
86typedef struct {
87 GHCB *Ghcb;
88
89 CC_INSTRUCTION_MODE Mode;
90 CC_INSTRUCTION_SIZE DataSize;
91 CC_INSTRUCTION_SIZE AddrSize;
92 BOOLEAN SegmentSpecified;
93 CC_INSTRUCTION_SEGMENT Segment;
94 CC_INSTRUCTION_REP RepMode;
95
96 UINT8 *Begin;
97 UINT8 *End;
98
99 UINT8 *Prefixes;
100 UINT8 *OpCodes;
101 UINT8 *Displacement;
102 UINT8 *Immediate;
103
104 INSTRUCTION_REX_PREFIX RexPrefix;
105
106 BOOLEAN ModRmPresent;
107 INSTRUCTION_MODRM ModRm;
108
109 BOOLEAN SibPresent;
110 INSTRUCTION_SIB Sib;
111
112 UINTN PrefixSize;
113 UINTN OpCodeSize;
114 UINTN DisplacementSize;
115 UINTN ImmediateSize;
116
119
122 IN OUT CC_INSTRUCTION_DATA *InstructionData,
123 IN GHCB *Ghcb,
125 );
126
139UINT64 *
142 IN UINT8 Register
143 );
144
155VOID
158 IN OUT CC_INSTRUCTION_DATA *InstructionData
159 );
160
171UINT64
173 IN CC_INSTRUCTION_DATA *InstructionData
174 );
175
192 IN OUT CC_INSTRUCTION_DATA *InstructionData,
193 IN GHCB *Ghcb,
195 );
196
197#endif
UINT64 UINTN
UINT64 * CcGetRegisterPointer(IN EFI_SYSTEM_CONTEXT_X64 *Regs, IN UINT8 Register)
Definition: CcInstruction.c:31
VOID CcDecodeModRm(IN EFI_SYSTEM_CONTEXT_X64 *Regs, IN OUT CC_INSTRUCTION_DATA *InstructionData)
EFI_STATUS CcInitInstructionData(IN OUT CC_INSTRUCTION_DATA *InstructionData, IN GHCB *Ghcb, IN EFI_SYSTEM_CONTEXT_X64 *Regs)
UINT64 CcInstructionLength(IN CC_INSTRUCTION_DATA *InstructionData)
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
EFI_STATUS EFIAPI Register(IN EFI_PEI_RSC_HANDLER_CALLBACK Callback)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29