Let specify GUID value for GUID-defined FV region, and remove potential dead loop...
authorxli24 <xli24@de2fecce-e211-0410-80a6-f3fac2684e05>
Thu, 7 Dec 2006 06:02:54 +0000 (06:02 +0000)
committerxli24 <xli24@de2fecce-e211-0410-80a6-f3fac2684e05>
Thu, 7 Dec 2006 06:02:54 +0000 (06:02 +0000)
git-svn-id: https://edk2.tianocore.org/svn/edk2/trunk@2065 de2fecce-e211-0410-80a6-f3fac2684e05

edk2/EdkModulePkg/Include/Common/FlashMap.h
edk2/EdkNt32Pkg/Pei/FlashMap/FlashMap.c
edk2/Tools/CCode/Source/FlashMap/FlashDefFile.c

index 829fa2d..9c0afc4 100644 (file)
@@ -103,6 +103,8 @@ typedef struct {
   UINTN                     Length;\r
   EFI_FLASH_AREA_ATTRIBUTES Attributes;\r
   EFI_FLASH_AREA_TYPE       AreaType;\r
+  UINT8                     Reserved[3];\r
+  EFI_GUID                  AreaTypeGuid;\r
 } EFI_FLASH_AREA_DATA;\r
 \r
 #pragma pack()\r
index af8e13c..ae3ceb9 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
@@ -213,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
@@ -275,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
@@ -284,7 +294,7 @@ GetAreaInfo (
         return EFI_SUCCESS;\r
       }\r
     }\r
-\r
+  NextHob:\r
     Hob.Raw = GET_NEXT_HOB (Hob);\r
   }\r
 \r
index 0bfdad2..5a9205a 100644 (file)
@@ -76,6 +76,8 @@ typedef struct _FLASH_BLOCK_DESCRIPTION {
   unsigned int                    Alignment;                  // power of 2 alignment\r
   WCHAR_T                         Attributes[MAX_ATTR_LEN];   // only used for Region definitions\r
   WCHAR_T                         AreaType[MAX_AREATYPE_LEN]; // only used for Region definitions\r
+  EFI_GUID                        AreaTypeGuid;\r
+  WCHAR_T                         AreaTypeGuidString[MAX_NAME_LEN];\r
   FLASH_SUBREGION_DESCRIPTION     *Subregions;\r
   FLASH_SUBREGION_DESCRIPTION     *LastSubregion;\r
 } FLASH_BLOCK_DESCRIPTION;\r
@@ -795,6 +797,41 @@ Returns:
       }\r
 \r
       PreviousComma = SFPIsToken (",");\r
+      //\r
+      // Parse optional attribute "AreaTypeGuid"\r
+      //\r
+      if (SFPIsKeyword ("AreaTypeGuid")) {\r
+        //\r
+        // Check for preceeding comma now\r
+        //\r
+        if (!PreviousComma) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ',' before 'AreaTypeGuid'", NULL);\r
+          WarningCount++;\r
+        }\r
+        \r
+        if (!SFPIsToken ("=")) {\r
+          Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL);\r
+          WarningCount++;\r
+        }\r
+        \r
+        if (SFPGetQuotedString (FBlockDesc->AreaTypeGuidString, sizeof (FBlockDesc->AreaTypeGuidString))) {\r
+          //\r
+          // Nothing else to do\r
+          //\r
+        } else if (!SFPGetGuid (PARSE_GUID_STYLE_5_FIELDS, &FBlockDesc->AreaTypeGuid)) {\r
+          Error (\r
+            SFPGetFileName (),\r
+            SFPGetLineNumber (),\r
+            0,\r
+            "expected AreaTypeGuid quoted string or GUID of form 12345678-1234-1234-1234-123456789ABC",\r
+            NULL\r
+            );\r
+          ErrorCount++;\r
+          goto Done;\r
+        }\r
+        PreviousComma = SFPIsToken (",");\r
+      }\r
+\r
       //\r
       // Parse optional Subregion definitions\r
       //\r
@@ -1781,7 +1818,32 @@ Returns:
     fprintf (OutFptr, "    FLASH_REGION_%s_BASE,\\\n", FBlock->Name);\r
     fprintf (OutFptr, "    FLASH_REGION_%s_SIZE,\\\n", FBlock->Name);\r
     fprintf (OutFptr, "    %s,\\\n", FBlock->Attributes);\r
-    fprintf (OutFptr, "    %s,\\\n  },\\\n", FBlock->AreaType);\r
+    fprintf (OutFptr, "    %s,\\\n", FBlock->AreaType);\r
+    fprintf (OutFptr, "    0, 0, 0,\\\n");\r
+    //\r
+    // The AreaTypeGuid may have been specified in the input flash definition file as a GUID, or\r
+    // as a quoted string. Do the right one.\r
+    //\r
+    if (FBlock->AreaTypeGuidString[0] != 0) {\r
+      fprintf (OutFptr, "    %s, \\\n", FBlock->AreaTypeGuidString);\r
+    } else {\r
+      fprintf (\r
+        OutFptr,\r
+        "    { 0x%08X, 0x%04X, 0x%04X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X },\\\n",\r
+        FBlock->AreaTypeGuid.Data1,\r
+        (unsigned int) FBlock->AreaTypeGuid.Data2,\r
+        (unsigned int) FBlock->AreaTypeGuid.Data3,\r
+        (unsigned int) FBlock->AreaTypeGuid.Data4[0],\r
+        (unsigned int) FBlock->AreaTypeGuid.Data4[1],\r
+        (unsigned int) FBlock->AreaTypeGuid.Data4[2],\r
+        (unsigned int) FBlock->AreaTypeGuid.Data4[3],\r
+        (unsigned int) FBlock->AreaTypeGuid.Data4[4],\r
+        (unsigned int) FBlock->AreaTypeGuid.Data4[5],\r
+        (unsigned int) FBlock->AreaTypeGuid.Data4[6],\r
+        (unsigned int) FBlock->AreaTypeGuid.Data4[7]\r
+        );\r
+    }\r
+    fprintf (OutFptr, "  },\\\n");\r
   }\r
 \r
   fprintf (OutFptr, "\n\n");\r