]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Include/Library/UefiBootManagerLib.h
MdeModulePkg/S3SmmInitDone.h: Fix copyright coding style error.
[mirror_edk2.git] / MdeModulePkg / Include / Library / UefiBootManagerLib.h
index 9b08364aaf35418c78c035cb17fee42a82fafc23..bfc0cb86f87738d61c2b37d01f04947bc1c6de82 100644 (file)
-/** @file
-  Provide Boot Manager related library APIs.
-
-Copyright (c) 2011 - 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 _UEFI_BOOT_MANAGER_LIB_H_
-#define _UEFI_BOOT_MANAGER_LIB_H_
-
-#include <Protocol/DriverHealth.h>
-#include <Library/SortLib.h>
-
-//
-// Boot Manager load option library functions.
-//
-
-//
-// Load Option Type
-//
-typedef enum {
-  LoadOptionTypeBoot,
-  LoadOptionTypeDriver,
-  LoadOptionTypeMax
-} EFI_BOOT_MANAGER_LOAD_OPTION_TYPE;
-
-typedef enum {
-  LoadOptionNumberMax = 0x10000,
-  LoadOptionNumberUnassigned = LoadOptionNumberMax
-} EFI_BOOT_MANAGER_LOAD_OPTION_NUMBER;
-
-//
-// Common structure definition for DriverOption and BootOption
-//
-typedef struct {
-  //
-  // Data read from UEFI NV variables
-  //
-  UINTN                             OptionNumber;       // #### numerical value, could be LoadOptionNumberUnassigned
-  EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType;         // LoadOptionTypeBoot or LoadOptionTypeDriver
-  UINT32                            Attributes;         // Load Option Attributes
-  CHAR16                            *Description;       // Load Option Description
-  EFI_DEVICE_PATH_PROTOCOL          *FilePath;          // Load Option Device Path
-  UINT8                             *OptionalData;      // Load Option optional data to pass into image
-  UINT32                            OptionalDataSize;   // Load Option size of OptionalData
-
-  //
-  // Used at runtime
-  //
-  EFI_STATUS                        Status;             // Status returned from boot attempt gBS->StartImage ()
-  CHAR16                            *ExitData;          // Exit data returned from gBS->StartImage () 
-  UINTN                             ExitDataSize;       // Size of ExitData
-} EFI_BOOT_MANAGER_LOAD_OPTION;
-
-/**
-  Returns an array of load options based on the EFI variable
-  L"BootOrder"/L"DriverOrder" and the L"Boot####"/L"Driver####" variables impled by it.
-  #### is the hex value of the UINT16 in each BootOrder/DriverOrder entry. 
-
-  @param  LoadOptionCount   Returns number of entries in the array.
-  @param  LoadOptionType    The type of the load option.
-
-  @retval NULL  No load options exist.
-  @retval !NULL Array of load option entries.
-
-**/
-EFI_BOOT_MANAGER_LOAD_OPTION *
-EFIAPI
-EfiBootManagerGetLoadOptions (
-  OUT UINTN                            *LoadOptionCount,
-  IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType
-  );
-
-/**
-  Free an array of load options returned from EfiBootManagerGetLoadOptions().
-
-  @param  LoadOptions      Pointer to the array of load options to free.
-  @param  LoadOptionCount  Number of array entries in LoadOptions.
-
-  @return EFI_SUCCESS           LoadOptions was freed.
-  @return EFI_INVALID_PARAMETER LoadOptions is NULL.
-**/
-EFI_STATUS
-EFIAPI
-EfiBootManagerFreeLoadOptions (
-  IN  EFI_BOOT_MANAGER_LOAD_OPTION  *LoadOptions,
-  IN  UINTN                         LoadOptionCount
-  );
-
-/**
-  Initialize a load option.
-
-  @param Option           Pointer to the load option to be initialized.
-  @param OptionNumber     Option number of the load option.
-  @param OptionType       Type of the load option.
-  @param Attributes       Attributes of the load option.
-  @param Description      Description of the load option.
-  @param FilePath         Device path of the load option.
-  @param OptionalData     Optional data of the load option.
-  @param OptionalDataSize Size of the optional data of the load option.
-
-  @retval EFI_SUCCESS           The load option was initialized successfully.
-  @retval EFI_INVALID_PARAMETER Option, Description or FilePath is NULL.
-**/
-EFI_STATUS
-EFIAPI
-EfiBootManagerInitializeLoadOption (
-  IN OUT EFI_BOOT_MANAGER_LOAD_OPTION   *Option,
-  IN  UINTN                             OptionNumber,
-  IN  EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType,
-  IN  UINT32                            Attributes,
-  IN  CHAR16                            *Description,
-  IN  EFI_DEVICE_PATH_PROTOCOL          *FilePath,
-  IN  UINT8                             *OptionalData,
-  IN  UINT32                            OptionalDataSize
-  );
-
-/**
-  Free a load option created by EfiBootManagerInitializeLoadOption()
-  or EfiBootManagerVariableToLoadOption().
-
-  @param  LoadOption   Pointer to the load option to free.
-  CONCERN: Check Boot#### instead of BootOrder, optimize, spec clarify
-  @return EFI_SUCCESS           LoadOption was freed.
-  @return EFI_INVALID_PARAMETER LoadOption is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-EfiBootManagerFreeLoadOption (
-  IN  EFI_BOOT_MANAGER_LOAD_OPTION  *LoadOption
-  );
-
-/**
-  Initialize the load option from the VariableName.
-
-  @param  VariableName          EFI Variable name which could be Boot#### or
-                                Driver####
-  @param  LoadOption            Pointer to the load option to be initialized
-
-  @retval EFI_SUCCESS           The option was created
-  @retval EFI_INVALID_PARAMETER VariableName or LoadOption is NULL.
-  @retval EFI_NOT_FOUND         The variable specified by VariableName cannot be found.
-**/
-EFI_STATUS
-EFIAPI
-EfiBootManagerVariableToLoadOption (
-  IN CHAR16                           *VariableName,
-  IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *LoadOption
-  );
-
-/**
-  Create the Boot#### or Driver#### variable from the load option.
-  
-  @param  LoadOption      Pointer to the load option.
-
-  @retval EFI_SUCCESS     The variable was created.
-  @retval Others          Error status returned by RT->SetVariable.
-**/
-EFI_STATUS
-EFIAPI
-EfiBootManagerLoadOptionToVariable (
-  IN CONST EFI_BOOT_MANAGER_LOAD_OPTION     *LoadOption
-  );
-
-/**
-  This function will update the Boot####/Driver#### and the BootOrder/DriverOrder
-  to add a new load option.
-
-  @param  Option        Pointer to load option to add.
-  @param  Position      Position of the new load option to put in the BootOrder/DriverOrder.
-
-  @retval EFI_SUCCESS   The load option has been successfully added.
-  @retval Others        Error status returned by RT->SetVariable.
-**/
-EFI_STATUS
-EFIAPI
-EfiBootManagerAddLoadOptionVariable (
-  IN EFI_BOOT_MANAGER_LOAD_OPTION  *Option,
-  IN UINTN                         Position
-  );
-
-/**
-  Delete the load option according to the OptionNumber and OptionType.
-  
-  Only the BootOrder/DriverOrder is updated to remove the reference of the OptionNumber.
-  
-  @param  OptionNumber        Option number of the load option.
-  @param  OptionType          Type of the load option.
-
-  @retval EFI_NOT_FOUND       The load option cannot be found.
-  @retval EFI_SUCCESS         The load option was deleted.
-**/
-EFI_STATUS
-EFIAPI
-EfiBootManagerDeleteLoadOptionVariable (
-  IN UINTN                              OptionNumber,
-  IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE  OptionType
-  );
-
-/**
-  Sort the load options. The DriverOrder/BootOrder variables will be re-created to 
-  reflect the new order.
-
-  @param OptionType        The type of the load option.
-  @param Comparator        The comparator function pointer.
-**/
-VOID
-EFIAPI
-EfiBootManagerSortLoadOptionVariable (
-  IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType,
-  IN SORT_COMPARE                      CompareFunction
-  );
-
-//
-// Boot Manager hot key library functions.
-//
-
-#pragma pack(1)
-///
-/// EFI Key Option.
-///
-typedef struct {
-  ///
-  /// Specifies options about how the key will be processed.
-  ///
-  EFI_BOOT_KEY_DATA  KeyData;
-  ///
-  /// The CRC-32 which should match the CRC-32 of the entire EFI_LOAD_OPTION to
-  /// which BootOption refers. If the CRC-32s do not match this value, then this key
-  /// option is ignored.
-  ///
-  UINT32             BootOptionCrc;
-  ///
-  /// The Boot#### option which will be invoked if this key is pressed and the boot option
-  /// is active (LOAD_OPTION_ACTIVE is set).
-  ///
-  UINT16             BootOption;
-  ///
-  /// The key codes to compare against those returned by the
-  /// EFI_SIMPLE_TEXT_INPUT and EFI_SIMPLE_TEXT_INPUT_EX protocols.
-  /// The number of key codes (0-3) is specified by the EFI_KEY_CODE_COUNT field in KeyOptions.
-  ///
-  EFI_INPUT_KEY      Keys[3];
-  UINT16             OptionNumber;
-} EFI_BOOT_MANAGER_KEY_OPTION;
-#pragma pack()
-
-/**
-  Start the hot key service so that the key press can trigger the boot option.
-
-  @param HotkeyTriggered  Return the waitable event and it will be signaled 
-                          when a valid hot key is pressed.
-
-  @retval EFI_SUCCESS     The hot key service is started.
-**/
-EFI_STATUS
-EFIAPI
-EfiBootManagerStartHotkeyService (
-  IN EFI_EVENT      *HotkeyTriggered
-  );
-
-//
-// Modifier for EfiBootManagerAddKeyOptionVariable and EfiBootManagerDeleteKeyOptionVariable
-//
-#define EFI_BOOT_MANAGER_SHIFT_PRESSED    0x00000001
-#define EFI_BOOT_MANAGER_CONTROL_PRESSED  0x00000002
-#define EFI_BOOT_MANAGER_ALT_PRESSED      0x00000004
-#define EFI_BOOT_MANAGER_LOGO_PRESSED     0x00000008
-#define EFI_BOOT_MANAGER_MENU_KEY_PRESSED 0x00000010
-#define EFI_BOOT_MANAGER_SYS_REQ_PRESSED  0x00000020
-
-/**
-  Add the key option.
-  It adds the key option variable and the key option takes affect immediately.
-
-  @param AddedOption      Return the added key option.
-  @param BootOptionNumber The boot option number for the key option.
-  @param Modifier         Key shift state.
-  @param ...              Parameter list of pointer of EFI_INPUT_KEY.
-
-  @retval EFI_SUCCESS         The key option is added.
-  @retval EFI_ALREADY_STARTED The hot key is already used by certain key option.
-**/
-EFI_STATUS
-EFIAPI
-EfiBootManagerAddKeyOptionVariable (
-  OUT EFI_BOOT_MANAGER_KEY_OPTION *AddedOption,   OPTIONAL
-  IN UINT16                       BootOptionNumber,
-  IN UINT32                       Modifier,
-  ...
-  );
-
-/**
-  Delete the Key Option variable and unregister the hot key
-
-  @param DeletedOption  Return the deleted key options.
-  @param Modifier       Key shift state.
-  @param ...            Parameter list of pointer of EFI_INPUT_KEY.
-
-  @retval EFI_SUCCESS   The key option is deleted.
-  @retval EFI_NOT_FOUND The key option cannot be found.
-**/
-EFI_STATUS
-EFIAPI
-EfiBootManagerDeleteKeyOptionVariable (
-  IN EFI_BOOT_MANAGER_KEY_OPTION *DeletedOption, OPTIONAL
-  IN UINT32                      Modifier,
-  ...
-  );
-
-/**
-  Register the key option to exit the waiting of the Boot Manager timeout.
-  Platform should ensure that the continue key option isn't conflict with
-  other boot key options.
-
-  @param Modifier     Key shift state.
-  @param  ...         Parameter list of pointer of EFI_INPUT_KEY.
-
-  @retval EFI_SUCCESS         Successfully register the continue key option.
-  @retval EFI_ALREADY_STARTED The continue key option is already registered.
-**/
-EFI_STATUS
-EFIAPI
-EfiBootManagerRegisterContinueKeyOption (
-  IN UINT32           Modifier,
-  ...
-  );
-
-/**
-  Try to boot the boot option triggered by hot key.
-**/
-VOID
-EFIAPI
-EfiBootManagerHotkeyBoot (
-  VOID
-  );
-//
-// Boot Manager boot library functions.
-//
-
-/**
-  The function creates boot options for all possible bootable medias in the following order:
-  1. Removable BlockIo            - The boot option only points to the removable media
-                                    device, like USB key, DVD, Floppy etc.
-  2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,
-                                    like HardDisk.
-  3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
-                                    SimpleFileSystem Protocol, but not supporting BlockIo
-                                    protocol.
-  4. LoadFile                     - The boot option points to the media supporting 
-                                    LoadFile protocol.
-  Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior
-
-  The function won't delete the boot option not added by itself.
-**/
-VOID
-EFIAPI
-EfiBootManagerRefreshAllBootOption (
-  VOID
-  );
-
-/**
-  Attempt to boot the EFI boot option. This routine sets L"BootCurent" and
-  signals the EFI ready to boot event. If the device path for the option starts
-  with a BBS device path a legacy boot is attempted. Short form device paths are
-  also supported via this rountine. A device path starting with 
-  MEDIA_HARDDRIVE_DP, MSG_USB_WWID_DP, MSG_USB_CLASS_DP gets expaned out
-  to find the first device that matches. If the BootOption Device Path 
-  fails the removable media boot algorithm is attempted (\EFI\BOOTIA32.EFI,
-  \EFI\BOOTX64.EFI,... only one file type is tried per processor type)
-
-  @param  BootOption    Boot Option to try and boot.
-                        On return, BootOption->Status contains the boot status:
-                        EFI_SUCCESS     BootOption was booted
-                        EFI_UNSUPPORTED BootOption isn't supported.
-                        EFI_NOT_FOUND   The BootOption was not found on the system
-                        Others          BootOption failed with this error status
-
-**/
-VOID
-EFIAPI
-EfiBootManagerBoot (
-  IN  EFI_BOOT_MANAGER_LOAD_OPTION  *BootOption
-  );
-
-/**
-  Return the Boot Manager Menu.
-  @param BootOption    Return the Boot Manager Menu.
-
-  @retval EFI_SUCCESS   The Boot Manager Menu is successfully returned.
-  @retval EFI_NOT_FOUND The Boot Manager Menu is not found.
-**/
-EFI_STATUS
-EFIAPI
-EfiBootManagerGetBootManagerMenu (
-  EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
-  );
-
-/**
-  The function enumerates all the legacy boot options, creates them and 
-  registers them in the BootOrder variable.
-**/
-typedef
-VOID
-(EFIAPI *EFI_BOOT_MANAGER_REFRESH_LEGACY_BOOT_OPTION) (
-  VOID
-  );
-
-/**
-  The function boots a legacy boot option.
-**/
-typedef
-VOID
-(EFIAPI *EFI_BOOT_MANAGER_LEGACY_BOOT) (
-  IN  EFI_BOOT_MANAGER_LOAD_OPTION  *BootOption
-  );
-
-/**
-  The function registers the legacy boot support capabilities.
-
-  @param RefreshLegacyBootOption The function pointer to create all the legacy boot options.
-  @param LegacyBoot              The function pointer to boot the legacy boot option.
-**/
-VOID
-EFIAPI
-EfiBootManagerRegisterLegacyBootSupport (
-  EFI_BOOT_MANAGER_REFRESH_LEGACY_BOOT_OPTION   RefreshLegacyBootOption,
-  EFI_BOOT_MANAGER_LEGACY_BOOT                  LegacyBoot
-  );
-
-
-//
-// Boot Manager connect and disconnect library functions
-//
-
-/**
-  This function will connect all the system driver to controller
-  first, and then special connect the default console, this make
-  sure all the system controller available and the platform default
-  console connected.
-**/
-VOID
-EFIAPI
-EfiBootManagerConnectAll (
-  VOID
-  );
-
-/**
-  This function will create all handles associate with every device
-  path node. If the handle associate with one device path node can not
-  be created successfully, then still give one chance to do the dispatch,
-  which load the missing drivers if possible.
-
-  @param  DevicePathToConnect   The device path which will be connected, it CANNOT be
-                                a multi-instance device path
-  @param  MatchingHandle        Return the controller handle closest to the DevicePathToConnect
-
-  @retval EFI_INVALID_PARAMETER DevicePathToConnect is NULL.
-  @retval EFI_NOT_FOUND         Failed to create all handles associate with every device path node.
-  @retval EFI_SUCCESS           Successful to create all handles associate with every device path node.
-
-**/
-EFI_STATUS
-EFIAPI
-EfiBootManagerConnectDevicePath (
-  IN  EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect,
-  OUT EFI_HANDLE                *MatchingHandle          OPTIONAL
-  );
-
-/**
-  This function will disconnect all current system handles. 
-  
-  gBS->DisconnectController() is invoked for each handle exists in system handle buffer.
-  If handle is a bus type handle, all childrens also are disconnected recursively by
-  gBS->DisconnectController().
-**/
-VOID
-EFIAPI
-EfiBootManagerDisconnectAll (
-  VOID
-  );
-
-
-//
-// Boot Manager console library functions
-//
-
-typedef enum {
-  ConIn,
-  ConOut,
-  ErrOut,
-  ConInDev,
-  ConOutDev,
-  ErrOutDev,
-  ConsoleTypeMax
-} CONSOLE_TYPE;
-
-/**
-  This function will connect all the console devices base on the console
-  device variable ConIn, ConOut and ErrOut.
-**/
-VOID
-EFIAPI
-EfiBootManagerConnectAllDefaultConsoles (
-  VOID
-  );
-
-/**
-  This function updates the console variable based on ConVarName. It can
-  add or remove one specific console device path from the variable
-
-  @param  ConsoleType              ConIn, ConOut, ErrOut, ConInDev, ConOutDev or ErrOutDev.
-  @param  CustomizedConDevicePath  The console device path to be added to
-                                   the console variable. Cannot be multi-instance.
-  @param  ExclusiveDevicePath      The console device path to be removed
-                                   from the console variable. Cannot be multi-instance.
-
-  @retval EFI_UNSUPPORTED          The added device path is the same as a removed one.
-  @retval EFI_SUCCESS              Successfully added or removed the device path from the
-                                   console variable.
-
-**/
-EFI_STATUS
-EFIAPI
-EfiBootManagerUpdateConsoleVariable (
-  IN  CONSOLE_TYPE              ConsoleType,
-  IN  EFI_DEVICE_PATH_PROTOCOL  *CustomizedConDevicePath,
-  IN  EFI_DEVICE_PATH_PROTOCOL  *ExclusiveDevicePath
-  );
-
-/**
-  Connect the console device base on the variable ConVarName, if
-  device path of the ConVarName is multi-instance device path, if
-  anyone of the instances is connected success, then this function
-  will return success.
-
-  @param  ConsoleType              ConIn, ConOut or ErrOut.
-
-  @retval EFI_NOT_FOUND            There is not any console devices connected
-                                   success
-  @retval EFI_SUCCESS              Success connect any one instance of the console
-                                   device path base on the variable ConVarName.
-
-**/
-EFI_STATUS
-EFIAPI
-EfiBootManagerConnectConsoleVariable (
-  IN  CONSOLE_TYPE              ConsoleType
-  );
-
-/**
-  Query all the children of VideoController and return the device paths of all the 
-  children that support GraphicsOutput protocol.
-
-  @param VideoController       PCI handle of video controller.
-
-  @return  Device paths of all the children that support GraphicsOutput protocol.
-**/
-EFI_DEVICE_PATH_PROTOCOL *
-EFIAPI
-EfiBootManagerGetGopDevicePath (
-  IN  EFI_HANDLE               VideoController
-  );
-
-/**
-  Connect the platform active active video controller.
-
-  @param VideoController       PCI handle of video controller.
-
-  @retval EFI_NOT_FOUND There is no active video controller.
-  @retval EFI_SUCCESS   The video controller is connected.
-**/
-EFI_STATUS
-EFIAPI
-EfiBootManagerConnectVideoController (
-  EFI_HANDLE                 VideoController  OPTIONAL
-  );
-
-//
-// Boot Manager driver health library functions.
-//
-
-typedef struct {
-  EFI_DRIVER_HEALTH_PROTOCOL      *DriverHealth;
-
-  ///
-  /// Driver relative handles
-  ///
-  EFI_HANDLE                      DriverHealthHandle;
-  EFI_HANDLE                      ControllerHandle;
-  EFI_HANDLE                      ChildHandle;
-
-  ///
-  /// Driver health messages of the specify Driver 
-  ///
-  EFI_DRIVER_HEALTH_HII_MESSAGE   *MessageList;
-
-  ///
-  /// HII relative handles
-  ///
-  EFI_HII_HANDLE                  HiiHandle;
-
-  ///
-  /// Driver Health status
-  ///
-  EFI_DRIVER_HEALTH_STATUS        HealthStatus;
-} EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO;
-
-/**
-  Return all the Driver Health information.
-
-  When the cumulative health status of all the controllers managed by the
-  driver who produces the EFI_DRIVER_HEALTH_PROTOCOL is healthy, only one
-  EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO entry is created for such
-  EFI_DRIVER_HEALTH_PROTOCOL instance.
-  Otherwise, every controller creates one EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO
-  entry. Additionally every child controller creates one
-  EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO entry if the driver is a bus driver.
-
-  @param Count      Return the count of the Driver Health information.
-
-  @retval NULL      No Driver Health information is returned.
-  @retval !NULL     Pointer to the Driver Health information array.
-**/
-EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO *
-EFIAPI
-EfiBootManagerGetDriverHealthInfo (
-  UINTN    *Count
-  );
-
-/**
-  Free the Driver Health information array.
-
-  @param DriverHealthInfo       Pointer to array of the Driver Health information.
-  @param Count                  Count of the array.
-
-  @retval EFI_SUCCESS           The array is freed.
-  @retval EFI_INVALID_PARAMETER The array is NULL.
-**/
-EFI_STATUS
-EFIAPI
-EfiBootManagerFreeDriverHealthInfo (
-  EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO  *DriverHealthInfo,
-  UINTN                                Count
-  );
-
-#endif
+/** @file\r
+  Provide Boot Manager related library APIs.\r
+\r
+Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2015-2016 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
+\r
+#ifndef _UEFI_BOOT_MANAGER_LIB_H_\r
+#define _UEFI_BOOT_MANAGER_LIB_H_\r
+\r
+#include <Protocol/DriverHealth.h>\r
+#include <Library/SortLib.h>\r
+\r
+//\r
+// Boot Manager load option library functions.\r
+//\r
+\r
+//\r
+// Load Option Type\r
+//\r
+typedef enum {\r
+  LoadOptionTypeDriver,\r
+  LoadOptionTypeSysPrep,\r
+  LoadOptionTypeBoot,\r
+  LoadOptionTypePlatformRecovery,\r
+  LoadOptionTypeMax\r
+} EFI_BOOT_MANAGER_LOAD_OPTION_TYPE;\r
+\r
+typedef enum {\r
+  LoadOptionNumberMax = 0x10000,\r
+  LoadOptionNumberUnassigned = LoadOptionNumberMax\r
+} EFI_BOOT_MANAGER_LOAD_OPTION_NUMBER;\r
+\r
+//\r
+// Common structure definition for DriverOption and BootOption\r
+//\r
+typedef struct {\r
+  //\r
+  // Data read from UEFI NV variables\r
+  //\r
+  UINTN                             OptionNumber;       // #### numerical value, could be LoadOptionNumberUnassigned\r
+  EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType;         // LoadOptionTypeBoot or LoadOptionTypeDriver\r
+  UINT32                            Attributes;         // Load Option Attributes\r
+  CHAR16                            *Description;       // Load Option Description\r
+  EFI_DEVICE_PATH_PROTOCOL          *FilePath;          // Load Option Device Path\r
+  UINT8                             *OptionalData;      // Load Option optional data to pass into image\r
+  UINT32                            OptionalDataSize;   // Load Option size of OptionalData\r
+  EFI_GUID                          VendorGuid;\r
+\r
+  //\r
+  // Used at runtime\r
+  //\r
+  EFI_STATUS                        Status;             // Status returned from boot attempt gBS->StartImage ()\r
+  CHAR16                            *ExitData;          // Exit data returned from gBS->StartImage ()\r
+  UINTN                             ExitDataSize;       // Size of ExitData\r
+} EFI_BOOT_MANAGER_LOAD_OPTION;\r
+\r
+/**\r
+  Returns an array of load options based on the EFI variable\r
+  L"BootOrder"/L"DriverOrder" and the L"Boot####"/L"Driver####" variables impled by it.\r
+  #### is the hex value of the UINT16 in each BootOrder/DriverOrder entry.\r
+\r
+  @param  LoadOptionCount   Returns number of entries in the array.\r
+  @param  LoadOptionType    The type of the load option.\r
+\r
+  @retval NULL  No load options exist.\r
+  @retval !NULL Array of load option entries.\r
+\r
+**/\r
+EFI_BOOT_MANAGER_LOAD_OPTION *\r
+EFIAPI\r
+EfiBootManagerGetLoadOptions (\r
+  OUT UINTN                            *LoadOptionCount,\r
+  IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType\r
+  );\r
+\r
+/**\r
+  Free an array of load options returned from EfiBootManagerGetLoadOptions().\r
+\r
+  @param  LoadOptions      Pointer to the array of load options to free.\r
+  @param  LoadOptionCount  Number of array entries in LoadOptions.\r
+\r
+  @return EFI_SUCCESS           LoadOptions was freed.\r
+  @return EFI_INVALID_PARAMETER LoadOptions is NULL.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerFreeLoadOptions (\r
+  IN  EFI_BOOT_MANAGER_LOAD_OPTION  *LoadOptions,\r
+  IN  UINTN                         LoadOptionCount\r
+  );\r
+\r
+/**\r
+  Initialize a load option.\r
+\r
+  @param Option           Pointer to the load option to be initialized.\r
+  @param OptionNumber     Option number of the load option.\r
+  @param OptionType       Type of the load option.\r
+  @param Attributes       Attributes of the load option.\r
+  @param Description      Description of the load option.\r
+  @param FilePath         Device path of the load option.\r
+  @param OptionalData     Optional data of the load option.\r
+  @param OptionalDataSize Size of the optional data of the load option.\r
+\r
+  @retval EFI_SUCCESS           The load option was initialized successfully.\r
+  @retval EFI_INVALID_PARAMETER Option, Description or FilePath is NULL.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerInitializeLoadOption (\r
+  IN OUT EFI_BOOT_MANAGER_LOAD_OPTION   *Option,\r
+  IN  UINTN                             OptionNumber,\r
+  IN  EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType,\r
+  IN  UINT32                            Attributes,\r
+  IN  CHAR16                            *Description,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL          *FilePath,\r
+  IN  UINT8                             *OptionalData,\r
+  IN  UINT32                            OptionalDataSize\r
+  );\r
+\r
+/**\r
+  Free a load option created by EfiBootManagerInitializeLoadOption()\r
+  or EfiBootManagerVariableToLoadOption().\r
+\r
+  @param  LoadOption   Pointer to the load option to free.\r
+  CONCERN: Check Boot#### instead of BootOrder, optimize, spec clarify\r
+  @return EFI_SUCCESS           LoadOption was freed.\r
+  @return EFI_INVALID_PARAMETER LoadOption is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerFreeLoadOption (\r
+  IN  EFI_BOOT_MANAGER_LOAD_OPTION  *LoadOption\r
+  );\r
+\r
+/**\r
+  Initialize the load option from the VariableName.\r
+\r
+  @param  VariableName          EFI Variable name which could be Boot#### or\r
+                                Driver####\r
+  @param  LoadOption            Pointer to the load option to be initialized\r
+\r
+  @retval EFI_SUCCESS           The option was created\r
+  @retval EFI_INVALID_PARAMETER VariableName or LoadOption is NULL.\r
+  @retval EFI_NOT_FOUND         The variable specified by VariableName cannot be found.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerVariableToLoadOption (\r
+  IN CHAR16                           *VariableName,\r
+  IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *LoadOption\r
+  );\r
+\r
+/**\r
+  Create the Boot#### or Driver#### variable from the load option.\r
+\r
+  @param  LoadOption      Pointer to the load option.\r
+\r
+  @retval EFI_SUCCESS     The variable was created.\r
+  @retval Others          Error status returned by RT->SetVariable.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerLoadOptionToVariable (\r
+  IN CONST EFI_BOOT_MANAGER_LOAD_OPTION     *LoadOption\r
+  );\r
+\r
+/**\r
+  This function will register the new Boot####, Driver#### or SysPrep#### option.\r
+  After the *#### is updated, the *Order will also be updated.\r
+\r
+  @param  Option            Pointer to load option to add. If on input\r
+                            Option->OptionNumber is LoadOptionNumberUnassigned,\r
+                            then on output Option->OptionNumber is updated to\r
+                            the number of the new Boot####,\r
+                            Driver#### or SysPrep#### option.\r
+  @param  Position          Position of the new load option to put in the ****Order variable.\r
+\r
+  @retval EFI_SUCCESS           The *#### have been successfully registered.\r
+  @retval EFI_INVALID_PARAMETER The option number exceeds 0xFFFF.\r
+  @retval EFI_ALREADY_STARTED   The option number of Option is being used already.\r
+                                Note: this API only adds new load option, no replacement support.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no free option number that can be used when the\r
+                                option number specified in the Option is LoadOptionNumberUnassigned.\r
+  @return                       Status codes of gRT->SetVariable ().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerAddLoadOptionVariable (\r
+  IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *Option,\r
+  IN     UINTN                        Position\r
+  );\r
+\r
+/**\r
+  Delete the load option according to the OptionNumber and OptionType.\r
+\r
+  Only the BootOrder/DriverOrder is updated to remove the reference of the OptionNumber.\r
+\r
+  @param  OptionNumber        Option number of the load option.\r
+  @param  OptionType          Type of the load option.\r
+\r
+  @retval EFI_NOT_FOUND       The load option cannot be found.\r
+  @retval EFI_SUCCESS         The load option was deleted.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerDeleteLoadOptionVariable (\r
+  IN UINTN                              OptionNumber,\r
+  IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE  OptionType\r
+  );\r
+\r
+/**\r
+  Sort the load options. The DriverOrder/BootOrder variables will be re-created to\r
+  reflect the new order.\r
+\r
+  @param OptionType        The type of the load option.\r
+  @param CompareFunction   The comparator function pointer.\r
+**/\r
+VOID\r
+EFIAPI\r
+EfiBootManagerSortLoadOptionVariable (\r
+  IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType,\r
+  IN SORT_COMPARE                      CompareFunction\r
+  );\r
+\r
+/**\r
+  Return the index of the load option in the load option array.\r
+\r
+  The function consider two load options are equal when the\r
+  OptionType, Attributes, Description, FilePath and OptionalData are equal.\r
+\r
+  @param Key    Pointer to the load option to be found.\r
+  @param Array  Pointer to the array of load options to be found.\r
+  @param Count  Number of entries in the Array.\r
+\r
+  @retval -1          Key wasn't found in the Array.\r
+  @retval 0 ~ Count-1 The index of the Key in the Array.\r
+**/\r
+INTN\r
+EFIAPI\r
+EfiBootManagerFindLoadOption (\r
+  IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,\r
+  IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,\r
+  IN UINTN                              Count\r
+  );\r
+\r
+//\r
+// Boot Manager hot key library functions.\r
+//\r
+\r
+#pragma pack(1)\r
+///\r
+/// EFI Key Option.\r
+///\r
+typedef struct {\r
+  ///\r
+  /// Specifies options about how the key will be processed.\r
+  ///\r
+  EFI_BOOT_KEY_DATA  KeyData;\r
+  ///\r
+  /// The CRC-32 which should match the CRC-32 of the entire EFI_LOAD_OPTION to\r
+  /// which BootOption refers. If the CRC-32s do not match this value, then this key\r
+  /// option is ignored.\r
+  ///\r
+  UINT32             BootOptionCrc;\r
+  ///\r
+  /// The Boot#### option which will be invoked if this key is pressed and the boot option\r
+  /// is active (LOAD_OPTION_ACTIVE is set).\r
+  ///\r
+  UINT16             BootOption;\r
+  ///\r
+  /// The key codes to compare against those returned by the\r
+  /// EFI_SIMPLE_TEXT_INPUT and EFI_SIMPLE_TEXT_INPUT_EX protocols.\r
+  /// The number of key codes (0-3) is specified by the EFI_KEY_CODE_COUNT field in KeyOptions.\r
+  ///\r
+  EFI_INPUT_KEY      Keys[3];\r
+  UINT16             OptionNumber;\r
+} EFI_BOOT_MANAGER_KEY_OPTION;\r
+#pragma pack()\r
+\r
+/**\r
+  Start the hot key service so that the key press can trigger the boot option.\r
+\r
+  @param HotkeyTriggered  Return the waitable event and it will be signaled\r
+                          when a valid hot key is pressed.\r
+\r
+  @retval EFI_SUCCESS     The hot key service is started.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerStartHotkeyService (\r
+  IN EFI_EVENT      *HotkeyTriggered\r
+  );\r
+\r
+//\r
+// Modifier for EfiBootManagerAddKeyOptionVariable and EfiBootManagerDeleteKeyOptionVariable\r
+//\r
+#define EFI_BOOT_MANAGER_SHIFT_PRESSED    0x00000001\r
+#define EFI_BOOT_MANAGER_CONTROL_PRESSED  0x00000002\r
+#define EFI_BOOT_MANAGER_ALT_PRESSED      0x00000004\r
+#define EFI_BOOT_MANAGER_LOGO_PRESSED     0x00000008\r
+#define EFI_BOOT_MANAGER_MENU_KEY_PRESSED 0x00000010\r
+#define EFI_BOOT_MANAGER_SYS_REQ_PRESSED  0x00000020\r
+\r
+/**\r
+  Add the key option.\r
+  It adds the key option variable and the key option takes affect immediately.\r
+\r
+  @param AddedOption      Return the added key option.\r
+  @param BootOptionNumber The boot option number for the key option.\r
+  @param Modifier         Key shift state.\r
+  @param ...              Parameter list of pointer of EFI_INPUT_KEY.\r
+\r
+  @retval EFI_SUCCESS         The key option is added.\r
+  @retval EFI_ALREADY_STARTED The hot key is already used by certain key option.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerAddKeyOptionVariable (\r
+  OUT EFI_BOOT_MANAGER_KEY_OPTION *AddedOption,   OPTIONAL\r
+  IN UINT16                       BootOptionNumber,\r
+  IN UINT32                       Modifier,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Delete the Key Option variable and unregister the hot key\r
+\r
+  @param DeletedOption  Return the deleted key options.\r
+  @param Modifier       Key shift state.\r
+  @param ...            Parameter list of pointer of EFI_INPUT_KEY.\r
+\r
+  @retval EFI_SUCCESS   The key option is deleted.\r
+  @retval EFI_NOT_FOUND The key option cannot be found.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerDeleteKeyOptionVariable (\r
+  IN EFI_BOOT_MANAGER_KEY_OPTION *DeletedOption, OPTIONAL\r
+  IN UINT32                      Modifier,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Register the key option to exit the waiting of the Boot Manager timeout.\r
+  Platform should ensure that the continue key option isn't conflict with\r
+  other boot key options.\r
+\r
+  @param Modifier     Key shift state.\r
+  @param  ...         Parameter list of pointer of EFI_INPUT_KEY.\r
+\r
+  @retval EFI_SUCCESS         Successfully register the continue key option.\r
+  @retval EFI_ALREADY_STARTED The continue key option is already registered.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerRegisterContinueKeyOption (\r
+  IN UINT32           Modifier,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Try to boot the boot option triggered by hot key.\r
+**/\r
+VOID\r
+EFIAPI\r
+EfiBootManagerHotkeyBoot (\r
+  VOID\r
+  );\r
+//\r
+// Boot Manager boot library functions.\r
+//\r
+\r
+/**\r
+  The function creates boot options for all possible bootable medias in the following order:\r
+  1. Removable BlockIo            - The boot option only points to the removable media\r
+                                    device, like USB key, DVD, Floppy etc.\r
+  2. Fixed BlockIo                - The boot option only points to a Fixed blockIo device,\r
+                                    like HardDisk.\r
+  3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting\r
+                                    SimpleFileSystem Protocol, but not supporting BlockIo\r
+                                    protocol.\r
+  4. LoadFile                     - The boot option points to the media supporting\r
+                                    LoadFile protocol.\r
+  Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior\r
+\r
+  The function won't delete the boot option not added by itself.\r
+**/\r
+VOID\r
+EFIAPI\r
+EfiBootManagerRefreshAllBootOption (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Attempt to boot the EFI boot option. This routine sets L"BootCurent" and\r
+  signals the EFI ready to boot event. If the device path for the option starts\r
+  with a BBS device path a legacy boot is attempted. Short form device paths are\r
+  also supported via this rountine. A device path starting with\r
+  MEDIA_HARDDRIVE_DP, MSG_USB_WWID_DP, MSG_USB_CLASS_DP gets expaned out\r
+  to find the first device that matches. If the BootOption Device Path\r
+  fails the removable media boot algorithm is attempted (\EFI\BOOTIA32.EFI,\r
+  \EFI\BOOTX64.EFI,... only one file type is tried per processor type)\r
+\r
+  @param  BootOption    Boot Option to try and boot.\r
+                        On return, BootOption->Status contains the boot status:\r
+                        EFI_SUCCESS     BootOption was booted\r
+                        EFI_UNSUPPORTED BootOption isn't supported.\r
+                        EFI_NOT_FOUND   The BootOption was not found on the system\r
+                        Others          BootOption failed with this error status\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EfiBootManagerBoot (\r
+  IN  EFI_BOOT_MANAGER_LOAD_OPTION  *BootOption\r
+  );\r
+\r
+/**\r
+  Return the boot option corresponding to the Boot Manager Menu.\r
+  It may automatically create one if the boot option hasn't been created yet.\r
+\r
+  @param BootOption    Return the Boot Manager Menu.\r
+\r
+  @retval EFI_SUCCESS   The Boot Manager Menu is successfully returned.\r
+  @retval EFI_NOT_FOUND The Boot Manager Menu cannot be found.\r
+  @retval others        Return status of gRT->SetVariable (). BootOption still points\r
+                        to the Boot Manager Menu even the Status is not EFI_SUCCESS\r
+                        and EFI_NOT_FOUND.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerGetBootManagerMenu (\r
+  EFI_BOOT_MANAGER_LOAD_OPTION *BootOption\r
+  );\r
+\r
+\r
+/**\r
+  Get the load option by its device path.\r
+\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 full device path of the load option after\r
+                   short-form device path expanding.\r
+                   Caller is responsible to free it.\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
+EFIAPI\r
+EfiBootManagerGetLoadOptionBuffer (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL          *FilePath,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL          **FullPath,\r
+  OUT UINTN                             *FileSize\r
+  );\r
+\r
+/**\r
+  The function enumerates all the legacy boot options, creates them and\r
+  registers them in the BootOrder variable.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_BOOT_MANAGER_REFRESH_LEGACY_BOOT_OPTION) (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  The function boots a legacy boot option.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_BOOT_MANAGER_LEGACY_BOOT) (\r
+  IN  EFI_BOOT_MANAGER_LOAD_OPTION  *BootOption\r
+  );\r
+\r
+/**\r
+  The function registers the legacy boot support capabilities.\r
+\r
+  @param RefreshLegacyBootOption The function pointer to create all the legacy boot options.\r
+  @param LegacyBoot              The function pointer to boot the legacy boot option.\r
+**/\r
+VOID\r
+EFIAPI\r
+EfiBootManagerRegisterLegacyBootSupport (\r
+  EFI_BOOT_MANAGER_REFRESH_LEGACY_BOOT_OPTION   RefreshLegacyBootOption,\r
+  EFI_BOOT_MANAGER_LEGACY_BOOT                  LegacyBoot\r
+  );\r
+\r
+/**\r
+  Return the platform provided boot option description for the controller.\r
+\r
+  @param Handle                Controller handle.\r
+  @param DefaultDescription    Default boot description provided by core.\r
+\r
+  @return  The callee allocated description string\r
+           or NULL if the handler wants to use DefaultDescription.\r
+**/\r
+typedef\r
+CHAR16 *\r
+(EFIAPI *EFI_BOOT_MANAGER_BOOT_DESCRIPTION_HANDLER) (\r
+  IN EFI_HANDLE                  Handle,\r
+  IN CONST CHAR16                *DefaultDescription\r
+  );\r
+\r
+/**\r
+  Register the platform provided boot description handler.\r
+\r
+  @param Handler  The platform provided boot description handler\r
+\r
+  @retval EFI_SUCCESS          The handler was registered successfully.\r
+  @retval EFI_ALREADY_STARTED  The handler was already registered.\r
+  @retval EFI_OUT_OF_RESOURCES There is not enough resource to perform the registration.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerRegisterBootDescriptionHandler (\r
+  IN EFI_BOOT_MANAGER_BOOT_DESCRIPTION_HANDLER  Handler\r
+  );\r
+\r
+//\r
+// Boot Manager connect and disconnect library functions\r
+//\r
+\r
+/**\r
+  This function will connect all the system driver to controller\r
+  first, and then special connect the default console, this make\r
+  sure all the system controller available and the platform default\r
+  console connected.\r
+**/\r
+VOID\r
+EFIAPI\r
+EfiBootManagerConnectAll (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  This function will create all handles associate with every device\r
+  path node. If the handle associate with one device path node can not\r
+  be created successfully, then still give chance to do the dispatch,\r
+  which load the missing drivers if possible.\r
+\r
+  @param  DevicePathToConnect   The device path which will be connected, it can be\r
+                                a multi-instance device path\r
+  @param  MatchingHandle        Return the controller handle closest to the DevicePathToConnect\r
+\r
+  @retval EFI_SUCCESS            All handles associate with every device path node\r
+                                 have been created.\r
+  @retval EFI_OUT_OF_RESOURCES   There is no resource to create new handles.\r
+  @retval EFI_NOT_FOUND          Create the handle associate with one device path\r
+                                 node failed.\r
+  @retval EFI_SECURITY_VIOLATION The user has no permission to start UEFI device\r
+                                 drivers on the DevicePath.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerConnectDevicePath (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect,\r
+  OUT EFI_HANDLE                *MatchingHandle          OPTIONAL\r
+  );\r
+\r
+/**\r
+  This function will disconnect all current system handles.\r
+\r
+  gBS->DisconnectController() is invoked for each handle exists in system handle buffer.\r
+  If handle is a bus type handle, all childrens also are disconnected recursively by\r
+  gBS->DisconnectController().\r
+**/\r
+VOID\r
+EFIAPI\r
+EfiBootManagerDisconnectAll (\r
+  VOID\r
+  );\r
+\r
+\r
+//\r
+// Boot Manager console library functions\r
+//\r
+\r
+typedef enum {\r
+  ConIn,\r
+  ConOut,\r
+  ErrOut,\r
+  ConInDev,\r
+  ConOutDev,\r
+  ErrOutDev,\r
+  ConsoleTypeMax\r
+} CONSOLE_TYPE;\r
+\r
+/**\r
+  This function will connect all the console devices base on the console\r
+  device variable ConIn, ConOut and ErrOut.\r
+\r
+  @retval EFI_DEVICE_ERROR         All the consoles were not connected due to an error.\r
+  @retval EFI_SUCCESS              Success connect any one instance of the console\r
+                                   device path base on the variable ConVarName.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerConnectAllDefaultConsoles (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  This function updates the console variable based on ConVarName. It can\r
+  add or remove one specific console device path from the variable\r
+\r
+  @param  ConsoleType              ConIn, ConOut, ErrOut, ConInDev, ConOutDev or ErrOutDev.\r
+  @param  CustomizedConDevicePath  The console device path to be added to\r
+                                   the console variable. Cannot be multi-instance.\r
+  @param  ExclusiveDevicePath      The console device path to be removed\r
+                                   from the console variable. Cannot be multi-instance.\r
+\r
+  @retval EFI_UNSUPPORTED          The added device path is the same as a removed one.\r
+  @retval EFI_SUCCESS              Successfully added or removed the device path from the\r
+                                   console variable.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerUpdateConsoleVariable (\r
+  IN  CONSOLE_TYPE              ConsoleType,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *CustomizedConDevicePath,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *ExclusiveDevicePath\r
+  );\r
+\r
+/**\r
+  Connect the console device base on the variable ConVarName, if\r
+  device path of the ConVarName is multi-instance device path, if\r
+  anyone of the instances is connected success, then this function\r
+  will return success.\r
+\r
+  @param  ConsoleType              ConIn, ConOut or ErrOut.\r
+\r
+  @retval EFI_NOT_FOUND            There is not any console devices connected\r
+                                   success\r
+  @retval EFI_SUCCESS              Success connect any one instance of the console\r
+                                   device path base on the variable ConVarName.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerConnectConsoleVariable (\r
+  IN  CONSOLE_TYPE              ConsoleType\r
+  );\r
+\r
+/**\r
+  Query all the children of VideoController and return the device paths of all the\r
+  children that support GraphicsOutput protocol.\r
+\r
+  @param VideoController       PCI handle of video controller.\r
+\r
+  @return  Device paths of all the children that support GraphicsOutput protocol.\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+EfiBootManagerGetGopDevicePath (\r
+  IN  EFI_HANDLE               VideoController\r
+  );\r
+\r
+/**\r
+  Connect the platform active active video controller.\r
+\r
+  @param VideoController       PCI handle of video controller.\r
+\r
+  @retval EFI_NOT_FOUND There is no active video controller.\r
+  @retval EFI_SUCCESS   The video controller is connected.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerConnectVideoController (\r
+  EFI_HANDLE                 VideoController  OPTIONAL\r
+  );\r
+\r
+//\r
+// Boot Manager driver health library functions.\r
+//\r
+\r
+typedef struct {\r
+  EFI_DRIVER_HEALTH_PROTOCOL      *DriverHealth;\r
+\r
+  ///\r
+  /// Driver relative handles\r
+  ///\r
+  EFI_HANDLE                      DriverHealthHandle;\r
+  EFI_HANDLE                      ControllerHandle;\r
+  EFI_HANDLE                      ChildHandle;\r
+\r
+  ///\r
+  /// Driver health messages of the specify Driver\r
+  ///\r
+  EFI_DRIVER_HEALTH_HII_MESSAGE   *MessageList;\r
+\r
+  ///\r
+  /// HII relative handles\r
+  ///\r
+  EFI_HII_HANDLE                  HiiHandle;\r
+\r
+  ///\r
+  /// Driver Health status\r
+  ///\r
+  EFI_DRIVER_HEALTH_STATUS        HealthStatus;\r
+} EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO;\r
+\r
+/**\r
+  Return all the Driver Health information.\r
+\r
+  When the cumulative health status of all the controllers managed by the\r
+  driver who produces the EFI_DRIVER_HEALTH_PROTOCOL is healthy, only one\r
+  EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO entry is created for such\r
+  EFI_DRIVER_HEALTH_PROTOCOL instance.\r
+  Otherwise, every controller creates one EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO\r
+  entry. Additionally every child controller creates one\r
+  EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO entry if the driver is a bus driver.\r
+\r
+  @param Count      Return the count of the Driver Health information.\r
+\r
+  @retval NULL      No Driver Health information is returned.\r
+  @retval !NULL     Pointer to the Driver Health information array.\r
+**/\r
+EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO *\r
+EFIAPI\r
+EfiBootManagerGetDriverHealthInfo (\r
+  UINTN    *Count\r
+  );\r
+\r
+/**\r
+  Free the Driver Health information array.\r
+\r
+  @param DriverHealthInfo       Pointer to array of the Driver Health information.\r
+  @param Count                  Count of the array.\r
+\r
+  @retval EFI_SUCCESS           The array is freed.\r
+  @retval EFI_INVALID_PARAMETER The array is NULL.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerFreeDriverHealthInfo (\r
+  EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO  *DriverHealthInfo,\r
+  UINTN                                Count\r
+  );\r
+\r
+/**\r
+  Process (load and execute) the load option.\r
+\r
+  @param LoadOption  Pointer to the load option.\r
+\r
+  @retval EFI_INVALID_PARAMETER  The load option type is invalid,\r
+                                 or the load option file path doesn't point to a valid file.\r
+  @retval EFI_UNSUPPORTED        The load option type is of LoadOptionTypeBoot.\r
+  @retval EFI_SUCCESS            The load option is inactive, or successfully loaded and executed.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerProcessLoadOption (\r
+  EFI_BOOT_MANAGER_LOAD_OPTION       *LoadOption\r
+  );\r
+\r
+/**\r
+  Check whether the VariableName is a valid load option variable name\r
+  and return the load option type and option number.\r
+\r
+  @param VariableName The name of the load option variable.\r
+  @param OptionType   Return the load option type.\r
+  @param OptionNumber Return the load option number.\r
+\r
+  @retval TRUE  The variable name is valid; The load option type and\r
+                load option number are returned.\r
+  @retval FALSE The variable name is NOT valid.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+EfiBootManagerIsValidLoadOptionVariableName (\r
+  IN CHAR16                             *VariableName,\r
+  OUT EFI_BOOT_MANAGER_LOAD_OPTION_TYPE *OptionType   OPTIONAL,\r
+  OUT UINT16                            *OptionNumber OPTIONAL\r
+  );\r
+\r
+\r
+/**\r
+  Dispatch the deferred images that are returned from all DeferredImageLoad instances.\r
+\r
+  @retval EFI_SUCCESS       At least one deferred image is loaded successfully and started.\r
+  @retval EFI_NOT_FOUND     There is no deferred image.\r
+  @retval EFI_ACCESS_DENIED There are deferred images but all of them are failed to load.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiBootManagerDispatchDeferredImages (\r
+  VOID\r
+  );\r
+#endif\r