-/** @file
- BDS library definition, include the file and data structure
-
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _INTERNAL_BM_H_
-#define _INTERNAL_BM_H_
-
-#include <PiDxe.h>
-
-#include <IndustryStandard/Pci.h>
-#include <IndustryStandard/PeImage.h>
-#include <IndustryStandard/Atapi.h>
-#include <IndustryStandard/Scsi.h>
-
-#include <Protocol/PciRootBridgeIo.h>
-#include <Protocol/BlockIo.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/SimpleFileSystem.h>
-#include <Protocol/LoadFile.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/SimpleTextIn.h>
-#include <Protocol/SimpleTextInEx.h>
-#include <Protocol/SimpleTextOut.h>
-#include <Protocol/SimpleNetwork.h>
-#include <Protocol/FirmwareVolume2.h>
-#include <Protocol/PciIo.h>
-#include <Protocol/GraphicsOutput.h>
-#include <Protocol/UsbIo.h>
-#include <Protocol/DiskInfo.h>
-#include <Protocol/IdeControllerInit.h>
-#include <Protocol/BootLogo.h>
-#include <Protocol/DriverHealth.h>
-#include <Protocol/FormBrowser2.h>
-
-#include <Guid/ZeroGuid.h>
-#include <Guid/MemoryTypeInformation.h>
-#include <Guid/FileInfo.h>
-#include <Guid/GlobalVariable.h>
-#include <Guid/Performance.h>
-#include <Guid/StatusCodeDataTypeVariable.h>
-
-#include <Library/PrintLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/UefiLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DxeServicesTableLib.h>
-#include <Library/HobLib.h>
-#include <Library/BaseLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/PerformanceLib.h>
-#include <Library/PcdLib.h>
-#include <Library/PeCoffGetEntryPointLib.h>
-#include <Library/UefiBootManagerLib.h>
-#include <Library/TimerLib.h>
-#include <Library/DxeServicesLib.h>
-#include <Library/ReportStatusCodeLib.h>
-#include <Library/CapsuleLib.h>
-#include <Library/PerformanceLib.h>
-#include <Library/HiiLib.h>
-
-#if !defined (EFI_REMOVABLE_MEDIA_FILE_NAME)
- #if defined (MDE_CPU_EBC)
- //
- // Uefi specification only defines the default boot file name for IA32, X64
- // and IPF processor, so need define boot file name for EBC architecture here.
- //
- #define EFI_REMOVABLE_MEDIA_FILE_NAME L"\\EFI\\BOOT\\BOOTEBC.EFI"
- #else
- #error "Can not determine the default boot file name for unknown processor type!"
- #endif
-#endif
-
-typedef enum {
- BmAcpiFloppyBoot,
- BmHardwareDeviceBoot,
- BmMessageAtapiBoot,
- BmMessageSataBoot,
- BmMessageUsbBoot,
- BmMessageScsiBoot,
- BmMessageNetworkBoot,
- BmMiscBoot
-} BM_BOOT_TYPE;
-
-typedef
-CHAR16 *
-(* BM_GET_BOOT_DESCRIPTION) (
- IN EFI_HANDLE Handle
- );
-
-#define BM_HOTKEY_SIGNATURE SIGNATURE_32 ('b', 'm', 'h', 'k')
-typedef struct {
- UINT32 Signature;
- LIST_ENTRY Link;
-
- BOOLEAN IsContinue;
- UINT16 BootOption;
- UINT8 CodeCount;
- UINT8 WaitingKey;
- EFI_KEY_DATA KeyData[3];
-} BM_HOTKEY;
-
-#define BM_HOTKEY_FROM_LINK(a) CR (a, BM_HOTKEY, Link, BM_HOTKEY_SIGNATURE)
-
-/**
- Get the image file buffer data and buffer size by its device path.
-
- @param FilePath On input, a pointer to an allocated buffer containing the device
- path of the file.
- On output the pointer could be NULL when the function fails to
- load the boot option, or could point to an allocated buffer containing
- the device path of the file.
- It could be updated by either short-form device path expanding,
- or default boot file path appending.
- Caller is responsible to free it when it's non-NULL.
- @param FileSize A pointer to the size of the file buffer.
-
- @retval NULL File is NULL, or FileSize is NULL. Or, the file can't be found.
- @retval other The file buffer. The caller is responsible to free the memory.
-**/
-VOID *
-BmLoadEfiBootOption (
- IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,
- OUT UINTN *FileSize
- );
-
-/**
- Get the Option Number that wasn't used.
-
- @param OrderVariableName Could be L"BootOrder" or L"DriverOrder".
- @param FreeOptionNumber To receive the minimal free option number.
-
- @retval EFI_SUCCESS The option number is found
- @retval EFI_OUT_OF_RESOURCES There is no free option number that can be used.
- @retval EFI_INVALID_PARAMETER FreeOptionNumber is NULL
-
-**/
-EFI_STATUS
-BmGetFreeOptionNumber (
- IN CHAR16 *OrderVariableName,
- OUT UINT16 *FreeOptionNumber
- );
-
-/**
-
- Writes performance data of booting into the allocated memory.
- OS can process these records.
-
- @param Event The triggered event.
- @param Context Context for this event.
-
-**/
-VOID
-EFIAPI
-BmWriteBootToOsPerformanceData (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-
-/**
- Get the headers (dos, image, optional header) from an image
-
- @param Device SimpleFileSystem device handle
- @param FileName File name for the image
- @param DosHeader Pointer to dos header
- @param Hdr The buffer in which to return the PE32, PE32+, or TE header.
-
- @retval EFI_SUCCESS Successfully get the machine type.
- @retval EFI_NOT_FOUND The file is not found.
- @retval EFI_LOAD_ERROR File is not a valid image file.
-
-**/
-EFI_STATUS
-BmGetImageHeader (
- IN EFI_HANDLE Device,
- IN CHAR16 *FileName,
- OUT EFI_IMAGE_DOS_HEADER *DosHeader,
- OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
- );
-
-/**
- This routine adjust the memory information for different memory type and
- save them into the variables for next boot.
-**/
-VOID
-BmSetMemoryTypeInformationVariable (
- VOID
- );
-
-/**
- Check whether there is a instance in BlockIoDevicePath, which contain multi device path
- instances, has the same partition node with HardDriveDevicePath device path
-
- @param BlockIoDevicePath Multi device path instances which need to check
- @param HardDriveDevicePath A device path which starts with a hard drive media
- device path.
-
- @retval TRUE There is a matched device path instance.
- @retval FALSE There is no matched device path instance.
-
-**/
-BOOLEAN
-BmMatchPartitionDevicePathNode (
- IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,
- IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath
- );
-
-/**
- Connect the specific Usb device which match the short form device path.
-
- @param DevicePath A short-form device path that starts with the first
- element being a USB WWID or a USB Class device
- path
-
- @return EFI_INVALID_PARAMETER DevicePath is NULL pointer.
- DevicePath is not a USB device path.
-
- @return EFI_SUCCESS Success to connect USB device
- @return EFI_NOT_FOUND Fail to find handle for USB controller to connect.
-
-**/
-EFI_STATUS
-BmConnectUsbShortFormDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- );
-
-/**
- Stop the hotkey processing.
-
- @param Event Event pointer related to hotkey service.
- @param Context Context pass to this function.
-**/
-VOID
-EFIAPI
-BmStopHotkeyService (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-/**
- Set the variable and report the error through status code upon failure.
-
- @param VariableName A Null-terminated string that is the name of the vendor's variable.
- Each VariableName is unique for each VendorGuid. VariableName must
- contain 1 or more characters. If VariableName is an empty string,
- then EFI_INVALID_PARAMETER is returned.
- @param VendorGuid A unique identifier for the vendor.
- @param Attributes Attributes bitmask to set for the variable.
- @param DataSize The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE,
- EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, or
- EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero
- causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is
- set, then a SetVariable() call with a DataSize of zero will not cause any change to
- the variable value (the timestamp associated with the variable may be updated however
- even if no new data value is provided,see the description of the
- EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not
- be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).
- @param Data The contents for the variable.
-
- @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as
- defined by the Attributes.
- @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits, name, and GUID was supplied, or the
- DataSize exceeds the maximum allowed.
- @retval EFI_INVALID_PARAMETER VariableName is an empty string.
- @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
- @retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.
- @retval EFI_WRITE_PROTECTED The variable in question is read-only.
- @retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.
- @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS
- or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo
- does NOT pass the validation check carried out by the firmware.
-
- @retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.
-**/
-EFI_STATUS
-BmSetVariableAndReportStatusCodeOnError (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data
- );
-
-/**
- Function compares a device path data structure to that of all the nodes of a
- second device path instance.
-
- @param Multi A pointer to a multi-instance device path data
- structure.
- @param Single A pointer to a single-instance device path data
- structure.
-
- @retval TRUE If the Single device path is contained within Multi device path.
- @retval FALSE The Single device path is not match within Multi device path.
-
-**/
-BOOLEAN
-BmMatchDevicePaths (
- IN EFI_DEVICE_PATH_PROTOCOL *Multi,
- IN EFI_DEVICE_PATH_PROTOCOL *Single
- );
-
-/**
- Delete the instance in Multi which matches partly with Single instance
-
- @param Multi A pointer to a multi-instance device path data
- structure.
- @param Single A pointer to a single-instance device path data
- structure.
-
- @return This function will remove the device path instances in Multi which partly
- match with the Single, and return the result device path. If there is no
- remaining device path as a result, this function will return NULL.
-
-**/
-EFI_DEVICE_PATH_PROTOCOL *
-BmDelPartMatchInstance (
- IN EFI_DEVICE_PATH_PROTOCOL *Multi,
- IN EFI_DEVICE_PATH_PROTOCOL *Single
- );
-
-
-/**
- Return the index of the load option in the load option array.
-
- The function consider two load options are equal when the
- OptionType, Attributes, Description, FilePath and OptionalData are equal.
-
- @param Key Pointer to the load option to be found.
- @param Array Pointer to the array of load options to be found.
- @param Count Number of entries in the Array.
-
- @retval -1 Key wasn't found in the Array.
- @retval 0 ~ Count-1 The index of the Key in the Array.
-**/
-INTN
-BmFindLoadOption (
- IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,
- IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,
- IN UINTN Count
- );
-
-/**
- Repair all the controllers according to the Driver Health status queried.
-**/
-VOID
-BmRepairAllControllers (
- VOID
- );
-
-#endif // _INTERNAL_BM_H_
+/** @file\r
+ BDS library definition, include the file and data structure\r
+\r
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _INTERNAL_BM_H_\r
+#define _INTERNAL_BM_H_\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <IndustryStandard/Pci.h>\r
+#include <IndustryStandard/PeImage.h>\r
+#include <IndustryStandard/Atapi.h>\r
+#include <IndustryStandard/Scsi.h>\r
+#include <IndustryStandard/Nvme.h>\r
+\r
+#include <Protocol/PciRootBridgeIo.h>\r
+#include <Protocol/BlockIo.h>\r
+#include <Protocol/LoadedImage.h>\r
+#include <Protocol/SimpleFileSystem.h>\r
+#include <Protocol/LoadFile.h>\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/SimpleTextIn.h>\r
+#include <Protocol/SimpleTextInEx.h>\r
+#include <Protocol/SimpleTextOut.h>\r
+#include <Protocol/SimpleNetwork.h>\r
+#include <Protocol/FirmwareVolume2.h>\r
+#include <Protocol/PciIo.h>\r
+#include <Protocol/GraphicsOutput.h>\r
+#include <Protocol/UsbIo.h>\r
+#include <Protocol/DiskInfo.h>\r
+#include <Protocol/NvmExpressPassthru.h>\r
+#include <Protocol/IdeControllerInit.h>\r
+#include <Protocol/BootLogo.h>\r
+#include <Protocol/DriverHealth.h>\r
+#include <Protocol/FormBrowser2.h>\r
+#include <Protocol/VariableLock.h>\r
+#include <Protocol/RamDisk.h>\r
+#include <Protocol/DeferredImageLoad.h>\r
+\r
+#include <Guid/MemoryTypeInformation.h>\r
+#include <Guid/FileInfo.h>\r
+#include <Guid/GlobalVariable.h>\r
+#include <Guid/StatusCodeDataTypeVariable.h>\r
+\r
+#include <Library/PrintLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/DxeServicesTableLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/PerformanceLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/PeCoffGetEntryPointLib.h>\r
+#include <Library/UefiBootManagerLib.h>\r
+#include <Library/DxeServicesLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
+#include <Library/CapsuleLib.h>\r
+#include <Library/PerformanceLib.h>\r
+#include <Library/HiiLib.h>\r
+\r
+#if !defined (EFI_REMOVABLE_MEDIA_FILE_NAME)\r
+ #if defined (MDE_CPU_EBC)\r
+ //\r
+ // Uefi specification only defines the default boot file name for IA32, X64\r
+ // and IPF processor, so need define boot file name for EBC architecture here.\r
+ //\r
+ #define EFI_REMOVABLE_MEDIA_FILE_NAME L"\\EFI\\BOOT\\BOOTEBC.EFI"\r
+ #else\r
+ #error "Can not determine the default boot file name for unknown processor type!"\r
+ #endif\r
+#endif\r
+\r
+typedef enum {\r
+ BmAcpiFloppyBoot,\r
+ BmHardwareDeviceBoot,\r
+ BmMessageAtapiBoot,\r
+ BmMessageSataBoot,\r
+ BmMessageUsbBoot,\r
+ BmMessageScsiBoot,\r
+ BmMiscBoot\r
+} BM_BOOT_TYPE;\r
+\r
+typedef\r
+CHAR16 *\r
+(* BM_GET_BOOT_DESCRIPTION) (\r
+ IN EFI_HANDLE Handle\r
+ );\r
+\r
+//\r
+// PlatformRecovery#### is the load option with the longest name\r
+//\r
+#define BM_OPTION_NAME_LEN sizeof ("PlatformRecovery####")\r
+extern CHAR16 *mBmLoadOptionName[];\r
+\r
+//\r
+// Maximum number of reconnect retry to repair controller; it is to limit the\r
+// number of recursive call of BmRepairAllControllers.\r
+//\r
+#define MAX_RECONNECT_REPAIR 10\r
+\r
+/**\r
+ Visitor function to be called by BmForEachVariable for each variable\r
+ in variable storage.\r
+\r
+ @param Name Variable name.\r
+ @param Guid Variable GUID.\r
+ @param Context The same context passed to BmForEachVariable.\r
+**/\r
+typedef\r
+VOID\r
+(*BM_VARIABLE_VISITOR) (\r
+ CHAR16 *Name,\r
+ EFI_GUID *Guid,\r
+ VOID *Context\r
+ );\r
+\r
+/**\r
+ Call Visitor function for each variable in variable storage.\r
+\r
+ @param Visitor Visitor function.\r
+ @param Context The context passed to Visitor function.\r
+**/\r
+VOID\r
+BmForEachVariable (\r
+ BM_VARIABLE_VISITOR Visitor,\r
+ VOID *Context\r
+ );\r
+\r
+#define BM_BOOT_DESCRIPTION_ENTRY_SIGNATURE SIGNATURE_32 ('b', 'm', 'd', 'h')\r
+typedef struct {\r
+ UINT32 Signature;\r
+ LIST_ENTRY Link;\r
+ EFI_BOOT_MANAGER_BOOT_DESCRIPTION_HANDLER Handler;\r
+} BM_BOOT_DESCRIPTION_ENTRY;\r
+\r
+/**\r
+ Repair all the controllers according to the Driver Health status queried.\r
+\r
+ @param ReconnectRepairCount To record the number of recursive call of\r
+ this function itself.\r
+**/\r
+VOID\r
+BmRepairAllControllers (\r
+ UINTN ReconnectRepairCount\r
+ );\r
+\r
+#define BM_HOTKEY_SIGNATURE SIGNATURE_32 ('b', 'm', 'h', 'k')\r
+typedef struct {\r
+ UINT32 Signature;\r
+ LIST_ENTRY Link;\r
+\r
+ BOOLEAN IsContinue;\r
+ UINT16 BootOption;\r
+ UINT8 CodeCount;\r
+ UINT8 WaitingKey;\r
+ EFI_KEY_DATA KeyData[3];\r
+} BM_HOTKEY;\r
+\r
+#define BM_HOTKEY_FROM_LINK(a) CR (a, BM_HOTKEY, Link, BM_HOTKEY_SIGNATURE)\r
+\r
+/**\r
+ Get the Option Number that wasn't used.\r
+\r
+ @param LoadOptionType Load option type.\r
+ @param FreeOptionNumber To receive the minimal free option number.\r
+\r
+ @retval EFI_SUCCESS The option number is found\r
+ @retval EFI_OUT_OF_RESOURCES There is no free option number that can be used.\r
+ @retval EFI_INVALID_PARAMETER FreeOptionNumber is NULL\r
+\r
+**/\r
+EFI_STATUS\r
+BmGetFreeOptionNumber (\r
+ IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType,\r
+ OUT UINT16 *FreeOptionNumber\r
+ );\r
+\r
+/**\r
+ This routine adjust the memory information for different memory type and\r
+ save them into the variables for next boot. It resets the system when\r
+ memory information is updated and the current boot option belongs to\r
+ boot category instead of application category. It doesn't count the\r
+ reserved memory occupied by RAM Disk.\r
+\r
+ @param Boot TRUE if current boot option belongs to boot\r
+ category instead of application category.\r
+**/\r
+VOID\r
+BmSetMemoryTypeInformationVariable (\r
+ IN BOOLEAN Boot\r
+ );\r
+\r
+/**\r
+ Check whether there is a instance in BlockIoDevicePath, which contain multi device path\r
+ instances, has the same partition node with HardDriveDevicePath device path\r
+\r
+ @param BlockIoDevicePath Multi device path instances which need to check\r
+ @param HardDriveDevicePath A device path which starts with a hard drive media\r
+ device path.\r
+\r
+ @retval TRUE There is a matched device path instance.\r
+ @retval FALSE There is no matched device path instance.\r
+\r
+**/\r
+BOOLEAN\r
+BmMatchPartitionDevicePathNode (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,\r
+ IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath\r
+ );\r
+\r
+/**\r
+ Connect the specific Usb device which match the short form device path.\r
+\r
+ @param DevicePath A short-form device path that starts with the first\r
+ element being a USB WWID or a USB Class device\r
+ path\r
+\r
+ @return EFI_INVALID_PARAMETER DevicePath is NULL pointer.\r
+ DevicePath is not a USB device path.\r
+\r
+ @return EFI_SUCCESS Success to connect USB device\r
+ @return EFI_NOT_FOUND Fail to find handle for USB controller to connect.\r
+\r
+**/\r
+EFI_STATUS\r
+BmConnectUsbShortFormDevicePath (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ );\r
+\r
+/**\r
+ Stop the hotkey processing.\r
+\r
+ @param Event Event pointer related to hotkey service.\r
+ @param Context Context pass to this function.\r
+**/\r
+VOID\r
+EFIAPI\r
+BmStopHotkeyService (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ );\r
+\r
+/**\r
+ Set the variable and report the error through status code upon failure.\r
+\r
+ @param VariableName A Null-terminated string that is the name of the vendor's variable.\r
+ Each VariableName is unique for each VendorGuid. VariableName must\r
+ contain 1 or more characters. If VariableName is an empty string,\r
+ then EFI_INVALID_PARAMETER is returned.\r
+ @param VendorGuid A unique identifier for the vendor.\r
+ @param Attributes Attributes bitmask to set for the variable.\r
+ @param DataSize The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE,\r
+ or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero\r
+ causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is\r
+ set, then a SetVariable() call with a DataSize of zero will not cause any change to\r
+ the variable value (the timestamp associated with the variable may be updated however\r
+ even if no new data value is provided,see the description of the\r
+ EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not\r
+ be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).\r
+ @param Data The contents for the variable.\r
+\r
+ @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as\r
+ defined by the Attributes.\r
+ @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits, name, and GUID was supplied, or the\r
+ DataSize exceeds the maximum allowed.\r
+ @retval EFI_INVALID_PARAMETER VariableName is an empty string.\r
+ @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r
+ @retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.\r
+ @retval EFI_WRITE_PROTECTED The variable in question is read-only.\r
+ @retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.\r
+ @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS\r
+ being set, but the AuthInfo does NOT pass the validation check carried out by the firmware.\r
+\r
+ @retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.\r
+**/\r
+EFI_STATUS\r
+BmSetVariableAndReportStatusCodeOnError (\r
+ IN CHAR16 *VariableName,\r
+ IN EFI_GUID *VendorGuid,\r
+ IN UINT32 Attributes,\r
+ IN UINTN DataSize,\r
+ IN VOID *Data\r
+ );\r
+\r
+/**\r
+ Function compares a device path data structure to that of all the nodes of a\r
+ second device path instance.\r
+\r
+ @param Multi A pointer to a multi-instance device path data\r
+ structure.\r
+ @param Single A pointer to a single-instance device path data\r
+ structure.\r
+\r
+ @retval TRUE If the Single device path is contained within Multi device path.\r
+ @retval FALSE The Single device path is not match within Multi device path.\r
+\r
+**/\r
+BOOLEAN\r
+BmMatchDevicePaths (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *Single\r
+ );\r
+\r
+/**\r
+ Delete the instance in Multi which matches partly with Single instance\r
+\r
+ @param Multi A pointer to a multi-instance device path data\r
+ structure.\r
+ @param Single A pointer to a single-instance device path data\r
+ structure.\r
+\r
+ @return This function will remove the device path instances in Multi which partly\r
+ match with the Single, and return the result device path. If there is no\r
+ remaining device path as a result, this function will return NULL.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+BmDelPartMatchInstance (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *Single\r
+ );\r
+\r
+/**\r
+ Print the device path info.\r
+\r
+ @param DevicePath The device path need to print.\r
+**/\r
+VOID\r
+BmPrintDp (\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ );\r
+\r
+/**\r
+ Convert a single character to number.\r
+ It assumes the input Char is in the scope of L'0' ~ L'9' and L'A' ~ L'F'\r
+\r
+ @param Char The input char which need to convert to int.\r
+\r
+ @return The converted 8-bit number or (UINTN) -1 if conversion failed.\r
+**/\r
+UINTN\r
+BmCharToUint (\r
+ IN CHAR16 Char\r
+ );\r
+\r
+/**\r
+ Return the boot description for the controller.\r
+\r
+ @param Handle Controller handle.\r
+\r
+ @return The description string.\r
+**/\r
+CHAR16 *\r
+BmGetBootDescription (\r
+ IN EFI_HANDLE Handle\r
+ );\r
+\r
+/**\r
+ Enumerate all boot option descriptions and append " 2"/" 3"/... to make\r
+ unique description.\r
+\r
+ @param BootOptions Array of boot options.\r
+ @param BootOptionCount Count of boot options.\r
+**/\r
+VOID\r
+BmMakeBootOptionDescriptionUnique (\r
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions,\r
+ UINTN BootOptionCount\r
+ );\r
+\r
+/**\r
+ Get the file buffer from the specified Load File instance.\r
+\r
+ @param LoadFileHandle The specified Load File instance.\r
+ @param FilePath The file path which will pass to LoadFile().\r
+\r
+ @return The full device path pointing to the load option buffer.\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+BmExpandLoadFile (\r
+ IN EFI_HANDLE LoadFileHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath\r
+ );\r
+\r
+/**\r
+ Return the RAM Disk device path created by LoadFile.\r
+\r
+ @param FilePath The source file path.\r
+\r
+ @return Callee-to-free RAM Disk device path\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+BmGetRamDiskDevicePath (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath\r
+ );\r
+\r
+/**\r
+ Destroy the RAM Disk.\r
+\r
+ The destroy operation includes to call RamDisk.Unregister to\r
+ unregister the RAM DISK from RAM DISK driver, free the memory\r
+ allocated for the RAM Disk.\r
+\r
+ @param RamDiskDevicePath RAM Disk device path.\r
+**/\r
+VOID\r
+BmDestroyRamDisk (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath\r
+ );\r
+\r
+/**\r
+ Get the next possible full path pointing to the load option.\r
+\r
+ @param FilePath The device path pointing to a load option.\r
+ It could be a short-form device path.\r
+ @param FullPath The full path returned by the routine in last call.\r
+ Set to NULL in first call.\r
+\r
+ @return The next possible full path pointing to the load option.\r
+ Caller is responsible to free the memory.\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+BmGetNextLoadOptionDevicePath (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *FullPath\r
+ );\r
+\r
+/**\r
+ Return the next matched load option buffer.\r
+ The routine keeps calling BmGetNextLoadOptionDevicePath() until a valid\r
+ load option is read.\r
+\r
+ @param Type The load option type.\r
+ It's used to check whether the load option is valid.\r
+ When it's LoadOptionTypeMax, the routine only guarantees\r
+ the load option is a valid PE image but doesn't guarantee\r
+ the PE's subsystem type is valid.\r
+ @param FilePath The device path pointing to a load option.\r
+ It could be a short-form device path.\r
+ @param FullPath Return the next full device path of the load option after\r
+ short-form device path expanding.\r
+ Caller is responsible to free it.\r
+ NULL to return the first matched full device path.\r
+ @param FileSize Return the load option size.\r
+\r
+ @return The load option buffer. Caller is responsible to free the memory.\r
+**/\r
+VOID *\r
+BmGetNextLoadOptionBuffer (\r
+ IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE Type,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,\r
+ OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,\r
+ OUT UINTN *FileSize\r
+ );\r
+#endif // _INTERNAL_BM_H_\r