clean up MSA/SPD files.
[mirror_edk2.git] / EdkNt32Pkg / Pei / FlashMap / FlashMap.c
index 54dc137a765cac4200b84db1dcc0db800a70113c..ae3ceb9dd7c049cfa3ae01acdd349e330eba352b 100644 (file)
@@ -60,7 +60,9 @@ static EFI_FLASH_AREA_DATA    mFlashAreaData[] = {
     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
+    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
@@ -69,7 +71,9 @@ static EFI_FLASH_AREA_DATA    mFlashAreaData[] = {
     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
+    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
@@ -78,7 +82,9 @@ static EFI_FLASH_AREA_DATA    mFlashAreaData[] = {
     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
+    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
@@ -87,7 +93,9 @@ static EFI_FLASH_AREA_DATA    mFlashAreaData[] = {
     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
+    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
@@ -96,7 +104,9 @@ static EFI_FLASH_AREA_DATA    mFlashAreaData[] = {
     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
+    EFI_FLASH_AREA_GUID_DEFINED,\r
+    0, 0, 0,\r
+    EFI_SYSTEM_NV_DATA_HOB_GUID\r
   },\r
 };\r
 \r
@@ -176,6 +186,25 @@ Returns:
     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
@@ -194,7 +223,7 @@ Returns:
     case EFI_FLASH_AREA_GUID_DEFINED:\r
       (*PeiServices)->CopyMem (\r
                         &FlashHobData.AreaTypeGuid,\r
-                        &gEfiSystemNvDataHobGuid,\r
+                        &mFlashAreaData[Index].AreaTypeGuid,\r
                         sizeof (EFI_GUID)\r
                         );\r
       (*PeiServices)->CopyMem (\r
@@ -202,12 +231,6 @@ Returns:
                         &gEfiFirmwareVolumeBlockProtocolGuid,\r
                         sizeof (EFI_GUID)\r
                         );\r
-\r
-      //\r
-      // We also update a PCD entry so that any driver that depend on\r
-      // PCD entry PcdFlashNvStorageVariableBase will get the information.\r
-      //\r
-      PcdSet32 (PcdFlashNvStorageVariableBase, (UINT32) FlashHobData.SubAreaData.Base);\r
       break;\r
 \r
     default:\r
@@ -262,7 +285,7 @@ GetAreaInfo (
       if (AreaType == FlashMapEntry->AreaType) {\r
         if (AreaType == EFI_FLASH_AREA_GUID_DEFINED) {\r
           if (!CompareGuid (AreaTypeGuid, &FlashMapEntry->AreaTypeGuid)) {\r
-            continue;\r
+            goto NextHob;\r
           }\r
         }\r
 \r
@@ -271,7 +294,7 @@ GetAreaInfo (
         return EFI_SUCCESS;\r
       }\r
     }\r
-\r
+  NextHob:\r
     Hob.Raw = GET_NEXT_HOB (Hob);\r
   }\r
 \r