X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FCCode%2FSource%2FFlashMap%2FFlashDefFile.c;h=5a9205ab36c1fa5d54e0d5ac7b162b8a5b0c0f11;hp=cdbf7886ece5d34e145a9fb78486c41f67017e12;hb=02918ed0ab12123f688fe23557180d4494efbbcc;hpb=604371b98d3ad2472e96be8d126df92b2fcf68df diff --git a/Tools/CCode/Source/FlashMap/FlashDefFile.c b/Tools/CCode/Source/FlashMap/FlashDefFile.c index cdbf7886ec..5a9205ab36 100644 --- a/Tools/CCode/Source/FlashMap/FlashDefFile.c +++ b/Tools/CCode/Source/FlashMap/FlashDefFile.c @@ -76,6 +76,8 @@ typedef struct _FLASH_BLOCK_DESCRIPTION { unsigned int Alignment; // power of 2 alignment WCHAR_T Attributes[MAX_ATTR_LEN]; // only used for Region definitions WCHAR_T AreaType[MAX_AREATYPE_LEN]; // only used for Region definitions + EFI_GUID AreaTypeGuid; + WCHAR_T AreaTypeGuidString[MAX_NAME_LEN]; FLASH_SUBREGION_DESCRIPTION *Subregions; FLASH_SUBREGION_DESCRIPTION *LastSubregion; } FLASH_BLOCK_DESCRIPTION; @@ -795,6 +797,41 @@ Returns: } PreviousComma = SFPIsToken (","); + // + // Parse optional attribute "AreaTypeGuid" + // + if (SFPIsKeyword ("AreaTypeGuid")) { + // + // Check for preceeding comma now + // + if (!PreviousComma) { + Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected ',' before 'AreaTypeGuid'", NULL); + WarningCount++; + } + + if (!SFPIsToken ("=")) { + Warning (SFPGetFileName (), SFPGetLineNumber (), 0, "expected '='", NULL); + WarningCount++; + } + + if (SFPGetQuotedString (FBlockDesc->AreaTypeGuidString, sizeof (FBlockDesc->AreaTypeGuidString))) { + // + // Nothing else to do + // + } else if (!SFPGetGuid (PARSE_GUID_STYLE_5_FIELDS, &FBlockDesc->AreaTypeGuid)) { + Error ( + SFPGetFileName (), + SFPGetLineNumber (), + 0, + "expected AreaTypeGuid quoted string or GUID of form 12345678-1234-1234-1234-123456789ABC", + NULL + ); + ErrorCount++; + goto Done; + } + PreviousComma = SFPIsToken (","); + } + // // Parse optional Subregion definitions // @@ -1781,7 +1818,32 @@ Returns: fprintf (OutFptr, " FLASH_REGION_%s_BASE,\\\n", FBlock->Name); fprintf (OutFptr, " FLASH_REGION_%s_SIZE,\\\n", FBlock->Name); fprintf (OutFptr, " %s,\\\n", FBlock->Attributes); - fprintf (OutFptr, " %s,\\\n },\\\n", FBlock->AreaType); + fprintf (OutFptr, " %s,\\\n", FBlock->AreaType); + fprintf (OutFptr, " 0, 0, 0,\\\n"); + // + // The AreaTypeGuid may have been specified in the input flash definition file as a GUID, or + // as a quoted string. Do the right one. + // + if (FBlock->AreaTypeGuidString[0] != 0) { + fprintf (OutFptr, " %s, \\\n", FBlock->AreaTypeGuidString); + } else { + fprintf ( + OutFptr, + " { 0x%08X, 0x%04X, 0x%04X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X },\\\n", + FBlock->AreaTypeGuid.Data1, + (unsigned int) FBlock->AreaTypeGuid.Data2, + (unsigned int) FBlock->AreaTypeGuid.Data3, + (unsigned int) FBlock->AreaTypeGuid.Data4[0], + (unsigned int) FBlock->AreaTypeGuid.Data4[1], + (unsigned int) FBlock->AreaTypeGuid.Data4[2], + (unsigned int) FBlock->AreaTypeGuid.Data4[3], + (unsigned int) FBlock->AreaTypeGuid.Data4[4], + (unsigned int) FBlock->AreaTypeGuid.Data4[5], + (unsigned int) FBlock->AreaTypeGuid.Data4[6], + (unsigned int) FBlock->AreaTypeGuid.Data4[7] + ); + } + fprintf (OutFptr, " },\\\n"); } fprintf (OutFptr, "\n\n"); @@ -1813,9 +1875,9 @@ Returns: fprintf (OutFptr, " \\\n"); fprintf (OutFptr, " /* %s.%s Subregion */\\\n", FBlock->Name, Subregion->Name); fprintf (OutFptr, " {\\\n"); - fprintf (OutFptr, " EFI_HOB_TYPE_GUID_EXTENSION,\\\n"); + fprintf (OutFptr, " {EFI_HOB_TYPE_GUID_EXTENSION,\\\n"); fprintf (OutFptr, " sizeof (EFI_HOB_FLASH_MAP_ENTRY_TYPE ),\\\n"); - fprintf (OutFptr, " 0,\\\n"); + fprintf (OutFptr, " 0},\\\n"); // // The NameGuid may have been specified in the input flash definition file as a GUID, or // as a quoted string. Do the right one. @@ -1825,7 +1887,7 @@ Returns: } else { fprintf ( OutFptr, - " { 0x%08X, 0x%04X, 0x%04X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X },\\\n", + " { 0x%08X, 0x%04X, 0x%04X, {0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X}},\\\n", Subregion->NameGuid.Data1, (unsigned int) Subregion->NameGuid.Data2, (unsigned int) Subregion->NameGuid.Data3, @@ -1840,7 +1902,7 @@ Returns: ); } - fprintf (OutFptr, " 0, 0, 0,\\\n"); + fprintf (OutFptr, " {0, 0, 0},\\\n"); fprintf (OutFptr, " %s,\\\n", Subregion->AreaType); // // The AreaTypeGuid may have been specified in the input flash definition file as a GUID, or @@ -1851,7 +1913,7 @@ Returns: } else { fprintf ( OutFptr, - " { 0x%08X, 0x%04X, 0x%04X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X },\\\n", + " { 0x%08X, 0x%04X, 0x%04X, {0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X}},\\\n", Subregion->AreaTypeGuid.Data1, (unsigned int) Subregion->AreaTypeGuid.Data2, (unsigned int) Subregion->AreaTypeGuid.Data3, @@ -1867,7 +1929,7 @@ Returns: } fprintf (OutFptr, " 1,\\\n"); - fprintf (OutFptr, " {\\\n"); + fprintf (OutFptr, " {{\\\n"); fprintf (OutFptr, " %s,\\\n", Subregion->Attributes); fprintf (OutFptr, " 0,\\\n"); fprintf (OutFptr, " FLASH_REGION_%s_SUBREGION_%s_BASE,\\\n", FBlock->Name, Subregion->Name); @@ -1881,7 +1943,7 @@ Returns: } else { fprintf ( OutFptr, - " { 0x%08X, 0x%04X, 0x%04X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X },\\\n", + " { 0x%08X, 0x%04X, 0x%04X, {0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X}},\\\n", Subregion->FileSystemGuid.Data1, (unsigned int) Subregion->FileSystemGuid.Data2, (unsigned int) Subregion->FileSystemGuid.Data3, @@ -1896,7 +1958,7 @@ Returns: ); } - fprintf (OutFptr, " },\\\n"); + fprintf (OutFptr, " }},\\\n"); fprintf (OutFptr, " },"); } }