1 #ifndef _EFI_API_H 2 #define _EFI_API_H 3 4 /*++ 5 6 Copyright (c) 1998 Intel Corporation 7 8 Module Name: 9 10 efiapi.h 11 12 Abstract: 13 14 Global EFI runtime & boot service interfaces 15 16 17 18 19 Revision History 20 21 --*/ 22 23 // 24 // EFI Specification Revision 25 // 26 27 #define EFI_SPECIFICATION_MAJOR_REVISION 1 28 #define EFI_SPECIFICATION_MINOR_REVISION 02 29 30 // 31 // Declare forward referenced data structures 32 // 33 34 INTERFACE_DECL(_EFI_SYSTEM_TABLE); 35 36 // 37 // EFI Memory 38 // 39 40 typedef 41 EFI_STATUS 42 (EFIAPI *EFI_ALLOCATE_PAGES) ( 43 IN EFI_ALLOCATE_TYPE Type, 44 IN EFI_MEMORY_TYPE MemoryType, 45 IN UINTN NoPages, 46 OUT EFI_PHYSICAL_ADDRESS *Memory 47 ); 48 49 typedef 50 EFI_STATUS 51 (EFIAPI *EFI_FREE_PAGES) ( 52 IN EFI_PHYSICAL_ADDRESS Memory, 53 IN UINTN NoPages 54 ); 55 56 typedef 57 EFI_STATUS 58 (EFIAPI *EFI_GET_MEMORY_MAP) ( 59 IN OUT UINTN *MemoryMapSize, 60 IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, 61 OUT UINTN *MapKey, 62 OUT UINTN *DescriptorSize, 63 OUT UINT32 *DescriptorVersion 64 ); 65 66 #define NextMemoryDescriptor(Ptr,Size) ((EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) Ptr) + Size)) 67 68 69 typedef 70 EFI_STATUS 71 (EFIAPI *EFI_ALLOCATE_POOL) ( 72 IN EFI_MEMORY_TYPE PoolType, 73 IN UINTN Size, 74 OUT VOID **Buffer 75 ); 76 77 typedef 78 EFI_STATUS 79 (EFIAPI *EFI_FREE_POOL) ( 80 IN VOID *Buffer 81 ); 82 83 typedef 84 EFI_STATUS 85 (EFIAPI *EFI_SET_VIRTUAL_ADDRESS_MAP) ( 86 IN UINTN MemoryMapSize, 87 IN UINTN DescriptorSize, 88 IN UINT32 DescriptorVersion, 89 IN EFI_MEMORY_DESCRIPTOR *VirtualMap 90 ); 91 92 93 #define EFI_OPTIONAL_PTR 0x00000001 94 #define EFI_INTERNAL_FNC 0x00000002 // Pointer to internal runtime fnc 95 #define EFI_INTERNAL_PTR 0x00000004 // Pointer to internal runtime data 96 97 98 typedef 99 EFI_STATUS 100 (EFIAPI *EFI_CONVERT_POINTER) ( 101 IN UINTN DebugDisposition, 102 IN OUT VOID **Address 103 ); 104 105 106 // 107 // EFI Events 108 // 109 110 #define EVT_TIMER 0x80000000 111 #define EVT_RUNTIME 0x40000000 112 #define EVT_RUNTIME_CONTEXT 0x20000000 113 114 #define EVT_NOTIFY_WAIT 0x00000100 115 #define EVT_NOTIFY_SIGNAL 0x00000200 116 117 #define EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201 118 #define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202 119 120 #define EVT_EFI_SIGNAL_MASK 0x000000FF 121 #define EVT_EFI_SIGNAL_MAX 4 122 123 #define EFI_EVENT_TIMER EVT_TIMER 124 #define EFI_EVENT_RUNTIME EVT_RUNTIME 125 #define EFI_EVENT_RUNTIME_CONTEXT EVT_RUNTIME_CONTEXT 126 #define EFI_EVENT_NOTIFY_WAIT EVT_NOTIFY_WAIT 127 #define EFI_EVENT_NOTIFY_SIGNAL EVT_NOTIFY_SIGNAL 128 #define EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES EVT_SIGNAL_EXIT_BOOT_SERVICES 129 #define EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 130 #define EFI_EVENT_EFI_SIGNAL_MASK EVT_EFI_SIGNAL_MASK 131 #define EFI_EVENT_EFI_SIGNAL_MAX EVT_EFI_SIGNAL_MAX 132 133 134 typedef 135 VOID 136 (EFIAPI *EFI_EVENT_NOTIFY) ( 137 IN EFI_EVENT Event, 138 IN VOID *Context 139 ); 140 141 typedef 142 EFI_STATUS 143 (EFIAPI *EFI_CREATE_EVENT) ( 144 IN UINT32 Type, 145 IN EFI_TPL NotifyTpl, 146 IN EFI_EVENT_NOTIFY NotifyFunction, 147 IN VOID *NotifyContext, 148 OUT EFI_EVENT *Event 149 ); 150 151 typedef enum { 152 TimerCancel, 153 TimerPeriodic, 154 TimerRelative, 155 TimerTypeMax 156 } EFI_TIMER_DELAY; 157 158 typedef 159 EFI_STATUS 160 (EFIAPI *EFI_SET_TIMER) ( 161 IN EFI_EVENT Event, 162 IN EFI_TIMER_DELAY Type, 163 IN UINT64 TriggerTime 164 ); 165 166 typedef 167 EFI_STATUS 168 (EFIAPI *EFI_SIGNAL_EVENT) ( 169 IN EFI_EVENT Event 170 ); 171 172 typedef 173 EFI_STATUS 174 (EFIAPI *EFI_WAIT_FOR_EVENT) ( 175 IN UINTN NumberOfEvents, 176 IN EFI_EVENT *Event, 177 OUT UINTN *Index 178 ); 179 180 typedef 181 EFI_STATUS 182 (EFIAPI *EFI_CLOSE_EVENT) ( 183 IN EFI_EVENT Event 184 ); 185 186 typedef 187 EFI_STATUS 188 (EFIAPI *EFI_CHECK_EVENT) ( 189 IN EFI_EVENT Event 190 ); 191 192 // 193 // Task priority level 194 // 195 196 #define TPL_APPLICATION 4 197 #define TPL_CALLBACK 8 198 #define TPL_NOTIFY 16 199 #define TPL_HIGH_LEVEL 31 200 #define EFI_TPL_APPLICATION TPL_APPLICATION 201 #define EFI_TPL_CALLBACK TPL_CALLBACK 202 #define EFI_TPL_NOTIFY TPL_NOTIFY 203 #define EFI_TPL_HIGH_LEVEL TPL_HIGH_LEVEL 204 typedef 205 EFI_TPL 206 (EFIAPI *EFI_RAISE_TPL) ( 207 IN EFI_TPL NewTpl 208 ); 209 210 typedef 211 VOID 212 (EFIAPI *EFI_RESTORE_TPL) ( 213 IN EFI_TPL OldTpl 214 ); 215 216 217 // 218 // EFI platform varibles 219 // 220 221 #define EFI_GLOBAL_VARIABLE \ 222 { 0x8BE4DF61, 0x93CA, 0x11d2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C} } 223 224 // Variable attributes 225 #define EFI_VARIABLE_NON_VOLATILE 0x00000001 226 #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002 227 #define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004 228 #define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008 229 #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x00000010 230 #define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x00000020 231 #define EFI_VARIABLE_APPEND_WRITE 0x00000040 232 233 // Variable size limitation 234 #define EFI_MAXIMUM_VARIABLE_SIZE 1024 235 236 typedef 237 EFI_STATUS 238 (EFIAPI *EFI_GET_VARIABLE) ( 239 IN CHAR16 *VariableName, 240 IN EFI_GUID *VendorGuid, 241 OUT UINT32 *Attributes OPTIONAL, 242 IN OUT UINTN *DataSize, 243 OUT VOID *Data 244 ); 245 246 typedef 247 EFI_STATUS 248 (EFIAPI *EFI_GET_NEXT_VARIABLE_NAME) ( 249 IN OUT UINTN *VariableNameSize, 250 IN OUT CHAR16 *VariableName, 251 IN OUT EFI_GUID *VendorGuid 252 ); 253 254 255 typedef 256 EFI_STATUS 257 (EFIAPI *EFI_SET_VARIABLE) ( 258 IN CHAR16 *VariableName, 259 IN EFI_GUID *VendorGuid, 260 IN UINT32 Attributes, 261 IN UINTN DataSize, 262 IN VOID *Data 263 ); 264 265 266 // 267 // EFI Time 268 // 269 270 typedef struct { 271 UINT32 Resolution; // 1e-6 parts per million 272 UINT32 Accuracy; // hertz 273 BOOLEAN SetsToZero; // Set clears sub-second time 274 } EFI_TIME_CAPABILITIES; 275 276 277 typedef 278 EFI_STATUS 279 (EFIAPI *EFI_GET_TIME) ( 280 OUT EFI_TIME *Time, 281 OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL 282 ); 283 284 typedef 285 EFI_STATUS 286 (EFIAPI *EFI_SET_TIME) ( 287 IN EFI_TIME *Time 288 ); 289 290 typedef 291 EFI_STATUS 292 (EFIAPI *EFI_GET_WAKEUP_TIME) ( 293 OUT BOOLEAN *Enabled, 294 OUT BOOLEAN *Pending, 295 OUT EFI_TIME *Time 296 ); 297 298 typedef 299 EFI_STATUS 300 (EFIAPI *EFI_SET_WAKEUP_TIME) ( 301 IN BOOLEAN Enable, 302 IN EFI_TIME *Time OPTIONAL 303 ); 304 305 306 // 307 // Image functions 308 // 309 310 311 // PE32+ Subsystem type for EFI images 312 313 #if !defined(IMAGE_SUBSYSTEM_EFI_APPLICATION) 314 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10 315 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11 316 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12 317 #endif 318 319 // PE32+ Machine type for EFI images 320 321 #if !defined(EFI_IMAGE_MACHINE_IA32) 322 #define EFI_IMAGE_MACHINE_IA32 0x014c 323 #endif 324 325 #if !defined(EFI_IMAGE_MACHINE_IA64) 326 #define EFI_IMAGE_MACHINE_IA64 0x0200 327 #endif 328 329 #if !defined(EFI_IMAGE_MACHINE_EBC) 330 #define EFI_IMAGE_MACHINE_EBC 0x0EBC 331 #endif 332 333 #if !defined(EFI_IMAGE_MACHINE_X64) 334 #define EFI_IMAGE_MACHINE_X64 0x8664 335 #endif 336 337 #if !defined(EFI_IMAGE_MACHINE_ARMTHUMB_MIXED) 338 #define EFI_IMAGE_MACHINE_ARMTHUMB_MIXED 0x01C2 339 #endif 340 341 #if !defined(EFI_IMAGE_MACHINE_AARCH64) 342 #define EFI_IMAGE_MACHINE_AARCH64 0xAA64 343 #endif 344 345 #if !defined(EFI_IMAGE_MACHINE_RISCV32) 346 #define EFI_IMAGE_MACHINE_RISCV32 0x5032 347 #endif 348 349 #if !defined(EFI_IMAGE_MACHINE_RISCV64) 350 #define EFI_IMAGE_MACHINE_RISCV64 0x5064 351 #endif 352 353 #if !defined(EFI_IMAGE_MACHINE_RISCV128) 354 #define EFI_IMAGE_MACHINE_RISCV128 0x5128 355 #endif 356 357 #if !defined(EFI_IMAGE_MACHINE_LOONGARCH32) 358 #define EFI_IMAGE_MACHINE_LOONGARCH32 0x6232 359 #endif 360 361 #if !defined(EFI_IMAGE_MACHINE_LOONGARCH64) 362 #define EFI_IMAGE_MACHINE_LOONGARCH64 0x6264 363 #endif 364 365 // Image Entry prototype 366 367 typedef 368 EFI_STATUS 369 (EFIAPI *EFI_IMAGE_ENTRY_POINT) ( 370 IN EFI_HANDLE ImageHandle, 371 IN struct _EFI_SYSTEM_TABLE *SystemTable 372 ); 373 374 typedef 375 EFI_STATUS 376 (EFIAPI *EFI_IMAGE_LOAD) ( 377 IN BOOLEAN BootPolicy, 378 IN EFI_HANDLE ParentImageHandle, 379 IN EFI_DEVICE_PATH *FilePath, 380 IN VOID *SourceBuffer OPTIONAL, 381 IN UINTN SourceSize, 382 OUT EFI_HANDLE *ImageHandle 383 ); 384 385 typedef 386 EFI_STATUS 387 (EFIAPI *EFI_IMAGE_START) ( 388 IN EFI_HANDLE ImageHandle, 389 OUT UINTN *ExitDataSize, 390 OUT CHAR16 **ExitData OPTIONAL 391 ); 392 393 typedef 394 EFI_STATUS 395 (EFIAPI *EFI_EXIT) ( 396 IN EFI_HANDLE ImageHandle, 397 IN EFI_STATUS ExitStatus, 398 IN UINTN ExitDataSize, 399 IN CHAR16 *ExitData OPTIONAL 400 ); 401 402 403 // Image handle 404 /*#define LOADED_IMAGE_PROTOCOL \ 405 { 0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} } 406 407 #define EFI_IMAGE_INFORMATION_REVISION 0x1000 408 typedef struct { 409 UINT32 Revision; 410 EFI_HANDLE ParentHandle; 411 struct _EFI_SYSTEM_TABLE *SystemTable; 412 413 // Source location of image 414 EFI_HANDLE DeviceHandle; 415 EFI_DEVICE_PATH *FilePath; 416 VOID *Reserved; 417 418 // Images load options 419 UINT32 LoadOptionsSize; 420 VOID *LoadOptions; 421 422 // Location of where image was loaded 423 VOID *ImageBase; 424 UINT64 ImageSize; 425 EFI_MEMORY_TYPE ImageCodeType; 426 EFI_MEMORY_TYPE ImageDataType; 427 428 // If the driver image supports a dynamic unload request 429 EFI_IMAGE_UNLOAD Unload; 430 431 } EFI_LOADED_IMAGE;*/ 432 433 434 typedef 435 EFI_STATUS 436 (EFIAPI *EFI_EXIT_BOOT_SERVICES) ( 437 IN EFI_HANDLE ImageHandle, 438 IN UINTN MapKey 439 ); 440 441 // 442 // Misc 443 // 444 445 446 typedef 447 EFI_STATUS 448 (EFIAPI *EFI_STALL) ( 449 IN UINTN Microseconds 450 ); 451 452 typedef 453 EFI_STATUS 454 (EFIAPI *EFI_SET_WATCHDOG_TIMER) ( 455 IN UINTN Timeout, 456 IN UINT64 WatchdogCode, 457 IN UINTN DataSize, 458 IN CHAR16 *WatchdogData OPTIONAL 459 ); 460 461 typedef 462 EFI_STATUS 463 (EFIAPI *EFI_CONNECT_CONTROLLER) ( 464 IN EFI_HANDLE ControllerHandle, 465 IN EFI_HANDLE *DriverImageHandle OPTIONAL, 466 IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL, 467 IN BOOLEAN Recursive 468 ); 469 470 typedef 471 EFI_STATUS 472 (EFIAPI *EFI_DISCONNECT_CONTROLLER) ( 473 IN EFI_HANDLE ControllerHandle, 474 IN EFI_HANDLE DriverImageHandle OPTIONAL, 475 IN EFI_HANDLE ChildHandle OPTIONAL 476 ); 477 478 #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001 479 #define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002 480 #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004 481 #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008 482 #define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010 483 #define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020 484 485 typedef 486 EFI_STATUS 487 (EFIAPI *EFI_OPEN_PROTOCOL) ( 488 IN EFI_HANDLE Handle, 489 IN EFI_GUID *Protocol, 490 OUT VOID **Interface OPTIONAL, 491 IN EFI_HANDLE AgentHandle, 492 IN EFI_HANDLE ControllerHandle, 493 IN UINT32 Attributes 494 ); 495 496 typedef 497 EFI_STATUS 498 (EFIAPI *EFI_CLOSE_PROTOCOL) ( 499 IN EFI_HANDLE Handle, 500 IN EFI_GUID *Protocol, 501 IN EFI_HANDLE AgentHandle, 502 IN EFI_HANDLE ControllerHandle 503 ); 504 505 typedef struct { 506 EFI_HANDLE AgentHandle; 507 EFI_HANDLE ControllerHandle; 508 UINT32 Attributes; 509 UINT32 OpenCount; 510 } EFI_OPEN_PROTOCOL_INFORMATION_ENTRY; 511 512 typedef 513 EFI_STATUS 514 (EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION) ( 515 IN EFI_HANDLE Handle, 516 IN EFI_GUID *Protocol, 517 OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer, 518 OUT UINTN *EntryCount 519 ); 520 521 typedef 522 EFI_STATUS 523 (EFIAPI *EFI_PROTOCOLS_PER_HANDLE) ( 524 IN EFI_HANDLE Handle, 525 OUT EFI_GUID ***ProtocolBuffer, 526 OUT UINTN *ProtocolBufferCount 527 ); 528 529 typedef enum { 530 AllHandles, 531 ByRegisterNotify, 532 ByProtocol 533 } EFI_LOCATE_SEARCH_TYPE; 534 535 typedef 536 EFI_STATUS 537 (EFIAPI *EFI_LOCATE_HANDLE_BUFFER) ( 538 IN EFI_LOCATE_SEARCH_TYPE SearchType, 539 IN EFI_GUID *Protocol OPTIONAL, 540 IN VOID *SearchKey OPTIONAL, 541 IN OUT UINTN *NoHandles, 542 OUT EFI_HANDLE **Buffer 543 ); 544 545 typedef 546 EFI_STATUS 547 (EFIAPI *EFI_LOCATE_PROTOCOL) ( 548 IN EFI_GUID *Protocol, 549 IN VOID *Registration OPTIONAL, 550 OUT VOID **Interface 551 ); 552 553 typedef 554 EFI_STATUS 555 (EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) ( 556 IN OUT EFI_HANDLE *Handle, 557 ... 558 ); 559 560 typedef 561 EFI_STATUS 562 (EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) ( 563 IN OUT EFI_HANDLE Handle, 564 ... 565 ); 566 567 typedef 568 EFI_STATUS 569 (EFIAPI *EFI_CALCULATE_CRC32) ( 570 IN VOID *Data, 571 IN UINTN DataSize, 572 OUT UINT32 *Crc32 573 ); 574 575 typedef 576 VOID 577 (EFIAPI *EFI_COPY_MEM) ( 578 IN VOID *Destination, 579 IN VOID *Source, 580 IN UINTN Length 581 ); 582 583 typedef 584 VOID 585 (EFIAPI *EFI_SET_MEM) ( 586 IN VOID *Buffer, 587 IN UINTN Size, 588 IN UINT8 Value 589 ); 590 591 592 typedef 593 EFI_STATUS 594 (EFIAPI *EFI_CREATE_EVENT_EX) ( 595 IN UINT32 Type, 596 IN EFI_TPL NotifyTpl, 597 IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL, 598 IN const VOID *NotifyContext OPTIONAL, 599 IN const EFI_GUID *EventGroup OPTIONAL, 600 OUT EFI_EVENT *Event 601 ); 602 603 typedef enum { 604 EfiResetCold, 605 EfiResetWarm, 606 EfiResetShutdown 607 } EFI_RESET_TYPE; 608 609 typedef 610 EFI_STATUS 611 (EFIAPI *EFI_RESET_SYSTEM) ( 612 IN EFI_RESET_TYPE ResetType, 613 IN EFI_STATUS ResetStatus, 614 IN UINTN DataSize, 615 IN CHAR16 *ResetData OPTIONAL 616 ); 617 618 typedef 619 EFI_STATUS 620 (EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT) ( 621 OUT UINT64 *Count 622 ); 623 624 typedef 625 EFI_STATUS 626 (EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT) ( 627 OUT UINT32 *HighCount 628 ); 629 630 typedef struct { 631 UINT64 Length; 632 union { 633 EFI_PHYSICAL_ADDRESS DataBlock; 634 EFI_PHYSICAL_ADDRESS ContinuationPointer; 635 } Union; 636 } EFI_CAPSULE_BLOCK_DESCRIPTOR; 637 638 typedef struct { 639 EFI_GUID CapsuleGuid; 640 UINT32 HeaderSize; 641 UINT32 Flags; 642 UINT32 CapsuleImageSize; 643 } EFI_CAPSULE_HEADER; 644 645 #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000 646 #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000 647 #define CAPSULE_FLAGS_INITIATE_RESET 0x00040000 648 649 typedef 650 EFI_STATUS 651 (EFIAPI *EFI_UPDATE_CAPSULE) ( 652 IN EFI_CAPSULE_HEADER **CapsuleHeaderArray, 653 IN UINTN CapsuleCount, 654 IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL 655 ); 656 657 typedef 658 EFI_STATUS 659 (EFIAPI *EFI_QUERY_CAPSULE_CAPABILITIES) ( 660 IN EFI_CAPSULE_HEADER **CapsuleHeaderArray, 661 IN UINTN CapsuleCount, 662 OUT UINT64 *MaximumCapsuleSize, 663 OUT EFI_RESET_TYPE *ResetType 664 ); 665 666 typedef 667 EFI_STATUS 668 (EFIAPI *EFI_QUERY_VARIABLE_INFO) ( 669 IN UINT32 Attributes, 670 OUT UINT64 *MaximumVariableStorageSize, 671 OUT UINT64 *RemainingVariableStorageSize, 672 OUT UINT64 *MaximumVariableSize 673 ); 674 675 // 676 // Protocol handler functions 677 // 678 679 typedef enum { 680 EFI_NATIVE_INTERFACE, 681 EFI_PCODE_INTERFACE 682 } EFI_INTERFACE_TYPE; 683 684 typedef 685 EFI_STATUS 686 (EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE) ( 687 IN OUT EFI_HANDLE *Handle, 688 IN EFI_GUID *Protocol, 689 IN EFI_INTERFACE_TYPE InterfaceType, 690 IN VOID *Interface 691 ); 692 693 typedef 694 EFI_STATUS 695 (EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE) ( 696 IN EFI_HANDLE Handle, 697 IN EFI_GUID *Protocol, 698 IN VOID *OldInterface, 699 IN VOID *NewInterface 700 ); 701 702 typedef 703 EFI_STATUS 704 (EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE) ( 705 IN EFI_HANDLE Handle, 706 IN EFI_GUID *Protocol, 707 IN VOID *Interface 708 ); 709 710 typedef 711 EFI_STATUS 712 (EFIAPI *EFI_HANDLE_PROTOCOL) ( 713 IN EFI_HANDLE Handle, 714 IN EFI_GUID *Protocol, 715 OUT VOID **Interface 716 ); 717 718 typedef 719 EFI_STATUS 720 (EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY) ( 721 IN EFI_GUID *Protocol, 722 IN EFI_EVENT Event, 723 OUT VOID **Registration 724 ); 725 726 typedef 727 EFI_STATUS 728 (EFIAPI *EFI_LOCATE_HANDLE) ( 729 IN EFI_LOCATE_SEARCH_TYPE SearchType, 730 IN EFI_GUID *Protocol OPTIONAL, 731 IN VOID *SearchKey OPTIONAL, 732 IN OUT UINTN *BufferSize, 733 OUT EFI_HANDLE *Buffer 734 ); 735 736 typedef 737 EFI_STATUS 738 (EFIAPI *EFI_LOCATE_DEVICE_PATH) ( 739 IN EFI_GUID *Protocol, 740 IN OUT EFI_DEVICE_PATH **DevicePath, 741 OUT EFI_HANDLE *Device 742 ); 743 744 typedef 745 EFI_STATUS 746 (EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE) ( 747 IN EFI_GUID *Guid, 748 IN VOID *Table 749 ); 750 751 typedef 752 EFI_STATUS 753 (EFIAPI *EFI_RESERVED_SERVICE) ( 754 ); 755 756 // 757 // Standard EFI table header 758 // 759 760 typedef struct _EFI_TABLE_HEADER { 761 UINT64 Signature; 762 UINT32 Revision; 763 UINT32 HeaderSize; 764 UINT32 CRC32; 765 UINT32 Reserved; 766 } EFI_TABLE_HEADER; 767 768 769 // 770 // EFI Runtime Serivces Table 771 // 772 773 #define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552 774 #define EFI_1_10_RUNTIME_SERVICES_REVISION ((1<<16) | (10)) 775 #define EFI_2_00_RUNTIME_SERVICES_REVISION ((2<<16) | (0)) 776 #define EFI_RUNTIME_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION) 777 778 typedef struct { 779 EFI_TABLE_HEADER Hdr; 780 781 // 782 // Time services 783 // 784 785 EFI_GET_TIME GetTime; 786 EFI_SET_TIME SetTime; 787 EFI_GET_WAKEUP_TIME GetWakeupTime; 788 EFI_SET_WAKEUP_TIME SetWakeupTime; 789 790 // 791 // Virtual memory services 792 // 793 794 EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap; 795 EFI_CONVERT_POINTER ConvertPointer; 796 797 // 798 // Variable serviers 799 // 800 801 EFI_GET_VARIABLE GetVariable; 802 EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName; 803 EFI_SET_VARIABLE SetVariable; 804 805 // 806 // Misc 807 // 808 809 EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount; 810 EFI_RESET_SYSTEM ResetSystem; 811 812 EFI_UPDATE_CAPSULE UpdateCapsule; 813 EFI_QUERY_CAPSULE_CAPABILITIES QueryCapsuleCapabilities; 814 EFI_QUERY_VARIABLE_INFO QueryVariableInfo; 815 } EFI_RUNTIME_SERVICES; 816 817 818 // 819 // EFI Boot Services Table 820 // 821 822 #define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42 823 #define EFI_1_10_BOOT_SERVICES_REVISION ((1<<16) | (10)) 824 #define EFI_2_00_BOOT_SERVICES_REVISION ((2<<16) | (0)) 825 #define EFI_BOOT_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION) 826 827 typedef struct _EFI_BOOT_SERVICES { 828 829 EFI_TABLE_HEADER Hdr; 830 831 // 832 // Task priority functions 833 // 834 835 EFI_RAISE_TPL RaiseTPL; 836 EFI_RESTORE_TPL RestoreTPL; 837 838 // 839 // Memory functions 840 // 841 842 EFI_ALLOCATE_PAGES AllocatePages; 843 EFI_FREE_PAGES FreePages; 844 EFI_GET_MEMORY_MAP GetMemoryMap; 845 EFI_ALLOCATE_POOL AllocatePool; 846 EFI_FREE_POOL FreePool; 847 848 // 849 // Event & timer functions 850 // 851 852 EFI_CREATE_EVENT CreateEvent; 853 EFI_SET_TIMER SetTimer; 854 EFI_WAIT_FOR_EVENT WaitForEvent; 855 EFI_SIGNAL_EVENT SignalEvent; 856 EFI_CLOSE_EVENT CloseEvent; 857 EFI_CHECK_EVENT CheckEvent; 858 859 // 860 // Protocol handler functions 861 // 862 863 EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface; 864 EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface; 865 EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface; 866 EFI_HANDLE_PROTOCOL HandleProtocol; 867 EFI_HANDLE_PROTOCOL PCHandleProtocol; 868 EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify; 869 EFI_LOCATE_HANDLE LocateHandle; 870 EFI_LOCATE_DEVICE_PATH LocateDevicePath; 871 EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable; 872 873 // 874 // Image functions 875 // 876 877 EFI_IMAGE_LOAD LoadImage; 878 EFI_IMAGE_START StartImage; 879 EFI_EXIT Exit; 880 EFI_IMAGE_UNLOAD UnloadImage; 881 EFI_EXIT_BOOT_SERVICES ExitBootServices; 882 883 // 884 // Misc functions 885 // 886 887 EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount; 888 EFI_STALL Stall; 889 EFI_SET_WATCHDOG_TIMER SetWatchdogTimer; 890 891 // 892 // DriverSupport Services 893 // 894 895 EFI_CONNECT_CONTROLLER ConnectController; 896 EFI_DISCONNECT_CONTROLLER DisconnectController; 897 898 // 899 // Open and Close Protocol Services 900 // 901 EFI_OPEN_PROTOCOL OpenProtocol; 902 EFI_CLOSE_PROTOCOL CloseProtocol; 903 EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation; 904 905 // 906 // Library Services 907 // 908 EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle; 909 EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer; 910 EFI_LOCATE_PROTOCOL LocateProtocol; 911 EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces; 912 EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces; 913 914 // 915 // 32-bit CRC Services 916 // 917 EFI_CALCULATE_CRC32 CalculateCrc32; 918 919 // 920 // Misc Services 921 // 922 EFI_COPY_MEM CopyMem; 923 EFI_SET_MEM SetMem; 924 EFI_CREATE_EVENT_EX CreateEventEx; 925 } EFI_BOOT_SERVICES; 926 927 928 // 929 // EFI Configuration Table and GUID definitions 930 // 931 932 #define MPS_TABLE_GUID \ 933 { 0xeb9d2d2f, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } 934 935 #define ACPI_TABLE_GUID \ 936 { 0xeb9d2d30, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } 937 938 #define ACPI_20_TABLE_GUID \ 939 { 0x8868e871, 0xe4f1, 0x11d3, {0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} } 940 941 #define SMBIOS_TABLE_GUID \ 942 { 0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } 943 944 #define SMBIOS3_TABLE_GUID \ 945 { 0xf2fd1544, 0x9794, 0x4a2c, {0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94} } 946 947 #define SAL_SYSTEM_TABLE_GUID \ 948 { 0xeb9d2d32, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } 949 950 #define EFI_DTB_TABLE_GUID \ 951 { 0xb1b621d5, 0xf19c, 0x41a5, {0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0} } 952 953 typedef struct _EFI_CONFIGURATION_TABLE { 954 EFI_GUID VendorGuid; 955 VOID *VendorTable; 956 } EFI_CONFIGURATION_TABLE; 957 958 959 // 960 // EFI System Table 961 // 962 963 964 965 966 #define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249 967 #define EFI_1_02_SYSTEM_TABLE_REVISION ((1<<16) | (02)) 968 #define EFI_1_10_SYSTEM_TABLE_REVISION ((1<<16) | (10)) 969 #define EFI_2_00_SYSTEM_TABLE_REVISION ((2<<16) | (0)) 970 #define EFI_SYSTEM_TABLE_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION) 971 972 typedef struct _EFI_SYSTEM_TABLE { 973 EFI_TABLE_HEADER Hdr; 974 975 CHAR16 *FirmwareVendor; 976 UINT32 FirmwareRevision; 977 978 EFI_HANDLE ConsoleInHandle; 979 SIMPLE_INPUT_INTERFACE *ConIn; 980 981 EFI_HANDLE ConsoleOutHandle; 982 SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut; 983 984 EFI_HANDLE StandardErrorHandle; 985 SIMPLE_TEXT_OUTPUT_INTERFACE *StdErr; 986 987 EFI_RUNTIME_SERVICES *RuntimeServices; 988 EFI_BOOT_SERVICES *BootServices; 989 990 UINTN NumberOfTableEntries; 991 EFI_CONFIGURATION_TABLE *ConfigurationTable; 992 993 } EFI_SYSTEM_TABLE; 994 995 #endif 996 997