summaryrefslogtreecommitdiffstats
path: root/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c
diff options
context:
space:
mode:
Diffstat (limited to 'IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c')
-rw-r--r--IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c184
1 files changed, 110 insertions, 74 deletions
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c
index c4b83ba0ff..252da3c321 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c
@@ -165,9 +165,10 @@ Var_ChangeBootOrder (
BootOrderListSize * sizeof (UINT16),
BootOrderList
);
- if (EFI_ERROR (Status)) {
- return Status;
- }
+ //
+ // Changing variable without increasing its size with current variable implementation shouldn't fail.
+ //
+ ASSERT_EFI_ERROR (Status);
}
return EFI_SUCCESS;
}
@@ -303,9 +304,10 @@ Var_ChangeDriverOrder (
DriverOrderListSize * sizeof (UINT16),
DriverOrderList
);
- if (EFI_ERROR (Status)) {
- return Status;
- }
+ //
+ // Changing variable without increasing its size with current variable implementation shouldn't fail.
+ //
+ ASSERT_EFI_ERROR (Status);
}
return EFI_SUCCESS;
}
@@ -338,7 +340,10 @@ Var_UpdateAllConsoleOption (
GetDevicePathSize (OutDevicePath),
OutDevicePath
);
- ASSERT (!EFI_ERROR (Status));
+ //
+ // Changing variable without increasing its size with current variable implementation shouldn't fail.
+ //
+ ASSERT_EFI_ERROR (Status);
}
if (InpDevicePath != NULL) {
@@ -350,7 +355,10 @@ Var_UpdateAllConsoleOption (
GetDevicePathSize (InpDevicePath),
InpDevicePath
);
- ASSERT (!EFI_ERROR (Status));
+ //
+ // Changing variable without increasing its size with current variable implementation shouldn't fail.
+ //
+ ASSERT_EFI_ERROR (Status);
}
if (ErrDevicePath != NULL) {
@@ -362,7 +370,10 @@ Var_UpdateAllConsoleOption (
GetDevicePathSize (ErrDevicePath),
ErrDevicePath
);
- ASSERT (!EFI_ERROR (Status));
+ //
+ // Changing variable without increasing its size with current variable implementation shouldn't fail.
+ //
+ ASSERT_EFI_ERROR (Status);
}
}
@@ -667,38 +678,40 @@ Var_UpdateDriverOption (
BufferSize,
Buffer
);
- ASSERT_EFI_ERROR (Status);
- DriverOrderList = BdsLibGetVariableAndSize (
- L"DriverOrder",
- &gEfiGlobalVariableGuid,
- &DriverOrderListSize
- );
- NewDriverOrderList = AllocateZeroPool (DriverOrderListSize + sizeof (UINT16));
- ASSERT (NewDriverOrderList != NULL);
- if (DriverOrderList != NULL) {
- CopyMem (NewDriverOrderList, DriverOrderList, DriverOrderListSize);
- EfiLibDeleteVariable (L"DriverOrder", &gEfiGlobalVariableGuid);
- }
- NewDriverOrderList[DriverOrderListSize / sizeof (UINT16)] = Index;
+ if (!EFI_ERROR (Status)) {
+ DriverOrderList = BdsLibGetVariableAndSize (
+ L"DriverOrder",
+ &gEfiGlobalVariableGuid,
+ &DriverOrderListSize
+ );
+ NewDriverOrderList = AllocateZeroPool (DriverOrderListSize + sizeof (UINT16));
+ ASSERT (NewDriverOrderList != NULL);
+ if (DriverOrderList != NULL) {
+ CopyMem (NewDriverOrderList, DriverOrderList, DriverOrderListSize);
+ EfiLibDeleteVariable (L"DriverOrder", &gEfiGlobalVariableGuid);
+ }
+ NewDriverOrderList[DriverOrderListSize / sizeof (UINT16)] = Index;
- Status = gRT->SetVariable (
- L"DriverOrder",
- &gEfiGlobalVariableGuid,
- VAR_FLAG,
- DriverOrderListSize + sizeof (UINT16),
- NewDriverOrderList
- );
- ASSERT_EFI_ERROR (Status);
- if (DriverOrderList != NULL) {
- FreePool (DriverOrderList);
- }
- DriverOrderList = NULL;
- FreePool (NewDriverOrderList);
- InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);
- DriverOptionMenu.MenuNumber++;
+ Status = gRT->SetVariable (
+ L"DriverOrder",
+ &gEfiGlobalVariableGuid,
+ VAR_FLAG,
+ DriverOrderListSize + sizeof (UINT16),
+ NewDriverOrderList
+ );
+ if (DriverOrderList != NULL) {
+ FreePool (DriverOrderList);
+ }
+ DriverOrderList = NULL;
+ FreePool (NewDriverOrderList);
+ if (!EFI_ERROR (Status)) {
+ InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);
+ DriverOptionMenu.MenuNumber++;
- *DescriptionData = 0x0000;
- *OptionalData = 0x0000;
+ *DescriptionData = 0x0000;
+ *OptionalData = 0x0000;
+ }
+ }
return EFI_SUCCESS;
}
@@ -835,39 +848,41 @@ Var_UpdateBootOption (
BufferSize,
Buffer
);
- ASSERT_EFI_ERROR (Status);
+ if (!EFI_ERROR (Status)) {
- BootOrderList = BdsLibGetVariableAndSize (
+ BootOrderList = BdsLibGetVariableAndSize (
+ L"BootOrder",
+ &gEfiGlobalVariableGuid,
+ &BootOrderListSize
+ );
+ ASSERT (BootOrderList != NULL);
+ NewBootOrderList = AllocateZeroPool (BootOrderListSize + sizeof (UINT16));
+ ASSERT (NewBootOrderList != NULL);
+ CopyMem (NewBootOrderList, BootOrderList, BootOrderListSize);
+ NewBootOrderList[BootOrderListSize / sizeof (UINT16)] = Index;
+
+ if (BootOrderList != NULL) {
+ FreePool (BootOrderList);
+ }
+
+ Status = gRT->SetVariable (
L"BootOrder",
&gEfiGlobalVariableGuid,
- &BootOrderListSize
+ VAR_FLAG,
+ BootOrderListSize + sizeof (UINT16),
+ NewBootOrderList
);
- ASSERT (BootOrderList != NULL);
- NewBootOrderList = AllocateZeroPool (BootOrderListSize + sizeof (UINT16));
- ASSERT (NewBootOrderList != NULL);
- CopyMem (NewBootOrderList, BootOrderList, BootOrderListSize);
- NewBootOrderList[BootOrderListSize / sizeof (UINT16)] = Index;
+ if (!EFI_ERROR (Status)) {
- if (BootOrderList != NULL) {
- FreePool (BootOrderList);
- }
+ FreePool (NewBootOrderList);
+ NewBootOrderList = NULL;
+ InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link);
+ BootOptionMenu.MenuNumber++;
- Status = gRT->SetVariable (
- L"BootOrder",
- &gEfiGlobalVariableGuid,
- VAR_FLAG,
- BootOrderListSize + sizeof (UINT16),
- NewBootOrderList
- );
- ASSERT_EFI_ERROR (Status);
-
- FreePool (NewBootOrderList);
- NewBootOrderList = NULL;
- InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link);
- BootOptionMenu.MenuNumber++;
-
- NvRamMap->DescriptionData[0] = 0x0000;
- NvRamMap->OptionalData[0] = 0x0000;
+ NvRamMap->DescriptionData[0] = 0x0000;
+ NvRamMap->OptionalData[0] = 0x0000;
+ }
+ }
return EFI_SUCCESS;
}
@@ -992,6 +1007,10 @@ Var_UpdateBootOrder (
BootOrderListSize,
BootOrderList
);
+ //
+ // Changing the content without increasing its size with current variable implementation shouldn't fail.
+ //
+ ASSERT_EFI_ERROR (Status);
FreePool (BootOrderList);
BOpt_FreeMenu (&BootOptionMenu);
@@ -1061,10 +1080,11 @@ Var_UpdateDriverOrder (
DriverOrderListSize,
NewDriverOrderList
);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
+ //
+ // Changing the content without increasing its size with current variable implementation shouldn't fail.
+ //
+ ASSERT_EFI_ERROR (Status);
+
BOpt_FreeMenu (&DriverOptionMenu);
BOpt_GetDriverOptions (CallbackData);
return EFI_SUCCESS;
@@ -1219,10 +1239,14 @@ Var_UpdateBBSOption (
Status = gRT->SetVariable (
VAR_LEGACY_DEV_ORDER,
&gEfiLegacyDevOrderVariableGuid,
- VAR_FLAG,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
VarSize,
OriginalPtr
- );
+ );
+ //
+ // Changing the content without increasing its size with current variable implementation shouldn't fail.
+ //
+ ASSERT_EFI_ERROR (Status);
//
@@ -1252,8 +1276,12 @@ Var_UpdateBBSOption (
&EnBootOptionCount,
DisBootOption,
&DisBootOptionCount
- );
-
+ );
+ //
+ // Changing the content without increasing its size with current variable implementation shouldn't fail.
+ //
+ ASSERT_EFI_ERROR (Status);
+
Status = gRT->SetVariable (
L"BootOrder",
&gEfiGlobalVariableGuid,
@@ -1286,6 +1314,10 @@ Var_UpdateBBSOption (
OptionSize,
BootOptionVar
);
+ //
+ // Changing the content without increasing its size with current variable implementation shouldn't fail.
+ //
+ ASSERT_EFI_ERROR (Status);
FreePool (BootOptionVar);
}
@@ -1309,6 +1341,10 @@ Var_UpdateBBSOption (
OptionSize,
BootOptionVar
);
+ //
+ // Changing the content without increasing its size with current variable implementation shouldn't fail.
+ //
+ ASSERT_EFI_ERROR (Status);
FreePool (BootOptionVar);
}