]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c
1. Use MemoryAllocationLib to replace boot services memory services functions in...
[mirror_edk2.git] / EdkModulePkg / Universal / Variable / RuntimeDxe / Variable.c
index 98137c6a3f0cf83d26a99320a34b1a5da07ec2db..e224558651e24fa5c100a9ea1b0435b630a83d73 100644 (file)
@@ -424,13 +424,9 @@ Returns:
     Variable = NextVariable;\r
   }\r
 \r
-  Status = gBS->AllocatePool (\r
-                  EfiBootServicesData,\r
-                  ValidBufferSize,\r
-                  (VOID **) &ValidBuffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
+  ValidBuffer = AllocatePool (ValidBufferSize);\r
+  if (ValidBuffer == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
   SetMem (ValidBuffer, ValidBufferSize, 0xff);\r
@@ -481,7 +477,7 @@ Returns:
     }\r
   }\r
 \r
-  gBS->FreePool (ValidBuffer);\r
+  FreePool (ValidBuffer);\r
 \r
   if (EFI_ERROR (Status)) {\r
     *LastVariableOffset = 0;\r
@@ -1253,13 +1249,13 @@ Returns:
         *RemainingVariableStorageSize -= VariableSize;\r
       }\r
     }\r
-    \r
+\r
     //\r
     // Go to the next one\r
     //\r
     Variable = NextVariable;\r
   }\r
\r
+\r
   ReleaseLockOnlyAtBootTime (&Global->VariableServicesLock);\r
   return EFI_SUCCESS;\r
 }\r
@@ -1308,14 +1304,9 @@ Returns:
   UINTN                           Index;\r
   UINT8                           Data;\r
 \r
-  Status = gBS->AllocatePool (\r
-                  EfiRuntimeServicesData,\r
-                  sizeof (ESAL_VARIABLE_GLOBAL),\r
-                  (VOID **) &mVariableModuleGlobal\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
+  mVariableModuleGlobal = AllocateRuntimePool (sizeof (ESAL_VARIABLE_GLOBAL));\r
+  if (mVariableModuleGlobal == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
   EfiInitializeLock(&mVariableModuleGlobal->VariableGlobal[Physical].VariableServicesLock, EFI_TPL_NOTIFY);\r
@@ -1323,15 +1314,10 @@ Returns:
   //\r
   // Allocate memory for volatile variable store\r
   //\r
-  Status = gBS->AllocatePool (\r
-                  EfiRuntimeServicesData,\r
-                  VARIABLE_STORE_SIZE + SCRATCH_SIZE,\r
-                  (VOID **) &VolatileVariableStore\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (mVariableModuleGlobal);\r
-    return Status;\r
+  VolatileVariableStore = AllocateRuntimePool (VARIABLE_STORE_SIZE + SCRATCH_SIZE);\r
+  if (VolatileVariableStore == NULL) {\r
+    FreePool (mVariableModuleGlobal);\r
+    return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
   SetMem (VolatileVariableStore, VARIABLE_STORE_SIZE + SCRATCH_SIZE, 0xff);\r
@@ -1367,8 +1353,8 @@ Returns:
 \r
   Status      = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);\r
   if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (mVariableModuleGlobal);\r
-    gBS->FreePool (VolatileVariableStore);\r
+    FreePool (mVariableModuleGlobal);\r
+    FreePool (VolatileVariableStore);\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
@@ -1378,8 +1364,8 @@ Returns:
                   GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (mVariableModuleGlobal);\r
-    gBS->FreePool (VolatileVariableStore);\r
+    FreePool (mVariableModuleGlobal);\r
+    FreePool (VolatileVariableStore);\r
     return EFI_UNSUPPORTED;\r
   }\r
   //\r
@@ -1448,8 +1434,8 @@ Returns:
     }\r
 \r
     if (EFI_ERROR (Status)) {\r
-      gBS->FreePool (mVariableModuleGlobal);\r
-      gBS->FreePool (VolatileVariableStore);\r
+      FreePool (mVariableModuleGlobal);\r
+      FreePool (VolatileVariableStore);\r
       return Status;\r
     }\r
 \r
@@ -1473,8 +1459,8 @@ Returns:
   }\r
 \r
   if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (mVariableModuleGlobal);\r
-    gBS->FreePool (VolatileVariableStore);\r
+    FreePool (mVariableModuleGlobal);\r
+    FreePool (VolatileVariableStore);\r
   }\r
 \r
   return Status;\r