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_IA64)
318 #define EFI_IMAGE_MACHINE_IA64 0x0200
321 #if !defined(EFI_IMAGE_MACHINE_EBC)
322 #define EFI_IMAGE_MACHINE_EBC 0x0EBC
325 // Image Entry prototype
329 (EFIAPI *EFI_IMAGE_ENTRY_POINT) (
330 IN EFI_HANDLE ImageHandle,
331 IN struct _EFI_SYSTEM_TABLE *SystemTable
336 (EFIAPI *EFI_IMAGE_LOAD) (
337 IN BOOLEAN BootPolicy,
338 IN EFI_HANDLE ParentImageHandle,
339 IN EFI_DEVICE_PATH *FilePath,
340 IN VOID *SourceBuffer OPTIONAL,
342 OUT EFI_HANDLE *ImageHandle
347 (EFIAPI *EFI_IMAGE_START) (
348 IN EFI_HANDLE ImageHandle,
349 OUT UINTN *ExitDataSize,
350 OUT CHAR16 **ExitData OPTIONAL
356 IN EFI_HANDLE ImageHandle,
357 IN EFI_STATUS ExitStatus,
358 IN UINTN ExitDataSize,
359 IN CHAR16 *ExitData OPTIONAL
364 (EFIAPI *EFI_IMAGE_UNLOAD) (
365 IN EFI_HANDLE ImageHandle
370 #define LOADED_IMAGE_PROTOCOL \
371 { 0x5B1B31A1, 0x9562, 0x11d2, 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }
373 #define EFI_LOADED_IMAGE_INFORMATION_REVISION 0x1000
376 EFI_HANDLE ParentHandle;
377 struct _EFI_SYSTEM_TABLE *SystemTable;
379 // Source location of image
380 EFI_HANDLE DeviceHandle;
381 EFI_DEVICE_PATH *FilePath;
384 // Images load options
385 UINT32 LoadOptionsSize;
388 // Location of where image was loaded
391 EFI_MEMORY_TYPE ImageCodeType;
392 EFI_MEMORY_TYPE ImageDataType;
394 // If the driver image supports a dynamic unload request
395 EFI_IMAGE_UNLOAD Unload;
402 (EFIAPI *EFI_EXIT_BOOT_SERVICES) (
403 IN EFI_HANDLE ImageHandle,
414 (EFIAPI *EFI_STALL) (
415 IN UINTN Microseconds
420 (EFIAPI *EFI_SET_WATCHDOG_TIMER) (
422 IN UINT64 WatchdogCode,
424 IN CHAR16 *WatchdogData OPTIONAL
436 (EFIAPI *EFI_RESET_SYSTEM) (
437 IN EFI_RESET_TYPE ResetType,
438 IN EFI_STATUS ResetStatus,
440 IN CHAR16 *ResetData OPTIONAL
445 (EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT) (
451 (EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT) (
452 OUT UINT32 *HighCount
456 // Protocol handler functions
461 } EFI_INTERFACE_TYPE;
465 (EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE) (
466 IN OUT EFI_HANDLE *Handle,
467 IN EFI_GUID *Protocol,
468 IN EFI_INTERFACE_TYPE InterfaceType,
474 (EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE) (
475 IN EFI_HANDLE Handle,
476 IN EFI_GUID *Protocol,
477 IN VOID *OldInterface,
478 IN VOID *NewInterface
483 (EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE) (
484 IN EFI_HANDLE Handle,
485 IN EFI_GUID *Protocol,
491 (EFIAPI *EFI_HANDLE_PROTOCOL) (
492 IN EFI_HANDLE Handle,
493 IN EFI_GUID *Protocol,
499 (EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY) (
500 IN EFI_GUID *Protocol,
502 OUT VOID **Registration
509 } EFI_LOCATE_SEARCH_TYPE;
513 (EFIAPI *EFI_LOCATE_HANDLE) (
514 IN EFI_LOCATE_SEARCH_TYPE SearchType,
515 IN EFI_GUID *Protocol OPTIONAL,
516 IN VOID *SearchKey OPTIONAL,
517 IN OUT UINTN *BufferSize,
518 OUT EFI_HANDLE *Buffer
523 (EFIAPI *EFI_LOCATE_DEVICE_PATH) (
524 IN EFI_GUID *Protocol,
525 IN OUT EFI_DEVICE_PATH **DevicePath,
526 OUT EFI_HANDLE *Device
531 (EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE) (
538 (EFIAPI *EFI_RESERVED_SERVICE) (
543 (EFIAPI *EFI_CONNECT_CONTROLLER) (
544 IN EFI_HANDLE ControllerHandle,
545 IN EFI_HANDLE *DriverImageHandle OPTIONAL,
546 IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL,
552 (EFIAPI *EFI_DISCONNECT_CONTROLLER)(
553 IN EFI_HANDLE ControllerHandle,
554 IN EFI_HANDLE DriverImageHandle, OPTIONAL
555 IN EFI_HANDLE ChildHandle OPTIONAL
558 #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
559 #define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
560 #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
561 #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
562 #define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
563 #define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020
567 (EFIAPI *EFI_OPEN_PROTOCOL) (
568 IN EFI_HANDLE Handle,
569 IN EFI_GUID *Protocol,
570 OUT VOID **Interface,
571 IN EFI_HANDLE ImageHandle,
572 IN EFI_HANDLE ControllerHandle, OPTIONAL
578 (EFIAPI *EFI_CLOSE_PROTOCOL) (
579 IN EFI_HANDLE Handle,
580 IN EFI_GUID *Protocol,
581 IN EFI_HANDLE ImageHandle,
582 IN EFI_HANDLE DeviceHandle
586 EFI_HANDLE AgentHandle;
587 EFI_HANDLE ControllerHandle;
590 } EFI_OPEN_PROTOCOL_INFORMATION_ENTRY;
594 (EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION) (
595 IN EFI_HANDLE UserHandle,
596 IN EFI_GUID *Protocol,
597 IN EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
598 OUT UINTN *EntryCount
603 (EFIAPI *EFI_PROTOCOLS_PER_HANDLE) (
604 IN EFI_HANDLE UserHandle,
605 OUT EFI_GUID ***ProtocolBuffer,
606 OUT UINTN *ProtocolBufferCount
611 (EFIAPI *EFI_LOCATE_HANDLE_BUFFER) (
612 IN EFI_LOCATE_SEARCH_TYPE SearchType,
613 IN EFI_GUID *Protocol OPTIONAL,
614 IN VOID *SearchKey OPTIONAL,
615 IN OUT UINTN *NumberHandles,
616 OUT EFI_HANDLE **Buffer
621 (EFIAPI *EFI_LOCATE_PROTOCOL) (
623 VOID *Registration, OPTIONAL
629 (EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
630 IN OUT EFI_HANDLE *Handle,
636 (EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
637 IN EFI_HANDLE Handle,
643 (EFIAPI *EFI_CALCULATE_CRC32) (
651 (EFIAPI *EFI_COPY_MEM) (
652 IN VOID *Destination,
659 (EFIAPI *EFI_SET_MEM) (
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))
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;
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
796 EFI_CONNECT_CONTROLLER ConnectController;
797 EFI_DISCONNECT_CONTROLLER DisconnectController;
800 // Open and Close Protocol Services
802 EFI_OPEN_PROTOCOL OpenProtocol;
803 EFI_CLOSE_PROTOCOL CloseProtocol;
804 EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation;
807 // Library Services to reduce size of drivers
809 EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle;
810 EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer;
811 EFI_LOCATE_PROTOCOL LocateProtocol;
813 EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces;
814 EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces;
819 EFI_CALCULATE_CRC32 CalculateCrc32;
822 // Memory Utility Services
824 EFI_COPY_MEM CopyMem;
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))
865 #define EFI_1_10_SYSTEM_TABLE_REVISION ((1<<16) | 10)
866 #define EFI_1_02_SYSTEM_TABLE_REVISION ((1<<16) | 02)
868 typedef struct _EFI_SYSTEM_TABLE {
869 EFI_TABLE_HEADER Hdr;
871 CHAR16 *FirmwareVendor;
872 UINT32 FirmwareRevision;
874 EFI_HANDLE ConsoleInHandle;
875 SIMPLE_INPUT_INTERFACE *ConIn;
877 EFI_HANDLE ConsoleOutHandle;
878 SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut;
880 EFI_HANDLE StandardErrorHandle;
881 SIMPLE_TEXT_OUTPUT_INTERFACE *StdErr;
883 EFI_RUNTIME_SERVICES *RuntimeServices;
884 EFI_BOOT_SERVICES *BootServices;
886 UINTN NumberOfTableEntries;
887 EFI_CONFIGURATION_TABLE *ConfigurationTable;