X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=IntelFrameworkModulePkg%2FUniversal%2FBdsDxe%2FBootMaint%2FBBSsupport.c;h=f9ba0a7bc78320037caa010e3490249085f77ed2;hb=0a6f48249a601f88af124ae1ff6814b195b699c3;hp=adf84f42f78e1d35d1696a2d44e91f418b5a5c92;hpb=69fc8f080e07ea026e8fbb8610cfb89c099d6db2;p=mirror_edk2.git diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c index adf84f42f7..f9ba0a7bc7 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c @@ -3,7 +3,7 @@ and manage the legacy boot option, all legacy boot option is getting from the legacy BBS table. -Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2018, 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 @@ -53,9 +53,9 @@ OrderLegacyBootOption4SameType ( UINTN BootOrderSize; UINTN Index; UINTN StartPosition; - + BDS_COMMON_OPTION *BootOption; - + CHAR16 OptionName[sizeof ("Boot####")]; UINT16 *BbsIndexArray; UINT16 *DeviceTypeArray; @@ -82,12 +82,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 +119,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)++; @@ -151,12 +151,13 @@ OrderLegacyBootOption4SameType ( 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: @@ -205,7 +206,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) { @@ -224,7 +225,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]++; }