and manage the legacy boot option, all legacy boot option is getting from\r
the legacy BBS table.\r
\r
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
UINTN BootOrderSize;\r
UINTN Index;\r
UINTN StartPosition;\r
- \r
+\r
BDS_COMMON_OPTION *BootOption;\r
- \r
+\r
CHAR16 OptionName[sizeof ("Boot####")];\r
UINT16 *BbsIndexArray;\r
UINT16 *DeviceTypeArray;\r
ASSERT (*DisBootOption != NULL);\r
\r
for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {\r
- \r
+\r
UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", BootOrder[Index]);\r
InitializeListHead (&List);\r
BootOption = BdsLibVariableToOption (&List, OptionName);\r
ASSERT (BootOption != NULL);\r
- \r
+\r
if ((DevicePathType (BootOption->DevicePath) == BBS_DEVICE_PATH) &&\r
(DevicePathSubType (BootOption->DevicePath) == BBS_BBS_DP)) {\r
//\r
if (BbsIndexArray[Index] == (DevOrder[DevOrderCount] & 0xFF)) {\r
StartPosition = MIN (StartPosition, Index);\r
NewBootOption[DevOrderCount] = BootOrder[Index];\r
- \r
+\r
if ((DevOrder[DevOrderCount] & 0xFF00) == 0xFF00) {\r
(*DisBootOption)[*DisBootOptionCount] = BootOrder[Index];\r
(*DisBootOptionCount)++;\r
BootOrderSize,\r
BootOrder\r
);\r
+ //\r
+ // Changing content without increasing its size with current variable implementation shouldn't fail.\r
+ //\r
ASSERT_EFI_ERROR (Status);\r
\r
FreePool (NewBootOption);\r
FreePool (DeviceTypeArray);\r
FreePool (BbsIndexArray);\r
+ FreePool (BootOrder);\r
}\r
\r
/**\r
Group the legacy boot options in the BootOption.\r
\r
- The routine assumes the boot options in the beginning that covers all the device \r
+ The routine assumes the boot options in the beginning that covers all the device\r
types are ordered properly and re-position the following boot options just after\r
the corresponding boot options with the same device type.\r
For example:\r
VOID\r
)\r
{\r
+ EFI_STATUS Status;\r
UINTN Index;\r
UINTN DeviceIndex;\r
UINTN DeviceTypeIndex[7];\r
//\r
// Legacy Boot Option\r
//\r
- ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceType & 0xF) < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0]));\r
+ ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceType & 0xF) < ARRAY_SIZE (DeviceTypeIndex));\r
NextIndex = &DeviceTypeIndex[((BBS_BBS_DEVICE_PATH *) BootOption->DevicePath)->DeviceType & 0xF];\r
\r
if (*NextIndex == (UINTN) -1) {\r
//\r
// Update the DeviceTypeIndex array to reflect the right shift operation\r
//\r
- for (DeviceIndex = 0; DeviceIndex < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0]); DeviceIndex++) {\r
+ for (DeviceIndex = 0; DeviceIndex < ARRAY_SIZE (DeviceTypeIndex); DeviceIndex++) {\r
if (DeviceTypeIndex[DeviceIndex] != (UINTN) -1 && DeviceTypeIndex[DeviceIndex] >= *NextIndex) {\r
DeviceTypeIndex[DeviceIndex]++;\r
}\r
FreePool (BootOption);\r
}\r
\r
- gRT->SetVariable (\r
- L"BootOrder",\r
- &gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
- BootOrderSize,\r
- BootOrder\r
- );\r
+ Status = gRT->SetVariable (\r
+ L"BootOrder",\r
+ &gEfiGlobalVariableGuid,\r
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+ BootOrderSize,\r
+ BootOrder\r
+ );\r
+ //\r
+ // Changing content without increasing its size with current variable implementation shouldn't fail.\r
+ //\r
+ ASSERT_EFI_ERROR (Status);\r
FreePool (BootOrder);\r
}\r
\r