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