efi.h revision 71803
1153186Spjd/*- 2153186Spjd * Copyright (c) 2000 Doug Rabson 3153186Spjd * All rights reserved. 4153186Spjd * 5153186Spjd * Redistribution and use in source and binary forms, with or without 6153186Spjd * modification, are permitted provided that the following conditions 7153186Spjd * are met: 8153186Spjd * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD: head/sys/ia64/include/efi.h 71803 2001-01-29 13:31:19Z dfr $ 27 */ 28 29#ifndef _MACHINE_EFI_H_ 30#define _MACHINE_EFI_H_ 31 32typedef u_int8_t BOOLEAN; 33typedef int32_t INTN; 34typedef u_int32_t UINTN; 35typedef int8_t INT8; 36typedef u_int8_t UINT8; 37typedef int16_t INT16; 38typedef u_int16_t UINT16; 39typedef int32_t INT32; 40typedef u_int32_t UINT32; 41typedef int64_t INT64; 42typedef u_int64_t UINT64; 43typedef UINT8 CHAR8; 44typedef UINT16 CHAR16; 45 46typedef struct _EFI_GUID { 47 UINT32 Data1; 48 UINT16 Data2; 49 UINT16 Data3; 50 UINT8 Data4[8]; 51} EFI_GUID; 52 53typedef INTN EFI_STATUS; 54typedef void *EFI_HANDLE; 55typedef void *EFI_EVENT; 56typedef UINT64 EFI_LBA; 57typedef UINTN EFI_TPL; 58 59/* 60 * EFI_STATUS Error Codes. 61 */ 62#define EFI_SUCCESS 0 63#define EFI_LOAD_ERROR 1 64#define EFI_INVALID_PARAMETER 2 65#define EFI_UNSUPPORTED 3 66#define EFI_BAD_BUFFER_SIZE 4 67#define EFI_BUFFER_TOO_SMALL 5 68#define EFI_NOT_READY 6 69#define EFI_DEVICE_ERROR 7 70#define EFI_WRITE_PROTECTED 8 71#define EFI_OUT_OF_RESOURCES 9 72#define EFI_VOLUME_CORRUPTED 10 73#define EFI_VOLUME_FULL 11 74#define EFI_NO_MEDIA 12 75#define EFI_MEDIA_CHANGED 13 76#define EFI_NOT_FOUND 14 77#define EFI_ACCESS_DENIED 15 78#define EFI_NO_RESPONSE 16 79#define EFI_NO_MAPPING 17 80#define EFI_TIMEOUT 18 81#define EFI_NOT_STARTED 19 82#define EFI_ALREADY_STARTED 20 83#define EFI_ABORTED 21 84#define EFI_ICMP_ERROR 22 85#define EFI_TFTP_ERROR 23 86#define EFI_PROTOCOL_ERROR 24 87 88/* 89 * EFI_STATUS Warning Codes. 90 */ 91#define EFI_WARN_UNKNOWN_GLYPH 1 92#define EFI_WARN_DELETE_FAILURE 2 93#define EFI_WARN_WRITE_FAILURE 3 94#define EFI_WARN_BUFFER_TOO_SMALL 4 95 96 97typedef struct _EFI_MAC_ADDRESS { 98 CHAR8 Address[32]; 99} EFI_MAC_ADDRESS; 100 101typedef struct _EFI_IPv4_ADDRESS { 102 CHAR8 Address[4]; 103} EFI_IPv4_ADDRESS; 104 105typedef struct _EFI_IPv6_ADDRESS { 106 CHAR8 Address[16]; 107} EFI_IPv6_ADDRESS, EFI_IP_ADDRESS; 108 109typedef struct _EFI_TIME { 110 UINT16 Year; /* 1998 - 20xx */ 111 UINT8 Month; /* 1 - 12 */ 112 UINT8 Day; /* 1 - 31 */ 113 UINT8 Hour; /* 0 - 23 */ 114 UINT8 Minute; /* 0 - 59 */ 115 UINT8 Second; /* 0 - 59 */ 116 UINT8 Pad1; 117 UINT32 Nanosecond; /* 0 - 999,999,999 */ 118 INT16 TimeZone; /* -1440 - 1440 or 2047 */ 119 UINT8 Daylight; 120 UINT8 Pad2; 121} EFI_TIME; 122 123typedef struct _EFI_TIME_CAPABILITIES { 124 UINT32 Resolution; 125 UINT32 Accuracy; 126 BOOLEAN SetsToZero; 127} EFI_TIME_CAPABILITIES; 128 129/* 130 * Reset types. 131 */ 132typedef enum _EFI_RESET_TYPE { 133 EfiResetCold, 134 EfiResetWarm 135} EFI_RESET_TYPE; 136 137/* 138 * Allocate Types. 139 */ 140typedef enum _EFI_ALLOCATE_TYPE { 141 AllocateAnyPages, 142 AllocateMaxAddress, 143 AllocateAddress, 144 MaxAllocateType 145} EFI_ALLOCATE_TYPE; 146 147/* 148 * Memory types. 149 */ 150typedef enum _EFI_MEMORY_TYPE { 151 EfiReservedMemoryType, 152 EfiLoaderCode, 153 EfiLoaderData, 154 EfiBootServicesCode, 155 EfiBootServicesData, 156 EfiRuntimeServicesCode, 157 EfiRuntimeServicesData, 158 EfiConventionalMemory, 159 EfiUnusableMemory, 160 EfiAcpiReclaimMemory, 161 EfiAcpiMemoryNvs, 162 EfiMemoryMappedIo, 163 EfiMemoryMappedIoPortSpace, 164 EfiPalCode, 165 EfiMaxMemoryType 166} EFI_MEMORY_TYPE; 167 168/* 169 * Physical Address. 170 */ 171typedef UINT64 EFI_PHYSICAL_ADDRESS; 172 173/* 174 * Virtual Address. 175 */ 176typedef UINT64 EFI_VIRTUAL_ADDRESS; 177 178 179/* 180 * Memory Descriptor. 181 */ 182typedef struct _EFI_MEMORY_DESCRIPTOR { 183 UINT32 Type; 184 EFI_PHYSICAL_ADDRESS PhysicalStart; 185 EFI_VIRTUAL_ADDRESS VirtualStart; 186 UINT64 NumberOfPages; 187 UINT64 Attribute; 188} EFI_MEMORY_DESCRIPTOR; 189 190#define EFI_MEMORY_DESCRIPTOR_VERSION 1 191 192/* 193 * Memory Attribute Definitions. 194 */ 195#define EFI_MEMORY_UC 0x0000000000000001 196#define EFI_MEMORY_WC 0x0000000000000002 197#define EFI_MEMORY_WT 0x0000000000000004 198#define EFI_MEMORY_WB 0x0000000000000008 199#define EFI_MEMORY_UCE 0x0000000000000010 200#define EFI_MEMORY_WP 0x0000000000001000 201#define EFI_MEMORY_RP 0x0000000000002000 202#define EFI_MEMORY_XP 0x0000000000004000 203#define EFI_MEMORY_RUNTIME 0x8000000000000000 204 205/* 206 * Variable Attributes. 207 */ 208#define EFI_VARIABLE_NON_VOLATILE 0x0000000000000001 209#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002 210#define EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004 211 212/* 213 * Task Priority Levels. 214 */ 215#define TPL_APPLICATION 4 216#define TPL_CALLBACK 8 217#define TPL_NOTIFY 16 218#define TPL_HIGH_LEVEL 31 219 220/* 221 * Event Types. 222 */ 223#define EVT_TIMER 0x80000000 224#define EVT_RUNTIME 0x40000000 225#define EVT_RUNTIME_CONTEXT 0x20000000 226 227#define EVT_NOTIFY_WAIT 0x00000100 228#define EVT_NOTIFY_SIGNAL 0x00000200 229#define EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201 230#define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202 231 232/* 233 * Event Notification Function. 234 */ 235typedef void (*EFI_EVENT_NOTIFY)(EFI_EVENT Event, 236 void *Context); 237/* 238 * Timer Delay 239 */ 240typedef enum _EFI_TIMER_DELAY { 241 TimerCancel, 242 TimerPeriodic, 243 TimerRelative 244} EFI_TIMER_DELAY; 245 246/* 247 * Interface Types. 248 */ 249typedef enum _EFI_INTERFACE_TYPE { 250 EFI_NATIVE_INTERFACE, 251 EFI_PCODE_INTERFACE 252} EFI_INTERFACE_TYPE; 253 254/* 255 * Search Type. 256 */ 257typedef enum _EFI_LOCATE_SEARCH_TYPE { 258 AllHandles, 259 ByRegisterNotify, 260 ByProtocol 261} EFI_LOCATE_SEARCH_TYPE; 262 263/* 264 * Device Path. 265 */ 266typedef struct _EFI_DEVICE_PATH { 267 UINT8 Type; 268 UINT8 SubType; 269 UINT8 Length[2]; 270} EFI_DEVICE_PATH; 271 272/* 273 * SIMPLE_INPUT Protocol 274 */ 275#define SIMPLE_INPUT_PROTOCOL \ 276 { 0x387477c1,0x69c7,0x11d2,0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b } 277 278typedef struct _EFI_INPUT_KEY { 279 UINT16 ScanCode; 280 CHAR16 UnicodeChar; 281} EFI_INPUT_KEY; 282 283typedef struct _SIMPLE_INPUT_INTERFACE SIMPLE_INPUT_INTERFACE; 284struct _SIMPLE_INPUT_INTERFACE { 285 EFI_STATUS (*Reset) 286 (SIMPLE_INPUT_INTERFACE *This, 287 BOOLEAN ExtendedVerification); 288 EFI_STATUS (*ReadKey) 289 (SIMPLE_INPUT_INTERFACE *This, 290 EFI_INPUT_KEY *Key); 291 EFI_EVENT WaitForKey; 292}; 293 294/* 295 * SIMPLE_TEXT_OUTPUT Protocol. 296 */ 297#define SIMPLE_TEXT_OUTPUT_PROTOCOL \ 298 { 0x387477c2,0x69c7,0x11d2,0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b } 299 300typedef struct _SIMPLE_TEXT_OUTPUT_MODE { 301 INT32 MaxMode; 302 /* current settings */ 303 INT32 Mode; 304 INT32 Attribute; 305 INT32 CursorColumn; 306 INT32 CursorRow; 307 BOOLEAN CursorVisible; 308} SIMPLE_TEXT_OUTPUT_MODE; 309 310typedef struct _SIMPLE_TEXT_OUTPUT_INTERFACE SIMPLE_TEXT_OUTPUT_INTERFACE; 311struct _SIMPLE_TEXT_OUTPUT_INTERFACE { 312 EFI_STATUS (*Reset) 313 (SIMPLE_TEXT_OUTPUT_INTERFACE *This, 314 BOOLEAN ExtendedVerification); 315 EFI_STATUS (*OutputString) 316 (SIMPLE_TEXT_OUTPUT_INTERFACE *This, 317 CHAR16 *String); 318 EFI_STATUS (*TestString) 319 (SIMPLE_TEXT_OUTPUT_INTERFACE *This, 320 CHAR16 *String); 321 EFI_STATUS (*QueryMode) 322 (SIMPLE_TEXT_OUTPUT_INTERFACE *This, 323 UINTN ModeNumber, 324 UINTN *Columns, 325 UINTN *Rows); 326 EFI_STATUS (*SetMode) 327 (SIMPLE_TEXT_OUTPUT_INTERFACE *This, 328 UINTN ModeNumber); 329 EFI_STATUS (*SetAttribute) 330 (SIMPLE_TEXT_OUTPUT_INTERFACE *This, 331 UINTN Attribute); 332 EFI_STATUS (*ClearScreen) 333 (SIMPLE_TEXT_OUTPUT_INTERFACE *This); 334 EFI_STATUS (*SetCursorPosition) 335 (SIMPLE_TEXT_OUTPUT_INTERFACE *This, 336 UINTN Column, 337 UINTN Row); 338 EFI_STATUS (*EnableCursor) 339 (SIMPLE_TEXT_OUTPUT_INTERFACE *This, 340 BOOLEAN Visible); 341 SIMPLE_TEXT_OUTPUT_MODE Mode; 342}; 343 344/* 345 * Standard EFI table header. 346 */ 347typedef struct _EFI_TABLE_HEADER { 348 u_int64_t Signature; 349 u_int32_t Revision; 350 u_int32_t HeaderSize; 351 u_int32_t CRC32; 352 u_int32_t Reserved; 353} EFI_TABLE_HEADER; 354 355/* 356 * EFI Runtime Services Table. 357 */ 358#define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552 359#define EFI_RUNTIME_SERVICES_REVISION ((1<<16) | 99) 360 361typedef struct _EFI_RUNTIME_SERVICES { 362 EFI_TABLE_HEADER Hdr; 363 364 /* 365 * Time Services. 366 */ 367 EFI_STATUS (*GetTime) 368 (EFI_TIME *Time, 369 EFI_TIME_CAPABILITIES *Capabilities); 370 EFI_STATUS (*SetTime) 371 (EFI_TIME *Time); 372 EFI_STATUS (*GetWakeupTime) 373 (BOOLEAN *Enabled, 374 BOOLEAN *Pending, 375 EFI_TIME *Time); 376 EFI_STATUS (*SetWakeupTime) 377 (BOOLEAN Enable, 378 EFI_TIME *Time); 379 380 /* 381 * Virtual Memory Services. 382 */ 383 EFI_STATUS (*SetVirtualAddressMap) 384 (UINTN MemoryMapSize, 385 UINTN DescriptorSize, 386 UINT32 DescriptorVersion, 387 EFI_MEMORY_DESCRIPTOR *VirtualMap); 388 EFI_STATUS (*ConvertPointer) 389 (UINTN DebugDisposition, 390 void **Address); 391 392 /* 393 * Variable Services. 394 */ 395 EFI_STATUS (*GetVariable) 396 (CHAR16 *VariableName, 397 EFI_GUID *VendorGuid, 398 UINT32 *Attributes, 399 UINTN *DataSize, 400 void *Data); 401 EFI_STATUS (*GetNextVariableName) 402 (UINTN *VariableNameSize, 403 CHAR16 *VariableName, 404 EFI_GUID *VendorGuid); 405 EFI_STATUS (*SetVariable) 406 (CHAR16 *VariableName, 407 EFI_GUID *VendorGuid, 408 UINT32 Attributes, 409 UINTN DataSize, 410 void *Data); 411 412 /* 413 * Miscellaneous Services. 414 */ 415 EFI_STATUS (*GetNextHighMonotonicCount) 416 (UINT32 *HighCount); 417 EFI_STATUS (*ResetSystem) 418 (EFI_RESET_TYPE ResetType, 419 EFI_STATUS ResetStatus, 420 UINTN DataSize, 421 CHAR16 *ResetData); 422 423} EFI_RUNTIME_SERVICES; 424 425/* 426 * Boot Services Table. 427 */ 428#define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42 429#define EFI_BOOT_SERVICES_REVISION ((0<<16) | 91) 430 431typedef struct _EFI_BOOT_SERVICES { 432 EFI_TABLE_HEADER Hdr; 433 434 /* 435 * Task Priority Services. 436 */ 437 EFI_TPL (*RaiseTPL) 438 (EFI_TPL NewTpl); 439 void (*RestoreTPL) 440 (EFI_TPL OldTpl); 441 442 /* 443 * Memory Services. 444 */ 445 EFI_STATUS (*AllocatePages) 446 (EFI_ALLOCATE_TYPE Type, 447 EFI_MEMORY_TYPE MemoryType, 448 UINTN Pages, 449 EFI_PHYSICAL_ADDRESS *Memory); 450 EFI_STATUS (*FreePages) 451 (EFI_PHYSICAL_ADDRESS Memory, 452 UINTN Pages); 453 EFI_STATUS (*GetMemoryMap) 454 (UINTN *MemoryMapSize, 455 EFI_MEMORY_DESCRIPTOR *MemoryMap, 456 UINTN *MapKey, 457 UINTN *DescriptorSize, 458 UINT32 *DescriptorVersion); 459 EFI_STATUS (*AllocatePool) 460 (EFI_MEMORY_TYPE *PoolType, 461 UINTN Size, 462 void **Buffer); 463 EFI_STATUS (*FreePool) 464 (void *Buffer); 465 466 /* 467 * Event & Timer Services. 468 */ 469 EFI_STATUS (*CreateEvent) 470 (UINT32 Type, 471 EFI_TPL NotifyTpl, 472 EFI_EVENT_NOTIFY NotifyFunction, 473 void *NotifyContext, 474 EFI_EVENT *Event); 475 EFI_STATUS (*SetTimer) 476 (EFI_EVENT Event, 477 EFI_TIMER_DELAY Type, 478 UINT64 TriggerTime); 479 EFI_STATUS (*WaitForEvent) 480 (UINTN NumberOfEvents, 481 EFI_EVENT *Event, 482 UINTN *Index); 483 EFI_STATUS (*SignalEvent) 484 (EFI_EVENT Event); 485 EFI_STATUS (*CloseEvent) 486 (EFI_EVENT Event); 487 EFI_STATUS (*CheckEvent) 488 (EFI_EVENT Event); 489 490 /* 491 * Protocol Handler Services. 492 */ 493 EFI_STATUS (*InstallProtocolInterface) 494 (EFI_HANDLE *Handle, 495 EFI_GUID *Protocol, 496 EFI_INTERFACE_TYPE InterfaceType, 497 void *Interface); 498 EFI_STATUS (*ReinstallProtocolInterface) 499 (EFI_HANDLE *Handle, 500 EFI_GUID *Protocol, 501 void *OldInterface, 502 void *NewInterface); 503 EFI_STATUS (*UninstallProtocolInterface) 504 (EFI_HANDLE Handle, 505 EFI_GUID *Protocol, 506 void *Interface); 507 EFI_STATUS (*HandleProtocol) 508 (EFI_HANDLE Handle, 509 EFI_GUID *Protocol, 510 void **Interface); 511 EFI_STATUS (*PCHandleProtocol) 512 (EFI_HANDLE Handle, 513 EFI_GUID *Protocol, 514 void **Interface); 515 EFI_STATUS (*RegisterProtocolNotify) 516 (EFI_GUID *Protocol, 517 EFI_EVENT Event, 518 void **Registration); 519 EFI_STATUS (*LocateHandle) 520 (EFI_LOCATE_SEARCH_TYPE SearchType, 521 EFI_GUID *Protocol, 522 void *SearchKey, 523 UINTN *BufferSize, 524 EFI_HANDLE *Buffer); 525 EFI_STATUS (*LocateDevicePath) 526 (EFI_GUID *Protocol, 527 EFI_DEVICE_PATH **DevicePath, 528 EFI_HANDLE Device); 529 EFI_STATUS (*InstallConfigurationTable) 530 (EFI_GUID *Guid, 531 void *Table); 532 533 /* 534 * Image Services. 535 */ 536 EFI_STATUS (*LoadImage) 537 (BOOLEAN BootPolicy, 538 EFI_HANDLE ParentImageHandle, 539 EFI_DEVICE_PATH *FilePath, 540 void *SourceBuffer, 541 UINTN SourceSize, 542 EFI_HANDLE *ImageHandle); 543 EFI_STATUS (*StartImage) 544 (EFI_HANDLE ImageHandle, 545 UINTN *ExitDataSize, 546 CHAR16 *ExitData); 547 EFI_STATUS (*Exit) 548 (EFI_HANDLE ImageHandle, 549 EFI_STATUS ExitStatus, 550 UINTN ExitDataSize, 551 CHAR16 ExitData); 552 EFI_STATUS (*UnloadImage) 553 (EFI_HANDLE ImageHandle); 554 EFI_STATUS (*ExitBootServices) 555 (EFI_HANDLE ImageHandle, 556 UINTN MapKey); 557 558 /* 559 * Miscellaneous Services. 560 */ 561 EFI_STATUS (*GetNextMonotonicCount) 562 (UINT64 *Count); 563 EFI_STATUS (*Stall) 564 (UINTN Microseconds); 565 EFI_STATUS (*SetWatchdogTimer) 566 (UINTN Timeout, 567 UINT64 WatchdogCode, 568 UINTN DataSize, 569 CHAR16 *WatchdogData); 570 571} EFI_BOOT_SERVICES; 572 573/* 574 * EFI Configuration Table and GUID Declarations. 575 */ 576#define MPS_TABLE_GUID \ 577 {0xeb9d2d2f,0x2d88,0x11d3,0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d} 578#define ACPI_TABLE_GUID \ 579 {0xeb9d2d30,0x2d88,0x11d3,0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d} 580#define ACPI_20_TABLE_GUID \ 581 {0x8868e871,0xe4f1,0x11d3,0xbc,0x22,0x00,x080,0xc7,0x3c,0x88,0x81} 582#define SMBIOS_TABLE_GUID \ 583 {0xeb9d2d31,0x2d88,0x11d3,0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d} 584#define SAL_TABLE_GUID \ 585 {0xeb9d2d32,0x2d88,0x11d3,0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d} 586 587typedef struct _EFI_CONFIGURATION_TABLE { 588 EFI_GUID VendorGuid; 589 void *VendorTable; 590} EFI_CONFIGURATION_TABLE; 591 592/* 593 * EFI System Table. 594 */ 595typedef struct _EFI_SYSTEM_TABLE { 596 EFI_TABLE_HEADER Hdr; 597 598 CHAR16 FirmwareVendor; 599 UINT32 FirmwareRevision; 600 601 EFI_HANDLE ConsoleInHandle; 602 SIMPLE_INPUT_INTERFACE *ConIn; 603 604 EFI_HANDLE ConsoleOutHandle; 605 SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut; 606 607 EFI_HANDLE StandardErrorHandle; 608 SIMPLE_TEXT_OUTPUT_INTERFACE *StdErr; 609 610 EFI_RUNTIME_SERVICES *RuntimeServices; 611 EFI_BOOT_SERVICES *BootServices; 612 613 UINTN NumberOfTableEntries; 614 EFI_CONFIGURATION_TABLE *ConfiguratioNTable; 615} EFI_SYSTEM_TABLE; 616 617#endif /* _MACHINE_EFI_H_ */ 618