1 #ifndef _EFILIB_INCLUDE_
2 #define _EFILIB_INCLUDE_
6 Copyright (c) 2000 Intel Corporation
24 #if defined(_M_X64) || defined(__x86_64__) || defined(__amd64__)
25 #include "x86_64/efilibplat.h"
26 #elif defined(_M_IX86) || defined(__i386__)
27 #include "ia32/efilibplat.h"
28 #elif defined(_M_IA64) || defined(__ia64__)
29 #include "ia64/efilibplat.h"
30 #elif defined (_M_ARM64) || defined(__aarch64__)
31 #include "aarch64/efilibplat.h"
32 #elif defined (_M_ARM) || defined(__arm__)
33 #include "arm/efilibplat.h"
34 #elif defined (_M_MIPS64) || defined(__mips64__)
35 #include "mips64el/efilibplat.h"
39 #include "efistdarg.h"
41 #include "libsmbios.h"
44 // Public read-only data in the EFI library
47 extern EFI_SYSTEM_TABLE
*ST
;
49 extern EFI_BOOT_SERVICES
*BS
;
51 extern EFI_RUNTIME_SERVICES
*RT
;
54 extern EFI_GUID gEfiDevicePathProtocolGuid
;
55 #define DevicePathProtocol gEfiDevicePathProtocolGuid
56 extern EFI_GUID gEfiDevicePathToTextProtocolGuid
;
57 #define DevicePathToTextProtocol gEfiDevicePathToTextProtocolGuid
58 extern EFI_GUID gEfiDevicePathFromTextProtocolGuid
;
59 #define DevicePathFromTextProtocol gEfiDevicePathFromTextProtocolGuid
60 extern EFI_GUID gEfiLoadedImageProtocolGuid
;
61 #define LoadedImageProtocol gEfiLoadedImageProtocolGuid
62 extern EFI_GUID gEfiSimpleTextInProtocolGuid
;
63 #define TextInProtocol gEfiSimpleTextInProtocolGuid
64 extern EFI_GUID gEfiSimpleTextOutProtocolGuid
;
65 #define TextOutProtocol gEfiSimpleTextOutProtocolGuid
66 extern EFI_GUID gEfiGraphicsOutputProtocolGuid
;
67 #define GraphicsOutputProtocol gEfiGraphicsOutputProtocolGuid
68 extern EFI_GUID gEfiEdidDiscoveredProtocolGuid
;
69 #define EdidDiscoveredProtocol gEfiEdidDiscoveredProtocolGuid
70 extern EFI_GUID gEfiEdidActiveProtocolGuid
;
71 #define EdidActiveProtocol gEfiEdidActiveProtocolGuid
72 extern EFI_GUID gEfiEdidOverrideProtocolGuid
;
73 #define EdidOverrideProtocol gEfiEdidOverrideProtocolGuid
74 extern EFI_GUID gEfiBlockIoProtocolGuid
;
75 #define BlockIoProtocol gEfiBlockIoProtocolGuid
76 extern EFI_GUID gEfiBlockIo2ProtocolGuid
;
77 #define BlockIo2Protocol gEfiBlockIo2ProtocolGuid
78 extern EFI_GUID gEfiDiskIoProtocolGuid
;
79 #define DiskIoProtocol gEfiDiskIoProtocolGuid
80 extern EFI_GUID gEfiDiskIo2ProtocolGuid
;
81 #define DiskIo2Protocol gEfiDiskIo2ProtocolGuid
82 extern EFI_GUID gEfiSimpleFileSystemProtocolGuid
;
83 #define FileSystemProtocol gEfiSimpleFileSystemProtocolGuid
84 extern EFI_GUID gEfiLoadFileProtocolGuid
;
85 #define LoadFileProtocol gEfiLoadFileProtocolGuid
86 extern EFI_GUID gEfiDeviceIoProtocolGuid
;
87 #define DeviceIoProtocol gEfiDeviceIoProtocolGuid
88 extern EFI_GUID VariableStoreProtocol
;
89 extern EFI_GUID LegacyBootProtocol
;
90 extern EFI_GUID gEfiUnicodeCollationProtocolGuid
;
91 #define UnicodeCollationProtocol gEfiUnicodeCollationProtocolGuid
92 extern EFI_GUID gEfiSerialIoProtocolGuid
;
93 #define SerialIoProtocol gEfiSerialIoProtocolGuid
94 extern EFI_GUID VgaClassProtocol
;
95 extern EFI_GUID TextOutSpliterProtocol
;
96 extern EFI_GUID ErrorOutSpliterProtocol
;
97 extern EFI_GUID TextInSpliterProtocol
;
98 extern EFI_GUID gEfiSimpleNetworkProtocolGuid
;
99 #define SimpleNetworkProtocol gEfiSimpleNetworkProtocolGuid
100 extern EFI_GUID gEfiPxeBaseCodeProtocolGuid
;
101 #define PxeBaseCodeProtocol gEfiPxeBaseCodeProtocolGuid
102 extern EFI_GUID gEfiPxeBaseCodeCallbackProtocolGuid
;
103 #define PxeCallbackProtocol gEfiPxeBaseCodeCallbackProtocolGuid
104 extern EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid
;
105 #define NetworkInterfaceIdentifierProtocol gEfiNetworkInterfaceIdentifierProtocolGuid
106 extern EFI_GUID gEFiUiInterfaceProtocolGuid
;
107 #define UiProtocol gEFiUiInterfaceProtocolGuid
108 extern EFI_GUID InternalShellProtocol
;
109 extern EFI_GUID gEfiPciIoProtocolGuid
;
110 #define PciIoProtocol gEfiPciIoProtocolGuid
111 extern EFI_GUID gEfiPciRootBridgeIoProtocolGuid
;
112 extern EFI_GUID gEfiDriverBindingProtocolGuid
;
113 #define DriverBindingProtocol gEfiDriverBindingProtocolGuid
114 extern EFI_GUID gEfiComponentNameProtocolGuid
;
115 #define ComponentNameProtocol gEfiComponentNameProtocolGuid
116 extern EFI_GUID gEfiComponentName2ProtocolGuid
;
117 #define ComponentName2Protocol gEfiComponentName2ProtocolGuid
118 extern EFI_GUID gEfiHashProtocolGuid
;
119 #define HashProtocol gEfiHashProtocolGuid
120 extern EFI_GUID gEfiPlatformDriverOverrideProtocolGuid
;
121 #define PlatformDriverOverrideProtocol gEfiPlatformDriverOverrideProtocolGuid
122 extern EFI_GUID gEfiBusSpecificDriverOverrideProtocolGuid
;
123 #define BusSpecificDriverOverrideProtocol gEfiBusSpecificDriverOverrideProtocolGuid
124 extern EFI_GUID gEfiDriverFamilyOverrideProtocolGuid
;
125 #define DriverFamilyOverrideProtocol gEfiDriverFamilyOverrideProtocolGuid
126 extern EFI_GUID gEfiEbcProtocolGuid
;
128 extern EFI_GUID gEfiGlobalVariableGuid
;
129 #define EfiGlobalVariable gEfiGlobalVariableGuid
130 extern EFI_GUID gEfiFileInfoGuid
;
131 #define GenericFileInfo gEfiFileInfoGuid
132 extern EFI_GUID gEfiFileSystemInfoGuid
;
133 #define FileSystemInfo gEfiFileSystemInfoGuid
134 extern EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid
;
135 #define FileSystemVolumeLabelInfo gEfiFileSystemVolumeLabelInfoIdGuid
136 extern EFI_GUID gEfiPcAnsiGuid
;
137 #define PcAnsiProtocol gEfiPcAnsiGuid
138 extern EFI_GUID gEfiVT100Guid
;
139 #define Vt100Protocol gEfiVT100Guid
140 extern EFI_GUID gEfiVT100PlusGuid
;
141 extern EFI_GUID gEfiVTUTF8Guid
;
143 extern EFI_GUID NullGuid
;
144 extern EFI_GUID UnknownDevice
;
146 extern EFI_GUID EfiPartTypeSystemPartitionGuid
;
147 extern EFI_GUID EfiPartTypeLegacyMbrGuid
;
149 extern EFI_GUID MpsTableGuid
;
150 extern EFI_GUID AcpiTableGuid
;
151 extern EFI_GUID SMBIOSTableGuid
;
152 extern EFI_GUID SMBIOS3TableGuid
;
153 extern EFI_GUID SalSystemTableGuid
;
155 extern EFI_GUID SimplePointerProtocol
;
156 extern EFI_GUID AbsolutePointerProtocol
;
158 extern EFI_GUID gEfiDebugImageInfoTableGuid
;
159 extern EFI_GUID gEfiDebugSupportProtocolGuid
;
161 extern EFI_GUID SimpleTextInputExProtocol
;
164 // EFI Variable strings
166 #define LOAD_OPTION_ACTIVE 0x00000001
168 #define VarLanguageCodes L"LangCodes"
169 #define VarLanguage L"Lang"
170 #define VarTimeout L"Timeout"
171 #define VarConsoleInp L"ConIn"
172 #define VarConsoleOut L"ConOut"
173 #define VarErrorOut L"ErrOut"
174 #define VarBootOption L"Boot%04x"
175 #define VarBootOrder L"BootOrder"
176 #define VarBootNext L"BootNext"
177 #define VarBootCurrent L"BootCurrent"
178 #define VarDriverOption L"Driver%04x"
179 #define VarDriverOrder L"DriverOrder"
180 #define VarConsoleInpDev L"ConInDev"
181 #define VarConsoleOutDev L"ConOutDev"
182 #define VarErrorOutDev L"ErrOutDev"
184 #define LanguageCodeEnglish "eng"
186 extern EFI_DEVICE_PATH RootDevicePath
[];
187 extern EFI_DEVICE_PATH EndDevicePath
[];
188 extern EFI_DEVICE_PATH EndInstanceDevicePath
[];
191 // Other public data in the EFI library
194 extern EFI_MEMORY_TYPE PoolAllocationType
;
197 // STATIC - Name is internal to the module
198 // INTERNAL - Name is internal to the component (i.e., directory)
199 // BOOTSERVCE - Name of a boot service function
212 IN EFI_HANDLE ImageHandle
,
213 IN EFI_SYSTEM_TABLE
*SystemTable
217 InitializeUnicodeSupport (
228 IN EFI_STATUS ExitStatus
,
229 IN UINTN ExitDataSize
,
230 IN CHAR16
*ExitData OPTIONAL
235 EFI_HANDLE ImageHandle
,
236 CHAR16
**Argv
[] /* Statically allocated */
241 IN OUT EFI_TABLE_HEADER
*Hdr
247 IN OUT EFI_TABLE_HEADER
*Hdr
253 IN OUT EFI_TABLE_HEADER
*Hdr
260 IN OUT EFI_TABLE_HEADER
*Hdr
334 IN CONST CHAR16
*Src
,
347 IN CONST CHAR16
*Src
,
360 IN CONST CHAR16
*Src
,
421 IN UINT64 Multiplicand
,
429 OUT UINTN
*Remainder OPTIONAL
485 IN CHAR16
*Prompt OPTIONAL
,
492 IN SIMPLE_TEXT_OUTPUT_INTERFACE
*ConOut
,
493 IN SIMPLE_INPUT_INTERFACE
*ConIn
,
494 IN CHAR16
*Prompt OPTIONAL
,
501 IN CONST CHAR16
*fmt
,
507 IN CONST CHAR16
*fmt
,
508 __builtin_ms_va_list args
515 IN CONST CHAR16
*fmt
,
523 IN CONST CHAR16
*fmt
,
524 __builtin_ms_va_list args
529 IN CONST CHAR16
*fmt
,
530 __builtin_ms_va_list args
535 IN CONST CHAR16
*fmt
,
547 IN OUT POOL_PRINT
*Str
,
548 IN CONST CHAR16
*fmt
,
556 IN CONST CHAR16
*fmt
,
562 IN SIMPLE_TEXT_OUTPUT_INTERFACE
*Out
,
563 IN CONST CHAR16
*fmt
,
569 IN SIMPLE_TEXT_OUTPUT_INTERFACE
*Out
,
572 IN CONST CHAR16
*fmt
,
582 /* For compatibility with previous versions */
583 #define APrint AsciiPrint
590 __builtin_ms_va_list args
641 IN OUT EFI_STATUS
*Status
,
642 IN OUT VOID
**Buffer
,
646 EFI_MEMORY_DESCRIPTOR
*
648 OUT UINTN
*NoEntries
,
650 OUT UINTN
*DescriptorSize
,
651 OUT UINT32
*DescriptorVersion
657 IN EFI_GUID
*VendorGuid
661 LibGetVariableAndSize (
663 IN EFI_GUID
*VendorGuid
,
676 IN EFI_GUID
*VarGuid
,
684 IN EFI_GUID
*VarGuid
,
689 LibInsertToTailOfBootOrder (
690 IN UINT16 BootOption
,
691 IN BOOLEAN OnlyInsertIfEmpty
696 IN EFI_GUID
*ProtocolGuid
,
702 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
703 IN EFI_GUID
*Protocol OPTIONAL
,
704 IN VOID
*SearchKey OPTIONAL
,
705 IN OUT UINTN
*NoHandles
,
706 OUT EFI_HANDLE
**Buffer
710 LibLocateHandleByDiskSignature (
712 IN UINT8 SignatureType
,
714 IN OUT UINTN
*NoHandles
,
715 OUT EFI_HANDLE
**Buffer
719 LibInstallProtocolInterfaces (
720 IN OUT EFI_HANDLE
*Handle
,
725 LibUninstallProtocolInterfaces (
726 IN EFI_HANDLE Handle
,
731 LibReinstallProtocolInterfaces (
732 IN OUT EFI_HANDLE
*Handle
,
737 LibCreateProtocolNotifyEvent (
738 IN EFI_GUID
*ProtocolGuid
,
739 IN EFI_TPL NotifyTpl
,
740 IN EFI_EVENT_NOTIFY NotifyFunction
,
741 IN VOID
*NotifyContext
,
742 OUT VOID
*Registration
748 IN UINT64 Timeout OPTIONAL
752 WaitForEventWithTimeout (
758 IN EFI_INPUT_KEY TimeoutKey
,
759 OUT EFI_INPUT_KEY
*Key
764 IN EFI_HANDLE DeviceHandle
769 IN EFI_FILE_HANDLE FHand
772 EFI_FILE_SYSTEM_INFO
*
774 IN EFI_FILE_HANDLE FHand
777 EFI_FILE_SYSTEM_VOLUME_LABEL_INFO
*
778 LibFileSystemVolumeLabelInfo (
779 IN EFI_FILE_HANDLE FHand
784 IN MASTER_BOOT_RECORD
*Mbr
,
785 IN EFI_BLOCK_IO
*BlkIo
789 LibMatchDevicePaths (
790 IN EFI_DEVICE_PATH
*Multi
,
791 IN EFI_DEVICE_PATH
*Single
795 LibDuplicateDevicePathInstance (
796 IN EFI_DEVICE_PATH
*DevPath
800 DevicePathFromHandle (
806 IN OUT EFI_DEVICE_PATH
**DevicePath
,
811 DevicePathInstanceCount (
812 IN EFI_DEVICE_PATH
*DevicePath
817 IN EFI_DEVICE_PATH
*Src1
,
818 IN EFI_DEVICE_PATH
*Src2
822 AppendDevicePathNode (
823 IN EFI_DEVICE_PATH
*Src1
,
824 IN EFI_DEVICE_PATH
*Src2
828 AppendDevicePathInstance (
829 IN EFI_DEVICE_PATH
*Src
,
830 IN EFI_DEVICE_PATH
*Instance
835 IN EFI_HANDLE Device OPTIONAL
,
841 IN EFI_DEVICE_PATH
*DevPath
845 DuplicateDevicePath (
846 IN EFI_DEVICE_PATH
*DevPath
851 IN EFI_DEVICE_PATH
*DevPath
855 LibDevicePathToInterface (
856 IN EFI_GUID
*Protocol
,
857 IN EFI_DEVICE_PATH
*FilePath
,
863 EFI_DEVICE_PATH
*DevPath
867 // BugBug: I need my own include files
879 EFI_ADDRESS EfiAddress
;
880 } EFI_PCI_ADDRESS_UNION
;
885 IN OUT EFI_PCI_ADDRESS_UNION
*Address
,
892 IN OUT EFI_PCI_ADDRESS_UNION
*DeviceAddress
,
895 IN OUT PCI_TYPE00
*Pci
899 // SIMPLE_READ_FILE object used to access files
902 typedef VOID
*SIMPLE_READ_FILE
;
906 IN BOOLEAN BootPolicy
,
907 IN VOID
*SourceBuffer OPTIONAL
,
909 IN OUT EFI_DEVICE_PATH
**FilePath
,
910 OUT EFI_HANDLE
*DeviceHandle
,
911 OUT SIMPLE_READ_FILE
*SimpleReadHandle
916 IN SIMPLE_READ_FILE SimpleReadHandle
,
918 IN OUT UINTN
*ReadSize
,
924 CloseSimpleReadFile (
925 IN SIMPLE_READ_FILE SimpleReadHandle
944 LibGetSystemConfigurationTable(
945 IN EFI_GUID
*TableGuid
,
950 LibIsValidTextGraphics (
952 OUT CHAR8
*PcAnsi
, OPTIONAL
953 OUT CHAR8
*Ascii OPTIONAL
968 IN EFI_HANDLE Handle
,
969 IN UI_STRING_TYPE StringType
,
970 IN ISO_639_2
*LangCode
,
971 IN BOOLEAN ReturnDevicePathStrOnMismatch
976 IN SMBIOS_STRUCTURE_POINTER
*Smbios
,
977 IN UINT16 StringNumber
981 LibGetSmbiosSystemGuidAndSerialNumber (
982 IN EFI_GUID
*SystemGuid
,
983 OUT CHAR8
**SystemSerialNumber
988 InitializeGlobalIoDevice (
989 IN EFI_DEVICE_PATH
*DevicePath
,
990 IN EFI_GUID
*Protocol
,
992 OUT EFI_DEVICE_IO_INTERFACE
**GlobalIoFncs
997 IN EFI_DEVICE_IO_INTERFACE
*GlobalIoFncs
,
998 IN EFI_IO_WIDTH Width
,
1004 IN EFI_DEVICE_IO_INTERFACE
*GlobalIoFncs
,
1005 IN EFI_IO_WIDTH Width
,
1012 IN EFI_DEVICE_IO_INTERFACE
*GlobalIoFncs
,
1013 IN EFI_IO_WIDTH Width
,
1019 IN EFI_DEVICE_IO_INTERFACE
*GlobalIoFncs
,
1020 IN EFI_IO_WIDTH Width
,
1030 extern EFI_DEVICE_IO_INTERFACE
*GlobalIoFncs
;
1032 #define outp(_Port, _DataByte) (UINT8)WritePort(GlobalIoFncs, IO_UINT8, (UINTN)_Port, (UINTN)_DataByte)
1033 #define inp(_Port) (UINT8)ReadPort(GlobalIoFncs, IO_UINT8, (UINTN)_Port)
1034 #define outpw(_Port, _DataByte) (UINT16)WritePort(GlobalIoFncs, IO_UINT16, (UINTN)_Port, (UINTN)_DataByte)
1035 #define inpw(_Port) (UINT16)ReadPort(GlobalIoFncs, IO_UINT16, (UINTN)_Port)
1036 #define outpd(_Port, _DataByte) (UINT32)WritePort(GlobalIoFncs, IO_UINT32, (UINTN)_Port, (UINTN)_DataByte)
1037 #define inpd(_Port) (UINT32)ReadPort(GlobalIoFncs, IO_UINT32, (UINTN)_Port)
1039 #define writepci8(_Addr, _DataByte) (UINT8)WritePciConfig(GlobalIoFncs, IO_UINT8, (UINTN)_Addr, (UINTN)_DataByte)
1040 #define readpci8(_Addr) (UINT8)ReadPciConfig(GlobalIoFncs, IO_UINT8, (UINTN)_Addr)
1041 #define writepci16(_Addr, _DataByte) (UINT16)WritePciConfig(GlobalIoFncs, IO_UINT16, (UINTN)_Addr, (UINTN)_DataByte)
1042 #define readpci16(_Addr) (UINT16)ReadPciConfig(GlobalIoFncs, IO_UINT16, (UINTN)_Addr)
1043 #define writepci32(_Addr, _DataByte) (UINT32)WritePciConfig(GlobalIoFncs, IO_UINT32, (UINTN)_Addr, (UINTN)_DataByte)
1044 #define readpci32(_Addr) (UINT32)ReadPciConfig(GlobalIoFncs, IO_UINT32, (UINTN)_Addr)
1046 #define Port80(_PostCode) GlobalIoFncs->Io.Write (GlobalIoFncs, IO_UINT16, (UINT64)0x80, 1, &(_PostCode))