1. Invoke InstallConfigurationTable () in OnReadyToBoot() to avoid the new registered...
authorgdong1 <gdong1@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 31 Dec 2010 04:31:42 +0000 (04:31 +0000)
committergdong1 <gdong1@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 31 Dec 2010 04:31:42 +0000 (04:31 +0000)
2. For SMM variable driver, it doesn’t need to mark the variable storage region of the FLASH as RUNTIME, so only keep it for non-SMM variable driver.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11212 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c

index 8bf585a..9da00f1 100644 (file)
@@ -2259,9 +2259,6 @@ VariableWriteServiceInitialize (
   VARIABLE_STORE_HEADER           *VariableStoreHeader;\r
   UINTN                           Index;\r
   UINT8                           Data;\r
-  EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;\r
-  EFI_PHYSICAL_ADDRESS            BaseAddress;\r
-  UINT64                          Length;\r
   EFI_PHYSICAL_ADDRESS            VariableStoreBase;\r
   UINT64                          VariableStoreLength;\r
 \r
@@ -2291,26 +2288,6 @@ VariableWriteServiceInitialize (
     }\r
   }\r
 \r
-  //\r
-  // Mark the variable storage region of the FLASH as RUNTIME.\r
-  //\r
-  BaseAddress = VariableStoreBase & (~EFI_PAGE_MASK);\r
-  Length      = VariableStoreLength + (VariableStoreBase - BaseAddress);\r
-  Length      = (Length + EFI_PAGE_SIZE - 1) & (~EFI_PAGE_MASK);\r
-\r
-  Status      = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME attribute to Flash.\n"));\r
-  } else {\r
-    Status = gDS->SetMemorySpaceAttributes (\r
-                    BaseAddress,\r
-                    Length,\r
-                    GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME attribute to Flash.\n"));\r
-    }\r
-  }\r
   return EFI_SUCCESS;\r
 }\r
 \r
index 70723b3..86028be 100644 (file)
@@ -255,6 +255,9 @@ OnReadyToBoot (
   )\r
 {\r
   ReclaimForOS ();\r
+  if (FeaturePcdGet (PcdVariableCollectStatistics)) {\r
+    gBS->InstallConfigurationTable (&gEfiVariableGuid, gVariableInfo);\r
+  }\r
 }\r
 \r
 \r
@@ -279,6 +282,11 @@ FtwNotificationEvent (
   EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL      *FvbProtocol;\r
   EFI_FAULT_TOLERANT_WRITE_PROTOCOL       *FtwProtocol;\r
   EFI_PHYSICAL_ADDRESS                    NvStorageVariableBase;\r
+  EFI_GCD_MEMORY_SPACE_DESCRIPTOR         GcdDescriptor;\r
+  EFI_PHYSICAL_ADDRESS                    BaseAddress;\r
+  UINT64                                  Length;\r
+  EFI_PHYSICAL_ADDRESS                    VariableStoreBase;\r
+  UINT64                                  VariableStoreLength;\r
 \r
   //\r
   // Ensure FTW protocol is installed.\r
@@ -300,6 +308,29 @@ FtwNotificationEvent (
     return ;\r
   }\r
   mVariableModuleGlobal->FvbInstance = FvbProtocol;\r
+\r
+  //\r
+  // Mark the variable storage region of the FLASH as RUNTIME.\r
+  //\r
+  VariableStoreBase   = mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase;\r
+  VariableStoreLength = ((VARIABLE_STORE_HEADER *)(UINTN)VariableStoreBase)->Size;\r
+  BaseAddress = VariableStoreBase & (~EFI_PAGE_MASK);\r
+  Length      = VariableStoreLength + (VariableStoreBase - BaseAddress);\r
+  Length      = (Length + EFI_PAGE_SIZE - 1) & (~EFI_PAGE_MASK);\r
+\r
+  Status      = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME attribute to Flash.\n"));\r
+  } else {\r
+    Status = gDS->SetMemorySpaceAttributes (\r
+                    BaseAddress,\r
+                    Length,\r
+                    GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME attribute to Flash.\n"));\r
+    }\r
+  }\r
   \r
   Status = VariableWriteServiceInitialize ();\r
   ASSERT_EFI_ERROR (Status);\r
@@ -395,9 +426,6 @@ VariableServiceInitialize (
              &ReadyToBootEvent\r
              );\r
 \r
-  if (FeaturePcdGet (PcdVariableCollectStatistics)) {\r
-    gBS->InstallConfigurationTable (&gEfiVariableGuid, gVariableInfo);\r
-  }\r
   return EFI_SUCCESS;\r
 }\r
 \r