Replace the FlashMapHob with PCD defined in FDF on Nt32 platform. Currently, the...
authoryshang1 <yshang1@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 3 Aug 2007 08:52:48 +0000 (08:52 +0000)
committeryshang1 <yshang1@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 3 Aug 2007 08:52:48 +0000 (08:52 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3544 6f19259b-4bc3-4df7-8a09-765794883524

12 files changed:
MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteDxe/FtwLite.c
Nt32Pkg/FvbServicesRuntimeDxe/FWBlockService.c
Nt32Pkg/FvbServicesRuntimeDxe/FvbInfo.c
Nt32Pkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
Nt32Pkg/Include/FlashLayout.h [deleted file]
Nt32Pkg/Nt32Pkg.dec
Nt32Pkg/Nt32Pkg.dsc
Nt32Pkg/Nt32Pkg.fdf
Nt32Pkg/WinNtFirmwareVolumePei/WinNtFirmwareVolumePei.inf
Nt32Pkg/WinNtFirmwareVolumePei/WinntFwh.c
Nt32Pkg/WinNtFlashMapPei/FlashMap.c
Nt32Pkg/WinNtFlashMapPei/WinNtFlashMapPei.inf

index 38fe11d..5bec0a2 100644 (file)
@@ -649,6 +649,8 @@ InitializeFtwLite (
 \r
   ASSERT_EFI_ERROR (Status);\r
 \r
+       __asm int 3;\r
+\r
   ZeroMem (FtwLiteDevice, sizeof (EFI_FTW_LITE_DEVICE));\r
   FtwLiteDevice->Signature = FTW_LITE_DEVICE_SIGNATURE;\r
 \r
index c2245f4..48926fb 100644 (file)
@@ -1281,6 +1281,7 @@ Returns:
   // Get the DXE services table\r
   //\r
   DxeServices = gDS;\r
+  __asm int 3;\r
 \r
   //\r
   // Allocate runtime services data for global variable, which contains\r
index 25df952..f455567 100644 (file)
@@ -48,10 +48,7 @@ Abstract:
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
-\r
-#include "FlashLayout.h"\r
-\r
-#define FIRMWARE_BLOCK_SIZE 0x10000\r
+#include <Library/PcdLib.h>\r
 \r
 typedef struct {\r
   UINT64                      FvLength;\r
@@ -62,22 +59,18 @@ typedef struct {
   EFI_FV_BLOCK_MAP_ENTRY      End[1];\r
 } EFI_FVB_MEDIA_INFO;\r
 \r
-#define FVB_MEDIA_BLOCK_SIZE    FIRMWARE_BLOCK_SIZE\r
-#define RECOVERY_BOIS_BLOCK_NUM FIRMWARE_BLOCK_NUMBER\r
-#define SYSTEM_NV_BLOCK_NUM     2\r
-\r
 EFI_FVB_MEDIA_INFO  mPlatformFvbMediaInfo[] = {\r
   //\r
   // Recovery BOIS FVB\r
   //\r
   {\r
-    EFI_WINNT_FIRMWARE_LENGTH,\r
+    FixedPcdGet32 (PcdWinNtFlashFvRecoverySize),\r
     {\r
       {\r
         0,\r
       },  // ZeroVector[16]\r
       EFI_FIRMWARE_FILE_SYSTEM2_GUID,\r
-      FVB_MEDIA_BLOCK_SIZE * RECOVERY_BOIS_BLOCK_NUM,\r
+      FixedPcdGet32 (PcdWinNtFlashFvRecoverySize),\r
       EFI_FVH_SIGNATURE,\r
       EFI_FVB2_READ_ENABLED_CAP |\r
         EFI_FVB2_READ_STATUS |\r
@@ -92,8 +85,8 @@ EFI_FVB_MEDIA_INFO  mPlatformFvbMediaInfo[] = {
       },  // Reserved[1]\r
       1,  // Revision\r
       {\r
-        RECOVERY_BOIS_BLOCK_NUM,\r
-        FVB_MEDIA_BLOCK_SIZE,\r
+        FixedPcdGet32 (PcdWinNtFlashFvRecoverySize)/FixedPcdGet32 (PcdWinNtFirmwareBlockSize),\r
+        FixedPcdGet32 (PcdWinNtFirmwareBlockSize),\r
       }\r
     },\r
     {\r
@@ -105,13 +98,19 @@ EFI_FVB_MEDIA_INFO  mPlatformFvbMediaInfo[] = {
   // Systen NvStorage FVB\r
   //\r
   {\r
-    EFI_WINNT_RUNTIME_UPDATABLE_LENGTH + EFI_WINNT_FTW_SPARE_BLOCK_LENGTH,\r
+    FixedPcdGet32 (PcdFlashNvStorageVariableSize) +\r
+    FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
+    FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
+    FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize),\r
     {\r
       {\r
         0,\r
       },  // ZeroVector[16]\r
       EFI_SYSTEM_NV_DATA_HOB_GUID,\r
-      FVB_MEDIA_BLOCK_SIZE * SYSTEM_NV_BLOCK_NUM,\r
+      FixedPcdGet32 (PcdFlashNvStorageVariableSize) +\r
+      FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
+      FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
+      FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize),\r
       EFI_FVH_SIGNATURE,\r
       EFI_FVB2_READ_ENABLED_CAP |\r
         EFI_FVB2_READ_STATUS |\r
@@ -126,8 +125,11 @@ EFI_FVB_MEDIA_INFO  mPlatformFvbMediaInfo[] = {
       },  // Reserved[1]\r
       1,  // Revision\r
       {\r
-        SYSTEM_NV_BLOCK_NUM,\r
-        FVB_MEDIA_BLOCK_SIZE,\r
+       (FixedPcdGet32 (PcdFlashNvStorageVariableSize) +\r
+        FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
+        FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
+        FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdWinNtFirmwareBlockSize),\r
+        FixedPcdGet32 (PcdWinNtFirmwareBlockSize),\r
       }\r
     },\r
     {\r
index f2530a1..314b225 100644 (file)
@@ -55,6 +55,7 @@
   BaseLib\r
   UefiDriverEntryPoint\r
   UefiLib\r
+  PcdLib\r
 \r
 \r
 [Guids]\r
   gEfiFirmwareVolumeBlockProtocolGuid           # PROTOCOL ALWAYS_PRODUCED\r
   gEfiDevicePathProtocolGuid                    # PROTOCOL SOMETIMES_PRODUCED\r
 \r
+[PcdsFixedAtBuild.common]\r
+  PcdWinNtFirmwareFdSize|gEfiNt32PkgTokenSpaceGuid\r
+  PcdWinNtFirmwareBlockSize|gEfiNt32PkgTokenSpaceGuid\r
+\r
+  PcdWinNtFlashFvRecoveryBase|gEfiNt32PkgTokenSpaceGuid\r
+  PcdWinNtFlashFvRecoverySize|gEfiNt32PkgTokenSpaceGuid\r
+  PcdWinNtFlashNvStorageEventLogBase|gEfiNt32PkgTokenSpaceGuid\r
+  PcdWinNtFlashNvStorageEventLogSize|gEfiNt32PkgTokenSpaceGuid\r
+\r
+  PcdFlashNvStorageFtwWorkingSize|gEfiMdeModulePkgTokenSpaceGuid\r
+  PcdFlashNvStorageFtwWorkingBase|gEfiMdeModulePkgTokenSpaceGuid\r
+  PcdFlashNvStorageFtwSpareSize|gEfiMdeModulePkgTokenSpaceGuid\r
+  PcdFlashNvStorageFtwSpareBase|gEfiMdeModulePkgTokenSpaceGuid\r
+  PcdFlashNvStorageVariableSize|gEfiMdeModulePkgTokenSpaceGuid\r
+  PcdFlashNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid\r
+\r
 [depex]\r
   TRUE
\ No newline at end of file
diff --git a/Nt32Pkg/Include/FlashLayout.h b/Nt32Pkg/Include/FlashLayout.h
deleted file mode 100644 (file)
index 1a13f16..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation                                                         \r
-All rights reserved. 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
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  FlashLayout.h\r
-   \r
-Abstract:\r
-\r
-  Platform specific flash layout\r
-\r
-  BugBug: We need a better way\r
-\r
---*/\r
-\r
-#ifndef __EFI_FLASH_LAYOUT__\r
-#define __EFI_FLASH_LAYOUT__\r
-\r
-//\r
-// Firmware Volume Information for Nt32\r
-// adding one working block before FFS FV,\r
-// and another one for spare block behind FFS FV\r
-//\r
-//\r
-// Note: When block number is changed in .dsc file,\r
-//       this value should be changed accordingly!!!\r
-//\r
-#define FIRMWARE_BLOCK_NUMBER                         0x28\r
-\r
-#define EFI_WINNT_FIRMWARE_OFFSET                     0x0\r
-#define EFI_WINNT_FIRMWARE_LENGTH                     (0x10000 * FIRMWARE_BLOCK_NUMBER)\r
-\r
-#define EFI_WINNT_RUNTIME_UPDATABLE_OFFSET            (EFI_WINNT_FIRMWARE_OFFSET + EFI_WINNT_FIRMWARE_LENGTH)\r
-\r
-#define EFI_WINNT_RUNTIME_UPDATABLE_LENGTH            0x10000\r
-\r
-#define EFI_WINNT_FTW_SPARE_BLOCK_OFFSET              (EFI_WINNT_RUNTIME_UPDATABLE_OFFSET + EFI_WINNT_RUNTIME_UPDATABLE_LENGTH)\r
-\r
-#define EFI_WINNT_FTW_SPARE_BLOCK_LENGTH              0x10000\r
-\r
-#define EFI_WINNT_RUNTIME_UPDATABLE_FV_HEADER_LENGTH  0x48\r
-\r
-#define EFI_VARIABLE_STORE_OFFSET                     EFI_WINNT_RUNTIME_UPDATABLE_OFFSET\r
-\r
-#define EFI_VARIABLE_STORE_LENGTH                     0x00C000\r
-\r
-#define EFI_EVENT_LOG_OFFSET                          (EFI_VARIABLE_STORE_OFFSET + EFI_VARIABLE_STORE_LENGTH)\r
-\r
-#define EFI_EVENT_LOG_LENGTH                          0x002000\r
-\r
-#define EFI_FTW_WORKING_OFFSET                        (EFI_EVENT_LOG_OFFSET + EFI_EVENT_LOG_LENGTH)\r
-\r
-#define EFI_FTW_WORKING_LENGTH                        0x002000\r
-\r
-#endif\r
-\r
index 894a11b..537f742 100644 (file)
   PcdWinNtFirmwareVolume|0x00001009|gEfiNt32PkgTokenSpaceGuid|VOID*|L"..\\Fv\\Fv_Recovery.fd"\r
   PcdWinNtMemorySizeForSecMain|0x0000100c|gEfiNt32PkgTokenSpaceGuid|VOID*|L"64!64"\r
 \r
+  PcdWinNtFlashNvStorageEventLogBase|0x0000100e|gEfiNt32PkgTokenSpaceGuid|UINT32|0x0\r
+  PcdWinNtFlashNvStorageEventLogSize|0x0000100f|gEfiNt32PkgTokenSpaceGuid|UINT32|0x0\r
+  PcdWinNtFlashFvRecoveryBase|0x00001010|gEfiNt32PkgTokenSpaceGuid|UINT32|0x0\r
+  PcdWinNtFlashFvRecoverySize|0x00001011|gEfiNt32PkgTokenSpaceGuid|UINT32|0x0\r
+  PcdWinNtFirmwareFdSize|0x00001012|gEfiNt32PkgTokenSpaceGuid|UINT32|0x0\r
+  PcdWinNtFirmwareBlockSize|0x00001013|gEfiNt32PkgTokenSpaceGuid|UINT32|0\r
+\r
+  PcdWinNtFlashNvStorageVariableBase|0x00001014|gEfiNt32PkgTokenSpaceGuid|UINT32|0x0\r
+  PcdWinNtFlashNvStorageFtwSpareBase|0x00001015|gEfiNt32PkgTokenSpaceGuid|UINT32|0x0\r
+  PcdWinNtFlashNvStorageFtwWorkingBase|0x00001016|gEfiNt32PkgTokenSpaceGuid|UINT32|0x0\r
+\r
 [PcdsDynamic.common]\r
   PcdWinNtPhysicalDisk|0x00001000|gEfiNt32PkgTokenSpaceGuid|VOID*|L"E:RW;245760;512"\r
   PcdWinNtVirtualDisk|0x00001001|gEfiNt32PkgTokenSpaceGuid|VOID*|L"FW;40960;512"\r
index 8649069..5588c39 100644 (file)
   PcdStatusCodeValueUncorrectableMemoryError|gEfiMdePkgTokenSpaceGuid|0x00051003\r
   PcdUefiLibMaxPrintBufferSize|gEfiMdePkgTokenSpaceGuid|320\r
 \r
+  PcdWinNtFirmwareFdSize|gEfiNt32PkgTokenSpaceGuid|0x2a0000\r
+  PcdWinNtFirmwareBlockSize|gEfiNt32PkgTokenSpaceGuid|0x10000\r
+  PcdWinNtFlashNvStorageEventLogBase|gEfiNt32PkgTokenSpaceGuid|0x28c000\r
+  PcdWinNtFlashNvStorageEventLogSize|gEfiNt32PkgTokenSpaceGuid|0x2000\r
+  PcdWinNtFlashFvRecoveryBase|gEfiNt32PkgTokenSpaceGuid|0x0\r
+  PcdWinNtFlashFvRecoverySize|gEfiNt32PkgTokenSpaceGuid|0x280000\r
+\r
+  PcdWinNtFlashNvStorageVariableBase|gEfiNt32PkgTokenSpaceGuid|0x280000\r
+  PcdWinNtFlashNvStorageFtwSpareBase|gEfiNt32PkgTokenSpaceGuid|0x290000\r
+  PcdWinNtFlashNvStorageFtwWorkingBase|gEfiNt32PkgTokenSpaceGuid|0x28e000\r
+\r
+  PcdFlashNvStorageFtwSpareSize|gEfiMdeModulePkgTokenSpaceGuid|0x10000\r
+  PcdFlashNvStorageFtwWorkingSize|gEfiMdeModulePkgTokenSpaceGuid|0x2000\r
+  PcdFlashNvStorageVariableSize|gEfiMdeModulePkgTokenSpaceGuid|0x00c000\r
+\r
 [PcdsFeatureFlag.IA32]\r
   PcdPeiPcdDatabaseTraverseEnabled|gEfiMdeModulePkgTokenSpaceGuid|TRUE\r
   PcdPeiPcdDatabaseCallbackOnSetEnabled|gEfiMdeModulePkgTokenSpaceGuid|TRUE\r
   PcdWinNtMemorySize|gEfiNt32PkgTokenSpaceGuid|L"64!64"|10\r
   PcdWinNtPhysicalDisk|gEfiNt32PkgTokenSpaceGuid|L"a:RW;2880;512!e:RW;262144;512"|58\r
   PcdWinNtUga|gEfiNt32PkgTokenSpaceGuid|L"UGA Window 1!UGA Window 2"|50\r
-  PcdFlashNvStorageFtwSpareBase|gEfiMdeModulePkgTokenSpaceGuid|0x0\r
-  PcdFlashNvStorageFtwSpareSize|gEfiMdeModulePkgTokenSpaceGuid|0x280000\r
-  PcdFlashNvStorageFtwWorkingBase|gEfiMdeModulePkgTokenSpaceGuid|0x28e000\r
-  PcdFlashNvStorageFtwWorkingSize|gEfiMdeModulePkgTokenSpaceGuid|0x2000\r
-  PcdFlashNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid|0x280000\r
-  PcdFlashNvStorageVariableSize|gEfiMdeModulePkgTokenSpaceGuid|0x00c000\r
+\r
+  PcdFlashNvStorageFtwSpareBase|gEfiMdeModulePkgTokenSpaceGuid|0\r
+  PcdFlashNvStorageFtwWorkingBase|gEfiMdeModulePkgTokenSpaceGuid|0\r
+  PcdFlashNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid|0\r
 \r
 ################################################################################\r
 #\r
index 5159708..9048af6 100644 (file)
@@ -25,7 +25,7 @@
 #\r
 ################################################################################\r
 [FD.Fv_Recovery]\r
-BaseAddress   = 0x0|PcdFdBaseAddress  #The base address of the FLASH Device.\r
+BaseAddress   = 0x0|PcdWinNtFdBaseAddress  #The base address of the FLASH Device.\r
 Size          = 0x002a0000            #The size in bytes of the FLASH Device\r
 ErasePolarity = 1\r
 BlockSize     = 0x10000\r
@@ -47,11 +47,11 @@ NumBlocks     = 0x2a
 #\r
 ################################################################################\r
 0x00000000|0x00280000\r
-PcdFlashFvRecoveryBase|PcdFlashFvRecoverySize\r
+PcdWinNtFlashFvRecoveryBase|PcdWinNtFlashFvRecoverySize\r
 FV = FvRecovery\r
 \r
 0x00280000|0x0000c000\r
-PcdFlashNvStorageBase|PcdFlashNvStorageSize\r
+PcdWinNtFlashNvStorageVariableBase|PcdFlashNvStorageVariableSize\r
 DATA = {\r
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
@@ -67,10 +67,10 @@ DATA = {
 }\r
 \r
 0x0028c000|0x00002000\r
-PcdFlashNvStorageEventLogBase|PcdFlashNvStorageEventLogSize\r
+PcdWinNtFlashNvStorageEventLogBase|PcdWinNtFlashNvStorageEventLogSize\r
 \r
 0x0028e000|0x00002000\r
-PcdFlashNvStorageFtwWorkingBase|PcdFlashNvStorageFtwWorkingSize\r
+PcdWinNtFlashNvStorageFtwWorkingBase|PcdFlashNvStorageFtwWorkingSize\r
 DATA = {\r
   0x8d, 0x2b, 0xf1, 0xff, 0x96, 0x76, 0x8b, 0x4c,\r
   0xa9, 0x85, 0x27, 0x47, 0x07, 0x5b, 0x4f, 0x50,\r
@@ -79,7 +79,7 @@ DATA = {
 }\r
 \r
 0x00290000|0x00010000\r
-PcdFlashNvStorageFtwSpareBase|PcdFlashNvStorageFtwSpareBase\r
+PcdWinNtFlashNvStorageFtwSpareBase|PcdFlashNvStorageFtwSpareSize\r
 \r
 ################################################################################\r
 #\r
index c29d400..a15bdbb 100644 (file)
   HobLib\r
   PeimEntryPoint\r
   DebugLib\r
+  PcdLib  \r
 \r
 [Ppis]\r
   gNtFwhPpiGuid                                 # PPI ALWAYS_CONSUMED\r
 \r
+\r
+[PcdsFixedAtBuild.common]\r
+  PcdWinNtFlashFvRecoveryBase|gEfiNt32PkgTokenSpaceGuid\r
+  PcdWinNtFlashFvRecoverySize|gEfiNt32PkgTokenSpaceGuid\r
+  PcdWinNtFlashNvStorageEventLogBase|gEfiNt32PkgTokenSpaceGuid\r
+  PcdWinNtFlashNvStorageEventLogSize|gEfiNt32PkgTokenSpaceGuid\r
+  PcdWinNtFlashNvStorageVariableBase|gEfiNt32PkgTokenSpaceGuid\r
+\r
+  PcdFlashNvStorageFtwWorkingSize|gEfiMdeModulePkgTokenSpaceGuid\r
+  PcdFlashNvStorageFtwSpareSize|gEfiMdeModulePkgTokenSpaceGuid\r
+  PcdFlashNvStorageVariableSize|gEfiMdeModulePkgTokenSpaceGuid\r
+\r
 [depex]\r
   gNtFwhPpiGuid AND gEfiPeiMemoryDiscoveredPpiGuid
\ No newline at end of file
index 2431133..643b92c 100644 (file)
@@ -34,9 +34,7 @@ Revision History
 #include <Library/DebugLib.h>\r
 #include <Library/PeimEntryPoint.h>\r
 #include <Library/HobLib.h>\r
-\r
-#include <FlashLayout.h>\r
-\r
+#include <Library/PcdLib.h>\r
 \r
 EFI_STATUS\r
 EFIAPI\r
@@ -68,6 +66,7 @@ Returns:
 \r
   DEBUG ((EFI_D_ERROR, "NT 32 Firmware Volume PEIM Loaded\n"));\r
 \r
+  __asm int 3;\r
   //\r
   // Get the Fwh Information PPI\r
   //\r
@@ -107,15 +106,24 @@ Returns:
           EFI_RESOURCE_FIRMWARE_DEVICE,\r
           (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
           FdBase,\r
-          (FvHeader->FvLength + EFI_WINNT_RUNTIME_UPDATABLE_LENGTH + EFI_WINNT_FTW_SPARE_BLOCK_LENGTH)\r
+          ( \r
+            FvHeader->FvLength + \r
+            PcdGet32 (PcdFlashNvStorageVariableSize) +\r
+            PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
+            PcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
+            PcdGet32 (PcdWinNtFlashNvStorageEventLogSize)\r
+          )\r
           );\r
-\r
         //\r
         // Hard code the address of the spare block and variable services.\r
         //  Assume it's a hard coded offset from FV0 in FD0.\r
         //\r
-        FdBase  = FdBase + EFI_WINNT_RUNTIME_UPDATABLE_OFFSET;\r
-        FdSize  = EFI_WINNT_RUNTIME_UPDATABLE_LENGTH + EFI_WINNT_FTW_SPARE_BLOCK_LENGTH;\r
+        FdBase  = FdBase + PcdGet32 (PcdWinNtFlashNvStorageVariableBase);\r
+        FdSize  = \r
+          PcdGet32 (PcdFlashNvStorageVariableSize) +\r
+          PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
+          PcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
+          PcdGet32 (PcdWinNtFlashNvStorageEventLogSize);\r
 \r
         BuildFvHob (FdBase, FdSize);\r
       } else {\r
index ac09056..6824070 100644 (file)
@@ -19,122 +19,20 @@ Abstract:
 \r
 --*/\r
 \r
-\r
 //\r
 // The package level header files this module uses\r
 //\r
 #include <PiPei.h>\r
+\r
 #include <WinNtPeim.h>\r
 //\r
 // The protocols, PPI and GUID defintions for this module\r
 //\r
 #include <Ppi/NtFwh.h>\r
-#include <Guid/FirmwareFileSystem2.h>\r
-#include <Ppi/FlashMap.h>\r
-#include <Guid/FlashMapHob.h>\r
-#include <Guid/SystemNvDataGuid.h>\r
-#include <Protocol/FirmwareVolumeBlock.h>\r
-//\r
-// The Library classes this module consumes\r
-//\r
+\r
 #include <Library/DebugLib.h>\r
-#include <Library/PeimEntryPoint.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/PeiServicesLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
 #include <Library/PcdLib.h>\r
-\r
-\r
-#include <FlashLayout.h>\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GetAreaInfo (\r
-  IN  EFI_PEI_SERVICES            **PeiServices,\r
-  IN PEI_FLASH_MAP_PPI            *This,\r
-  IN  EFI_FLASH_AREA_TYPE         AreaType,\r
-  IN  EFI_GUID                    *AreaTypeGuid,\r
-  OUT UINT32                      *NumEntries,\r
-  OUT EFI_FLASH_SUBAREA_ENTRY     **Entries\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-MemoryDiscoveredPpiNotifyCallback (\r
-  IN EFI_PEI_SERVICES           **PeiServices,\r
-  IN EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyDescriptor,\r
-  IN VOID                       *Ppi\r
-  );\r
-\r
-//\r
-// Module globals\r
-//\r
-static PEI_FLASH_MAP_PPI      mFlashMapPpi = { GetAreaInfo };\r
-\r
-static EFI_PEI_PPI_DESCRIPTOR mPpiListFlashMap = {\r
-  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
-  &gPeiFlashMapPpiGuid,\r
-  &mFlashMapPpi\r
-};\r
-\r
-static EFI_FLASH_AREA_DATA    mFlashAreaData[] = {\r
-  //\r
-  // Variable area\r
-  //\r
-  {\r
-    EFI_VARIABLE_STORE_OFFSET,\r
-    EFI_VARIABLE_STORE_LENGTH,\r
-    EFI_FLASH_AREA_SUBFV | EFI_FLASH_AREA_MEMMAPPED_FV,\r
-    EFI_FLASH_AREA_EFI_VARIABLES,\r
-    0, 0, 0,\r
-    { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }\r
-  },\r
-  //\r
-  // FTW spare (backup) block\r
-  //\r
-  {\r
-    EFI_WINNT_FTW_SPARE_BLOCK_OFFSET,\r
-    EFI_WINNT_FTW_SPARE_BLOCK_LENGTH,\r
-    EFI_FLASH_AREA_SUBFV | EFI_FLASH_AREA_MEMMAPPED_FV,\r
-    EFI_FLASH_AREA_FTW_BACKUP,\r
-    0, 0, 0,\r
-    { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }\r
-  },\r
-  //\r
-  // FTW private working (state) area\r
-  //\r
-  {\r
-    EFI_FTW_WORKING_OFFSET,\r
-    EFI_FTW_WORKING_LENGTH,\r
-    EFI_FLASH_AREA_SUBFV | EFI_FLASH_AREA_MEMMAPPED_FV,\r
-    EFI_FLASH_AREA_FTW_STATE,\r
-    0, 0, 0,\r
-    { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }\r
-  },\r
-  //\r
-  // Recovery FV\r
-  //\r
-  {\r
-    EFI_WINNT_FIRMWARE_OFFSET,\r
-    EFI_WINNT_FIRMWARE_LENGTH,\r
-    EFI_FLASH_AREA_FV | EFI_FLASH_AREA_MEMMAPPED_FV,\r
-    EFI_FLASH_AREA_RECOVERY_BIOS,\r
-    0, 0, 0,\r
-    { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }\r
-  },\r
-  //\r
-  // System Non-Volatile Storage FV\r
-  //\r
-  {\r
-    EFI_WINNT_RUNTIME_UPDATABLE_OFFSET,\r
-    EFI_WINNT_RUNTIME_UPDATABLE_LENGTH + EFI_WINNT_FTW_SPARE_BLOCK_LENGTH,\r
-    EFI_FLASH_AREA_FV | EFI_FLASH_AREA_MEMMAPPED_FV,\r
-    EFI_FLASH_AREA_GUID_DEFINED,\r
-    0, 0, 0,\r
-    EFI_SYSTEM_NV_DATA_HOB_GUID\r
-  },\r
-};\r
-\r
+#include <Library/PeiServicesLib.h>\r
 \r
 EFI_STATUS\r
 EFIAPI\r
@@ -159,22 +57,13 @@ Returns:
 {\r
   EFI_STATUS              Status;\r
   NT_FWH_PPI              *NtFwhPpi;\r
-  EFI_PEI_PPI_DESCRIPTOR  *PpiDescriptor;\r
   EFI_PHYSICAL_ADDRESS    FdBase;\r
   UINT64                  FdSize;\r
-  UINTN                   NumOfHobData;\r
-  UINTN                   Index;\r
-  EFI_FLASH_AREA_HOB_DATA FlashHobData;\r
+  EFI_PEI_PPI_DESCRIPTOR  *PpiDescriptor;\r
 \r
   DEBUG ((EFI_D_ERROR, "NT 32 Flash Map PEIM Loaded\n"));\r
 \r
-  //\r
-  // Install FlashMap PPI\r
-  //\r
-  Status = PeiServicesInstallPpi (&mPpiListFlashMap);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-\r
+  __asm int 3;\r
   //\r
   // Get the Fwh Information PPI\r
   //\r
@@ -195,133 +84,12 @@ Returns:
   }\r
 \r
   //\r
-  // Get number of types\r
-  //\r
-  NumOfHobData = sizeof (mFlashAreaData) / sizeof (EFI_FLASH_AREA_DATA);\r
-\r
-  //\r
-  // Build flash area entries as GUIDed HOBs.\r
-  //\r
-  for (Index = 0; Index < NumOfHobData; Index++) {\r
-    (*PeiServices)->SetMem (&FlashHobData, sizeof (EFI_FLASH_AREA_HOB_DATA), 0);\r
-\r
-    FlashHobData.AreaType               = mFlashAreaData[Index].AreaType;\r
-    FlashHobData.NumberOfEntries        = 1;\r
-    FlashHobData.SubAreaData.Attributes = mFlashAreaData[Index].Attributes;\r
-    FlashHobData.SubAreaData.Base       = FdBase + (EFI_PHYSICAL_ADDRESS) (UINTN) mFlashAreaData[Index].Base;\r
-    FlashHobData.SubAreaData.Length     = (EFI_PHYSICAL_ADDRESS) (UINTN) mFlashAreaData[Index].Length;\r
-\r
-    //\r
-    // We also update a PCD entry so that any driver that depend on\r
-    // PCD entry will get the information.\r
-    //\r
-    if (FlashHobData.AreaType == EFI_FLASH_AREA_EFI_VARIABLES) {\r
-      PcdSet32 (PcdFlashNvStorageVariableBase, (UINT32) FlashHobData.SubAreaData.Base);\r
-      PcdSet32 (PcdFlashNvStorageVariableSize, (UINT32) FlashHobData.SubAreaData.Length);\r
-    }\r
-\r
-    if (FlashHobData.AreaType == EFI_FLASH_AREA_FTW_STATE) {\r
-      PcdSet32 (PcdFlashNvStorageFtwWorkingBase, (UINT32) FlashHobData.SubAreaData.Base);\r
-      PcdSet32 (PcdFlashNvStorageFtwWorkingSize, (UINT32) FlashHobData.SubAreaData.Length);\r
-    }\r
-\r
-    if (FlashHobData.AreaType == EFI_FLASH_AREA_FTW_BACKUP) {\r
-      PcdSet32 (PcdFlashNvStorageFtwSpareBase, (UINT32) FlashHobData.SubAreaData.Base);\r
-      PcdSet32 (PcdFlashNvStorageFtwSpareSize, (UINT32) FlashHobData.SubAreaData.Length);\r
-    }\r
-\r
-    switch (FlashHobData.AreaType) {\r
-    case EFI_FLASH_AREA_RECOVERY_BIOS:\r
-    case EFI_FLASH_AREA_MAIN_BIOS:\r
-      (*PeiServices)->CopyMem (\r
-                        &FlashHobData.AreaTypeGuid,\r
-                        &gEfiFirmwareFileSystem2Guid,\r
-                        sizeof (EFI_GUID)\r
-                        );\r
-      (*PeiServices)->CopyMem (\r
-                        &FlashHobData.SubAreaData.FileSystem,\r
-                        &gEfiFirmwareVolumeBlockProtocolGuid,\r
-                        sizeof (EFI_GUID)\r
-                        );\r
-      break;\r
-\r
-    case EFI_FLASH_AREA_GUID_DEFINED:\r
-      (*PeiServices)->CopyMem (\r
-                        &FlashHobData.AreaTypeGuid,\r
-                        &mFlashAreaData[Index].AreaTypeGuid,\r
-                        sizeof (EFI_GUID)\r
-                        );\r
-      (*PeiServices)->CopyMem (\r
-                        &FlashHobData.SubAreaData.FileSystem,\r
-                        &gEfiFirmwareVolumeBlockProtocolGuid,\r
-                        sizeof (EFI_GUID)\r
-                        );\r
-      break;\r
-\r
-    default:\r
-      break;\r
-    }\r
-\r
-    //BuildGuidDataHob (\r
-    //  &gEfiFlashMapHobGuid,\r
-    //  &FlashHobData,\r
-    //  sizeof (EFI_FLASH_AREA_HOB_DATA)\r
-    //  );\r
-  }\r
+  // Relocate the base of FV region \r
+  // \r
+  PcdSet32 (PcdFlashNvStorageVariableBase, PcdGet32 (PcdWinNtFlashNvStorageVariableBase) + (UINT32) FdBase);\r
+  PcdSet32 (PcdFlashNvStorageFtwWorkingBase, PcdGet32 (PcdWinNtFlashNvStorageFtwWorkingBase) + (UINT32) FdBase);\r
+  PcdSet32 (PcdFlashNvStorageFtwSpareBase, PcdGet32 (PcdWinNtFlashNvStorageFtwWorkingBase) + (UINT32) FdBase);\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
-EFI_STATUS\r
-EFIAPI\r
-GetAreaInfo (\r
-  IN  EFI_PEI_SERVICES            **PeiServices,\r
-  IN PEI_FLASH_MAP_PPI            *This,\r
-  IN  EFI_FLASH_AREA_TYPE         AreaType,\r
-  IN  EFI_GUID                    *AreaTypeGuid,\r
-  OUT UINT32                      *NumEntries,\r
-  OUT EFI_FLASH_SUBAREA_ENTRY     **Entries\r
-  )\r
-/*++\r
-\r
-  Routine Description:    \r
-    Implementation of Flash Map PPI\r
-    \r
---*/\r
-// TODO: function comment is missing 'Arguments:'\r
-// TODO: function comment is missing 'Returns:'\r
-// TODO:    PeiServices - add argument and description to function comment\r
-// TODO:    This - add argument and description to function comment\r
-// TODO:    AreaType - add argument and description to function comment\r
-// TODO:    AreaTypeGuid - add argument and description to function comment\r
-// TODO:    NumEntries - add argument and description to function comment\r
-// TODO:    Entries - add argument and description to function comment\r
-// TODO:    EFI_SUCCESS - add return value to function comment\r
-// TODO:    EFI_NOT_FOUND - add return value to function comment\r
-{\r
-  EFI_STATUS                    Status;\r
-  EFI_PEI_HOB_POINTERS          Hob;\r
-  EFI_HOB_FLASH_MAP_ENTRY_TYPE  *FlashMapEntry;\r
-\r
-  Status = PeiServicesGetHobList (&Hob.Raw);\r
-  while (!END_OF_HOB_LIST (Hob)) {\r
-    if (Hob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION && CompareGuid (&Hob.Guid->Name, &gEfiFlashMapHobGuid)) {\r
-      FlashMapEntry = (EFI_HOB_FLASH_MAP_ENTRY_TYPE *) Hob.Raw;\r
-      if (AreaType == FlashMapEntry->AreaType) {\r
-        if (AreaType == EFI_FLASH_AREA_GUID_DEFINED) {\r
-          if (!CompareGuid (AreaTypeGuid, &FlashMapEntry->AreaTypeGuid)) {\r
-            goto NextHob;\r
-          }\r
-        }\r
-\r
-        *NumEntries = FlashMapEntry->NumEntries;\r
-        *Entries    = FlashMapEntry->Entries;\r
-        return EFI_SUCCESS;\r
-      }\r
-    }\r
-  NextHob:\r
-    Hob.Raw = GET_NEXT_HOB (Hob);\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
index 8ea67e3..785c59f 100644 (file)
@@ -70,3 +70,7 @@
   PcdFlashNvStorageVariableSize|gEfiMdeModulePkgTokenSpaceGuid\r
   PcdFlashNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid\r
 \r
+  PcdWinNtFlashNvStorageFtwWorkingBase|gEfiNt32PkgTokenSpaceGuid\r
+  PcdWinNtFlashNvStorageFtwSpareBase|gEfiNt32PkgTokenSpaceGuid\r
+  PcdWinNtFlashNvStorageVariableBase|gEfiNt32PkgTokenSpaceGuid\r
+\r