7 Copyright (c) 1999 - 2002 Intel Corporation. All rights reserved
8 This software and associated documentation (if any) is furnished
9 under a license and may only be used or copied in accordance
10 with the terms of the license. Except as permitted by such
11 license, no part of this software or documentation may be
12 reproduced, stored in a retrieval system, or transmitted in any
13 form or by any means without the express written consent of
22 Global EFI runtime & boot service interfaces
32 // EFI Specification Revision
35 #define EFI_SPECIFICATION_MAJOR_REVISION 1
36 #define EFI_SPECIFICATION_MINOR_REVISION 10
39 // Declare forward referenced data structures
42 INTERFACE_DECL(_EFI_SYSTEM_TABLE);
50 (EFIAPI *EFI_ALLOCATE_PAGES) (
51 IN EFI_ALLOCATE_TYPE Type,
52 IN EFI_MEMORY_TYPE MemoryType,
54 OUT EFI_PHYSICAL_ADDRESS *Memory
59 (EFIAPI *EFI_FREE_PAGES) (
60 IN EFI_PHYSICAL_ADDRESS Memory,
66 (EFIAPI *EFI_GET_MEMORY_MAP) (
67 IN OUT UINTN *MemoryMapSize,
68 IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
70 OUT UINTN *DescriptorSize,
71 OUT UINT32 *DescriptorVersion
74 #define NextMemoryDescriptor(Ptr,Size) ((EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) Ptr) + Size))
79 (EFIAPI *EFI_ALLOCATE_POOL) (
80 IN EFI_MEMORY_TYPE PoolType,
87 (EFIAPI *EFI_FREE_POOL) (
93 (EFIAPI *EFI_SET_VIRTUAL_ADDRESS_MAP) (
94 IN UINTN MemoryMapSize,
95 IN UINTN DescriptorSize,
96 IN UINT32 DescriptorVersion,
97 IN EFI_MEMORY_DESCRIPTOR *VirtualMap
101 #define EFI_OPTIONAL_PTR 0x00000001
102 #define EFI_INTERNAL_FNC 0x00000002 // Pointer to internal runtime fnc
103 #define EFI_INTERNAL_PTR 0x00000004 // Pointer to internal runtime data
108 (EFIAPI *EFI_CONVERT_POINTER) (
109 IN UINTN DebugDisposition,
110 IN OUT VOID **Address
120 #define EVT_TIMER 0x80000000
121 #define EVT_RUNTIME 0x40000000
122 #define EVT_RUNTIME_CONTEXT 0x20000000
124 #define EVT_NOTIFY_WAIT 0x00000100
125 #define EVT_NOTIFY_SIGNAL 0x00000200
127 #define EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201
128 #define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202
130 #define EVT_EFI_SIGNAL_MASK 0x000000FF
131 #define EVT_EFI_SIGNAL_MAX 2
135 (EFIAPI *EFI_EVENT_NOTIFY) (
142 (EFIAPI *EFI_CREATE_EVENT) (
144 IN EFI_TPL NotifyTpl,
145 IN EFI_EVENT_NOTIFY NotifyFunction,
146 IN VOID *NotifyContext,
159 (EFIAPI *EFI_SET_TIMER) (
161 IN EFI_TIMER_DELAY Type,
162 IN UINT64 TriggerTime
167 (EFIAPI *EFI_SIGNAL_EVENT) (
173 (EFIAPI *EFI_WAIT_FOR_EVENT) (
174 IN UINTN NumberOfEvents,
181 (EFIAPI *EFI_CLOSE_EVENT) (
187 (EFIAPI *EFI_CHECK_EVENT) (
192 // Task priority level
195 #define TPL_APPLICATION 4
196 #define TPL_CALLBACK 8
197 #define TPL_NOTIFY 16
198 #define TPL_HIGH_LEVEL 31
202 (EFIAPI *EFI_RAISE_TPL) (
208 (EFIAPI *EFI_RESTORE_TPL) (
214 // EFI platform varibles
217 #define EFI_GLOBAL_VARIABLE \
218 { 0x8BE4DF61, 0x93CA, 0x11d2, 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C }
220 // Variable attributes
221 #define EFI_VARIABLE_NON_VOLATILE 0x00000001
222 #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
223 #define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
225 // Variable size limitation
226 #define EFI_MAXIMUM_VARIABLE_SIZE 1024
230 (EFIAPI *EFI_GET_VARIABLE) (
231 IN CHAR16 *VariableName,
232 IN EFI_GUID *VendorGuid,
233 OUT UINT32 *Attributes OPTIONAL,
234 IN OUT UINTN *DataSize,
240 (EFIAPI *EFI_GET_NEXT_VARIABLE_NAME) (
241 IN OUT UINTN *VariableNameSize,
242 IN OUT CHAR16 *VariableName,
243 IN OUT EFI_GUID *VendorGuid
249 (EFIAPI *EFI_SET_VARIABLE) (
250 IN CHAR16 *VariableName,
251 IN EFI_GUID *VendorGuid,
252 IN UINT32 Attributes,
263 UINT32 Resolution; // 1e-6 parts per million
264 UINT32 Accuracy; // hertz
265 BOOLEAN SetsToZero; // Set clears sub-second time
266 } EFI_TIME_CAPABILITIES;
271 (EFIAPI *EFI_GET_TIME) (
273 OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL
278 (EFIAPI *EFI_SET_TIME) (
284 (EFIAPI *EFI_GET_WAKEUP_TIME) (
285 OUT BOOLEAN *Enabled,
286 OUT BOOLEAN *Pending,
292 (EFIAPI *EFI_SET_WAKEUP_TIME) (
294 IN EFI_TIME *Time OPTIONAL
303 // PE32+ Subsystem type for EFI images
305 #if !defined(IMAGE_SUBSYSTEM_EFI_APPLICATION)
306 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
307 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
308 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
311 // PE32+ Machine type for EFI images
313 #if !defined(EFI_IMAGE_MACHINE_IA32)
314 #define EFI_IMAGE_MACHINE_IA32 0x014c
317 #if !defined(EFI_IMAGE_MACHINE_EBC)
318 #define EFI_IMAGE_MACHINE_EBC 0x0EBC
321 // Image Entry prototype
325 (EFIAPI *EFI_IMAGE_ENTRY_POINT) (
326 IN EFI_HANDLE ImageHandle,
327 IN struct _EFI_SYSTEM_TABLE *SystemTable
332 (EFIAPI *EFI_IMAGE_LOAD) (
333 IN BOOLEAN BootPolicy,
334 IN EFI_HANDLE ParentImageHandle,
335 IN EFI_DEVICE_PATH *FilePath,
336 IN VOID *SourceBuffer OPTIONAL,
338 OUT EFI_HANDLE *ImageHandle
343 (EFIAPI *EFI_IMAGE_START) (
344 IN EFI_HANDLE ImageHandle,
345 OUT UINTN *ExitDataSize,
346 OUT CHAR16 **ExitData OPTIONAL
352 IN EFI_HANDLE ImageHandle,
353 IN EFI_STATUS ExitStatus,
354 IN UINTN ExitDataSize,
355 IN CHAR16 *ExitData OPTIONAL
360 (EFIAPI *EFI_IMAGE_UNLOAD) (
361 IN EFI_HANDLE ImageHandle
366 #define LOADED_IMAGE_PROTOCOL \
367 { 0x5B1B31A1, 0x9562, 0x11d2, 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }
369 #define EFI_LOADED_IMAGE_INFORMATION_REVISION 0x1000
372 EFI_HANDLE ParentHandle;
373 struct _EFI_SYSTEM_TABLE *SystemTable;
375 // Source location of image
376 EFI_HANDLE DeviceHandle;
377 EFI_DEVICE_PATH *FilePath;
380 // Images load options
381 UINT32 LoadOptionsSize;
384 // Location of where image was loaded
387 EFI_MEMORY_TYPE ImageCodeType;
388 EFI_MEMORY_TYPE ImageDataType;
390 // If the driver image supports a dynamic unload request
391 EFI_IMAGE_UNLOAD Unload;
398 (EFIAPI *EFI_EXIT_BOOT_SERVICES) (
399 IN EFI_HANDLE ImageHandle,
410 (EFIAPI *EFI_STALL) (
411 IN UINTN Microseconds
416 (EFIAPI *EFI_SET_WATCHDOG_TIMER) (
418 IN UINT64 WatchdogCode,
420 IN CHAR16 *WatchdogData OPTIONAL
432 (EFIAPI *EFI_RESET_SYSTEM) (
433 IN EFI_RESET_TYPE ResetType,
434 IN EFI_STATUS ResetStatus,
436 IN CHAR16 *ResetData OPTIONAL
441 (EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT) (
447 (EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT) (
448 OUT UINT32 *HighCount
452 // Protocol handler functions
457 } EFI_INTERFACE_TYPE;
461 (EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE) (
462 IN OUT EFI_HANDLE *Handle,
463 IN EFI_GUID *Protocol,
464 IN EFI_INTERFACE_TYPE InterfaceType,
470 (EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE) (
471 IN EFI_HANDLE Handle,
472 IN EFI_GUID *Protocol,
473 IN VOID *OldInterface,
474 IN VOID *NewInterface
479 (EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE) (
480 IN EFI_HANDLE Handle,
481 IN EFI_GUID *Protocol,
487 (EFIAPI *EFI_HANDLE_PROTOCOL) (
488 IN EFI_HANDLE Handle,
489 IN EFI_GUID *Protocol,
495 (EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY) (
496 IN EFI_GUID *Protocol,
498 OUT VOID **Registration
505 } EFI_LOCATE_SEARCH_TYPE;
509 (EFIAPI *EFI_LOCATE_HANDLE) (
510 IN EFI_LOCATE_SEARCH_TYPE SearchType,
511 IN EFI_GUID *Protocol OPTIONAL,
512 IN VOID *SearchKey OPTIONAL,
513 IN OUT UINTN *BufferSize,
514 OUT EFI_HANDLE *Buffer
519 (EFIAPI *EFI_LOCATE_DEVICE_PATH) (
520 IN EFI_GUID *Protocol,
521 IN OUT EFI_DEVICE_PATH **DevicePath,
522 OUT EFI_HANDLE *Device
527 (EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE) (
534 (EFIAPI *EFI_RESERVED_SERVICE) (
539 (EFIAPI *EFI_CONNECT_CONTROLLER) (
540 IN EFI_HANDLE ControllerHandle,
541 IN EFI_HANDLE *DriverImageHandle OPTIONAL,
542 IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL,
548 (EFIAPI *EFI_DISCONNECT_CONTROLLER)(
549 IN EFI_HANDLE ControllerHandle,
550 IN EFI_HANDLE DriverImageHandle, OPTIONAL
551 IN EFI_HANDLE ChildHandle OPTIONAL
554 #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
555 #define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
556 #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
557 #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
558 #define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
559 #define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020
563 (EFIAPI *EFI_OPEN_PROTOCOL) (
564 IN EFI_HANDLE Handle,
565 IN EFI_GUID *Protocol,
566 OUT VOID **Interface,
567 IN EFI_HANDLE ImageHandle,
568 IN EFI_HANDLE ControllerHandle, OPTIONAL
574 (EFIAPI *EFI_CLOSE_PROTOCOL) (
575 IN EFI_HANDLE Handle,
576 IN EFI_GUID *Protocol,
577 IN EFI_HANDLE ImageHandle,
578 IN EFI_HANDLE DeviceHandle
582 EFI_HANDLE AgentHandle;
583 EFI_HANDLE ControllerHandle;
586 } EFI_OPEN_PROTOCOL_INFORMATION_ENTRY;
590 (EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION) (
591 IN EFI_HANDLE UserHandle,
592 IN EFI_GUID *Protocol,
593 IN EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
594 OUT UINTN *EntryCount
599 (EFIAPI *EFI_PROTOCOLS_PER_HANDLE) (
600 IN EFI_HANDLE UserHandle,
601 OUT EFI_GUID ***ProtocolBuffer,
602 OUT UINTN *ProtocolBufferCount
607 (EFIAPI *EFI_LOCATE_HANDLE_BUFFER) (
608 IN EFI_LOCATE_SEARCH_TYPE SearchType,
609 IN EFI_GUID *Protocol OPTIONAL,
610 IN VOID *SearchKey OPTIONAL,
611 IN OUT UINTN *NumberHandles,
612 OUT EFI_HANDLE **Buffer
617 (EFIAPI *EFI_LOCATE_PROTOCOL) (
619 VOID *Registration, OPTIONAL
625 (EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
626 IN OUT EFI_HANDLE *Handle,
632 (EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
633 IN EFI_HANDLE Handle,
639 (EFIAPI *EFI_CALCULATE_CRC32) (
647 (EFIAPI *EFI_COPY_MEM) (
648 IN VOID *Destination,
655 (EFIAPI *EFI_SET_MEM) (
662 // Standard EFI table header
665 typedef struct _EFI_TABLE_HEARDER {
675 // EFI Runtime Serivces Table
678 #define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552
679 #define EFI_RUNTIME_SERVICES_REVISION ((EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION))
682 EFI_TABLE_HEADER Hdr;
688 EFI_GET_TIME GetTime;
689 EFI_SET_TIME SetTime;
690 EFI_GET_WAKEUP_TIME GetWakeupTime;
691 EFI_SET_WAKEUP_TIME SetWakeupTime;
694 // Virtual memory services
697 EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap;
698 EFI_CONVERT_POINTER ConvertPointer;
704 EFI_GET_VARIABLE GetVariable;
705 EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName;
706 EFI_SET_VARIABLE SetVariable;
712 EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount;
713 EFI_RESET_SYSTEM ResetSystem;
715 } EFI_RUNTIME_SERVICES;
719 // EFI Boot Services Table
722 #define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42
723 #define EFI_BOOT_SERVICES_REVISION ((EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION))
727 EFI_TABLE_HEADER Hdr;
730 // Task priority functions
733 EFI_RAISE_TPL RaiseTPL;
734 EFI_RESTORE_TPL RestoreTPL;
740 EFI_ALLOCATE_PAGES AllocatePages;
741 EFI_FREE_PAGES FreePages;
742 EFI_GET_MEMORY_MAP GetMemoryMap;
743 EFI_ALLOCATE_POOL AllocatePool;
744 EFI_FREE_POOL FreePool;
747 // Event & timer functions
750 EFI_CREATE_EVENT CreateEvent;
751 EFI_SET_TIMER SetTimer;
752 EFI_WAIT_FOR_EVENT WaitForEvent;
753 EFI_SIGNAL_EVENT SignalEvent;
754 EFI_CLOSE_EVENT CloseEvent;
755 EFI_CHECK_EVENT CheckEvent;
758 // Protocol handler functions
761 EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface;
762 EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface;
763 EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface;
764 EFI_HANDLE_PROTOCOL HandleProtocol;
766 EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify;
767 EFI_LOCATE_HANDLE LocateHandle;
768 EFI_LOCATE_DEVICE_PATH LocateDevicePath;
769 EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable;
775 EFI_IMAGE_LOAD LoadImage;
776 EFI_IMAGE_START StartImage;
778 EFI_IMAGE_UNLOAD UnloadImage;
779 EFI_EXIT_BOOT_SERVICES ExitBootServices;
785 EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount;
787 EFI_SET_WATCHDOG_TIMER SetWatchdogTimer;
790 // DriverSupport Services
792 EFI_CONNECT_CONTROLLER ConnectController;
793 EFI_DISCONNECT_CONTROLLER DisconnectController;
796 // Open and Close Protocol Services
798 EFI_OPEN_PROTOCOL OpenProtocol;
799 EFI_CLOSE_PROTOCOL CloseProtocol;
800 EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation;
803 // Library Services to reduce size of drivers
805 EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle;
806 EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer;
807 EFI_LOCATE_PROTOCOL LocateProtocol;
809 EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces;
810 EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces;
815 EFI_CALCULATE_CRC32 CalculateCrc32;
818 // Memory Utility Services
820 EFI_COPY_MEM CopyMem;
827 // EFI Configuration Table and GUID definitions
830 #define MPS_TABLE_GUID \
831 { 0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
833 #define ACPI_TABLE_GUID \
834 { 0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
836 #define ACPI_20_TABLE_GUID \
837 { 0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }
839 #define SMBIOS_TABLE_GUID \
840 { 0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
842 #define SAL_SYSTEM_TABLE_GUID \
843 { 0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
845 #define FDT_TABLE_GUID \
846 { 0xb1b621d5, 0xf19c, 0x41a5, 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 }
848 typedef struct _EFI_CONFIGURATION_TABLE {
851 } EFI_CONFIGURATION_TABLE;
861 #define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249
862 #define EFI_SYSTEM_TABLE_REVISION ((EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION))
863 #define EFI_1_10_SYSTEM_TABLE_REVISION ((1<<16) | 10)
864 #define EFI_1_02_SYSTEM_TABLE_REVISION ((1<<16) | 02)
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;