Align the overrider with UDK2014.SP1 core.
The override fixed Showing IPv4 and IPv6 string format as "EFI Network <MAC Address><IP version>" in Boot Manager Group under BIOS setup. This override will be removed after core fixing. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Shifei Lu <shifeix.a.lu@intel.com> Reviewed-by: Tim He <tim.he@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16675 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
BDS Lib functions which relate with create or process the boot option.
|
||||
|
||||
Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
|
||||
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
|
||||
@@ -14,6 +14,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
#include "InternalBdsLib.h"
|
||||
#include "String.h"
|
||||
#include <Library/NetLib.h>
|
||||
#include "Library/DebugLib.h"
|
||||
|
||||
BOOLEAN mEnumBootDevice = FALSE;
|
||||
EFI_HII_HANDLE gBdsLibStringPackHandle = NULL;
|
||||
@@ -82,6 +84,10 @@ BdsDeleteBootOption (
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
//
|
||||
// Deleting variable with existing variable implementation shouldn't fail.
|
||||
//
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// adjust boot order array
|
||||
@@ -517,6 +523,15 @@ BdsDeleteAllInvalidLegacyBootOptions (
|
||||
return Status;
|
||||
}
|
||||
|
||||
BootOrder = BdsLibGetVariableAndSize (
|
||||
L"BootOrder",
|
||||
&gEfiGlobalVariableGuid,
|
||||
&BootOrderSize
|
||||
);
|
||||
if (BootOrder == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
LegacyBios->GetBbsInfo (
|
||||
LegacyBios,
|
||||
&HddCount,
|
||||
@@ -525,15 +540,6 @@ BdsDeleteAllInvalidLegacyBootOptions (
|
||||
&LocalBbsTable
|
||||
);
|
||||
|
||||
BootOrder = BdsLibGetVariableAndSize (
|
||||
L"BootOrder",
|
||||
&gEfiGlobalVariableGuid,
|
||||
&BootOrderSize
|
||||
);
|
||||
if (BootOrder == NULL) {
|
||||
BootOrderSize = 0;
|
||||
}
|
||||
|
||||
Index = 0;
|
||||
while (Index < BootOrderSize / sizeof (UINT16)) {
|
||||
UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", BootOrder[Index]);
|
||||
@@ -626,9 +632,11 @@ BdsDeleteAllInvalidLegacyBootOptions (
|
||||
BootOrderSize,
|
||||
BootOrder
|
||||
);
|
||||
if (BootOrder != NULL) {
|
||||
FreePool (BootOrder);
|
||||
}
|
||||
//
|
||||
// Shrinking variable with existing variable implementation shouldn't fail.
|
||||
//
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
FreePool (BootOrder);
|
||||
|
||||
return Status;
|
||||
}
|
||||
@@ -857,11 +865,11 @@ BdsAddNonExistingLegacyBootOptions (
|
||||
&BootOrder,
|
||||
&BootOrderSize
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
if (!EFI_ERROR (Status)) {
|
||||
ASSERT (BootOrder != NULL);
|
||||
BbsIndex = Index;
|
||||
OptionNumber = BootOrder[BootOrderSize / sizeof (UINT16) - 1];
|
||||
}
|
||||
BbsIndex = Index;
|
||||
OptionNumber = BootOrder[BootOrderSize / sizeof (UINT16) - 1];
|
||||
}
|
||||
|
||||
ASSERT (BbsIndex == Index);
|
||||
@@ -1036,7 +1044,7 @@ BdsCreateDevOrder (
|
||||
Status = gRT->SetVariable (
|
||||
VAR_LEGACY_DEV_ORDER,
|
||||
&gEfiLegacyDevOrderVariableGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
TotalSize,
|
||||
DevOrder
|
||||
);
|
||||
@@ -1357,7 +1365,7 @@ BdsUpdateLegacyDevOrder (
|
||||
Status = gRT->SetVariable (
|
||||
VAR_LEGACY_DEV_ORDER,
|
||||
&gEfiLegacyDevOrderVariableGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
TotalSize,
|
||||
NewDevOrder
|
||||
);
|
||||
@@ -1407,7 +1415,7 @@ BdsSetBootPriority4SameTypeDev (
|
||||
break;
|
||||
}
|
||||
|
||||
DevOrderPtr = (LEGACY_DEV_ORDER_ENTRY *) ((UINT8 *) DevOrderPtr + sizeof (BBS_TYPE) + DevOrderPtr->Length);
|
||||
DevOrderPtr = (LEGACY_DEV_ORDER_ENTRY *) ((UINTN) DevOrderPtr + sizeof (BBS_TYPE) + DevOrderPtr->Length);
|
||||
}
|
||||
|
||||
if ((UINT8 *) DevOrderPtr >= (UINT8 *) DevOrder + DevOrderSize) {
|
||||
@@ -1636,6 +1644,8 @@ BdsRefreshBbsTableForBoot (
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (DeviceType);
|
||||
|
||||
if (BootOrder != NULL) {
|
||||
FreePool (BootOrder);
|
||||
}
|
||||
@@ -2265,7 +2275,7 @@ BdsLibBootViaBootOption (
|
||||
// In this case, "BootCurrent" is not created.
|
||||
// Only create the BootCurrent variable when it points to a valid Boot#### variable.
|
||||
//
|
||||
gRT->SetVariable (
|
||||
SetVariableAndReportStatusCodeOnError (
|
||||
L"BootCurrent",
|
||||
&gEfiGlobalVariableGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
@@ -2463,13 +2473,14 @@ Done:
|
||||
|
||||
//
|
||||
// Clear Boot Current
|
||||
// Deleting variable with current implementation shouldn't fail.
|
||||
//
|
||||
gRT->SetVariable (
|
||||
L"BootCurrent",
|
||||
&gEfiGlobalVariableGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
0,
|
||||
&Option->BootCurrent
|
||||
NULL
|
||||
);
|
||||
|
||||
return Status;
|
||||
@@ -2518,11 +2529,28 @@ BdsExpandPartitionPartialDevicePathToFull (
|
||||
// If exist, search the front path which point to partition node in the variable instants.
|
||||
// If fail to find or HD_BOOT_DEVICE_PATH_VARIABLE_NAME not exist, reconnect all and search in all system
|
||||
//
|
||||
CachedDevicePath = BdsLibGetVariableAndSize (
|
||||
HD_BOOT_DEVICE_PATH_VARIABLE_NAME,
|
||||
&gHdBootDevicePathVariablGuid,
|
||||
&CachedDevicePathSize
|
||||
);
|
||||
GetVariable2 (
|
||||
HD_BOOT_DEVICE_PATH_VARIABLE_NAME,
|
||||
&gHdBootDevicePathVariablGuid,
|
||||
(VOID **) &CachedDevicePath,
|
||||
&CachedDevicePathSize
|
||||
);
|
||||
|
||||
//
|
||||
// Delete the invalid HD_BOOT_DEVICE_PATH_VARIABLE_NAME variable.
|
||||
//
|
||||
if ((CachedDevicePath != NULL) && !IsDevicePathValid (CachedDevicePath, CachedDevicePathSize)) {
|
||||
FreePool (CachedDevicePath);
|
||||
CachedDevicePath = NULL;
|
||||
Status = gRT->SetVariable (
|
||||
HD_BOOT_DEVICE_PATH_VARIABLE_NAME,
|
||||
&gHdBootDevicePathVariablGuid,
|
||||
0,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
if (CachedDevicePath != NULL) {
|
||||
TempNewDevicePath = CachedDevicePath;
|
||||
@@ -2580,11 +2608,12 @@ BdsExpandPartitionPartialDevicePathToFull (
|
||||
FreePool (TempNewDevicePath);
|
||||
//
|
||||
// Save the matching Device Path so we don't need to do a connect all next time
|
||||
// Failure to set the variable only impacts the performance when next time expanding the short-form device path.
|
||||
//
|
||||
Status = gRT->SetVariable (
|
||||
HD_BOOT_DEVICE_PATH_VARIABLE_NAME,
|
||||
&gHdBootDevicePathVariablGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
GetDevicePathSize (CachedDevicePath),
|
||||
CachedDevicePath
|
||||
);
|
||||
@@ -2678,11 +2707,12 @@ BdsExpandPartitionPartialDevicePathToFull (
|
||||
|
||||
//
|
||||
// Save the matching Device Path so we don't need to do a connect all next time
|
||||
// Failure to set the variable only impacts the performance when next time expanding the short-form device path.
|
||||
//
|
||||
Status = gRT->SetVariable (
|
||||
HD_BOOT_DEVICE_PATH_VARIABLE_NAME,
|
||||
&gHdBootDevicePathVariablGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
GetDevicePathSize (CachedDevicePath),
|
||||
CachedDevicePath
|
||||
);
|
||||
@@ -2887,6 +2917,10 @@ BdsLibDeleteOptionFromHandle (
|
||||
BootOrderSize,
|
||||
BootOrder
|
||||
);
|
||||
//
|
||||
// Shrinking variable with existing variable implementation shouldn't fail.
|
||||
//
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
FreePool (BootOrder);
|
||||
|
||||
@@ -2985,6 +3019,10 @@ BdsDeleteAllInvalidEfiBootOption (
|
||||
NULL
|
||||
);
|
||||
//
|
||||
// Deleting variable with current variable implementation shouldn't fail.
|
||||
//
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
//
|
||||
// Mark this boot option in boot order as deleted
|
||||
//
|
||||
BootOrder[Index] = 0xffff;
|
||||
@@ -3012,6 +3050,10 @@ BdsDeleteAllInvalidEfiBootOption (
|
||||
Index2 * sizeof (UINT16),
|
||||
BootOrder
|
||||
);
|
||||
//
|
||||
// Shrinking variable with current variable implementation shouldn't fail.
|
||||
//
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
FreePool (BootOrder);
|
||||
|
||||
@@ -3103,6 +3145,10 @@ BdsLibEnumerateAllBootOption (
|
||||
CHAR8 *LastLang;
|
||||
EFI_IMAGE_OPTIONAL_HEADER_UNION HdrData;
|
||||
EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
|
||||
CHAR16 *MacStr;
|
||||
CHAR16 *IPverStr;
|
||||
EFI_HANDLE *NetworkHandles;
|
||||
UINTN BufferSize;
|
||||
|
||||
FloppyNumber = 0;
|
||||
HarddriveNumber = 0;
|
||||
@@ -3135,7 +3181,9 @@ BdsLibEnumerateAllBootOption (
|
||||
AsciiStrSize (PlatLang),
|
||||
PlatLang
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
//
|
||||
// Failure to set the variable only impacts the performance next time enumerating the boot options.
|
||||
//
|
||||
|
||||
if (LastLang != NULL) {
|
||||
FreePool (LastLang);
|
||||
@@ -3180,9 +3228,16 @@ BdsLibEnumerateAllBootOption (
|
||||
(VOID **) &BlkIo
|
||||
);
|
||||
//
|
||||
// skip the fixed block io then the removable block io
|
||||
// skip the logical partition
|
||||
//
|
||||
if (EFI_ERROR (Status) || (BlkIo->Media->RemovableMedia == Removable[RemovableIndex])) {
|
||||
if (EFI_ERROR (Status) || BlkIo->Media->LogicalPartition) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// firstly fixed block io then the removable block io
|
||||
//
|
||||
if (BlkIo->Media->RemovableMedia == Removable[RemovableIndex]) {
|
||||
continue;
|
||||
}
|
||||
DevicePath = DevicePathFromHandle (BlockIoHandles[Index]);
|
||||
@@ -3244,6 +3299,7 @@ BdsLibEnumerateAllBootOption (
|
||||
break;
|
||||
|
||||
case BDS_EFI_MESSAGE_MISC_BOOT:
|
||||
default:
|
||||
if (MiscNumber != 0) {
|
||||
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_MISC)), MiscNumber);
|
||||
} else {
|
||||
@@ -3252,9 +3308,6 @@ BdsLibEnumerateAllBootOption (
|
||||
BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);
|
||||
MiscNumber++;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3341,11 +3394,113 @@ BdsLibEnumerateAllBootOption (
|
||||
);
|
||||
|
||||
for (Index = 0; Index < NumOfLoadFileHandles; Index++) {
|
||||
if (Index != 0) {
|
||||
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s%d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NETWORK)), 6);
|
||||
} else {
|
||||
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s%d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NETWORK)), 4);
|
||||
|
||||
//
|
||||
//Locate EFI_DEVICE_PATH_PROTOCOL to dynamically get IPv4/IPv6 protocol information.
|
||||
//
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
LoadFileHandles[Index],
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &DevicePath
|
||||
);
|
||||
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
while (!IsDevicePathEnd (DevicePath)) {
|
||||
if ((DevicePath->Type == MESSAGING_DEVICE_PATH) &&
|
||||
(DevicePath->SubType == MSG_IPv4_DP)) {
|
||||
|
||||
//
|
||||
//Get handle infomation
|
||||
//
|
||||
BufferSize = 0;
|
||||
NetworkHandles = NULL;
|
||||
Status = gBS->LocateHandle (
|
||||
ByProtocol,
|
||||
&gEfiSimpleNetworkProtocolGuid,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
NetworkHandles
|
||||
);
|
||||
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
NetworkHandles = AllocateZeroPool(BufferSize);
|
||||
if (NetworkHandles == NULL) {
|
||||
return (EFI_OUT_OF_RESOURCES);
|
||||
}
|
||||
Status = gBS->LocateHandle(
|
||||
ByProtocol,
|
||||
&gEfiSimpleNetworkProtocolGuid,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
NetworkHandles
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
//Get the MAC string
|
||||
//
|
||||
Status = NetLibGetMacString (
|
||||
*NetworkHandles,
|
||||
NULL,
|
||||
&MacStr
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
IPverStr = L" IPv4";
|
||||
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s%s%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NETWORK)),MacStr,IPverStr);
|
||||
break;
|
||||
}
|
||||
if((DevicePath->Type == MESSAGING_DEVICE_PATH) &&
|
||||
(DevicePath->SubType == MSG_IPv6_DP)) {
|
||||
|
||||
//
|
||||
//Get handle infomation
|
||||
//
|
||||
BufferSize = 0;
|
||||
NetworkHandles = NULL;
|
||||
Status = gBS->LocateHandle (
|
||||
ByProtocol,
|
||||
&gEfiSimpleNetworkProtocolGuid,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
NetworkHandles
|
||||
);
|
||||
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
NetworkHandles = AllocateZeroPool(BufferSize);
|
||||
if (NetworkHandles == NULL) {
|
||||
return (EFI_OUT_OF_RESOURCES);
|
||||
}
|
||||
Status = gBS->LocateHandle(
|
||||
ByProtocol,
|
||||
&gEfiSimpleNetworkProtocolGuid,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
NetworkHandles
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
//Get the MAC string
|
||||
//
|
||||
Status = NetLibGetMacString (
|
||||
*NetworkHandles,
|
||||
NULL,
|
||||
&MacStr
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
IPverStr = L" IPv6";
|
||||
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s%s%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NETWORK)),MacStr,IPverStr);
|
||||
break;
|
||||
}
|
||||
DevicePath = NextDevicePathNode (DevicePath);
|
||||
}
|
||||
|
||||
BdsLibBuildOptionFromHandle (LoadFileHandles[Index], BdsBootOptionList, Buffer);
|
||||
}
|
||||
|
||||
@@ -3478,6 +3633,7 @@ BdsLibBootNext (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT16 *BootNext;
|
||||
UINTN BootNextSize;
|
||||
CHAR16 Buffer[20];
|
||||
@@ -3502,13 +3658,17 @@ BdsLibBootNext (
|
||||
// Clear the boot next variable first
|
||||
//
|
||||
if (BootNext != NULL) {
|
||||
gRT->SetVariable (
|
||||
L"BootNext",
|
||||
&gEfiGlobalVariableGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
0,
|
||||
BootNext
|
||||
);
|
||||
Status = gRT->SetVariable (
|
||||
L"BootNext",
|
||||
&gEfiGlobalVariableGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
//
|
||||
// Deleting variable with current variable implementation shouldn't fail.
|
||||
//
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Start to build the boot option and try to boot
|
||||
@@ -3518,6 +3678,8 @@ BdsLibBootNext (
|
||||
ASSERT (BootOption != NULL);
|
||||
BdsLibConnectDevicePath (BootOption->DevicePath);
|
||||
BdsLibBootViaBootOption (BootOption, BootOption->DevicePath, &ExitDataSize, &ExitData);
|
||||
FreePool(BootOption);
|
||||
FreePool(BootNext);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4303,6 +4465,7 @@ BdsLibUpdateFvFileDevicePath (
|
||||
NewDevicePath = DevicePathFromHandle (FoundFvHandle);
|
||||
EfiInitializeFwVolDevicepathNode (&FvFileNode, FileGuid);
|
||||
NewDevicePath = AppendDevicePathNode (NewDevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &FvFileNode);
|
||||
ASSERT (NewDevicePath != NULL);
|
||||
*DevicePath = NewDevicePath;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
Reference in New Issue
Block a user