]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/CCode/Source/FlashMap/Microcode.c
Modified to strip leading white-space characters and ignore blank or comment only...
[mirror_edk2.git] / Tools / CCode / Source / FlashMap / Microcode.c
index 23353254a4b9a880e18ad51152063ac516c15902..84534e316ff11f9b6d9ac0c73f1194bffb04b28f 100644 (file)
@@ -30,6 +30,8 @@ Abstract:
 \r
 #define MAX_LINE_LEN  256\r
 \r
+#define STATUS_IGNORE 0xA\r
+\r
 //\r
 // Structure definition for a microcode header\r
 //\r
@@ -120,6 +122,7 @@ Returns:
 {\r
   char  Line[MAX_LINE_LEN];\r
   char  *cptr;\r
+  unsigned int  ctr;\r
 \r
   Line[MAX_LINE_LEN - 1]  = 0;\r
   *Data                   = 0;\r
@@ -132,6 +135,17 @@ Returns:
   if (Line[MAX_LINE_LEN - 1] != 0) {\r
     return STATUS_ERROR;\r
   }\r
+\r
+  // Strip leading white-space characters (except carriage returns) from Line\r
+  //\r
+  if (isspace(Line[0]) && Line[0] != '\n') {\r
+    while (isspace(Line[0])) {\r
+       for (ctr = 0; ctr < strlen(Line); ctr++)\r
+         if (Line[ctr] != '\n')\r
+           Line[ctr] = Line[ctr + 1];\r
+    }\r
+  }\r
+\r
   //\r
   // Look for\r
   // dd 000000001h ; comment\r
@@ -155,6 +169,12 @@ Returns:
     }\r
     return STATUS_SUCCESS;\r
   }\r
+  if (strlen(Line) == 1) {\r
+    return STATUS_IGNORE;\r
+  }\r
+  if (tolower(cptr[0]) == ';') {\r
+    return STATUS_IGNORE;\r
+  }\r
   return STATUS_ERROR;\r
 }\r
 \r
@@ -188,6 +208,7 @@ Returns:
   unsigned int            Checksum;\r
   char                    *Buffer;\r
   char                    *Ptr;\r
+  char                    *OrigPtr;\r
   unsigned int            TotalSize;\r
 \r
   Status  = STATUS_ERROR;\r
@@ -212,6 +233,9 @@ Returns:
     if (Status == STATUS_SUCCESS) {\r
       Size += sizeof (Data);\r
     }\r
+    if (Status == STATUS_IGNORE) {\r
+      Status = STATUS_SUCCESS;\r
+    }\r
   } while (Status == STATUS_SUCCESS);\r
   //\r
   // Error if no data.\r
@@ -237,12 +261,18 @@ Returns:
   //\r
   fseek (InFptr, 0, SEEK_SET);\r
   Ptr = Buffer;\r
+  OrigPtr = Ptr;\r
   do {\r
+    OrigPtr = Ptr;\r
     Status = MicrocodeReadData (InFptr, &Data);\r
     if (Status == STATUS_SUCCESS) {\r
       *(unsigned int *) Ptr = Data;\r
       Ptr += sizeof (Data);\r
     }\r
+    if (Status == STATUS_IGNORE) {\r
+      Ptr = OrigPtr;\r
+      Status = STATUS_SUCCESS;\r
+    }\r
   } while (Status == STATUS_SUCCESS);\r
   //\r
   // Can't do much checking on the header because, per the spec, the\r