]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/Variable.c
Report the setting variable failure to platform through the status code when core...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / BootMaint / Variable.c
index ef36ae2dc81b39122e62a6c8d55de76c46470df7..f374e5b2561ae4ab53fe16c0b123a0479f9996f1 100644 (file)
@@ -1,7 +1,7 @@
 /** @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 - 2014, 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
@@ -165,9 +165,10 @@ Var_ChangeBootOrder (
                     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
@@ -303,9 +304,10 @@ Var_ChangeDriverOrder (
                     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
@@ -338,7 +340,10 @@ Var_UpdateAllConsoleOption (
                     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
@@ -350,7 +355,10 @@ Var_UpdateAllConsoleOption (
                     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
@@ -362,7 +370,10 @@ Var_UpdateAllConsoleOption (
                     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
@@ -667,38 +678,40 @@ Var_UpdateDriverOption (
                   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
-  *DescriptionData  = 0x0000;\r
-  *OptionalData     = 0x0000;\r
+      *DescriptionData  = 0x0000;\r
+      *OptionalData     = 0x0000;\r
+    }\r
+  }\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -835,39 +848,41 @@ Var_UpdateBootOption (
                   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
-  if (BootOrderList != NULL) {\r
-    FreePool (BootOrderList);\r
-  }\r
+      FreePool (NewBootOrderList);\r
+      NewBootOrderList = NULL;\r
+      InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link);\r
+      BootOptionMenu.MenuNumber++;\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
+      NvRamMap->DescriptionData[0]  = 0x0000;\r
+      NvRamMap->OptionalData[0]     = 0x0000;\r
+    }\r
+  }\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -987,6 +1002,10 @@ Var_UpdateBootOrder (
                   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
@@ -1058,10 +1077,11 @@ Var_UpdateDriverOrder (
                   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
@@ -1258,6 +1278,10 @@ Var_UpdateBBSOption (
                       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
@@ -1281,6 +1305,10 @@ Var_UpdateBBSOption (
                       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