RDFU
1.0
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Arch.h
Go to the documentation of this file.
1
11
#ifndef _ARCH_H
12
#define _ARCH_H
13
14
15
#include "
EfiScannerHeaders.h
"
16
17
23
#if defined(_WIN64)
24
typedef
UINT64
UINT_ARCH
;
25
#else
26
typedef
UINT32
UINT_ARCH
;
27
#endif
28
29
30
VOID
ASMDbgBreak
(VOID);
31
VOID
Int03Handler
(VOID);
32
33
USHORT
ASMGetRegCs
(VOID);
34
USHORT
ASMGetRegDs
(VOID);
35
USHORT
ASMGetRegEs
(VOID);
36
USHORT
ASMGetRegSs
(VOID);
37
USHORT
ASMGetRegFs
(VOID);
38
USHORT
ASMGetRegGs
(VOID);
39
40
UINT_ARCH
ASMGetRegCr0
(VOID);
41
UINT_ARCH
ASMGetRegCr2
(VOID);
42
UINT_ARCH
ASMGetRegCr3
(VOID);
43
UINT_ARCH
ASMGetRegCr4
(VOID);
44
UINT_ARCH
ASMGetRegCr8
(VOID);
45
UINT_ARCH
ASMGetRegRflags
(VOID);
46
47
48
UINT_ARCH
ASMGetIdtBase
(VOID);
49
USHORT
ASMGetIdtLimit
(VOID);
50
UINT_ARCH
ASMGetGdtBase
(VOID);
51
USHORT
ASMGetGdtLimit
(VOID);
52
USHORT
GetLdtr
(VOID);
53
54
USHORT
ASMGetTrSelector
(VOID);
55
UINT_ARCH
ASMGetRegRbx
(VOID);
56
UINT_ARCH
ASMGetRegRax
(VOID);
57
UINT_ARCH
ASMGetRegRcx
(VOID);
58
UINT_ARCH
ASMGetRegRdx
(VOID);
59
UINT_ARCH
ASMGetRegRsi
(VOID);
60
UINT_ARCH
ASMGetRegRdi
(VOID);
61
UINT_ARCH
ASMGetRegRbp
(VOID);
62
UINT_ARCH
ASMGetRegRsp
(VOID);
63
64
65
66
UINT_ARCH
ASMGetRegDr0
(VOID);
67
UINT_ARCH
ASMGetRegDr1
(VOID);
68
UINT_ARCH
ASMGetRegDr2
(VOID);
69
UINT_ARCH
ASMGetRegDr3
(VOID);
70
UINT_ARCH
ASMGetRegDr6
(VOID);
71
UINT_ARCH
ASMGetRegDr7
(VOID);
72
UINT_ARCH
ASMSetRegDr0
(VOID);
73
UINT_ARCH
ASMSetRegDr1
(VOID);
74
UINT_ARCH
ASMSetRegDr2
(VOID);
75
UINT_ARCH
ASMSetRegDr3
(VOID);
76
77
UINT_ARCH
ASMSetRegCr3
(
PVOID
NewCr3);
78
UINT_ARCH
ASMSetRegCr4
(
PVOID
NewCr4);
79
UINT_ARCH
ASMSetRegCr8
(
UINT_ARCH
NewCr8);
80
81
82
VOID
ASMWritePortByte
(
ULONG
Port,
UCHAR
Value);
83
UCHAR
ASMReadPortByte
(
ULONG
Port);
84
85
86
91
typedef
struct
_x64_context
92
{
93
ULONG64
_Rax
;
94
ULONG64
_Rbx
;
95
ULONG64
_Rcx
;
96
ULONG64
_Rdx
;
97
ULONG64
_Rsi
;
98
ULONG64
_Rdi
;
99
ULONG64
_Rbp
;
100
ULONG64
_Rsp
;
101
102
ULONG64
_Cr0
;
103
ULONG64
_Cr2
;
104
ULONG64
_Cr3
;
105
ULONG64
_Cr4
;
106
ULONG64
_Cr8
;
107
108
ULONG64
_Dr0
;
109
ULONG64
_Dr1
;
110
ULONG64
_Dr2
;
111
ULONG64
_Dr3
;
112
ULONG64
_Dr6
;
113
ULONG64
_Dr7
;
114
115
ULONG64
_Rflags
;
116
117
118
USHORT
_Cs
;
119
USHORT
_Ds
;
120
USHORT
_Es
;
121
USHORT
_Fs
;
122
USHORT
_Gs
;
123
USHORT
_Ss
;
124
125
}
x64_context
;
126
127
128
133
typedef
struct
_x86_context
134
{
135
ULONG
_Eax
;
136
ULONG
_Ebx
;
137
ULONG
_Ecx
;
138
ULONG
_Edx
;
139
ULONG
_Esi
;
140
ULONG
_Edi
;
141
ULONG
_Ebp
;
142
ULONG
_Esp
;
143
144
ULONG
_Cr0
;
145
ULONG
_Cr2
;
146
ULONG
_Cr3
;
147
ULONG
_Cr4
;
148
149
ULONG
_Dr0
;
150
ULONG
_Dr1
;
151
ULONG
_Dr2
;
152
ULONG
_Dr3
;
153
ULONG
_Dr6
;
154
ULONG
_Dr7
;
155
156
ULONG
_Eflags
;
157
158
159
USHORT
_Cs
;
160
USHORT
_Ds
;
161
USHORT
_Es
;
162
USHORT
_Fs
;
163
USHORT
_Gs
;
164
USHORT
_Ss
;
165
166
}
x86_context
;
167
168
174
#pragma pack(push, 1)
175
176
typedef
struct
_gdt_entry
177
{
178
struct
179
{
180
USHORT
LimitLow
;
181
USHORT
Base0
;
182
UCHAR
Base1
;
183
UCHAR
Type
: 4;
// 10EWA (code), E=ExpandDown, W=Writable, A=Accessed
184
// 11CRA (data), C=Conforming, R=Readable, A=Accessed
185
UCHAR
System
: 1;
// if 1 then it is a gate or LDT
186
UCHAR
DPL
: 2;
// descriptor privilege level;
187
// for data selectors, MAX(CPL, RPL) must be <= DPL to access (or else GP# fault)
188
// for non-conforming code selectors (without callgate), MAX(CPL, RPL) must be <= DPL to access (or else GP# fault)
189
// for conforming code selectors, MAX(CPL, RPL) must be >= DPL (i.e., CPL 0-2 cannot access if DPL is 3)
190
// for non-conforming code selectors (with call gate), DPL indicates lowest privilege allowed to access gate
191
UCHAR
Present
: 1;
192
UCHAR
LimitHigh
: 4;
193
UCHAR
Available
: 1;
// aka AVL
194
UCHAR
Reserved
: 1;
195
UCHAR
Is32Bit
: 1;
// aka B flag
196
UCHAR
Granularity
: 1;
// aka G flag
197
UCHAR
Base2
: 8;
198
199
// x64 extension
200
//ULONG HighOffset64;
201
//ULONG Reserved2;
202
}
s
;
203
}
gdt_entry
;
204
205
206
210
typedef
struct
211
{
212
USHORT
Limit:16;
213
USHORT
IdtBaseLo:16;
214
USHORT
IdtBaseHi:16;
215
}
idt_base
;
216
217
222
typedef
struct
223
{
224
UINT32 OffsetLow:16;
225
UINT32 SegmentSelector:16;
226
UINT32 Reserved:8;
227
UINT32 Type:4;
228
UINT32 Reserved2:1;
229
UINT32 Dpl:2;
230
UINT32 Present:1;
231
UINT32 OffsetHigh:16;
232
233
#if defined(_WIN64)
234
// for x64
235
ULONG
HighOffset64;
236
ULONG
Reserved64;
237
#endif
238
239
}
idt_entry
;
240
241
242
243
#pragma pack(pop)
244
245
246
247
#endif
Arch.h
Generated on Thu Apr 18 2013 10:57:17 for RDFU by
1.8.3.1