EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index
Functions | Variables

IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c File Reference

#include "InternalBdsLib.h"
#include "String.h"

Go to the source code of this file.

Functions

EFI_STATUS EFIAPI GenericBdsLibConstructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS BdsLibDoLegacyBoot (IN BDS_COMMON_OPTION *Option)
BOOLEAN IsBootOptionValidNVVarialbe (IN BDS_COMMON_OPTION *OptionToCheck)
BOOLEAN BdsMatchUsbClass (IN EFI_USB_IO_PROTOCOL *UsbIo, IN USB_CLASS_DEVICE_PATH *UsbClass)
BOOLEAN BdsMatchUsbWwid (IN EFI_USB_IO_PROTOCOL *UsbIo, IN USB_WWID_DEVICE_PATH *UsbWwid)
EFI_HANDLEBdsFindUsbDevice (IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath, IN EFI_DEVICE_PATH_PROTOCOL *ShortFormDevicePath)
EFI_HANDLEBdsExpandUsbShortFormDevicePath (IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
EFI_STATUS EFIAPI BdsLibBootViaBootOption (IN BDS_COMMON_OPTION *Option, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, OUT UINTN *ExitDataSize, OUT CHAR16 **ExitData OPTIONAL)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI BdsExpandPartitionPartialDevicePathToFull (IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath)
BOOLEAN EFIAPI MatchPartitionDevicePathNode (IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath, IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath)
EFI_STATUS BdsLibDeleteOptionFromHandle (IN EFI_HANDLE Handle)
EFI_STATUS BdsDeleteAllInvalidEfiBootOption (VOID)
EFI_STATUS EFIAPI BdsLibEnumerateAllBootOption (IN OUT LIST_ENTRY *BdsBootOptionList)
VOID EFIAPI BdsLibBuildOptionFromHandle (IN EFI_HANDLE Handle, IN LIST_ENTRY *BdsBootOptionList, IN CHAR16 *String)
VOID EFIAPI BdsLibBuildOptionFromShell (IN EFI_HANDLE Handle, IN OUT LIST_ENTRY *BdsBootOptionList)
VOID EFIAPI BdsLibBootNext (VOID)
EFI_HANDLE EFIAPI BdsLibGetBootableHandle (IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
BOOLEAN BdsLibNetworkBootWithMediaPresent (IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
UINT32 EFIAPI BdsGetBootTypeFromDevicePath (IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
BOOLEAN EFIAPI BdsLibIsValidEFIBootOptDevicePath (IN EFI_DEVICE_PATH_PROTOCOL *DevPath, IN BOOLEAN CheckMedia)
BOOLEAN EFIAPI BdsLibIsValidEFIBootOptDevicePathExt (IN EFI_DEVICE_PATH_PROTOCOL *DevPath, IN BOOLEAN CheckMedia, IN CHAR16 *Description)
EFI_STATUS EFIAPI BdsLibUpdateFvFileDevicePath (IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, IN EFI_GUID *FileGuid)

Variables

BOOLEAN mEnumBootDevice = FALSE
EFI_HII_HANDLE gBdsLibStringPackHandle = NULL

Detailed Description

BDS Lib functions which relate with create or process the boot option.

Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.
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.

Definition in file BdsBoot.c.


Function Documentation

EFI_STATUS BdsDeleteAllInvalidEfiBootOption ( VOID  )

Delete all invalid EFI boot options.

Return values:
EFI_SUCCESSDelete all invalid boot option success
EFI_NOT_FOUNDVariable "BootOrder" is not found
EFI_OUT_OF_RESOURCESLack of memory resource
OtherError return value from SetVariable()

Definition at line 1277 of file BdsBoot.c.

EFI_DEVICE_PATH_PROTOCOL* EFIAPI BdsExpandPartitionPartialDevicePathToFull ( IN HARDDRIVE_DEVICE_PATH HardDriveDevicePath)

Expand a device path that starts with a hard drive media device path node to be a full device path that includes the full hardware path to the device. We need to do this so it can be booted. As an optimization the front match (the part point to the partition node. E.g. ACPI() /PCI()/ATA()/Partition() ) is saved in a variable so a connect all is not required on every boot. All successful history device path which point to partition node (the front part) will be saved.

Parameters:
HardDriveDevicePathEFI Device Path to boot, if it starts with a hard drive media device path.
Returns:
A Pointer to the full device path or NULL if a valid Hard Drive devic path cannot be found.

Definition at line 871 of file BdsBoot.c.

EFI_HANDLE* BdsExpandUsbShortFormDevicePath ( IN EFI_DEVICE_PATH_PROTOCOL DevicePath)

Expand USB Class or USB WWID device path node to be full device path of a USB device in platform then load the boot file on this full device path and return the image handle.

This function support following 4 cases: 1) Boot Option device path starts with a USB Class or USB WWID device path, and there is no Media FilePath device path in the end. In this case, it will follow Removable Media Boot Behavior. 2) Boot Option device path starts with a USB Class or USB WWID device path, and ended with Media FilePath device path. 3) Boot Option device path starts with a full device path to a USB Host Controller, contains a USB Class or USB WWID device path node, while not ended with Media FilePath device path. In this case, it will follow Removable Media Boot Behavior. 4) Boot Option device path starts with a full device path to a USB Host Controller, contains a USB Class or USB WWID device path node, and ended with Media FilePath device path.

Parameters:
DevicePathThe Boot Option device path.
Returns:
The image handle of boot file, or NULL if there is no boot file found in the specified USB Class or USB WWID device path.

Definition at line 523 of file BdsBoot.c.

EFI_HANDLE* BdsFindUsbDevice ( IN EFI_DEVICE_PATH_PROTOCOL ParentDevicePath,
IN EFI_DEVICE_PATH_PROTOCOL ShortFormDevicePath 
)

Find a USB device path which match the specified short-form device path start with USB Class or USB WWID device path and load the boot file then return the image handle. If ParentDevicePath is NULL, this function will search in all USB devices of the platform. If ParentDevicePath is not NULL,this function will only search in its child devices.

Parameters:
ParentDevicePathThe device path of the parent.
ShortFormDevicePathThe USB Class or USB WWID device path to match.
Returns:
The image Handle if find load file from specified short-form device path or NULL if not found.

Definition at line 356 of file BdsBoot.c.

UINT32 EFIAPI BdsGetBootTypeFromDevicePath ( IN EFI_DEVICE_PATH_PROTOCOL DevicePath)

For a bootable Device path, return its boot type.

Parameters:
DevicePathThe bootable device Path to check
Return values:
BDS_EFI_MEDIA_HD_BOOTIf given device path contains MEDIA_DEVICE_PATH type device path node which subtype is MEDIA_HARDDRIVE_DP
BDS_EFI_MEDIA_CDROM_BOOTIf given device path contains MEDIA_DEVICE_PATH type device path node which subtype is MEDIA_CDROM_DP
BDS_EFI_ACPI_FLOPPY_BOOTIf given device path contains ACPI_DEVICE_PATH type device path node which HID is floppy device.
BDS_EFI_MESSAGE_ATAPI_BOOTIf given device path contains MESSAGING_DEVICE_PATH type device path node and its last device path node's subtype is MSG_ATAPI_DP.
BDS_EFI_MESSAGE_SCSI_BOOTIf given device path contains MESSAGING_DEVICE_PATH type device path node and its last device path node's subtype is MSG_SCSI_DP.
BDS_EFI_MESSAGE_USB_DEVICE_BOOTIf given device path contains MESSAGING_DEVICE_PATH type device path node and its last device path node's subtype is MSG_USB_DP.
BDS_EFI_MESSAGE_MISC_BOOTIf the device path not contains any media device path node, and its last device path node point to a message device path node.
BDS_LEGACY_BBS_BOOTIf given device path contains BBS_DEVICE_PATH type device path node.
BDS_EFI_UNSUPPORTAn EFI Removable BlockIO device path not point to a media and message device,

Definition at line 2181 of file BdsBoot.c.

VOID EFIAPI BdsLibBootNext ( VOID  )

Boot from the UEFI spec defined "BootNext" variable.

Definition at line 1838 of file BdsBoot.c.

EFI_STATUS EFIAPI BdsLibBootViaBootOption ( IN BDS_COMMON_OPTION Option,
IN EFI_DEVICE_PATH_PROTOCOL DevicePath,
OUT UINTN ExitDataSize,
OUT CHAR16 **ExitData  OPTIONAL 
)

Process the boot option follow the UEFI specification and special treat the legacy boot option with BBS_DEVICE_PATH.

Parameters:
OptionThe boot option need to be processed
DevicePathThe device path which describe where to load the boot image or the legacy BBS device path to boot the legacy OS
ExitDataSizeThe size of exit data.
ExitDataData returned when Boot image failed.
Return values:
EFI_SUCCESSBoot from the input boot option successfully.
EFI_NOT_FOUNDIf the Device Path is not found in the system

Definition at line 609 of file BdsBoot.c.

VOID EFIAPI BdsLibBuildOptionFromHandle ( IN EFI_HANDLE  Handle,
IN LIST_ENTRY BdsBootOptionList,
IN CHAR16 String 
)

Build the boot option with the handle parsed in

Parameters:
HandleThe handle which present the device path to create boot option
BdsBootOptionListThe header of the link list which indexed all current boot options
StringThe description of the boot option.

Definition at line 1780 of file BdsBoot.c.

VOID EFIAPI BdsLibBuildOptionFromShell ( IN EFI_HANDLE  Handle,
IN OUT LIST_ENTRY BdsBootOptionList 
)

Build the on flash shell boot option with the handle parsed in.

Parameters:
HandleThe handle which present the device path to create on flash shell boot option
BdsBootOptionListThe header of the link list which indexed all current boot options

Definition at line 1808 of file BdsBoot.c.

EFI_STATUS BdsLibDeleteOptionFromHandle ( IN EFI_HANDLE  Handle)

Delete the boot option associated with the handle passed in.

Parameters:
HandleThe handle which present the device path to create boot option
Return values:
EFI_SUCCESSDelete the boot option success
EFI_NOT_FOUNDIf the Device Path is not found in the system
EFI_OUT_OF_RESOURCESLack of memory resource
OtherError return value from SetVariable()

Definition at line 1171 of file BdsBoot.c.

EFI_STATUS BdsLibDoLegacyBoot ( IN BDS_COMMON_OPTION Option)

Boot the legacy system with the boot option

Parameters:
OptionThe legacy boot option which have BBS device path
Return values:
EFI_UNSUPPORTEDThere is no legacybios protocol, do not support legacy boot.
EFI_STATUSReturn the status of LegacyBios->LegacyBoot ().

Definition at line 66 of file BdsBoot.c.

EFI_STATUS EFIAPI BdsLibEnumerateAllBootOption ( IN OUT LIST_ENTRY BdsBootOptionList)

For EFI boot option, BDS separate them as six types: 1. Network - The boot option points to the SimpleNetworkProtocol device. Bds will try to automatically create this type boot option when enumerate. 2. Shell - The boot option points to internal flash shell. Bds will try to automatically create this type boot option when enumerate. 3. Removable BlockIo - The boot option only points to the removable media device, like USB flash disk, DVD, Floppy etc. These device should contain a *removable* blockIo protocol in their device handle. Bds will try to automatically create this type boot option when enumerate. 4. Fixed BlockIo - The boot option only points to a Fixed blockIo device, like HardDisk. These device should contain a *fixed* blockIo protocol in their device handle. BDS will skip fixed blockIo devices, and NOT automatically create boot option for them. But BDS will help to delete those fixed blockIo boot option, whose description rule conflict with other auto-created boot options. 5. Non-BlockIo Simplefile - The boot option points to a device whose handle has SimpleFileSystem Protocol, but has no blockio protocol. These devices do not offer blockIo protocol, but BDS still can get the {machinename}.EFI by SimpleFileSystem Protocol. 6. File - The boot option points to a file. These boot options are usually created by user manually or OS loader. BDS will not delete or modify these boot options.

This function will enumerate all possible boot device in the system, and automatically create boot options for Network, Shell, Removable BlockIo, and Non-BlockIo Simplefile devices. It will only execute once of every boot.

Parameters:
BdsBootOptionListThe header of the link list which indexed all current boot options
Return values:
EFI_SUCCESSFinished all the boot device enumerate and create the boot option base on that boot device
EFI_OUT_OF_RESOURCESFailed to enumerate the boot device and create the boot option list

Definition at line 1429 of file BdsBoot.c.

EFI_HANDLE EFIAPI BdsLibGetBootableHandle ( IN EFI_DEVICE_PATH_PROTOCOL DevicePath)

Return the bootable media handle. First, check the device is connected Second, check whether the device path point to a device which support SimpleFileSystemProtocol, Third, detect the the default boot file in the Media, and return the removable Media handle.

Parameters:
DevicePathDevice Path to a bootable device
Returns:
The bootable media handle. If the media on the DevicePath is not bootable, NULL will return.

Definition at line 1899 of file BdsBoot.c.

BOOLEAN EFIAPI BdsLibIsValidEFIBootOptDevicePath ( IN EFI_DEVICE_PATH_PROTOCOL DevPath,
IN BOOLEAN  CheckMedia 
)

Check whether the Device path in a boot option point to a valid bootable device, And if CheckMedia is true, check the device is ready to boot now.

Parameters:
DevPaththe Device path in a boot option
CheckMediaif true, check the device is ready to boot now.
Return values:
TRUEthe Device path is valid
FALSEthe Device path is invalid .

Definition at line 2284 of file BdsBoot.c.

BOOLEAN EFIAPI BdsLibIsValidEFIBootOptDevicePathExt ( IN EFI_DEVICE_PATH_PROTOCOL DevPath,
IN BOOLEAN  CheckMedia,
IN CHAR16 Description 
)

Check whether the Device path in a boot option point to a valid bootable device, And if CheckMedia is true, check the device is ready to boot now. If Description is not NULL and the device path point to a fixed BlockIo device, check the description whether conflict with other auto-created boot options.

Parameters:
DevPaththe Device path in a boot option
CheckMediaif true, check the device is ready to boot now.
Descriptionthe description in a boot option
Return values:
TRUEthe Device path is valid
FALSEthe Device path is invalid .

Definition at line 2309 of file BdsBoot.c.

BOOLEAN BdsLibNetworkBootWithMediaPresent ( IN EFI_DEVICE_PATH_PROTOCOL DevicePath)

Check to see if the network cable is plugged in. If the DevicePath is not connected it will be connected.

Parameters:
DevicePathDevice Path to check
Return values:
TRUEDevicePath points to an Network that is connected
FALSEDevicePath does not point to a bootable network

Definition at line 2071 of file BdsBoot.c.

EFI_STATUS EFIAPI BdsLibUpdateFvFileDevicePath ( IN OUT EFI_DEVICE_PATH_PROTOCOL **  DevicePath,
IN EFI_GUID FileGuid 
)

According to a file guild, check a Fv file device path is valid. If it is invalid, try to return the valid device path. FV address maybe changes for memory layout adjust from time to time, use this function could promise the Fv file device path is right.

Parameters:
DevicePathon input, the Fv file device path need to check on output, the updated valid Fv file device path
FileGuidthe Fv file guild
Return values:
EFI_INVALID_PARAMETERthe input DevicePath or FileGuid is invalid parameter
EFI_UNSUPPORTEDthe input DevicePath does not contain Fv file guild at all
EFI_ALREADY_STARTEDthe input DevicePath has pointed to Fv file, it is valid
EFI_SUCCESShas successfully updated the invalid DevicePath, and return the updated device path in DevicePath

Definition at line 2493 of file BdsBoot.c.

BOOLEAN BdsMatchUsbClass ( IN EFI_USB_IO_PROTOCOL UsbIo,
IN USB_CLASS_DEVICE_PATH UsbClass 
)

Check whether a USB device match the specified USB Class device path. This function follows "Load Option Processing" behavior in UEFI specification.

Parameters:
UsbIoUSB I/O protocol associated with the USB device.
UsbClassThe USB Class device path to match.
Return values:
TRUEThe USB device match the USB Class device path.
FALSEThe USB device does not match the USB Class device path.

Definition at line 157 of file BdsBoot.c.

BOOLEAN BdsMatchUsbWwid ( IN EFI_USB_IO_PROTOCOL UsbIo,
IN USB_WWID_DEVICE_PATH UsbWwid 
)

Check whether a USB device match the specified USB WWID device path. This function follows "Load Option Processing" behavior in UEFI specification.

Parameters:
UsbIoUSB I/O protocol associated with the USB device.
UsbWwidThe USB WWID device path to match.
Return values:
TRUEThe USB device match the USB WWID device path.
FALSEThe USB device does not match the USB WWID device path.

Definition at line 243 of file BdsBoot.c.

EFI_STATUS EFIAPI GenericBdsLibConstructor ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The constructor function register UNI strings into imageHandle.

It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.

Parameters:
ImageHandleThe firmware allocated handle for the EFI image.
SystemTableA pointer to the EFI System Table.
Return values:
EFI_SUCCESSThe constructor successfully added string package.
Othervalue The constructor can't add string package.

Definition at line 35 of file BdsBoot.c.

BOOLEAN IsBootOptionValidNVVarialbe ( IN BDS_COMMON_OPTION OptionToCheck)

Internal function to check if the input boot option is a valid EFI NV Boot####.

Parameters:
OptionToCheckBoot option to be checked.
Return values:
TRUEThis boot option matches a valid EFI NV Boot####.
FALSEIf not.

Definition at line 111 of file BdsBoot.c.

BOOLEAN EFIAPI MatchPartitionDevicePathNode ( IN EFI_DEVICE_PATH_PROTOCOL BlockIoDevicePath,
IN HARDDRIVE_DEVICE_PATH HardDriveDevicePath 
)

Check whether there is a instance in BlockIoDevicePath, which contain multi device path instances, has the same partition node with HardDriveDevicePath device path

Parameters:
BlockIoDevicePathMulti device path instances which need to check
HardDriveDevicePathA device path which starts with a hard drive media device path.
Return values:
TRUEThere is a matched device path instance.
FALSEThere is no matched device path instance.

Definition at line 1094 of file BdsBoot.c.


Variable Documentation

Definition at line 19 of file BdsBoot.c.

Definition at line 18 of file BdsBoot.c.

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines