Use Hob to get the variable base address in NV storage, but this need to be changed...
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 6 Jul 2007 09:07:47 +0000 (09:07 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 6 Jul 2007 09:07:47 +0000 (09:07 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3111 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/VariableRuntimeDxe/CommonHeader.h
MdeModulePkg/Universal/VariableRuntimeDxe/Variable.c
MdeModulePkg/Universal/VariableRuntimeDxe/Variable.inf
Nt32Pkg/Nt32Pkg.dsc
Nt32Pkg/Nt32Pkg.fdf

index 7148577..2cb78e7 100644 (file)
@@ -43,6 +43,8 @@
 #include <Library/UefiLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
-\r
+#include <Library/HobLib.h>\r
+#include <Common/FlashMap.h>\r
+#include <Guid/FlashMapHob.h>\r
 \r
 #endif\r
index 4322961..6f663d4 100644 (file)
@@ -1299,13 +1299,15 @@ Returns:
   EFI_PHYSICAL_ADDRESS            FvVolHdr;\r
 \r
   UINT64                          TempVariableStoreHeader;\r
-\r
+  UINT64                          TempVariableStoreLen;\r
   EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;\r
   EFI_FLASH_SUBAREA_ENTRY         VariableStoreEntry;\r
   UINT64                          BaseAddress;\r
   UINT64                          Length;\r
   UINTN                           Index;\r
   UINT8                           Data;\r
+  EFI_PEI_HOB_POINTERS            FvHob;\r
+  EFI_FLASH_MAP_ENTRY_DATA        *FlashMapEntry;\r
 \r
   mVariableModuleGlobal = AllocateRuntimePool (sizeof (ESAL_VARIABLE_GLOBAL));\r
   if (mVariableModuleGlobal == NULL) {\r
@@ -1341,11 +1343,29 @@ Returns:
   //\r
   // Get non volatile varaible store\r
   //\r
+  // BUGBUG: Here should use dynamic PCD to get NvStorageVariableBase when build tools is ready.\r
+  TempVariableStoreHeader = 0;\r
+  TempVariableStoreLen    = 0;\r
+  FvHob.Raw = GetHobList ();\r
+  while ((FvHob.Raw = GetNextGuidHob (&gEfiFlashMapHobGuid, FvHob.Raw)) != NULL) {\r
+\r
+    FlashMapEntry = (EFI_FLASH_MAP_ENTRY_DATA *) GET_GUID_HOB_DATA (FvHob.Guid);\r
+      \r
+    //\r
+    // Get the FTW work space Flash Map SUB area\r
+    //\r
+    if ((FlashMapEntry->AreaType == EFI_FLASH_AREA_EFI_VARIABLES) && (FlashMapEntry->NumEntries == 1)) {\r
+      TempVariableStoreHeader = FlashMapEntry->Entries[0].Base;\r
+           TempVariableStoreLen    = FlashMapEntry->Entries[0].Length;\r
+    }\r
+    FvHob.Raw = GET_NEXT_HOB (FvHob);\r
+  }\r
+  ASSERT ((TempVariableStoreHeader != 0) && (TempVariableStoreLen != 0));\r
 \r
-  TempVariableStoreHeader = (UINT64) PcdGet32 (PcdFlashNvStorageVariableBase);\r
+  //TempVariableStoreHeader = (UINT64) PcdGet32 (PcdFlashNvStorageVariableBase);\r
   VariableStoreEntry.Base = TempVariableStoreHeader + \\r
                               (((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) (TempVariableStoreHeader)) -> HeaderLength);\r
-  VariableStoreEntry.Length = (UINT64) PcdGet32 (PcdFlashNvStorageVariableSize) - \\r
+  VariableStoreEntry.Length = TempVariableStoreLen - \\r
                                 (((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) (TempVariableStoreHeader)) -> HeaderLength);\r
   //\r
   // Mark the variable storage region of the FLASH as RUNTIME\r
index 8236cd9..5765c26 100644 (file)
   DxeServicesTableLib\r
   UefiDriverEntryPoint\r
   PcdLib\r
+  HobLib\r
 \r
+[Guids]\r
+  gEfiFlashMapHobGuid\r
 \r
 ################################################################################\r
 #\r
index 716a80e..5943ba4 100644 (file)
 [Components.IA32]\r
   $(WORKSPACE)/Nt32Pkg/BootModePei/BootMode.inf\r
   $(WORKSPACE)/Nt32Pkg/WinNtThunkDxe/WinNtThunk.inf\r
+  $(WORKSPACE)/MdeModulePkg/Universal/RuntimeDxe/Runtime.inf\r
   $(WORKSPACE)/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriver.inf\r
   $(WORKSPACE)/Nt32Pkg/WinNtThunkPPIToProtocolPei/WinNtThunkPPIToProtocol.inf\r
   $(WORKSPACE)/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScan.inf\r
   $(WORKSPACE)/MdeModulePkg/Universal/Capsule/RuntimeDxe/CapsuleRuntime.inf\r
   $(WORKSPACE)/MdeModulePkg/Universal/Ebc/Dxe/Ebc.inf\r
   $(WORKSPACE)/MdeModulePkg/Universal/GenericMemoryTest/Dxe/NullMemoryTest.inf\r
-  $(WORKSPACE)/MdeModulePkg/Universal/RuntimeDxe/Runtime.inf\r
   $(WORKSPACE)/MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteLite/Dxe/FtwLite.inf\r
   $(WORKSPACE)/MdeModulePkg/Universal/BaseMemoryTestPei/BaseMemoryTest.inf\r
   $(WORKSPACE)/MdeModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.inf\r
index 09e9ce8..ec04699 100644 (file)
@@ -111,6 +111,7 @@ READ_LOCK_STATUS   = TRUE
 ################################################################################\r
 INF  $(WORKSPACE)/MdeModulePkg/Core/Pei/PeiMain.inf\r
 INF  $(WORKSPACE)/MdeModulePkg/Core/Dxe/DxeMain.inf\r
+INF  $(WORKSPACE)/MdeModulePkg/Universal/RuntimeDxe/Runtime.inf\r
 INF  $(WORKSPACE)/Nt32Pkg/BootModePei/BootMode.inf\r
 INF  $(WORKSPACE)/Nt32Pkg/WinNtThunkDxe/WinNtThunk.inf\r
 #INF  $(WORKSPACE)/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriver.inf\r
@@ -137,7 +138,6 @@ INF  $(WORKSPACE)/MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.inf
 INF  $(WORKSPACE)/MdeModulePkg/Universal/Capsule/RuntimeDxe/CapsuleRuntime.inf\r
 INF  $(WORKSPACE)/MdeModulePkg/Universal/Ebc/Dxe/Ebc.inf\r
 INF  $(WORKSPACE)/MdeModulePkg/Universal/GenericMemoryTest/Dxe/NullMemoryTest.inf\r
-INF  $(WORKSPACE)/MdeModulePkg/Universal/RuntimeDxe/Runtime.inf\r
 INF  $(WORKSPACE)/MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteLite/Dxe/FtwLite.inf\r
 INF  $(WORKSPACE)/MdeModulePkg/Universal/BaseMemoryTestPei/BaseMemoryTest.inf\r
 INF  $(WORKSPACE)/MdeModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.inf\r