RDFU  1.0
 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 
46 
47 
52 USHORT GetLdtr(VOID);
53 
63 
64 
65 
76 
80 
81 
82 VOID ASMWritePortByte(ULONG Port, UCHAR Value);
84 
85 
86 
91 typedef struct _x64_context
92 {
101 
107 
114 
116 
117 
124 
125 } x64_context;
126 
127 
128 
133 typedef struct _x86_context
134 {
143 
148 
155 
157 
158 
165 
166 } x86_context;
167 
168 
174 #pragma pack(push, 1)
175 
176 typedef struct _gdt_entry
177 {
178  struct
179  {
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
193  UCHAR Available: 1; // aka AVL
195  UCHAR Is32Bit : 1; // aka B flag
196  UCHAR Granularity : 1; // aka G flag
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