1 #ifndef _EFILIB_INCLUDE_
2 #define _EFILIB_INCLUDE_
6 Copyright (c) 2000 Intel Corporation
24 #include "efilibplat.h"
28 #include "libsmbios.h"
31 // Public read-only data in the EFI library
34 extern EFI_SYSTEM_TABLE
*ST
;
35 extern EFI_BOOT_SERVICES
*BS
;
36 extern EFI_RUNTIME_SERVICES
*RT
;
38 extern EFI_GUID DevicePathProtocol
;
39 extern EFI_GUID LoadedImageProtocol
;
40 extern EFI_GUID TextInProtocol
;
41 extern EFI_GUID TextOutProtocol
;
42 extern EFI_GUID BlockIoProtocol
;
43 extern EFI_GUID DiskIoProtocol
;
44 extern EFI_GUID FileSystemProtocol
;
45 extern EFI_GUID LoadFileProtocol
;
46 extern EFI_GUID DeviceIoProtocol
;
47 extern EFI_GUID VariableStoreProtocol
;
48 extern EFI_GUID LegacyBootProtocol
;
49 extern EFI_GUID UnicodeCollationProtocol
;
50 extern EFI_GUID SerialIoProtocol
;
51 extern EFI_GUID VgaClassProtocol
;
52 extern EFI_GUID TextOutSpliterProtocol
;
53 extern EFI_GUID ErrorOutSpliterProtocol
;
54 extern EFI_GUID TextInSpliterProtocol
;
55 extern EFI_GUID SimpleNetworkProtocol
;
56 extern EFI_GUID PxeBaseCodeProtocol
;
57 extern EFI_GUID PxeCallbackProtocol
;
58 extern EFI_GUID NetworkInterfaceIdentifierProtocol
;
59 extern EFI_GUID UiProtocol
;
60 extern EFI_GUID InternalShellProtocol
;
61 extern EFI_GUID PciIoProtocol
;
63 extern EFI_GUID EfiGlobalVariable
;
64 extern EFI_GUID GenericFileInfo
;
65 extern EFI_GUID FileSystemInfo
;
66 extern EFI_GUID FileSystemVolumeLabelInfo
;
67 extern EFI_GUID PcAnsiProtocol
;
68 extern EFI_GUID Vt100Protocol
;
69 extern EFI_GUID NullGuid
;
70 extern EFI_GUID UnknownDevice
;
72 extern EFI_GUID EfiPartTypeSystemPartitionGuid
;
73 extern EFI_GUID EfiPartTypeLegacyMbrGuid
;
75 extern EFI_GUID MpsTableGuid
;
76 extern EFI_GUID AcpiTableGuid
;
77 extern EFI_GUID SMBIOSTableGuid
;
78 extern EFI_GUID SalSystemTableGuid
;
81 // EFI Variable strings
83 #define LOAD_OPTION_ACTIVE 0x00000001
85 #define VarLanguageCodes L"LangCodes"
86 #define VarLanguage L"Lang"
87 #define VarTimeout L"Timeout"
88 #define VarConsoleInp L"ConIn"
89 #define VarConsoleOut L"ConOut"
90 #define VarErrorOut L"ErrOut"
91 #define VarBootOption L"Boot%04x"
92 #define VarBootOrder L"BootOrder"
93 #define VarBootNext L"BootNext"
94 #define VarBootCurrent L"BootCurrent"
95 #define VarDriverOption L"Driver%04x"
96 #define VarDriverOrder L"DriverOrder"
97 #define VarConsoleInpDev L"ConInDev"
98 #define VarConsoleOutDev L"ConOutDev"
99 #define VarErrorOutDev L"ErrOutDev"
101 #define LanguageCodeEnglish "eng"
103 extern EFI_DEVICE_PATH RootDevicePath
[];
104 extern EFI_DEVICE_PATH EndDevicePath
[];
105 extern EFI_DEVICE_PATH EndInstanceDevicePath
[];
108 // Other public data in the EFI library
111 extern EFI_MEMORY_TYPE PoolAllocationType
;
114 // STATIC - Name is internal to the module
115 // INTERNAL - Name is internal to the component (i.e., directory)
116 // BOOTSERVCE - Name of a boot service function
129 IN EFI_HANDLE ImageHandle
,
130 IN EFI_SYSTEM_TABLE
*SystemTable
134 InitializeUnicodeSupport (
145 IN OUT EFI_TABLE_HEADER
*Hdr
151 IN OUT EFI_TABLE_HEADER
*Hdr
157 IN OUT EFI_TABLE_HEADER
*Hdr
164 IN OUT EFI_TABLE_HEADER
*Hdr
310 IN UINT64 Multiplicand
,
318 OUT UINTN
*Remainder OPTIONAL
374 IN CHAR16
*Prompt OPTIONAL
,
381 IN SIMPLE_TEXT_OUTPUT_INTERFACE
*ConOut
,
382 IN SIMPLE_INPUT_INTERFACE
*ConIn
,
383 IN CHAR16
*Prompt OPTIONAL
,
416 IN OUT POOL_PRINT
*Str
,
431 IN SIMPLE_TEXT_OUTPUT_INTERFACE
*Out
,
438 IN SIMPLE_TEXT_OUTPUT_INTERFACE
*Out
,
492 IN OUT EFI_STATUS
*Status
,
493 IN OUT VOID
**Buffer
,
497 EFI_MEMORY_DESCRIPTOR
*
499 OUT UINTN
*NoEntries
,
501 OUT UINTN
*DescriptorSize
,
502 OUT UINT32
*DescriptorVersion
508 IN EFI_GUID
*VendorGuid
512 LibGetVariableAndSize (
514 IN EFI_GUID
*VendorGuid
,
527 IN EFI_GUID
*VarGuid
,
535 IN EFI_GUID
*VarGuid
,
540 LibInsertToTailOfBootOrder (
541 IN UINT16 BootOption
,
542 IN BOOLEAN OnlyInsertIfEmpty
547 IN EFI_GUID
*ProtocolGuid
,
553 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
554 IN EFI_GUID
*Protocol OPTIONAL
,
555 IN VOID
*SearchKey OPTIONAL
,
556 IN OUT UINTN
*NoHandles
,
557 OUT EFI_HANDLE
**Buffer
561 LibLocateHandleByDiskSignature (
563 IN UINT8 SignatureType
,
565 IN OUT UINTN
*NoHandles
,
566 OUT EFI_HANDLE
**Buffer
570 LibInstallProtocolInterfaces (
571 IN OUT EFI_HANDLE
*Handle
,
576 LibUninstallProtocolInterfaces (
577 IN EFI_HANDLE Handle
,
582 LibReinstallProtocolInterfaces (
583 IN OUT EFI_HANDLE
*Handle
,
588 LibCreateProtocolNotifyEvent (
589 IN EFI_GUID
*ProtocolGuid
,
590 IN EFI_TPL NotifyTpl
,
591 IN EFI_EVENT_NOTIFY NotifyFunction
,
592 IN VOID
*NotifyContext
,
593 OUT VOID
*Registration
599 IN UINT64 Timeout OPTIONAL
603 WaitForEventWithTimeout (
609 IN EFI_INPUT_KEY TimeoutKey
,
610 OUT EFI_INPUT_KEY
*Key
615 IN EFI_HANDLE DeviceHandle
620 IN EFI_FILE_HANDLE FHand
623 EFI_FILE_SYSTEM_INFO
*
625 IN EFI_FILE_HANDLE FHand
628 EFI_FILE_SYSTEM_VOLUME_LABEL_INFO
*
629 LibFileSystemVolumeLabelInfo (
630 IN EFI_FILE_HANDLE FHand
635 IN MASTER_BOOT_RECORD
*Mbr
,
636 IN EFI_BLOCK_IO
*BlkIo
640 LibMatchDevicePaths (
641 IN EFI_DEVICE_PATH
*Multi
,
642 IN EFI_DEVICE_PATH
*Single
646 LibDuplicateDevicePathInstance (
647 IN EFI_DEVICE_PATH
*DevPath
651 DevicePathFromHandle (
657 IN OUT EFI_DEVICE_PATH
**DevicePath
,
662 DevicePathInstanceCount (
663 IN EFI_DEVICE_PATH
*DevicePath
668 IN EFI_DEVICE_PATH
*Src1
,
669 IN EFI_DEVICE_PATH
*Src2
673 AppendDevicePathNode (
674 IN EFI_DEVICE_PATH
*Src1
,
675 IN EFI_DEVICE_PATH
*Src2
679 AppendDevicePathInstance (
680 IN EFI_DEVICE_PATH
*Src
,
681 IN EFI_DEVICE_PATH
*Instance
686 IN EFI_HANDLE Device OPTIONAL
,
692 IN EFI_DEVICE_PATH
*DevPath
696 DuplicateDevicePath (
697 IN EFI_DEVICE_PATH
*DevPath
702 IN EFI_DEVICE_PATH
*DevPath
706 LibDevicePathToInterface (
707 IN EFI_GUID
*Protocol
,
708 IN EFI_DEVICE_PATH
*FilePath
,
714 EFI_DEVICE_PATH
*DevPath
718 // BugBug: I need my own include files
730 EFI_ADDRESS EfiAddress
;
731 } EFI_PCI_ADDRESS_UNION
;
736 IN OUT EFI_PCI_ADDRESS_UNION
*Address
,
743 IN OUT EFI_PCI_ADDRESS_UNION
*DeviceAddress
,
746 IN OUT PCI_TYPE00
*Pci
750 // SIMPLE_READ_FILE object used to access files
753 typedef VOID
*SIMPLE_READ_FILE
;
757 IN BOOLEAN BootPolicy
,
758 IN VOID
*SourceBuffer OPTIONAL
,
760 IN OUT EFI_DEVICE_PATH
**FilePath
,
761 OUT EFI_HANDLE
*DeviceHandle
,
762 OUT SIMPLE_READ_FILE
*SimpleReadHandle
767 IN SIMPLE_READ_FILE SimpleReadHandle
,
769 IN OUT UINTN
*ReadSize
,
775 CloseSimpleReadFile (
776 IN SIMPLE_READ_FILE SimpleReadHandle
795 LibGetSystemConfigurationTable(
796 IN EFI_GUID
*TableGuid
,
801 LibIsValidTextGraphics (
803 OUT CHAR8
*PcAnsi
, OPTIONAL
804 OUT CHAR8
*Ascii OPTIONAL
819 IN EFI_HANDLE Handle
,
820 IN UI_STRING_TYPE StringType
,
821 IN ISO_639_2
*LangCode
,
822 IN BOOLEAN ReturnDevicePathStrOnMismatch
827 IN SMBIOS_STRUCTURE_POINTER
*Smbios
,
828 IN UINT16 StringNumber
832 LibGetSmbiosSystemGuidAndSerialNumber (
833 IN EFI_GUID
*SystemGuid
,
834 OUT CHAR8
**SystemSerialNumber
839 InitializeGlobalIoDevice (
840 IN EFI_DEVICE_PATH
*DevicePath
,
841 IN EFI_GUID
*Protocol
,
843 OUT EFI_DEVICE_IO_INTERFACE
**GlobalIoFncs
848 IN EFI_DEVICE_IO_INTERFACE
*GlobalIoFncs
,
849 IN EFI_IO_WIDTH Width
,
855 IN EFI_DEVICE_IO_INTERFACE
*GlobalIoFncs
,
856 IN EFI_IO_WIDTH Width
,
863 IN EFI_DEVICE_IO_INTERFACE
*GlobalIoFncs
,
864 IN EFI_IO_WIDTH Width
,
870 IN EFI_DEVICE_IO_INTERFACE
*GlobalIoFncs
,
871 IN EFI_IO_WIDTH Width
,
876 extern EFI_DEVICE_IO_INTERFACE
*GlobalIoFncs
;
878 #define outp(_Port, _DataByte) (UINT8)WritePort(GlobalIoFncs, IO_UINT8, (UINTN)_Port, (UINTN)_DataByte)
879 #define inp(_Port) (UINT8)ReadPort(GlobalIoFncs, IO_UINT8, (UINTN)_Port)
880 #define outpw(_Port, _DataByte) (UINT16)WritePort(GlobalIoFncs, IO_UINT16, (UINTN)_Port, (UINTN)_DataByte)
881 #define inpw(_Port) (UINT16)ReadPort(GlobalIoFncs, IO_UINT16, (UINTN)_Port)
882 #define outpd(_Port, _DataByte) (UINT32)WritePort(GlobalIoFncs, IO_UINT32, (UINTN)_Port, (UINTN)_DataByte)
883 #define inpd(_Port) (UINT32)ReadPort(GlobalIoFncs, IO_UINT32, (UINTN)_Port)
885 #define writepci8(_Addr, _DataByte) (UINT8)WritePciConfig(GlobalIoFncs, IO_UINT8, (UINTN)_Addr, (UINTN)_DataByte)
886 #define readpci8(_Addr) (UINT8)ReadPciConfig(GlobalIoFncs, IO_UINT8, (UINTN)_Addr)
887 #define writepci16(_Addr, _DataByte) (UINT16)WritePciConfig(GlobalIoFncs, IO_UINT16, (UINTN)_Addr, (UINTN)_DataByte)
888 #define readpci16(_Addr) (UINT16)ReadPciConfig(GlobalIoFncs, IO_UINT16, (UINTN)_Addr)
889 #define writepci32(_Addr, _DataByte) (UINT32)WritePciConfig(GlobalIoFncs, IO_UINT32, (UINTN)_Addr, (UINTN)_DataByte)
890 #define readpci32(_Addr) (UINT32)ReadPciConfig(GlobalIoFncs, IO_UINT32, (UINTN)_Addr)
892 #define Pause() WaitForSingleEvent (ST->ConIn->WaitForKey, 0)
893 #define Port80(_PostCode) GlobalIoFncs->Io.Write (GlobalIoFncs, IO_UINT16, (UINT64)0x80, 1, &(_PostCode))