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 // Image Entry prototype 358 359 typedef 360 EFI_STATUS 361 (EFIAPI *EFI_IMAGE_ENTRY_POINT) ( 362 IN EFI_HANDLE ImageHandle, 363 IN struct _EFI_SYSTEM_TABLE *SystemTable 364 ); 365 366 typedef 367 EFI_STATUS 368 (EFIAPI *EFI_IMAGE_LOAD) ( 369 IN BOOLEAN BootPolicy, 370 IN EFI_HANDLE ParentImageHandle, 371 IN EFI_DEVICE_PATH *FilePath, 372 IN VOID *SourceBuffer OPTIONAL, 373 IN UINTN SourceSize, 374 OUT EFI_HANDLE *ImageHandle 375 ); 376 377 typedef 378 EFI_STATUS 379 (EFIAPI *EFI_IMAGE_START) ( 380 IN EFI_HANDLE ImageHandle, 381 OUT UINTN *ExitDataSize, 382 OUT CHAR16 **ExitData OPTIONAL 383 ); 384 385 typedef 386 EFI_STATUS 387 (EFIAPI *EFI_EXIT) ( 388 IN EFI_HANDLE ImageHandle, 389 IN EFI_STATUS ExitStatus, 390 IN UINTN ExitDataSize, 391 IN CHAR16 *ExitData OPTIONAL 392 ); 393 394 395 // Image handle 396 /*#define LOADED_IMAGE_PROTOCOL \ 397 { 0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} } 398 399 #define EFI_IMAGE_INFORMATION_REVISION 0x1000 400 typedef struct { 401 UINT32 Revision; 402 EFI_HANDLE ParentHandle; 403 struct _EFI_SYSTEM_TABLE *SystemTable; 404 405 // Source location of image 406 EFI_HANDLE DeviceHandle; 407 EFI_DEVICE_PATH *FilePath; 408 VOID *Reserved; 409 410 // Images load options 411 UINT32 LoadOptionsSize; 412 VOID *LoadOptions; 413 414 // Location of where image was loaded 415 VOID *ImageBase; 416 UINT64 ImageSize; 417 EFI_MEMORY_TYPE ImageCodeType; 418 EFI_MEMORY_TYPE ImageDataType; 419 420 // If the driver image supports a dynamic unload request 421 EFI_IMAGE_UNLOAD Unload; 422 423 } EFI_LOADED_IMAGE;*/ 424 425 426 typedef 427 EFI_STATUS 428 (EFIAPI *EFI_EXIT_BOOT_SERVICES) ( 429 IN EFI_HANDLE ImageHandle, 430 IN UINTN MapKey 431 ); 432 433 // 434 // Misc 435 // 436 437 438 typedef 439 EFI_STATUS 440 (EFIAPI *EFI_STALL) ( 441 IN UINTN Microseconds 442 ); 443 444 typedef 445 EFI_STATUS 446 (EFIAPI *EFI_SET_WATCHDOG_TIMER) ( 447 IN UINTN Timeout, 448 IN UINT64 WatchdogCode, 449 IN UINTN DataSize, 450 IN CHAR16 *WatchdogData OPTIONAL 451 ); 452 453 typedef 454 EFI_STATUS 455 (EFIAPI *EFI_CONNECT_CONTROLLER) ( 456 IN EFI_HANDLE ControllerHandle, 457 IN EFI_HANDLE *DriverImageHandle OPTIONAL, 458 IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL, 459 IN BOOLEAN Recursive 460 ); 461 462 typedef 463 EFI_STATUS 464 (EFIAPI *EFI_DISCONNECT_CONTROLLER) ( 465 IN EFI_HANDLE ControllerHandle, 466 IN EFI_HANDLE DriverImageHandle OPTIONAL, 467 IN EFI_HANDLE ChildHandle OPTIONAL 468 ); 469 470 #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001 471 #define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002 472 #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004 473 #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008 474 #define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010 475 #define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020 476 477 typedef 478 EFI_STATUS 479 (EFIAPI *EFI_OPEN_PROTOCOL) ( 480 IN EFI_HANDLE Handle, 481 IN EFI_GUID *Protocol, 482 OUT VOID **Interface OPTIONAL, 483 IN EFI_HANDLE AgentHandle, 484 IN EFI_HANDLE ControllerHandle, 485 IN UINT32 Attributes 486 ); 487 488 typedef 489 EFI_STATUS 490 (EFIAPI *EFI_CLOSE_PROTOCOL) ( 491 IN EFI_HANDLE Handle, 492 IN EFI_GUID *Protocol, 493 IN EFI_HANDLE AgentHandle, 494 IN EFI_HANDLE ControllerHandle 495 ); 496 497 typedef struct { 498 EFI_HANDLE AgentHandle; 499 EFI_HANDLE ControllerHandle; 500 UINT32 Attributes; 501 UINT32 OpenCount; 502 } EFI_OPEN_PROTOCOL_INFORMATION_ENTRY; 503 504 typedef 505 EFI_STATUS 506 (EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION) ( 507 IN EFI_HANDLE Handle, 508 IN EFI_GUID *Protocol, 509 OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer, 510 OUT UINTN *EntryCount 511 ); 512 513 typedef 514 EFI_STATUS 515 (EFIAPI *EFI_PROTOCOLS_PER_HANDLE) ( 516 IN EFI_HANDLE Handle, 517 OUT EFI_GUID ***ProtocolBuffer, 518 OUT UINTN *ProtocolBufferCount 519 ); 520 521 typedef enum { 522 AllHandles, 523 ByRegisterNotify, 524 ByProtocol 525 } EFI_LOCATE_SEARCH_TYPE; 526 527 typedef 528 EFI_STATUS 529 (EFIAPI *EFI_LOCATE_HANDLE_BUFFER) ( 530 IN EFI_LOCATE_SEARCH_TYPE SearchType, 531 IN EFI_GUID *Protocol OPTIONAL, 532 IN VOID *SearchKey OPTIONAL, 533 IN OUT UINTN *NoHandles, 534 OUT EFI_HANDLE **Buffer 535 ); 536 537 typedef 538 EFI_STATUS 539 (EFIAPI *EFI_LOCATE_PROTOCOL) ( 540 IN EFI_GUID *Protocol, 541 IN VOID *Registration OPTIONAL, 542 OUT VOID **Interface 543 ); 544 545 typedef 546 EFI_STATUS 547 (EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) ( 548 IN OUT EFI_HANDLE *Handle, 549 ... 550 ); 551 552 typedef 553 EFI_STATUS 554 (EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) ( 555 IN OUT EFI_HANDLE Handle, 556 ... 557 ); 558 559 typedef 560 EFI_STATUS 561 (EFIAPI *EFI_CALCULATE_CRC32) ( 562 IN VOID *Data, 563 IN UINTN DataSize, 564 OUT UINT32 *Crc32 565 ); 566 567 typedef 568 VOID 569 (EFIAPI *EFI_COPY_MEM) ( 570 IN VOID *Destination, 571 IN VOID *Source, 572 IN UINTN Length 573 ); 574 575 typedef 576 VOID 577 (EFIAPI *EFI_SET_MEM) ( 578 IN VOID *Buffer, 579 IN UINTN Size, 580 IN UINT8 Value 581 ); 582 583 584 typedef 585 EFI_STATUS 586 (EFIAPI *EFI_CREATE_EVENT_EX) ( 587 IN UINT32 Type, 588 IN EFI_TPL NotifyTpl, 589 IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL, 590 IN const VOID *NotifyContext OPTIONAL, 591 IN const EFI_GUID *EventGroup OPTIONAL, 592 OUT EFI_EVENT *Event 593 ); 594 595 typedef enum { 596 EfiResetCold, 597 EfiResetWarm, 598 EfiResetShutdown 599 } EFI_RESET_TYPE; 600 601 typedef 602 EFI_STATUS 603 (EFIAPI *EFI_RESET_SYSTEM) ( 604 IN EFI_RESET_TYPE ResetType, 605 IN EFI_STATUS ResetStatus, 606 IN UINTN DataSize, 607 IN CHAR16 *ResetData OPTIONAL 608 ); 609 610 typedef 611 EFI_STATUS 612 (EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT) ( 613 OUT UINT64 *Count 614 ); 615 616 typedef 617 EFI_STATUS 618 (EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT) ( 619 OUT UINT32 *HighCount 620 ); 621 622 typedef struct { 623 UINT64 Length; 624 union { 625 EFI_PHYSICAL_ADDRESS DataBlock; 626 EFI_PHYSICAL_ADDRESS ContinuationPointer; 627 } Union; 628 } EFI_CAPSULE_BLOCK_DESCRIPTOR; 629 630 typedef struct { 631 EFI_GUID CapsuleGuid; 632 UINT32 HeaderSize; 633 UINT32 Flags; 634 UINT32 CapsuleImageSize; 635 } EFI_CAPSULE_HEADER; 636 637 #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000 638 #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000 639 #define CAPSULE_FLAGS_INITIATE_RESET 0x00040000 640 641 typedef 642 EFI_STATUS 643 (EFIAPI *EFI_UPDATE_CAPSULE) ( 644 IN EFI_CAPSULE_HEADER **CapsuleHeaderArray, 645 IN UINTN CapsuleCount, 646 IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL 647 ); 648 649 typedef 650 EFI_STATUS 651 (EFIAPI *EFI_QUERY_CAPSULE_CAPABILITIES) ( 652 IN EFI_CAPSULE_HEADER **CapsuleHeaderArray, 653 IN UINTN CapsuleCount, 654 OUT UINT64 *MaximumCapsuleSize, 655 OUT EFI_RESET_TYPE *ResetType 656 ); 657 658 typedef 659 EFI_STATUS 660 (EFIAPI *EFI_QUERY_VARIABLE_INFO) ( 661 IN UINT32 Attributes, 662 OUT UINT64 *MaximumVariableStorageSize, 663 OUT UINT64 *RemainingVariableStorageSize, 664 OUT UINT64 *MaximumVariableSize 665 ); 666 667 // 668 // Protocol handler functions 669 // 670 671 typedef enum { 672 EFI_NATIVE_INTERFACE, 673 EFI_PCODE_INTERFACE 674 } EFI_INTERFACE_TYPE; 675 676 typedef 677 EFI_STATUS 678 (EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE) ( 679 IN OUT EFI_HANDLE *Handle, 680 IN EFI_GUID *Protocol, 681 IN EFI_INTERFACE_TYPE InterfaceType, 682 IN VOID *Interface 683 ); 684 685 typedef 686 EFI_STATUS 687 (EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE) ( 688 IN EFI_HANDLE Handle, 689 IN EFI_GUID *Protocol, 690 IN VOID *OldInterface, 691 IN VOID *NewInterface 692 ); 693 694 typedef 695 EFI_STATUS 696 (EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE) ( 697 IN EFI_HANDLE Handle, 698 IN EFI_GUID *Protocol, 699 IN VOID *Interface 700 ); 701 702 typedef 703 EFI_STATUS 704 (EFIAPI *EFI_HANDLE_PROTOCOL) ( 705 IN EFI_HANDLE Handle, 706 IN EFI_GUID *Protocol, 707 OUT VOID **Interface 708 ); 709 710 typedef 711 EFI_STATUS 712 (EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY) ( 713 IN EFI_GUID *Protocol, 714 IN EFI_EVENT Event, 715 OUT VOID **Registration 716 ); 717 718 typedef 719 EFI_STATUS 720 (EFIAPI *EFI_LOCATE_HANDLE) ( 721 IN EFI_LOCATE_SEARCH_TYPE SearchType, 722 IN EFI_GUID *Protocol OPTIONAL, 723 IN VOID *SearchKey OPTIONAL, 724 IN OUT UINTN *BufferSize, 725 OUT EFI_HANDLE *Buffer 726 ); 727 728 typedef 729 EFI_STATUS 730 (EFIAPI *EFI_LOCATE_DEVICE_PATH) ( 731 IN EFI_GUID *Protocol, 732 IN OUT EFI_DEVICE_PATH **DevicePath, 733 OUT EFI_HANDLE *Device 734 ); 735 736 typedef 737 EFI_STATUS 738 (EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE) ( 739 IN EFI_GUID *Guid, 740 IN VOID *Table 741 ); 742 743 typedef 744 EFI_STATUS 745 (EFIAPI *EFI_RESERVED_SERVICE) ( 746 ); 747 748 // 749 // Standard EFI table header 750 // 751 752 typedef struct _EFI_TABLE_HEADER { 753 UINT64 Signature; 754 UINT32 Revision; 755 UINT32 HeaderSize; 756 UINT32 CRC32; 757 UINT32 Reserved; 758 } EFI_TABLE_HEADER; 759 760 761 // 762 // EFI Runtime Serivces Table 763 // 764 765 #define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552 766 #define EFI_RUNTIME_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION) 767 768 typedef struct { 769 EFI_TABLE_HEADER Hdr; 770 771 // 772 // Time services 773 // 774 775 EFI_GET_TIME GetTime; 776 EFI_SET_TIME SetTime; 777 EFI_GET_WAKEUP_TIME GetWakeupTime; 778 EFI_SET_WAKEUP_TIME SetWakeupTime; 779 780 // 781 // Virtual memory services 782 // 783 784 EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap; 785 EFI_CONVERT_POINTER ConvertPointer; 786 787 // 788 // Variable serviers 789 // 790 791 EFI_GET_VARIABLE GetVariable; 792 EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName; 793 EFI_SET_VARIABLE SetVariable; 794 795 // 796 // Misc 797 // 798 799 EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount; 800 EFI_RESET_SYSTEM ResetSystem; 801 802 EFI_UPDATE_CAPSULE UpdateCapsule; 803 EFI_QUERY_CAPSULE_CAPABILITIES QueryCapsuleCapabilities; 804 EFI_QUERY_VARIABLE_INFO QueryVariableInfo; 805 } EFI_RUNTIME_SERVICES; 806 807 808 // 809 // EFI Boot Services Table 810 // 811 812 #define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42 813 #define EFI_BOOT_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION) 814 815 typedef struct _EFI_BOOT_SERVICES { 816 817 EFI_TABLE_HEADER Hdr; 818 819 // 820 // Task priority functions 821 // 822 823 EFI_RAISE_TPL RaiseTPL; 824 EFI_RESTORE_TPL RestoreTPL; 825 826 // 827 // Memory functions 828 // 829 830 EFI_ALLOCATE_PAGES AllocatePages; 831 EFI_FREE_PAGES FreePages; 832 EFI_GET_MEMORY_MAP GetMemoryMap; 833 EFI_ALLOCATE_POOL AllocatePool; 834 EFI_FREE_POOL FreePool; 835 836 // 837 // Event & timer functions 838 // 839 840 EFI_CREATE_EVENT CreateEvent; 841 EFI_SET_TIMER SetTimer; 842 EFI_WAIT_FOR_EVENT WaitForEvent; 843 EFI_SIGNAL_EVENT SignalEvent; 844 EFI_CLOSE_EVENT CloseEvent; 845 EFI_CHECK_EVENT CheckEvent; 846 847 // 848 // Protocol handler functions 849 // 850 851 EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface; 852 EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface; 853 EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface; 854 EFI_HANDLE_PROTOCOL HandleProtocol; 855 EFI_HANDLE_PROTOCOL PCHandleProtocol; 856 EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify; 857 EFI_LOCATE_HANDLE LocateHandle; 858 EFI_LOCATE_DEVICE_PATH LocateDevicePath; 859 EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable; 860 861 // 862 // Image functions 863 // 864 865 EFI_IMAGE_LOAD LoadImage; 866 EFI_IMAGE_START StartImage; 867 EFI_EXIT Exit; 868 EFI_IMAGE_UNLOAD UnloadImage; 869 EFI_EXIT_BOOT_SERVICES ExitBootServices; 870 871 // 872 // Misc functions 873 // 874 875 EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount; 876 EFI_STALL Stall; 877 EFI_SET_WATCHDOG_TIMER SetWatchdogTimer; 878 879 // 880 // DriverSupport Services 881 // 882 883 EFI_CONNECT_CONTROLLER ConnectController; 884 EFI_DISCONNECT_CONTROLLER DisconnectController; 885 886 // 887 // Open and Close Protocol Services 888 // 889 EFI_OPEN_PROTOCOL OpenProtocol; 890 EFI_CLOSE_PROTOCOL CloseProtocol; 891 EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation; 892 893 // 894 // Library Services 895 // 896 EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle; 897 EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer; 898 EFI_LOCATE_PROTOCOL LocateProtocol; 899 EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces; 900 EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces; 901 902 // 903 // 32-bit CRC Services 904 // 905 EFI_CALCULATE_CRC32 CalculateCrc32; 906 907 // 908 // Misc Services 909 // 910 EFI_COPY_MEM CopyMem; 911 EFI_SET_MEM SetMem; 912 EFI_CREATE_EVENT_EX CreateEventEx; 913 } EFI_BOOT_SERVICES; 914 915 916 // 917 // EFI Configuration Table and GUID definitions 918 // 919 920 #define MPS_TABLE_GUID \ 921 { 0xeb9d2d2f, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } 922 923 #define ACPI_TABLE_GUID \ 924 { 0xeb9d2d30, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } 925 926 #define ACPI_20_TABLE_GUID \ 927 { 0x8868e871, 0xe4f1, 0x11d3, {0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} } 928 929 #define SMBIOS_TABLE_GUID \ 930 { 0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } 931 932 #define SMBIOS3_TABLE_GUID \ 933 { 0xf2fd1544, 0x9794, 0x4a2c, {0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94} } 934 935 #define SAL_SYSTEM_TABLE_GUID \ 936 { 0xeb9d2d32, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } 937 938 #define EFI_DTB_TABLE_GUID \ 939 { 0xb1b621d5, 0xf19c, 0x41a5, {0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0} } 940 941 typedef struct _EFI_CONFIGURATION_TABLE { 942 EFI_GUID VendorGuid; 943 VOID *VendorTable; 944 } EFI_CONFIGURATION_TABLE; 945 946 947 // 948 // EFI System Table 949 // 950 951 952 953 954 #define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249 955 #define EFI_SYSTEM_TABLE_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION) 956 957 typedef struct _EFI_SYSTEM_TABLE { 958 EFI_TABLE_HEADER Hdr; 959 960 CHAR16 *FirmwareVendor; 961 UINT32 FirmwareRevision; 962 963 EFI_HANDLE ConsoleInHandle; 964 SIMPLE_INPUT_INTERFACE *ConIn; 965 966 EFI_HANDLE ConsoleOutHandle; 967 SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut; 968 969 EFI_HANDLE StandardErrorHandle; 970 SIMPLE_TEXT_OUTPUT_INTERFACE *StdErr; 971 972 EFI_RUNTIME_SERVICES *RuntimeServices; 973 EFI_BOOT_SERVICES *BootServices; 974 975 UINTN NumberOfTableEntries; 976 EFI_CONFIGURATION_TABLE *ConfigurationTable; 977 978 } EFI_SYSTEM_TABLE; 979 980 #endif 981 982