6 Copyright (c) 1998 Intel Corporation
14 Global EFI runtime & boot service interfaces
24 // EFI Specification Revision
27 #define EFI_SPECIFICATION_MAJOR_REVISION 1
28 #define EFI_SPECIFICATION_MINOR_REVISION 02
31 // Declare forward referenced data structures
34 INTERFACE_DECL(_EFI_SYSTEM_TABLE
);
42 (EFIAPI
*EFI_ALLOCATE_PAGES
) (
43 IN EFI_ALLOCATE_TYPE Type
,
44 IN EFI_MEMORY_TYPE MemoryType
,
46 OUT EFI_PHYSICAL_ADDRESS
*Memory
51 (EFIAPI
*EFI_FREE_PAGES
) (
52 IN EFI_PHYSICAL_ADDRESS Memory
,
58 (EFIAPI
*EFI_GET_MEMORY_MAP
) (
59 IN OUT UINTN
*MemoryMapSize
,
60 IN OUT EFI_MEMORY_DESCRIPTOR
*MemoryMap
,
62 OUT UINTN
*DescriptorSize
,
63 OUT UINT32
*DescriptorVersion
66 #define NextMemoryDescriptor(Ptr,Size) ((EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) Ptr) + Size))
71 (EFIAPI
*EFI_ALLOCATE_POOL
) (
72 IN EFI_MEMORY_TYPE PoolType
,
79 (EFIAPI
*EFI_FREE_POOL
) (
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
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
100 (EFIAPI
*EFI_CONVERT_POINTER
) (
101 IN UINTN DebugDisposition
,
102 IN OUT VOID
**Address
112 #define EVT_TIMER 0x80000000
113 #define EVT_RUNTIME 0x40000000
114 #define EVT_RUNTIME_CONTEXT 0x20000000
116 #define EVT_NOTIFY_WAIT 0x00000100
117 #define EVT_NOTIFY_SIGNAL 0x00000200
119 #define EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201
120 #define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202
122 #define EVT_EFI_SIGNAL_MASK 0x000000FF
123 #define EVT_EFI_SIGNAL_MAX 2
127 (EFIAPI
*EFI_EVENT_NOTIFY
) (
134 (EFIAPI
*EFI_CREATE_EVENT
) (
136 IN EFI_TPL NotifyTpl
,
137 IN EFI_EVENT_NOTIFY NotifyFunction
,
138 IN VOID
*NotifyContext
,
151 (EFIAPI
*EFI_SET_TIMER
) (
153 IN EFI_TIMER_DELAY Type
,
154 IN UINT64 TriggerTime
159 (EFIAPI
*EFI_SIGNAL_EVENT
) (
165 (EFIAPI
*EFI_WAIT_FOR_EVENT
) (
166 IN UINTN NumberOfEvents
,
173 (EFIAPI
*EFI_CLOSE_EVENT
) (
179 (EFIAPI
*EFI_CHECK_EVENT
) (
184 // Task priority level
187 #define TPL_APPLICATION 4
188 #define TPL_CALLBACK 8
189 #define TPL_NOTIFY 16
190 #define TPL_HIGH_LEVEL 31
194 (EFIAPI
*EFI_RAISE_TPL
) (
200 (EFIAPI
*EFI_RESTORE_TPL
) (
206 // EFI platform varibles
209 #define EFI_GLOBAL_VARIABLE \
210 { 0x8BE4DF61, 0x93CA, 0x11d2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C} }
212 // Variable attributes
213 #define EFI_VARIABLE_NON_VOLATILE 0x00000001
214 #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
215 #define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
217 // Variable size limitation
218 #define EFI_MAXIMUM_VARIABLE_SIZE 1024
222 (EFIAPI
*EFI_GET_VARIABLE
) (
223 IN CHAR16
*VariableName
,
224 IN EFI_GUID
*VendorGuid
,
225 OUT UINT32
*Attributes OPTIONAL
,
226 IN OUT UINTN
*DataSize
,
232 (EFIAPI
*EFI_GET_NEXT_VARIABLE_NAME
) (
233 IN OUT UINTN
*VariableNameSize
,
234 IN OUT CHAR16
*VariableName
,
235 IN OUT EFI_GUID
*VendorGuid
241 (EFIAPI
*EFI_SET_VARIABLE
) (
242 IN CHAR16
*VariableName
,
243 IN EFI_GUID
*VendorGuid
,
244 IN UINT32 Attributes
,
255 UINT32 Resolution
; // 1e-6 parts per million
256 UINT32 Accuracy
; // hertz
257 BOOLEAN SetsToZero
; // Set clears sub-second time
258 } EFI_TIME_CAPABILITIES
;
263 (EFIAPI
*EFI_GET_TIME
) (
265 OUT EFI_TIME_CAPABILITIES
*Capabilities OPTIONAL
270 (EFIAPI
*EFI_SET_TIME
) (
276 (EFIAPI
*EFI_GET_WAKEUP_TIME
) (
277 OUT BOOLEAN
*Enabled
,
278 OUT BOOLEAN
*Pending
,
284 (EFIAPI
*EFI_SET_WAKEUP_TIME
) (
286 IN EFI_TIME
*Time OPTIONAL
295 // PE32+ Subsystem type for EFI images
297 #if !defined(IMAGE_SUBSYSTEM_EFI_APPLICATION)
298 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
299 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
300 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
303 // PE32+ Machine type for EFI images
305 #if !defined(EFI_IMAGE_MACHINE_IA32)
306 #define EFI_IMAGE_MACHINE_IA32 0x014c
309 #if !defined(EFI_IMAGE_MACHINE_IA64)
310 #define EFI_IMAGE_MACHINE_IA64 0x0200
313 // Image Entry prototype
317 (EFIAPI
*EFI_IMAGE_ENTRY_POINT
) (
318 IN EFI_HANDLE ImageHandle
,
319 IN
struct _EFI_SYSTEM_TABLE
*SystemTable
324 (EFIAPI
*EFI_IMAGE_LOAD
) (
325 IN BOOLEAN BootPolicy
,
326 IN EFI_HANDLE ParentImageHandle
,
327 IN EFI_DEVICE_PATH
*FilePath
,
328 IN VOID
*SourceBuffer OPTIONAL
,
330 OUT EFI_HANDLE
*ImageHandle
335 (EFIAPI
*EFI_IMAGE_START
) (
336 IN EFI_HANDLE ImageHandle
,
337 OUT UINTN
*ExitDataSize
,
338 OUT CHAR16
**ExitData OPTIONAL
344 IN EFI_HANDLE ImageHandle
,
345 IN EFI_STATUS ExitStatus
,
346 IN UINTN ExitDataSize
,
347 IN CHAR16
*ExitData OPTIONAL
352 (EFIAPI
*EFI_IMAGE_UNLOAD
) (
353 IN EFI_HANDLE ImageHandle
358 #define LOADED_IMAGE_PROTOCOL \
359 { 0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} }
361 #define EFI_IMAGE_INFORMATION_REVISION 0x1000
364 EFI_HANDLE ParentHandle
;
365 struct _EFI_SYSTEM_TABLE
*SystemTable
;
367 // Source location of image
368 EFI_HANDLE DeviceHandle
;
369 EFI_DEVICE_PATH
*FilePath
;
372 // Images load options
373 UINT32 LoadOptionsSize
;
376 // Location of where image was loaded
379 EFI_MEMORY_TYPE ImageCodeType
;
380 EFI_MEMORY_TYPE ImageDataType
;
382 // If the driver image supports a dynamic unload request
383 EFI_IMAGE_UNLOAD Unload
;
390 (EFIAPI
*EFI_EXIT_BOOT_SERVICES
) (
391 IN EFI_HANDLE ImageHandle
,
402 (EFIAPI
*EFI_STALL
) (
403 IN UINTN Microseconds
408 (EFIAPI
*EFI_SET_WATCHDOG_TIMER
) (
410 IN UINT64 WatchdogCode
,
412 IN CHAR16
*WatchdogData OPTIONAL
417 (EFIAPI
*EFI_CONNECT_CONTROLLER
) (
418 IN EFI_HANDLE ControllerHandle
,
419 IN EFI_HANDLE
*DriverImageHandle OPTIONAL
,
420 IN EFI_DEVICE_PATH
*RemainingDevicePath OPTIONAL
,
426 (EFIAPI
*EFI_DISCONNECT_CONTROLLER
) (
427 IN EFI_HANDLE ControllerHandle
,
428 IN EFI_HANDLE DriverImageHandle OPTIONAL
,
429 IN EFI_HANDLE ChildHandle OPTIONAL
432 #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
433 #define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
434 #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
435 #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
436 #define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
437 #define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020
441 (EFIAPI
*EFI_OPEN_PROTOCOL
) (
442 IN EFI_HANDLE Handle
,
443 IN EFI_GUID
*Protocol
,
444 OUT VOID
**Interface OPTIONAL
,
445 IN EFI_HANDLE AgentHandle
,
446 IN EFI_HANDLE ControllerHandle
,
452 (EFIAPI
*EFI_CLOSE_PROTOCOL
) (
453 IN EFI_HANDLE Handle
,
454 IN EFI_GUID
*Protocol
,
455 IN EFI_HANDLE AgentHandle
,
456 IN EFI_HANDLE ControllerHandle
460 EFI_HANDLE AgentHandle
;
461 EFI_HANDLE ControllerHandle
;
464 } EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
;
468 (EFIAPI
*EFI_OPEN_PROTOCOL_INFORMATION
) (
469 IN EFI_HANDLE Handle
,
470 IN EFI_GUID
*Protocol
,
471 OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
**EntryBuffer
,
472 OUT UINTN
*EntryCount
477 (EFIAPI
*EFI_PROTOCOLS_PER_HANDLE
) (
478 IN EFI_HANDLE Handle
,
479 OUT EFI_GUID
***ProtocolBuffer
,
480 OUT UINTN
*ProtocolBufferCount
487 } EFI_LOCATE_SEARCH_TYPE
;
491 (EFIAPI
*EFI_LOCATE_HANDLE_BUFFER
) (
492 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
493 IN EFI_GUID
*Protocol OPTIONAL
,
494 IN VOID
*SearchKey OPTIONAL
,
495 IN OUT UINTN
*NoHandles
,
496 OUT EFI_HANDLE
**Buffer
501 (EFIAPI
*EFI_LOCATE_PROTOCOL
) (
502 IN EFI_GUID
*Protocol
,
503 IN VOID
*Registration OPTIONAL
,
509 (EFIAPI
*EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES
) (
510 IN OUT EFI_HANDLE
*Handle
,
516 (EFIAPI
*EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES
) (
517 IN OUT EFI_HANDLE Handle
,
523 (EFIAPI
*EFI_CALCULATE_CRC32
) (
531 (EFIAPI
*EFI_COPY_MEM
) (
532 IN VOID
*Destination
,
539 (EFIAPI
*EFI_SET_MEM
) (
548 (EFIAPI
*EFI_CREATE_EVENT_EX
) (
550 IN EFI_TPL NotifyTpl
,
551 IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL
,
552 IN
const VOID
*NotifyContext OPTIONAL
,
553 IN
const EFI_GUID EventGroup OPTIONAL
,
565 (EFIAPI
*EFI_RESET_SYSTEM
) (
566 IN EFI_RESET_TYPE ResetType
,
567 IN EFI_STATUS ResetStatus
,
569 IN CHAR16
*ResetData OPTIONAL
574 (EFIAPI
*EFI_GET_NEXT_MONOTONIC_COUNT
) (
580 (EFIAPI
*EFI_GET_NEXT_HIGH_MONO_COUNT
) (
581 OUT UINT32
*HighCount
585 // Protocol handler functions
589 EFI_NATIVE_INTERFACE
,
591 } EFI_INTERFACE_TYPE
;
595 (EFIAPI
*EFI_INSTALL_PROTOCOL_INTERFACE
) (
596 IN OUT EFI_HANDLE
*Handle
,
597 IN EFI_GUID
*Protocol
,
598 IN EFI_INTERFACE_TYPE InterfaceType
,
604 (EFIAPI
*EFI_REINSTALL_PROTOCOL_INTERFACE
) (
605 IN EFI_HANDLE Handle
,
606 IN EFI_GUID
*Protocol
,
607 IN VOID
*OldInterface
,
608 IN VOID
*NewInterface
613 (EFIAPI
*EFI_UNINSTALL_PROTOCOL_INTERFACE
) (
614 IN EFI_HANDLE Handle
,
615 IN EFI_GUID
*Protocol
,
621 (EFIAPI
*EFI_HANDLE_PROTOCOL
) (
622 IN EFI_HANDLE Handle
,
623 IN EFI_GUID
*Protocol
,
629 (EFIAPI
*EFI_REGISTER_PROTOCOL_NOTIFY
) (
630 IN EFI_GUID
*Protocol
,
632 OUT VOID
**Registration
637 (EFIAPI
*EFI_LOCATE_HANDLE
) (
638 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
639 IN EFI_GUID
*Protocol OPTIONAL
,
640 IN VOID
*SearchKey OPTIONAL
,
641 IN OUT UINTN
*BufferSize
,
642 OUT EFI_HANDLE
*Buffer
647 (EFIAPI
*EFI_LOCATE_DEVICE_PATH
) (
648 IN EFI_GUID
*Protocol
,
649 IN OUT EFI_DEVICE_PATH
**DevicePath
,
650 OUT EFI_HANDLE
*Device
655 (EFIAPI
*EFI_INSTALL_CONFIGURATION_TABLE
) (
662 (EFIAPI
*EFI_RESERVED_SERVICE
) (
666 // Standard EFI table header
669 typedef struct _EFI_TABLE_HEARDER
{
679 // EFI Runtime Serivces Table
682 #define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552
683 #define EFI_RUNTIME_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
686 EFI_TABLE_HEADER Hdr
;
692 EFI_GET_TIME GetTime
;
693 EFI_SET_TIME SetTime
;
694 EFI_GET_WAKEUP_TIME GetWakeupTime
;
695 EFI_SET_WAKEUP_TIME SetWakeupTime
;
698 // Virtual memory services
701 EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap
;
702 EFI_CONVERT_POINTER ConvertPointer
;
708 EFI_GET_VARIABLE GetVariable
;
709 EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName
;
710 EFI_SET_VARIABLE SetVariable
;
716 EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount
;
717 EFI_RESET_SYSTEM ResetSystem
;
719 } EFI_RUNTIME_SERVICES
;
723 // EFI Boot Services Table
726 #define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42
727 #define EFI_BOOT_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
729 typedef struct _EFI_BOOT_SERVICES
{
731 EFI_TABLE_HEADER Hdr
;
734 // Task priority functions
737 EFI_RAISE_TPL RaiseTPL
;
738 EFI_RESTORE_TPL RestoreTPL
;
744 EFI_ALLOCATE_PAGES AllocatePages
;
745 EFI_FREE_PAGES FreePages
;
746 EFI_GET_MEMORY_MAP GetMemoryMap
;
747 EFI_ALLOCATE_POOL AllocatePool
;
748 EFI_FREE_POOL FreePool
;
751 // Event & timer functions
754 EFI_CREATE_EVENT CreateEvent
;
755 EFI_SET_TIMER SetTimer
;
756 EFI_WAIT_FOR_EVENT WaitForEvent
;
757 EFI_SIGNAL_EVENT SignalEvent
;
758 EFI_CLOSE_EVENT CloseEvent
;
759 EFI_CHECK_EVENT CheckEvent
;
762 // Protocol handler functions
765 EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface
;
766 EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface
;
767 EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface
;
768 EFI_HANDLE_PROTOCOL HandleProtocol
;
769 EFI_HANDLE_PROTOCOL PCHandleProtocol
;
770 EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify
;
771 EFI_LOCATE_HANDLE LocateHandle
;
772 EFI_LOCATE_DEVICE_PATH LocateDevicePath
;
773 EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable
;
779 EFI_IMAGE_LOAD LoadImage
;
780 EFI_IMAGE_START StartImage
;
782 EFI_IMAGE_UNLOAD UnloadImage
;
783 EFI_EXIT_BOOT_SERVICES ExitBootServices
;
789 EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount
;
791 EFI_SET_WATCHDOG_TIMER SetWatchdogTimer
;
794 // DriverSupport Services
797 EFI_CONNECT_CONTROLLER ConnectController
;
798 EFI_DISCONNECT_CONTROLLER DisconnectController
;
801 // Open and Close Protocol Services
803 EFI_OPEN_PROTOCOL OpenProtocol
;
804 EFI_CLOSE_PROTOCOL CloseProtocol
;
805 EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation
;
810 EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle
;
811 EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
;
812 EFI_LOCATE_PROTOCOL LocateProtocol
;
813 EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces
;
814 EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
;
817 // 32-bit CRC Services
819 EFI_CALCULATE_CRC32 CalculateCrc32
;
824 EFI_COPY_MEM CopyMem
;
826 EFI_CREATE_EVENT_EX CreateEventEx
;
831 // EFI Configuration Table and GUID definitions
834 #define MPS_TABLE_GUID \
835 { 0xeb9d2d2f, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
837 #define ACPI_TABLE_GUID \
838 { 0xeb9d2d30, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
840 #define ACPI_20_TABLE_GUID \
841 { 0x8868e871, 0xe4f1, 0x11d3, {0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} }
843 #define SMBIOS_TABLE_GUID \
844 { 0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
846 #define SAL_SYSTEM_TABLE_GUID \
847 { 0xeb9d2d32, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
850 typedef struct _EFI_CONFIGURATION_TABLE
{
853 } EFI_CONFIGURATION_TABLE
;
863 #define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249
864 #define EFI_SYSTEM_TABLE_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
866 typedef struct _EFI_SYSTEM_TABLE
{
867 EFI_TABLE_HEADER Hdr
;
869 CHAR16
*FirmwareVendor
;
870 UINT32 FirmwareRevision
;
872 EFI_HANDLE ConsoleInHandle
;
873 SIMPLE_INPUT_INTERFACE
*ConIn
;
875 EFI_HANDLE ConsoleOutHandle
;
876 SIMPLE_TEXT_OUTPUT_INTERFACE
*ConOut
;
878 EFI_HANDLE StandardErrorHandle
;
879 SIMPLE_TEXT_OUTPUT_INTERFACE
*StdErr
;
881 EFI_RUNTIME_SERVICES
*RuntimeServices
;
882 EFI_BOOT_SERVICES
*BootServices
;
884 UINTN NumberOfTableEntries
;
885 EFI_CONFIGURATION_TABLE
*ConfigurationTable
;