/** @file\r
Variable operation that will be used by bootmaint\r
\r
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2015, 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
BootOrderListSize * sizeof (UINT16),\r
BootOrderList\r
);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
+ //\r
+ // Changing variable without increasing its size with current variable implementation shouldn't fail.\r
+ //\r
+ ASSERT_EFI_ERROR (Status);\r
}\r
return EFI_SUCCESS;\r
}\r
DriverOrderListSize * sizeof (UINT16),\r
DriverOrderList\r
);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
+ //\r
+ // Changing variable without increasing its size with current variable implementation shouldn't fail.\r
+ //\r
+ ASSERT_EFI_ERROR (Status);\r
}\r
return EFI_SUCCESS;\r
}\r
GetDevicePathSize (OutDevicePath),\r
OutDevicePath\r
);\r
- ASSERT (!EFI_ERROR (Status));\r
+ //\r
+ // Changing variable without increasing its size with current variable implementation shouldn't fail.\r
+ //\r
+ ASSERT_EFI_ERROR (Status);\r
}\r
\r
if (InpDevicePath != NULL) {\r
GetDevicePathSize (InpDevicePath),\r
InpDevicePath\r
);\r
- ASSERT (!EFI_ERROR (Status));\r
+ //\r
+ // Changing variable without increasing its size with current variable implementation shouldn't fail.\r
+ //\r
+ ASSERT_EFI_ERROR (Status);\r
}\r
\r
if (ErrDevicePath != NULL) {\r
GetDevicePathSize (ErrDevicePath),\r
ErrDevicePath\r
);\r
- ASSERT (!EFI_ERROR (Status));\r
+ //\r
+ // Changing variable without increasing its size with current variable implementation shouldn't fail.\r
+ //\r
+ ASSERT_EFI_ERROR (Status);\r
}\r
}\r
\r
);\r
\r
if (*DescriptionData == 0x0000) {\r
- StrCpy (DescriptionData, DriverString);\r
+ StrCpyS (DescriptionData, DESCRIPTION_DATA_SIZE, DriverString);\r
}\r
\r
BufferSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (DescriptionData);\r
BufferSize,\r
Buffer\r
);\r
- ASSERT_EFI_ERROR (Status);\r
- DriverOrderList = BdsLibGetVariableAndSize (\r
- L"DriverOrder",\r
- &gEfiGlobalVariableGuid,\r
- &DriverOrderListSize\r
- );\r
- NewDriverOrderList = AllocateZeroPool (DriverOrderListSize + sizeof (UINT16));\r
- ASSERT (NewDriverOrderList != NULL);\r
- if (DriverOrderList != NULL) {\r
- CopyMem (NewDriverOrderList, DriverOrderList, DriverOrderListSize);\r
- EfiLibDeleteVariable (L"DriverOrder", &gEfiGlobalVariableGuid);\r
- }\r
- NewDriverOrderList[DriverOrderListSize / sizeof (UINT16)] = Index;\r
+ if (!EFI_ERROR (Status)) {\r
+ DriverOrderList = BdsLibGetVariableAndSize (\r
+ L"DriverOrder",\r
+ &gEfiGlobalVariableGuid,\r
+ &DriverOrderListSize\r
+ );\r
+ NewDriverOrderList = AllocateZeroPool (DriverOrderListSize + sizeof (UINT16));\r
+ ASSERT (NewDriverOrderList != NULL);\r
+ if (DriverOrderList != NULL) {\r
+ CopyMem (NewDriverOrderList, DriverOrderList, DriverOrderListSize);\r
+ EfiLibDeleteVariable (L"DriverOrder", &gEfiGlobalVariableGuid);\r
+ }\r
+ NewDriverOrderList[DriverOrderListSize / sizeof (UINT16)] = Index;\r
\r
- Status = gRT->SetVariable (\r
- L"DriverOrder",\r
- &gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
- DriverOrderListSize + sizeof (UINT16),\r
- NewDriverOrderList\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
- if (DriverOrderList != NULL) {\r
- FreePool (DriverOrderList);\r
- }\r
- DriverOrderList = NULL;\r
- FreePool (NewDriverOrderList);\r
- InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);\r
- DriverOptionMenu.MenuNumber++;\r
+ Status = gRT->SetVariable (\r
+ L"DriverOrder",\r
+ &gEfiGlobalVariableGuid,\r
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+ DriverOrderListSize + sizeof (UINT16),\r
+ NewDriverOrderList\r
+ );\r
+ if (DriverOrderList != NULL) {\r
+ FreePool (DriverOrderList);\r
+ }\r
+ DriverOrderList = NULL;\r
+ FreePool (NewDriverOrderList);\r
+ if (!EFI_ERROR (Status)) {\r
+ InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);\r
+ DriverOptionMenu.MenuNumber++;\r
+\r
+ //\r
+ // Update "change boot order" page used data, append the new add boot\r
+ // option at the end.\r
+ //\r
+ Index = 0;\r
+ while (CallbackData->BmmFakeNvData.DriverOptionOrder[Index] != 0) {\r
+ Index++;\r
+ }\r
+ CallbackData->BmmFakeNvData.DriverOptionOrder[Index] = (UINT32) (NewMenuEntry->OptionNumber + 1);\r
\r
- *DescriptionData = 0x0000;\r
- *OptionalData = 0x0000;\r
+ *DescriptionData = 0x0000;\r
+ *OptionalData = 0x0000;\r
+ }\r
+ }\r
return EFI_SUCCESS;\r
}\r
\r
Index = BOpt_GetBootOptionNumber () ;\r
UnicodeSPrint (BootString, sizeof (BootString), L"Boot%04x", Index);\r
\r
- if (NvRamMap->DescriptionData[0] == 0x0000) {\r
- StrCpy (NvRamMap->DescriptionData, BootString);\r
+ if (NvRamMap->BootDescriptionData[0] == 0x0000) {\r
+ StrCpyS (\r
+ NvRamMap->BootDescriptionData,\r
+ sizeof (NvRamMap->BootDescriptionData) / sizeof (NvRamMap->BootDescriptionData[0]),\r
+ BootString\r
+ );\r
}\r
\r
- BufferSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (NvRamMap->DescriptionData);\r
+ BufferSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (NvRamMap->BootDescriptionData);\r
BufferSize += GetDevicePathSize (CallbackData->LoadContext->FilePathList);\r
\r
- if (NvRamMap->OptionalData[0] != 0x0000) {\r
+ if (NvRamMap->BootOptionalData[0] != 0x0000) {\r
OptionalDataExist = TRUE;\r
- BufferSize += StrSize (NvRamMap->OptionalData);\r
+ BufferSize += StrSize (NvRamMap->BootOptionalData);\r
}\r
\r
Buffer = AllocateZeroPool (BufferSize);\r
\r
CopyMem (\r
Ptr,\r
- NvRamMap->DescriptionData,\r
- StrSize (NvRamMap->DescriptionData)\r
+ NvRamMap->BootDescriptionData,\r
+ StrSize (NvRamMap->BootDescriptionData)\r
);\r
\r
- NewLoadContext->Description = AllocateZeroPool (StrSize (NvRamMap->DescriptionData));\r
+ NewLoadContext->Description = AllocateZeroPool (StrSize (NvRamMap->BootDescriptionData));\r
ASSERT (NewLoadContext->Description != NULL);\r
\r
NewMenuEntry->DisplayString = NewLoadContext->Description;\r
CopyMem (\r
NewLoadContext->Description,\r
(VOID *) Ptr,\r
- StrSize (NvRamMap->DescriptionData)\r
+ StrSize (NvRamMap->BootDescriptionData)\r
);\r
\r
- Ptr += StrSize (NvRamMap->DescriptionData);\r
+ Ptr += StrSize (NvRamMap->BootDescriptionData);\r
CopyMem (\r
Ptr,\r
CallbackData->LoadContext->FilePathList,\r
if (OptionalDataExist) {\r
Ptr += (UINT8) GetDevicePathSize (CallbackData->LoadContext->FilePathList);\r
\r
- CopyMem (Ptr, NvRamMap->OptionalData, StrSize (NvRamMap->OptionalData));\r
+ CopyMem (Ptr, NvRamMap->BootOptionalData, StrSize (NvRamMap->BootOptionalData));\r
}\r
\r
Status = gRT->SetVariable (\r
BufferSize,\r
Buffer\r
);\r
- ASSERT_EFI_ERROR (Status);\r
+ if (!EFI_ERROR (Status)) {\r
\r
- BootOrderList = BdsLibGetVariableAndSize (\r
+ BootOrderList = BdsLibGetVariableAndSize (\r
+ L"BootOrder",\r
+ &gEfiGlobalVariableGuid,\r
+ &BootOrderListSize\r
+ );\r
+ ASSERT (BootOrderList != NULL);\r
+ NewBootOrderList = AllocateZeroPool (BootOrderListSize + sizeof (UINT16));\r
+ ASSERT (NewBootOrderList != NULL);\r
+ CopyMem (NewBootOrderList, BootOrderList, BootOrderListSize);\r
+ NewBootOrderList[BootOrderListSize / sizeof (UINT16)] = Index;\r
+\r
+ if (BootOrderList != NULL) {\r
+ FreePool (BootOrderList);\r
+ }\r
+\r
+ Status = gRT->SetVariable (\r
L"BootOrder",\r
&gEfiGlobalVariableGuid,\r
- &BootOrderListSize\r
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+ BootOrderListSize + sizeof (UINT16),\r
+ NewBootOrderList\r
);\r
- ASSERT (BootOrderList != NULL);\r
- NewBootOrderList = AllocateZeroPool (BootOrderListSize + sizeof (UINT16));\r
- ASSERT (NewBootOrderList != NULL);\r
- CopyMem (NewBootOrderList, BootOrderList, BootOrderListSize);\r
- NewBootOrderList[BootOrderListSize / sizeof (UINT16)] = Index;\r
+ if (!EFI_ERROR (Status)) {\r
+\r
+ FreePool (NewBootOrderList);\r
+ NewBootOrderList = NULL;\r
+ InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link);\r
+ BootOptionMenu.MenuNumber++;\r
+\r
+ //\r
+ // Update "change driver order" page used data, append the new add driver\r
+ // option at the end.\r
+ //\r
+ Index = 0;\r
+ while (CallbackData->BmmFakeNvData.BootOptionOrder[Index] != 0) {\r
+ Index++;\r
+ }\r
+ CallbackData->BmmFakeNvData.BootOptionOrder[Index] = (UINT32) (NewMenuEntry->OptionNumber + 1);\r
\r
- if (BootOrderList != NULL) {\r
- FreePool (BootOrderList);\r
+ NvRamMap->BootDescriptionData[0] = 0x0000;\r
+ NvRamMap->BootOptionalData[0] = 0x0000;\r
+ }\r
}\r
-\r
- Status = gRT->SetVariable (\r
- L"BootOrder",\r
- &gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
- BootOrderListSize + sizeof (UINT16),\r
- NewBootOrderList\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- FreePool (NewBootOrderList);\r
- NewBootOrderList = NULL;\r
- InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link);\r
- BootOptionMenu.MenuNumber++;\r
-\r
- NvRamMap->DescriptionData[0] = 0x0000;\r
- NvRamMap->OptionalData[0] = 0x0000;\r
return EFI_SUCCESS;\r
}\r
\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
- ASSERT (BootOptionMenu.MenuNumber <= (sizeof (CallbackData->BmmFakeNvData.OptionOrder) / sizeof (CallbackData->BmmFakeNvData.OptionOrder[0])));\r
+ ASSERT (BootOptionMenu.MenuNumber <= (sizeof (CallbackData->BmmFakeNvData.BootOptionOrder) / sizeof (CallbackData->BmmFakeNvData.BootOptionOrder[0])));\r
\r
- for (OrderIndex = 0; (OrderIndex < BootOptionMenu.MenuNumber) && (CallbackData->BmmFakeNvData.OptionOrder[OrderIndex] != 0); OrderIndex++) {\r
+ for (OrderIndex = 0; (OrderIndex < BootOptionMenu.MenuNumber) && (CallbackData->BmmFakeNvData.BootOptionOrder[OrderIndex] != 0); OrderIndex++) {\r
for (Index = OrderIndex; Index < BootOrderListSize / sizeof (UINT16); Index++) {\r
- if ((BootOrderList[Index] == (UINT16) (CallbackData->BmmFakeNvData.OptionOrder[OrderIndex] - 1)) && (OrderIndex != Index)) {\r
+ if ((BootOrderList[Index] == (UINT16) (CallbackData->BmmFakeNvData.BootOptionOrder[OrderIndex] - 1)) && (OrderIndex != Index)) {\r
OptionNumber = BootOrderList[Index];\r
CopyMem (&BootOrderList[OrderIndex + 1], &BootOrderList[OrderIndex], (Index - OrderIndex) * sizeof (UINT16));\r
BootOrderList[OrderIndex] = OptionNumber;\r
BootOrderListSize,\r
BootOrderList\r
);\r
+ //\r
+ // Changing the content without increasing its size with current variable implementation shouldn't fail.\r
+ //\r
+ ASSERT_EFI_ERROR (Status);\r
FreePool (BootOrderList);\r
\r
GroupMultipleLegacyBootOption4SameType ();\r
FreePool (DriverOrderList);\r
}\r
\r
- ASSERT (DriverOptionMenu.MenuNumber <= (sizeof (CallbackData->BmmFakeNvData.OptionOrder) / sizeof (CallbackData->BmmFakeNvData.OptionOrder[0])));\r
+ ASSERT (DriverOptionMenu.MenuNumber <= (sizeof (CallbackData->BmmFakeNvData.DriverOptionOrder) / sizeof (CallbackData->BmmFakeNvData.DriverOptionOrder[0])));\r
for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {\r
- NewDriverOrderList[Index] = (UINT16) (CallbackData->BmmFakeNvData.OptionOrder[Index] - 1);\r
+ NewDriverOrderList[Index] = (UINT16) (CallbackData->BmmFakeNvData.DriverOptionOrder[Index] - 1);\r
}\r
\r
Status = gRT->SetVariable (\r
DriverOrderListSize,\r
NewDriverOrderList\r
);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
+ //\r
+ // Changing the content without increasing its size with current variable implementation shouldn't fail.\r
+ //\r
+ ASSERT_EFI_ERROR (Status);\r
+ \r
BOpt_FreeMenu (&DriverOptionMenu);\r
BOpt_GetDriverOptions (CallbackData);\r
return EFI_SUCCESS;\r
is also updated.\r
\r
@param CallbackData The context data for BMM.\r
+ @param FormId The form id.\r
\r
@return EFI_SUCCESS The function completed successfully.\r
@retval EFI_NOT_FOUND If VAR_LEGACY_DEV_ORDER and gEfiLegacyDevOrderVariableGuid EFI Variable can be found.\r
**/\r
EFI_STATUS\r
Var_UpdateBBSOption (\r
- IN BMM_CALLBACK_DATA *CallbackData\r
+ IN BMM_CALLBACK_DATA *CallbackData,\r
+ IN EFI_FORM_ID FormId\r
)\r
{\r
UINTN Index;\r
DisMap = NULL;\r
NewOrder = NULL;\r
\r
- switch (CallbackData->BmmPreviousPageId) {\r
+ switch (FormId) {\r
case FORM_SET_FD_ORDER_ID:\r
OptionMenu = (BM_MENU_OPTION *) &LegacyFDMenu;\r
LegacyDev = CallbackData->BmmFakeNvData.LegacyFD;\r
Status = gRT->SetVariable (\r
VAR_LEGACY_DEV_ORDER,\r
&gEfiLegacyDevOrderVariableGuid,\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
VarSize,\r
OriginalPtr\r
);\r
OptionSize,\r
BootOptionVar\r
);\r
+ //\r
+ // Changing the content without increasing its size with current variable implementation shouldn't fail.\r
+ //\r
+ ASSERT_EFI_ERROR (Status);\r
\r
FreePool (BootOptionVar);\r
}\r
OptionSize,\r
BootOptionVar\r
);\r
+ //\r
+ // Changing the content without increasing its size with current variable implementation shouldn't fail.\r
+ //\r
+ ASSERT_EFI_ERROR (Status);\r
\r
FreePool (BootOptionVar);\r
}\r