]> git.saurik.com Git - apple/xnu.git/blob - pexpert/pexpert/i386/efi.h
c8fc91a67db38245c9a6b609b721eec4fa33388a
[apple/xnu.git] / pexpert / pexpert / i386 / efi.h
1 /*
2 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 2.0 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23 #ifndef _PEXPERT_I386_EFI_H
24 #define _PEXPERT_I386_EFI_H
25
26 typedef uint8_t EFI_UINT8;
27 typedef uint16_t EFI_UINT16;
28 typedef uint32_t EFI_UINT32;
29 typedef uint64_t EFI_UINT64;
30
31 typedef uint32_t EFI_UINTN;
32
33 typedef int8_t EFI_INT8;
34 typedef int16_t EFI_INT16;
35 typedef int32_t EFI_INT32;
36 typedef int64_t EFI_INT64;
37
38 typedef int8_t EFI_CHAR8;
39 typedef int16_t EFI_CHAR16;
40 typedef int32_t EFI_CHAR32;
41 typedef int64_t EFI_CHAR64;
42
43 typedef uint32_t EFI_STATUS;
44 typedef boolean_t EFI_BOOLEAN;
45 typedef void VOID;
46 typedef VOID * EFI_HANDLE;
47
48 typedef uint64_t EFI_PTR64;
49 typedef uint64_t EFI_HANDLE64;
50 /*
51
52 Portions Copyright 2004, Intel Corporation
53 All rights reserved. This program and the accompanying materials
54 are licensed and made available under the terms and conditions of the BSD License
55 which accompanies this distribution. The full text of the license may be found at
56 http://opensource.org/licenses/bsd-license.php
57
58 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
59 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
60
61 */
62
63
64 //
65 // Modifiers for EFI Runtime and Boot Services
66 //
67 #define EFI_RUNTIMESERVICE
68 #define EFIAPI
69 #define IN
70 #define OUT
71 #define OPTIONAL
72
73 #define EFI_MAX_BIT 0x80000000
74
75 //
76 // Set the upper bit to indicate EFI Error.
77 //
78 #define EFIERR(a) (EFI_MAX_BIT | (a))
79
80 #define EFIWARN(a) (a)
81 #define EFI_ERROR(a) (((INTN) (a)) < 0)
82
83 #define EFI_SUCCESS 0
84 #define EFI_LOAD_ERROR EFIERR (1)
85 #define EFI_INVALID_PARAMETER EFIERR (2)
86 #define EFI_UNSUPPORTED EFIERR (3)
87 #define EFI_BAD_BUFFER_SIZE EFIERR (4)
88 #define EFI_BUFFER_TOO_SMALL EFIERR (5)
89 #define EFI_NOT_READY EFIERR (6)
90 #define EFI_DEVICE_ERROR EFIERR (7)
91 #define EFI_WRITE_PROTECTED EFIERR (8)
92 #define EFI_OUT_OF_RESOURCES EFIERR (9)
93 #define EFI_VOLUME_CORRUPTED EFIERR (10)
94 #define EFI_VOLUME_FULL EFIERR (11)
95 #define EFI_NO_MEDIA EFIERR (12)
96 #define EFI_MEDIA_CHANGED EFIERR (13)
97 #define EFI_NOT_FOUND EFIERR (14)
98 #define EFI_ACCESS_DENIED EFIERR (15)
99 #define EFI_NO_RESPONSE EFIERR (16)
100 #define EFI_NO_MAPPING EFIERR (17)
101 #define EFI_TIMEOUT EFIERR (18)
102 #define EFI_NOT_STARTED EFIERR (19)
103 #define EFI_ALREADY_STARTED EFIERR (20)
104 #define EFI_ABORTED EFIERR (21)
105 #define EFI_ICMP_ERROR EFIERR (22)
106 #define EFI_TFTP_ERROR EFIERR (23)
107 #define EFI_PROTOCOL_ERROR EFIERR (24)
108 #define EFI_INCOMPATIBLE_VERSION EFIERR (25)
109 #define EFI_SECURITY_VIOLATION EFIERR (26)
110 #define EFI_CRC_ERROR EFIERR (27)
111
112 #define EFI_WARN_UNKNOWN_GLYPH EFIWARN (1)
113 #define EFI_WARN_DELETE_FAILURE EFIWARN (2)
114 #define EFI_WARN_WRITE_FAILURE EFIWARN (3)
115 #define EFI_WARN_BUFFER_TOO_SMALL EFIWARN (4)
116
117 //
118 // EFI Specification Revision information
119 //
120 #define EFI_SPECIFICATION_MAJOR_REVISION 1
121 #define EFI_SPECIFICATION_MINOR_REVISION 10
122
123 typedef struct {
124 EFI_UINT32 Data1;
125 EFI_UINT16 Data2;
126 EFI_UINT16 Data3;
127 EFI_UINT8 Data4[8];
128 } EFI_GUID;
129
130 #define APPLE_VENDOR_GUID \
131 {0xAC39C713, 0x7E50, 0x423D, {0x88, 0x9D, 0x27,0x8F, 0xCC, 0x34, 0x22, 0xB6} }
132
133 #define EFI_GLOBAL_VARIABLE_GUID \
134 {0x8BE4DF61, 0x93CA, 0x11d2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C} }
135
136 typedef union {
137 EFI_GUID Guid;
138 EFI_UINT8 Raw[16];
139 } EFI_GUID_UNION;
140
141 //
142 // EFI Time Abstraction:
143 // Year: 2000 - 20XX
144 // Month: 1 - 12
145 // Day: 1 - 31
146 // Hour: 0 - 23
147 // Minute: 0 - 59
148 // Second: 0 - 59
149 // Nanosecond: 0 - 999,999,999
150 // TimeZone: -1440 to 1440 or 2047
151 //
152 typedef struct {
153 EFI_UINT16 Year;
154 EFI_UINT8 Month;
155 EFI_UINT8 Day;
156 EFI_UINT8 Hour;
157 EFI_UINT8 Minute;
158 EFI_UINT8 Second;
159 EFI_UINT8 Pad1;
160 EFI_UINT32 Nanosecond;
161 EFI_INT16 TimeZone;
162 EFI_UINT8 Daylight;
163 EFI_UINT8 Pad2;
164 } EFI_TIME;
165
166 //
167 // Bit definitions for EFI_TIME.Daylight
168 //
169 #define EFI_TIME_ADJUST_DAYLIGHT 0x01
170 #define EFI_TIME_IN_DAYLIGHT 0x02
171
172 //
173 // Value definition for EFI_TIME.TimeZone
174 //
175 #define EFI_UNSPECIFIED_TIMEZONE 0x07FF
176
177 typedef enum {
178 EfiReservedMemoryType,
179 EfiLoaderCode,
180 EfiLoaderData,
181 EfiBootServicesCode,
182 EfiBootServicesData,
183 EfiRuntimeServicesCode,
184 EfiRuntimeServicesData,
185 EfiConventionalMemory,
186 EfiUnusableMemory,
187 EfiACPIReclaimMemory,
188 EfiACPIMemoryNVS,
189 EfiMemoryMappedIO,
190 EfiMemoryMappedIOPortSpace,
191 EfiPalCode,
192 EfiMaxMemoryType
193 } EFI_MEMORY_TYPE;
194
195 typedef struct {
196 EFI_UINT64 Signature;
197 EFI_UINT32 Revision;
198 EFI_UINT32 HeaderSize;
199 EFI_UINT32 CRC32;
200 EFI_UINT32 Reserved;
201 } __attribute__((aligned(8))) EFI_TABLE_HEADER;
202
203 //
204 // possible caching types for the memory range
205 //
206 #define EFI_MEMORY_UC 0x0000000000000001ULL
207 #define EFI_MEMORY_WC 0x0000000000000002ULL
208 #define EFI_MEMORY_WT 0x0000000000000004ULL
209 #define EFI_MEMORY_WB 0x0000000000000008ULL
210 #define EFI_MEMORY_UCE 0x0000000000000010ULL
211
212 //
213 // physical memory protection on range
214 //
215 #define EFI_MEMORY_WP 0x0000000000001000ULL
216 #define EFI_MEMORY_RP 0x0000000000002000ULL
217 #define EFI_MEMORY_XP 0x0000000000004000ULL
218
219 //
220 // range requires a runtime mapping
221 //
222 #define EFI_MEMORY_RUNTIME 0x8000000000000000ULL
223
224 typedef EFI_UINT64 EFI_PHYSICAL_ADDRESS;
225 typedef EFI_UINT64 EFI_VIRTUAL_ADDRESS;
226
227 #define EFI_MEMORY_DESCRIPTOR_VERSION 1
228 typedef struct {
229 EFI_UINT32 Type;
230 EFI_UINT32 Pad;
231 EFI_PHYSICAL_ADDRESS PhysicalStart;
232 EFI_VIRTUAL_ADDRESS VirtualStart;
233 EFI_UINT64 NumberOfPages;
234 EFI_UINT64 Attribute;
235 } __attribute__((aligned(8))) EFI_MEMORY_DESCRIPTOR;
236
237
238 typedef
239 EFI_RUNTIMESERVICE
240 EFI_STATUS
241 (EFIAPI *EFI_SET_VIRTUAL_ADDRESS_MAP) (
242 IN EFI_UINTN MemoryMapSize,
243 IN EFI_UINTN DescriptorSize,
244 IN EFI_UINT32 DescriptorVersion,
245 IN EFI_MEMORY_DESCRIPTOR * VirtualMap
246 ) __attribute__((regparm(0)));
247
248 typedef
249 EFI_RUNTIMESERVICE
250 EFI_STATUS
251 (EFIAPI *EFI_CONVERT_POINTER) (
252 IN EFI_UINTN DebugDisposition,
253 IN OUT VOID **Address
254 ) __attribute__((regparm(0)));
255
256 //
257 // Variable attributes
258 //
259 #define EFI_VARIABLE_NON_VOLATILE 0x00000001
260 #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
261 #define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
262 #define EFI_VARIABLE_READ_ONLY 0x00000008
263
264 typedef
265 EFI_RUNTIMESERVICE
266 EFI_STATUS
267 (EFIAPI *EFI_GET_VARIABLE) (
268 IN EFI_CHAR16 * VariableName,
269 IN EFI_GUID * VendorGuid,
270 OUT EFI_UINT32 * Attributes OPTIONAL,
271 IN OUT EFI_UINTN * DataSize,
272 OUT VOID * Data
273 ) __attribute__((regparm(0)));
274
275 typedef
276 EFI_RUNTIMESERVICE
277 EFI_STATUS
278 (EFIAPI *EFI_GET_NEXT_VARIABLE_NAME) (
279 IN OUT EFI_UINTN * VariableNameSize,
280 IN OUT EFI_CHAR16 * VariableName,
281 IN OUT EFI_GUID * VendorGuid
282 ) __attribute__((regparm(0)));
283
284 typedef
285 EFI_RUNTIMESERVICE
286 EFI_STATUS
287 (EFIAPI *EFI_SET_VARIABLE) (
288 IN EFI_CHAR16 * VariableName,
289 IN EFI_GUID * VendorGuid,
290 IN EFI_UINT32 Attributes,
291 IN EFI_UINTN DataSize,
292 IN VOID * Data
293 ) __attribute__((regparm(0)));
294
295 //
296 // EFI Time
297 //
298 typedef struct {
299 EFI_UINT32 Resolution;
300 EFI_UINT32 Accuracy;
301 EFI_BOOLEAN SetsToZero;
302 } __attribute__((aligned(4))) EFI_TIME_CAPABILITIES;
303
304 typedef
305 EFI_RUNTIMESERVICE
306 EFI_STATUS
307 (EFIAPI *EFI_GET_TIME) (
308 OUT EFI_TIME * Time,
309 OUT EFI_TIME_CAPABILITIES * Capabilities OPTIONAL
310 ) __attribute__((regparm(0)));
311
312 typedef
313 EFI_RUNTIMESERVICE
314 EFI_STATUS
315 (EFIAPI *EFI_SET_TIME) (
316 IN EFI_TIME * Time
317 ) __attribute__((regparm(0)));
318
319 typedef
320 EFI_RUNTIMESERVICE
321 EFI_STATUS
322 (EFIAPI *EFI_GET_WAKEUP_TIME) (
323 OUT EFI_BOOLEAN * Enabled,
324 OUT EFI_BOOLEAN * Pending,
325 OUT EFI_TIME * Time
326 ) __attribute__((regparm(0)));
327
328 typedef
329 EFI_RUNTIMESERVICE
330 EFI_STATUS
331 (EFIAPI *EFI_SET_WAKEUP_TIME) (
332 IN EFI_BOOLEAN Enable,
333 IN EFI_TIME * Time OPTIONAL
334 ) __attribute((regparm(0)));
335
336 typedef enum {
337 EfiResetCold,
338 EfiResetWarm,
339 EfiResetShutdown,
340
341 #ifdef TIANO_EXTENSION_FLAG
342 EfiResetUpdate
343 #endif
344
345 } EFI_RESET_TYPE;
346
347 typedef
348 EFI_RUNTIMESERVICE
349 VOID
350 (EFIAPI *EFI_RESET_SYSTEM) (
351 IN EFI_RESET_TYPE ResetType,
352 IN EFI_STATUS ResetStatus,
353 IN EFI_UINTN DataSize,
354 IN EFI_CHAR16 * ResetData OPTIONAL
355 ) __attribute__((regparm(0)));
356
357 typedef
358 EFI_RUNTIMESERVICE
359 EFI_STATUS
360 (EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT) (
361 OUT EFI_UINT32 * HighCount
362 ) __attribute__((regparm(0)));
363
364 //
365 // Definition of Status Code extended data header
366 //
367 // HeaderSize The size of the architecture. This is specified to enable
368 // the future expansion
369 //
370 // Size The size of the data in bytes. This does not include the size
371 // of the header structure.
372 //
373 // Type A GUID defining the type of the data
374 //
375 //
376 #ifdef TIANO_EXTENSION_FLAG
377
378 typedef
379 EFI_RUNTIMESERVICE
380 EFI_STATUS
381 (EFIAPI *EFI_REPORT_STATUS_CODE) (
382 IN EFI_STATUS_CODE_TYPE Type,
383 IN EFI_STATUS_CODE_VALUE Value,
384 IN EFI_UINT32 Instance,
385 IN EFI_GUID * CallerId OPTIONAL,
386 IN EFI_STATUS_CODE_DATA * Data OPTIONAL
387 ) __attribute__((regparm(0)));
388
389 #endif
390 //
391 // EFI Runtime Services Table
392 //
393 #define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552ULL
394 #define EFI_RUNTIME_SERVICES_REVISION ((EFI_SPECIFICATION_MAJOR_REVISION << 16) | (EFI_SPECIFICATION_MINOR_REVISION))
395
396 typedef struct {
397 EFI_TABLE_HEADER Hdr;
398
399 //
400 // Time services
401 //
402 EFI_GET_TIME GetTime;
403 EFI_SET_TIME SetTime;
404 EFI_GET_WAKEUP_TIME GetWakeupTime;
405 EFI_SET_WAKEUP_TIME SetWakeupTime;
406
407 //
408 // Virtual memory services
409 //
410 EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap;
411 EFI_CONVERT_POINTER ConvertPointer;
412
413 //
414 // Variable services
415 //
416 EFI_GET_VARIABLE GetVariable;
417 EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName;
418 EFI_SET_VARIABLE SetVariable;
419
420 //
421 // Misc
422 //
423 EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount;
424 EFI_RESET_SYSTEM ResetSystem;
425
426 #ifdef TIANO_EXTENSION_FLAG
427 //
428 // ////////////////////////////////////////////////////
429 // Extended EFI Services
430 //////////////////////////////////////////////////////
431 //
432 EFI_REPORT_STATUS_CODE ReportStatusCode;
433 #endif
434
435 } __attribute__((aligned(8))) EFI_RUNTIME_SERVICES;
436
437 typedef struct {
438 EFI_TABLE_HEADER Hdr;
439
440 //
441 // Time services
442 //
443 EFI_PTR64 GetTime;
444 EFI_PTR64 SetTime;
445 EFI_PTR64 GetWakeupTime;
446 EFI_PTR64 SetWakeupTime;
447
448 //
449 // Virtual memory services
450 //
451 EFI_PTR64 SetVirtualAddressMap;
452 EFI_PTR64 ConvertPointer;
453
454 //
455 // Variable services
456 //
457 EFI_PTR64 GetVariable;
458 EFI_PTR64 GetNextVariableName;
459 EFI_PTR64 SetVariable;
460
461 //
462 // Misc
463 //
464 EFI_PTR64 GetNextHighMonotonicCount;
465 EFI_PTR64 ResetSystem;
466
467 #ifdef TIANO_EXTENSION_FLAG
468 //
469 // ////////////////////////////////////////////////////
470 // Extended EFI Services
471 //////////////////////////////////////////////////////
472 //
473 EFI_PTR64 ReportStatusCode;
474 #endif
475
476 } __attribute__((aligned(8))) EFI_RUNTIME_SERVICES_64;
477
478 //
479 // EFI Configuration Table
480 //
481 typedef struct {
482 EFI_GUID VendorGuid;
483 VOID *VendorTable;
484 } EFI_CONFIGURATION_TABLE;
485
486 //
487 // EFI System Table
488 //
489 #define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249ULL
490 #define EFI_SYSTEM_TABLE_REVISION ((EFI_SPECIFICATION_MAJOR_REVISION << 16) | (EFI_SPECIFICATION_MINOR_REVISION))
491 #define EFI_2_00_SYSTEM_TABLE_REVISION ((2 << 16) | 00)
492 #define EFI_1_02_SYSTEM_TABLE_REVISION ((1 << 16) | 02)
493 #define EFI_1_10_SYSTEM_TABLE_REVISION ((1 << 16) | 10)
494
495 typedef struct EFI_SYSTEM_TABLE {
496 EFI_TABLE_HEADER Hdr;
497
498 EFI_CHAR16 *FirmwareVendor;
499 EFI_UINT32 FirmwareRevision;
500
501 EFI_HANDLE ConsoleInHandle;
502 VOID *ConIn;
503
504 EFI_HANDLE ConsoleOutHandle;
505 VOID *ConOut;
506
507 EFI_HANDLE StandardErrorHandle;
508 VOID *StdErr;
509
510 EFI_RUNTIME_SERVICES *RuntimeServices;
511 VOID *BootServices;
512
513 EFI_UINTN NumberOfTableEntries;
514 EFI_CONFIGURATION_TABLE *ConfigurationTable;
515
516 } __attribute__((aligned(8))) EFI_SYSTEM_TABLE;
517
518 typedef struct EFI_SYSTEM_TABLE_64 {
519 EFI_TABLE_HEADER Hdr;
520
521 EFI_PTR64 FirmwareVendor;
522 EFI_UINT32 FirmwareRevision;
523
524 EFI_UINT32 __pad;
525
526 EFI_HANDLE64 ConsoleInHandle;
527 EFI_PTR64 ConIn;
528
529 EFI_HANDLE64 ConsoleOutHandle;
530 EFI_PTR64 ConOut;
531
532 EFI_HANDLE64 StandardErrorHandle;
533 EFI_PTR64 StdErr;
534
535 EFI_PTR64 RuntimeServices;
536 EFI_PTR64 BootServices;
537
538 EFI_UINT64 NumberOfTableEntries;
539 EFI_PTR64 ConfigurationTable;
540
541 } __attribute__((aligned(8))) EFI_SYSTEM_TABLE_64;
542
543 #endif /* _PEXPERT_I386_EFI_H */