X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=IntelFrameworkModulePkg%2FUniversal%2FBdsDxe%2FBootMaint%2FBBSsupport.c;h=7ba4fa2ab84f0f1e84813bf7230be6abccd46b6f;hb=c0a00b14385347c3c5e8d490fa4b065e1675a06c;hp=db0fed5834d512b415784f86e537d6f745ef131c;hpb=2d1f3dd497f343bc54b4a164d4e9f015ae04f7dc;p=mirror_edk2.git diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c index db0fed5834..7ba4fa2ab8 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c @@ -3,14 +3,8 @@ and manage the legacy boot option, all legacy boot option is getting from the legacy BBS table. -Copyright (c) 2004 - 2012, 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. +Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -53,9 +47,9 @@ OrderLegacyBootOption4SameType ( UINTN BootOrderSize; UINTN Index; UINTN StartPosition; - + BDS_COMMON_OPTION *BootOption; - + CHAR16 OptionName[sizeof ("Boot####")]; UINT16 *BbsIndexArray; UINT16 *DeviceTypeArray; @@ -82,12 +76,12 @@ OrderLegacyBootOption4SameType ( ASSERT (*DisBootOption != NULL); for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) { - + UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", BootOrder[Index]); InitializeListHead (&List); BootOption = BdsLibVariableToOption (&List, OptionName); ASSERT (BootOption != NULL); - + if ((DevicePathType (BootOption->DevicePath) == BBS_DEVICE_PATH) && (DevicePathSubType (BootOption->DevicePath) == BBS_BBS_DP)) { // @@ -119,7 +113,7 @@ OrderLegacyBootOption4SameType ( if (BbsIndexArray[Index] == (DevOrder[DevOrderCount] & 0xFF)) { StartPosition = MIN (StartPosition, Index); NewBootOption[DevOrderCount] = BootOrder[Index]; - + if ((DevOrder[DevOrderCount] & 0xFF00) == 0xFF00) { (*DisBootOption)[*DisBootOptionCount] = BootOrder[Index]; (*DisBootOptionCount)++; @@ -143,17 +137,21 @@ OrderLegacyBootOption4SameType ( BootOrderSize, BootOrder ); + // + // Changing content without increasing its size with current variable implementation shouldn't fail. + // ASSERT_EFI_ERROR (Status); FreePool (NewBootOption); FreePool (DeviceTypeArray); FreePool (BbsIndexArray); + FreePool (BootOrder); } /** Group the legacy boot options in the BootOption. - The routine assumes the boot options in the beginning that covers all the device + The routine assumes the boot options in the beginning that covers all the device types are ordered properly and re-position the following boot options just after the corresponding boot options with the same device type. For example: @@ -171,6 +169,7 @@ GroupMultipleLegacyBootOption4SameType ( VOID ) { + EFI_STATUS Status; UINTN Index; UINTN DeviceIndex; UINTN DeviceTypeIndex[7]; @@ -201,7 +200,7 @@ GroupMultipleLegacyBootOption4SameType ( // // Legacy Boot Option // - ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceType & 0xF) < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0])); + ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceType & 0xF) < ARRAY_SIZE (DeviceTypeIndex)); NextIndex = &DeviceTypeIndex[((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceType & 0xF]; if (*NextIndex == (UINTN) -1) { @@ -220,7 +219,7 @@ GroupMultipleLegacyBootOption4SameType ( // // Update the DeviceTypeIndex array to reflect the right shift operation // - for (DeviceIndex = 0; DeviceIndex < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0]); DeviceIndex++) { + for (DeviceIndex = 0; DeviceIndex < ARRAY_SIZE (DeviceTypeIndex); DeviceIndex++) { if (DeviceTypeIndex[DeviceIndex] != (UINTN) -1 && DeviceTypeIndex[DeviceIndex] >= *NextIndex) { DeviceTypeIndex[DeviceIndex]++; } @@ -233,13 +232,17 @@ GroupMultipleLegacyBootOption4SameType ( FreePool (BootOption); } - gRT->SetVariable ( - L"BootOrder", - &gEfiGlobalVariableGuid, - EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, - BootOrderSize, - BootOrder - ); + Status = gRT->SetVariable ( + L"BootOrder", + &gEfiGlobalVariableGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, + BootOrderSize, + BootOrder + ); + // + // Changing content without increasing its size with current variable implementation shouldn't fail. + // + ASSERT_EFI_ERROR (Status); FreePool (BootOrder); }