TianoCore EDK2 master
Loading...
Searching...
No Matches
BdsEntry.c File Reference
#include "Bds.h"
#include "Language.h"
#include "HwErrRecSupport.h"
#include <Library/VariablePolicyHelperLib.h>

Go to the source code of this file.

Macros

#define SET_BOOT_OPTION_SUPPORT_KEY_COUNT(a, c)
 

Functions

VOID EFIAPI BdsDxeOnConnectConInCallBack (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI CheckDeferredLoadImageOnReadyToBoot (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_STATUS EFIAPI BdsInitialize (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS BdsWaitForSingleEvent (IN EFI_EVENT Event, IN UINT64 Timeout OPTIONAL)
 
VOID BdsReadKeys (VOID)
 
VOID BdsWait (IN EFI_EVENT HotkeyTriggered)
 
BOOLEAN BootBootOptions (IN EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions, IN UINTN BootOptionCount, IN EFI_BOOT_MANAGER_LOAD_OPTION *BootManagerMenu OPTIONAL)
 
VOID ProcessLoadOptions (IN EFI_BOOT_MANAGER_LOAD_OPTION *LoadOptions, IN UINTN LoadOptionCount)
 
VOID BdsFormalizeConsoleVariable (IN CHAR16 *VariableName)
 
VOID BdsFormalizeOSIndicationVariable (VOID)
 
VOID BdsFormalizeEfiGlobalVariable (VOID)
 
VOID EFIAPI BdsEntry (IN EFI_BDS_ARCH_PROTOCOL *This)
 
EFI_STATUS BdsDxeSetVariableAndReportStatusCodeOnError (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data)
 

Variables

EFI_BDS_ARCH_PROTOCOL gBds
 
EFI_EVENT gConnectConInEvent = NULL
 
CHAR16 * mReadOnlyVariables []
 
CHAR16 * mBdsLoadOptionName []
 

Detailed Description

This module produce main entry for BDS phase - BdsEntry. When this module was dispatched by DxeCore, gEfiBdsArchProtocolGuid will be installed which contains interface of BdsEntry. After DxeCore finish DXE phase, gEfiBdsArchProtocolGuid->BdsEntry will be invoked to enter BDS phase.

Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.
(C) Copyright 2016-2019 Hewlett Packard Enterprise Development LP
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file BdsEntry.c.

Macro Definition Documentation

◆ SET_BOOT_OPTION_SUPPORT_KEY_COUNT

#define SET_BOOT_OPTION_SUPPORT_KEY_COUNT (   a,
 
)
Value:
{ \
(a) = ((a) & ~EFI_BOOT_OPTION_SUPPORT_COUNT) | (((c) << LowBitSet32 (EFI_BOOT_OPTION_SUPPORT_COUNT)) & EFI_BOOT_OPTION_SUPPORT_COUNT); \
}
INTN EFIAPI LowBitSet32(IN UINT32 Operand)
Definition: LowBitSet32.c:26

Definition at line 20 of file BdsEntry.c.

Function Documentation

◆ BdsDxeOnConnectConInCallBack()

VOID EFIAPI BdsDxeOnConnectConInCallBack ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Event to Connect ConIn.

Parameters
EventEvent whose notification function is being invoked.
ContextPointer to the notification function's context, which is implementation-dependent.

Definition at line 64 of file BdsEntry.c.

◆ BdsDxeSetVariableAndReportStatusCodeOnError()

EFI_STATUS BdsDxeSetVariableAndReportStatusCodeOnError ( IN CHAR16 *  VariableName,
IN EFI_GUID VendorGuid,
IN UINT32  Attributes,
IN UINTN  DataSize,
IN VOID *  Data 
)

Set the variable and report the error through status code upon failure.

Parameters
VariableNameA 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.
VendorGuidA unique identifier for the vendor.
AttributesAttributes bitmask to set for the variable.
DataSizeThe size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE, 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).
DataThe contents for the variable.
Return values
EFI_SUCCESSThe firmware has successfully stored the variable and its data as defined by the Attributes.
EFI_INVALID_PARAMETERAn invalid combination of attribute bits, name, and GUID was supplied, or the DataSize exceeds the maximum allowed.
EFI_INVALID_PARAMETERVariableName is an empty string.
EFI_OUT_OF_RESOURCESNot enough storage is available to hold the variable and its data.
EFI_DEVICE_ERRORThe variable could not be retrieved due to a hardware error.
EFI_WRITE_PROTECTEDThe variable in question is read-only.
EFI_WRITE_PROTECTEDThe variable in question cannot be deleted.
EFI_SECURITY_VIOLATIONThe variable could not be written due to EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo does NOT pass the validation check carried out by the firmware.
EFI_NOT_FOUNDThe variable trying to be updated or deleted was not found.

Definition at line 1159 of file BdsEntry.c.

◆ BdsEntry()

VOID EFIAPI BdsEntry ( IN EFI_BDS_ARCH_PROTOCOL This)

Service routine for BdsInstance->Entry(). Devices are connected, the consoles are initialized, and the boot options are tried.

Parameters
ThisProtocol Instance structure.

Definition at line 669 of file BdsEntry.c.

◆ BdsFormalizeConsoleVariable()

VOID BdsFormalizeConsoleVariable ( IN CHAR16 *  VariableName)

Validate input console variable data.

If found the device path is not a valid device path, remove the variable.

Parameters
VariableNameInput console variable name.

Definition at line 513 of file BdsEntry.c.

◆ BdsFormalizeEfiGlobalVariable()

VOID BdsFormalizeEfiGlobalVariable ( VOID  )

Validate variables.

Definition at line 642 of file BdsEntry.c.

◆ BdsFormalizeOSIndicationVariable()

VOID BdsFormalizeOSIndicationVariable ( VOID  )

Formalize OsIndication related variables.

For OsIndicationsSupported, Create a BS/RT/UINT64 variable to report caps Delete OsIndications variable if it is not NV/BS/RT UINT64.

Item 3 is used to solve case when OS corrupts OsIndications. Here simply delete this NV variable.

Create a boot option for BootManagerMenu if it hasn't been created yet

Definition at line 553 of file BdsEntry.c.

◆ BdsInitialize()

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

Install Boot Device Selection Protocol

Parameters
ImageHandleThe image handle.
SystemTableThe system table.
Return values
EFI_SUCEESSBDS has finished initializing. Return the dispatcher and recall BDS.Entry
OtherReturn status from AllocatePool() or gBS->InstallProtocolInterface

Definition at line 177 of file BdsEntry.c.

◆ BdsReadKeys()

VOID BdsReadKeys ( VOID  )

The function reads user inputs.

Definition at line 284 of file BdsEntry.c.

◆ BdsWait()

VOID BdsWait ( IN EFI_EVENT  HotkeyTriggered)

The function waits for the boot manager timeout expires or hotkey is pressed.

It calls PlatformBootManagerWaitCallback each second.

Parameters
HotkeyTriggeredInput hotkey event.

Definition at line 315 of file BdsEntry.c.

◆ BdsWaitForSingleEvent()

EFI_STATUS BdsWaitForSingleEvent ( IN EFI_EVENT  Event,
IN UINT64 Timeout  OPTIONAL 
)

Function waits for a given event to fire, or for an optional timeout to expire.

Parameters
EventThe event to wait for
TimeoutAn optional timeout value in 100 ns units.
Return values
EFI_SUCCESSEvent fired before Timeout expired.
EFI_TIME_OUTTimout expired before Event fired..

Definition at line 226 of file BdsEntry.c.

◆ BootBootOptions()

BOOLEAN BootBootOptions ( IN EFI_BOOT_MANAGER_LOAD_OPTION BootOptions,
IN UINTN  BootOptionCount,
IN EFI_BOOT_MANAGER_LOAD_OPTION *BootManagerMenu  OPTIONAL 
)

Attempt to boot each boot option in the BootOptions array.

Parameters
BootOptionsInput boot option array.
BootOptionCountInput boot option count.
BootManagerMenuInput boot manager menu.
Return values
TRUESuccessfully boot one of the boot options.
FALSEFailed boot any of the boot options.

Definition at line 375 of file BdsEntry.c.

◆ CheckDeferredLoadImageOnReadyToBoot()

VOID EFIAPI CheckDeferredLoadImageOnReadyToBoot ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT. This is used to check whether there is remaining deferred load images.

Parameters
[in]EventThe Event that is being processed.
[in]ContextThe Event Context.

Definition at line 95 of file BdsEntry.c.

◆ ProcessLoadOptions()

VOID ProcessLoadOptions ( IN EFI_BOOT_MANAGER_LOAD_OPTION LoadOptions,
IN UINTN  LoadOptionCount 
)

The function will load and start every Driver####, SysPrep#### or PlatformRecovery####.

Parameters
LoadOptionsLoad option array.
LoadOptionCountLoad option count.

Definition at line 438 of file BdsEntry.c.

Variable Documentation

◆ gBds

Initial value:
= {
}
VOID EFIAPI BdsEntry(IN EFI_BDS_ARCH_PROTOCOL *This)
Definition: BdsEntry.c:669

BDS arch protocol instance initial value.

Definition at line 27 of file BdsEntry.c.

◆ gConnectConInEvent

EFI_EVENT gConnectConInEvent = NULL

Definition at line 34 of file BdsEntry.c.

◆ mBdsLoadOptionName

CHAR16* mBdsLoadOptionName[]
Initial value:
= {
L"Driver",
L"SysPrep",
L"Boot",
L"PlatformRecovery"
}

Definition at line 47 of file BdsEntry.c.

◆ mReadOnlyVariables

CHAR16* mReadOnlyVariables[]
Initial value:

The read-only variables defined in UEFI Spec.

Definition at line 39 of file BdsEntry.c.