-
Notifications
You must be signed in to change notification settings - Fork 0
/
EFIAPI.cs
347 lines (276 loc) · 11.7 KB
/
EFIAPI.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
using System;
using System.Runtime.InteropServices;
public enum EfiEventType : uint
{
EvtTimer = 0x80000000,
EvtRuntime = 0x40000000,
EvtRuntimeContext = 0x20000000,
EvtNotifyWait = 0x00000100,
EvtNotifySignal = 0x00000200,
EvtSignalExitBootServices = 0x00000201,
EvtSignalVirtualAddressChange = 0x60000202,
EvtEfiSignalMask = 0x000000FF,
EvtEfiSignalMax = 4,
EfiEventTimer = EvtTimer,
EfiEventRuntime = EvtRuntime,
EfiEventRuntimeContext = EvtRuntimeContext,
EfiEventNotifyWait = EvtNotifyWait,
EfiEventNotifySignal = EvtNotifySignal,
EfiEventSignalExitBootServices = EvtSignalExitBootServices,
EfiEventSignalVirtualAddressChange = EvtSignalVirtualAddressChange,
EfiEventEfiSignalMask = EvtEfiSignalMask,
EfiEventEfiSignalMax = EvtEfiSignalMax
}
[StructLayout(LayoutKind.Sequential)]
public struct EfiTimeCapabilities
{
public uint Resolution; // 1e-6 parts per million
public uint Accuracy; // hertz
public byte SetsToZero; // Set clears sub-second time
}
[StructLayout(LayoutKind.Sequential)]
public struct EfiHandle
{
public UIntPtr Handle;
}
[StructLayout(LayoutKind.Sequential)]
public struct EfiEvent
{
public UIntPtr Handle;
}
[StructLayout(LayoutKind.Sequential)]
public struct EfiVirtualAddress
{
public UIntPtr Address;
}
[StructLayout(LayoutKind.Sequential)]
public struct EfiPhysicalAddress
{
public UIntPtr Address;
}
[StructLayout(LayoutKind.Sequential)]
public struct EfiOpenProtocolInformationEntry
{
public EfiHandle AgentHandle;
public EfiHandle ControllerHandle;
public uint Attributes;
public uint OpenCount;
}
public enum EfiLocateSearchType
{
AllHandles,
ByRegisterNotify,
ByProtocol
}
public enum EfiResetType
{
EfiResetCold,
EfiResetWarm,
EfiResetShutdown
}
[StructLayout(LayoutKind.Sequential)]
public struct BlockContent
{
[FieldOffset(0)] public EfiPhysicalAddress DataBlock;
[FieldOffset(0)] public EfiPhysicalAddress ContinuationPointer;
}
[StructLayout(LayoutKind.Sequential)]
public struct EfiCapsuleBlockDescriptor
{
public ulong Length;
public BlockContent Union;
}
[StructLayout(LayoutKind.Sequential)]
public struct EfiCapsuleHeader
{
public EfiGuid CapsuleGuid;
public uint HeaderSize;
public uint Flags;
public uint CapsuleImageSize;
}
public enum EfiInterfaceType
{
EfiNativeInterface,
EfiPcodeInterface
}
public enum EfiTpl : ulong
{
TplApplication = 4,
TplCallback = 8,
TplNotify = 16,
TplHighLevel = 31,
EfiTplApplication = TplApplication,
EfiTplCallback = TplCallback,
EfiTplNotify = TplNotify,
EfiTplHighLevel = TplHighLevel
}
[Flags]
public enum EfiStatus : ulong
{
EfiSuccess = 0,
EfiLoadError = 0x8000000000000000 | 1,
EfiInvalidParameter = 0x8000000000000000 | 2,
EfiUnsupported = 0x8000000000000000 | 3,
EfiBadBufferSize = 0x8000000000000000 | 4,
EfiBufferTooSmall = 0x8000000000000000 | 5,
EfiNotReady = 0x8000000000000000 | 6,
EfiDeviceError = 0x8000000000000000 | 7,
EfiWriteProtected = 0x8000000000000000 | 8,
EfiOutOfResources = 0x8000000000000000 | 9,
EfiVolumeCorrupted = 0x8000000000000000 | 10,
EfiVolumeFull = 0x8000000000000000 | 11,
EfiNoMedia = 0x8000000000000000 | 12,
EfiMediaChanged = 0x8000000000000000 | 13,
EfiNotFound = 0x8000000000000000 | 14,
EfiAccessDenied = 0x8000000000000000 | 15,
EfiNoResponse = 0x8000000000000000 | 16,
EfiNoMapping = 0x8000000000000000 | 17,
EfiTimeout = 0x8000000000000000 | 18,
EfiNotStarted = 0x8000000000000000 | 19,
EfiAlreadyStarted = 0x8000000000000000 | 20,
EfiAborted = 0x8000000000000000 | 21,
EfiIcmpError = 0x8000000000000000 | 22,
EfiTftpError = 0x8000000000000000 | 23,
EfiProtocolError = 0x8000000000000000 | 24,
EfiIncompatibleVersion = 0x8000000000000000 | 25,
EfiSecurityViolation = 0x8000000000000000 | 26,
EfiCrcError = 0x8000000000000000 | 27,
EfiEndOfMedia = 0x8000000000000000 | 28,
EfiEndOfFile = 0x8000000000000000 | 31,
EfiInvalidLanguage = 0x8000000000000000 | 32,
EfiCompromisedData = 0x8000000000000000 | 33,
EfiWarnUnknownGlyph = 1,
EfiWarnDeleteFailure = 2,
EfiWarnWriteFailure = 3,
EfiWarnBufferTooSmall = 4
}
[StructLayout(LayoutKind.Sequential)]
public readonly struct EfiTableHeader
{
public readonly ulong Signature;
public readonly uint Revision;
public readonly uint HeaderSize;
public readonly uint CRC32;
public readonly uint Reserved;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct EfiRuntimeServices
{
public readonly EfiTableHeader Hdr;
public readonly delegate* unmanaged< EfiTime*, EfiTimeCapabilities*, EfiStatus> GetTime;
public readonly delegate* unmanaged<EfiTime*, EfiStatus> SetTime;
public readonly delegate* unmanaged<byte*, byte*, EfiTime*, EfiStatus> GetWakeupTime;
public readonly delegate* unmanaged<byte, EfiTime*, EfiStatus> SetWakeupTime;
public readonly delegate* unmanaged<ulong, ulong, uint, EfiMemoryDescriptor*, EfiStatus> SetVirtualAddressMap;
public readonly delegate* unmanaged<ulong, void**, EfiStatus> ConvertPointer;
public readonly delegate* unmanaged<char*, EfiGuid*, uint*, ulong*, void*, EfiStatus> GetVariable;
public readonly delegate* unmanaged<ulong*, char*, EfiGuid*, EfiStatus> GetNextVariableName;
public readonly delegate* unmanaged<char*, EfiGuid, uint, ulong, void*, EfiStatus> SetVariable;
public readonly delegate* unmanaged<uint*, EfiStatus> GetNextHighMonotonicCount;
public readonly delegate* unmanaged<EfiResetType, ulong, char*, EfiStatus> ResetSystem;
public readonly delegate* unmanaged<EfiCapsuleHeader**, ulong, EfiPhysicalAddress, EfiStatus> UpdateCapsule;
public readonly delegate* unmanaged<EfiCapsuleHeader**, ulong, ulong*, EfiResetType*, EfiStatus>
QueryCapsuleCapabilities;
public readonly delegate* unmanaged<uint, ulong*, ulong*, ulong*, EfiStatus> QueryVariableInfo;
}
public enum EfiTimerDelay
{
TimerCancel,
TimerPeriodic,
TimerRelative,
TimerTypeMax
}
public enum EfiProtocolAttributes : uint
{
EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL = 0x00000001,
EFI_OPEN_PROTOCOL_GET_PROTOCOL = 0x00000002,
EFI_OPEN_PROTOCOL_TEST_PROTOCOL = 0x00000004,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER = 0x00000008,
EFI_OPEN_PROTOCOL_BY_DRIVER = 0x00000010,
EFI_OPEN_PROTOCOL_EXCLUSIVE = 0x00000020
}
[StructLayout(LayoutKind.Sequential)]
public readonly unsafe struct EfiBootServices
{
public readonly EfiTableHeader Hdr;
public readonly delegate* unmanaged<EfiTpl, EfiTpl> RaiseTPL;
public readonly delegate* unmanaged<EfiTpl, void> RestoreTPL;
public readonly delegate* unmanaged<EfiAllocateType, EfiMemoryType, ulong, EfiPhysicalAddress*, EfiStatus>
AllocatePages;
public readonly delegate* unmanaged<EfiPhysicalAddress, ulong, EfiStatus> FreePages;
public readonly delegate* unmanaged<ulong*, EfiMemoryDescriptor*, ulong*, ulong*, uint*, EfiStatus> GetMemoryMap;
public readonly delegate* unmanaged<EfiMemoryType, ulong, void**, EfiStatus> AllocatePool;
public readonly delegate* unmanaged<void*, EfiStatus> FreePool;
public readonly delegate* unmanaged<EfiEventType, EfiTpl,
delegate* unmanaged<EfiEvent, void*, void>,
void*, EfiEvent*, EfiStatus> CreateEvent;
public readonly delegate* unmanaged<EfiEvent, EfiTimerDelay, ulong, EfiStatus> SetTimer;
public readonly delegate* unmanaged<ulong, EfiEvent*, ulong*, EfiStatus> WaitForEvent;
public readonly delegate* unmanaged<EfiEvent, EfiStatus> SignalEvent;
public readonly delegate* unmanaged<EfiEvent, EfiStatus> CloseEvent;
public readonly delegate* unmanaged<EfiEvent, EfiStatus> CheckEvent;
public readonly delegate* unmanaged<EfiHandle*, EfiGuid*, EfiInterfaceType, void*, EfiStatus>
InstallProtocolInterface;
public readonly delegate* unmanaged<EfiHandle, EfiGuid*, void*, void*, EfiStatus> ReinstallProtocolInterface;
public readonly delegate* unmanaged<EfiHandle, EfiGuid*, void*, EfiStatus> UninstallProtocolInterface;
public readonly delegate* unmanaged<EfiHandle, EfiGuid*, void**, EfiStatus> HandleProtocol;
public readonly delegate* unmanaged<EfiHandle, EfiGuid*, void**, EfiStatus> PCHandleProtocol;
public readonly delegate* unmanaged<EfiGuid*, EfiEvent, void**> RegisterProtocolNotify;
public readonly delegate* unmanaged<EfiLocateSearchType, EfiGuid*, void*, ulong*, EfiHandle*, EfiStatus>
LocateHandle;
public readonly delegate* unmanaged<EfiGuid*, EfiDevicePathProtocol**, EfiHandle*, EfiStatus>
LocateDevicePath;
public readonly delegate* unmanaged<EfiGuid*, void*, EfiStatus> InstallConfigurationTable;
public readonly delegate* unmanaged<bool, EfiHandle, EfiDevicePathProtocol*, void*, ulong, EfiHandle*,
EfiStatus> LoadImage;
public readonly delegate* unmanaged<EfiHandle, ulong*, char**, EfiStatus> StartImage;
public readonly delegate* unmanaged<EfiHandle, EfiStatus, ulong, char*, EfiStatus> Exit;
public readonly delegate* unmanaged<EfiHandle, EfiStatus> UnloadImage;
public readonly delegate* unmanaged<EfiHandle, ulong, EfiStatus> ExitBootServices;
public readonly delegate* unmanaged<ulong*, EfiStatus> GetNextMonotonicCount;
public readonly delegate* unmanaged<ulong, EfiStatus> Stall;
public readonly delegate* unmanaged<ulong, ulong, int, char*, EfiStatus> SetWatchdogTimer;
public readonly delegate* unmanaged<EfiHandle, EfiHandle*, EfiDevicePathProtocol*, bool, EfiStatus>
ConnectController;
public readonly delegate* unmanaged<EfiHandle, EfiHandle, EfiHandle, EfiStatus> DisconnectController;
public readonly delegate* unmanaged<EfiHandle, EfiGuid*, void**, EfiHandle, EfiHandle, EfiProtocolAttributes,
EfiStatus> OpenProtocol;
public readonly delegate* unmanaged<EfiHandle, EfiGuid*, EfiHandle, EfiHandle, EfiStatus> CloseProtocol;
public readonly delegate* unmanaged<EfiHandle, EfiGuid*, EfiOpenProtocolInformationEntry**,
ulong*, EfiStatus> OpenProtocolInformation;
public readonly delegate* unmanaged<EfiHandle, EfiGuid***, ulong*, EfiStatus> ProtocolsPerHandle;
public readonly delegate* unmanaged<EfiLocateSearchType, EfiGuid*, void*, ulong*, EfiHandle**, EfiStatus>
LocateHandleBuffer;
public readonly delegate* unmanaged<EfiGuid*, void*, void**, EfiStatus> LocateProtocol;
public readonly void* InstallMultipleProtocolInterfaces;
public readonly void* UninstallMultipleProtocolInterfaces;
public readonly delegate* unmanaged<void*, ulong, int*, EfiStatus> CalculateCrc32;
public readonly delegate* unmanaged<void*, void*, ulong, void> CopyMem;
public readonly delegate* unmanaged<void*, ulong, byte, void> SetMem;
public readonly delegate* unmanaged<uint, EfiTpl,
delegate* unmanaged<EfiEvent, void*, void>, void*, EfiGuid*,
EfiEvent*, EfiStatus> CreateEventEx;
}
[StructLayout(LayoutKind.Sequential)]
public readonly unsafe struct EfiConfigurationTable
{
private readonly EfiGuid VendorGuid;
private readonly void* VendorTable;
}
[StructLayout(LayoutKind.Sequential)]
public readonly unsafe struct EfiSystemTable
{
public readonly EfiTableHeader Hdr;
public readonly char* FirmwareVendor;
public readonly uint FirmwareRevision;
public readonly EfiHandle ConsoleInHandle;
public readonly SIMPLE_INPUT_INTERFACE* ConIn;
public readonly EfiHandle ConsoleOutHandle;
public readonly SimpleTextOutputInterface* ConOut;
public readonly EfiHandle StandardErrorHandle;
public readonly SimpleTextOutputInterface* StdErr;
public readonly EfiRuntimeServices* RuntimeServices;
public readonly EfiBootServices* BootServices;
public readonly ulong NumberOfTableEntries;
public readonly EfiConfigurationTable* ConfigurationTable;
}