]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/GnuGenBootSector/GnuGenBootSector.c
BaseTools: Clean up source files
[mirror_edk2.git] / BaseTools / Source / C / GnuGenBootSector / GnuGenBootSector.c
index 1804e683fb9114158d777609b06aa9d03953c547..6cdffcba3ac578f426dd60622ac0f88861a1c475 100644 (file)
@@ -3,15 +3,15 @@ Reading/writing MBR/DBR.
   NOTE:\r
     If we write MBR to disk, we just update the MBR code and the partition table wouldn't be over written.\r
     If we process DBR, we will patch MBR to set first partition active if no active partition exists.\r
-    \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
-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
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+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
 **/\r
 \r
@@ -132,21 +132,21 @@ GetPathInfo (
   if (strncmp(PathInfo->Path, "/dev/", 5) == 0) {\r
     //\r
     // Process disk path here.\r
-    // \r
-    \r
+    //\r
+\r
     // Process floppy disk\r
     if (PathInfo->Path[5] == 'f' && PathInfo->Path[6] == 'd' && PathInfo->Path[8] == '\0') {\r
       PathInfo->Type = PathFloppy;\r
       strcpy (PathInfo->PhysicalPath, PathInfo->Path);\r
-      \r
+\r
       return ErrorSuccess;\r
     } else {\r
     // Other disk types is not supported yet.\r
     fprintf (stderr, "ERROR: It's not a floppy disk!\n");\r
     return ErrorPath;\r
-    }  \r
-     \r
-    // Try to open the device.   \r
+    }\r
+\r
+    // Try to open the device.\r
     f = fopen (LongFilePath (PathInfo->Path),"r");\r
     if (f == NULL) {\r
       printf ("error :open device failed!\n");\r
@@ -155,7 +155,7 @@ GetPathInfo (
     fclose (f);\r
     return ErrorSuccess;\r
   }\r
\r
+\r
   // Process file path here.\r
   PathInfo->Type = PathFile;\r
   if (PathInfo->Input) {\r
@@ -183,12 +183,12 @@ ListDrive (
 }\r
 \r
 /**\r
-  Writing or reading boot sector or MBR according to the argument. \r
-   \r
+  Writing or reading boot sector or MBR according to the argument.\r
+\r
   @param InputInfo PATH_INFO instance for input path\r
   @param OutputInfo PATH_INFO instance for output path\r
   @param ProcessMbr TRUE is to process MBR, otherwise, processing boot sector\r
-  \r
+\r
   @return ERROR_STATUS\r
  **/\r
 ERROR_STATUS\r
@@ -200,34 +200,34 @@ ProcessBsOrMbr (
 {\r
   CHAR8 FirstSector[0x200] = {0};\r
   CHAR8 FirstSectorBackup[0x200] = {0};\r
-  \r
+\r
   FILE *InputFile;\r
   FILE *OutputFile;\r
-  \r
-  \r
+\r
+\r
   InputFile = fopen (LongFilePath (InputInfo->PhysicalPath), "r");\r
   if (InputFile == NULL) {\r
     return ErrorFileReadWrite;\r
   }\r
-   \r
+\r
   if (0x200 != fread(FirstSector, 1, 0x200, InputFile)) {\r
     fclose(InputFile);\r
     return ErrorFileReadWrite;\r
   }\r
-  \r
+\r
   fclose(InputFile);\r
-  \r
+\r
   //Not support USB and IDE.\r
   if (InputInfo->Type == PathUsb) {\r
     printf("USB has not been supported yet!");\r
     return ErrorSuccess;\r
   }\r
-  \r
+\r
   if (InputInfo->Type == PathIde) {\r
     printf("IDE has not been supported yet!");\r
     return ErrorSuccess;\r
-  } \r
-  \r
+  }\r
+\r
   //Process Floppy Disk\r
   OutputFile = fopen (LongFilePath (OutputInfo->PhysicalPath), "r+");\r
   if (OutputFile == NULL) {\r
@@ -236,7 +236,7 @@ ProcessBsOrMbr (
       return ErrorFileReadWrite;\r
     }\r
   }\r
-  \r
+\r
   if (OutputInfo->Type != PathFile) {\r
     if (ProcessMbr) {\r
       //\r
@@ -244,16 +244,16 @@ ProcessBsOrMbr (
       //\r
       if (0x200 != fread (FirstSectorBackup, 1, 0x200, OutputFile)) {\r
         fclose(OutputFile);\r
-        return ErrorFileReadWrite; \r
+        return ErrorFileReadWrite;\r
         }\r
-      memcpy (FirstSector + 0x1BE, FirstSectorBackup + 0x1BE, 0x40);  \r
+      memcpy (FirstSector + 0x1BE, FirstSectorBackup + 0x1BE, 0x40);\r
     }\r
   }\r
   if(0x200 != fwrite(FirstSector, 1, 0x200, OutputFile)) {\r
     fclose(OutputFile);\r
     return ErrorFileReadWrite;\r
   }\r
-  \r
+\r
   fclose(OutputFile);\r
   return ErrorSuccess;\r
 }\r
@@ -308,20 +308,20 @@ main (
   UINT64         LogLevel;\r
 \r
   SetUtilityName (UTILITY_NAME);\r
-  \r
+\r
   ZeroMem(&InputPathInfo, sizeof(PATH_INFO));\r
   ZeroMem(&OutputPathInfo, sizeof(PATH_INFO));\r
-  \r
+\r
   argv ++;\r
   argc --;\r
-  \r
+\r
   ProcessMbr    = FALSE;\r
 \r
   if (argc == 0) {\r
     PrintUsage();\r
     return 0;\r
   }\r
-   \r
+\r
   //\r
   // Parse command line\r
   //\r
@@ -329,61 +329,61 @@ main (
     if ((stricmp (argv[Index], "-l") == 0) || (stricmp (argv[Index], "--list") == 0)) {\r
       ListDrive ();\r
       return 0;\r
-    } \r
-    \r
+    }\r
+\r
     if ((stricmp (argv[Index], "-m") == 0) || (stricmp (argv[Index], "--mbr") == 0)) {\r
       ProcessMbr = TRUE;\r
       continue;\r
     }\r
-    \r
+\r
     if ((stricmp (argv[Index], "-i") == 0) || (stricmp (argv[Index], "--input") == 0)) {\r
       InputPathInfo.Path  = argv[Index + 1];\r
       InputPathInfo.Input = TRUE;\r
       if (InputPathInfo.Path == NULL) {\r
         Error (NULL, 0, 1003, "Invalid option value", "Input file name can't be NULL");\r
         return 1;\r
-      } \r
+      }\r
       if (InputPathInfo.Path[0] == '-') {\r
         Error (NULL, 0, 1003, "Invalid option value", "Input file is missing");\r
-        return 1;       \r
+        return 1;\r
       }\r
       ++Index;\r
       continue;\r
     }\r
-    \r
+\r
     if ((stricmp (argv[Index], "-o") == 0) || (stricmp (argv[Index], "--output") == 0)) {\r
       OutputPathInfo.Path  = argv[Index + 1];\r
       OutputPathInfo.Input = FALSE;\r
       if (OutputPathInfo.Path == NULL) {\r
         Error (NULL, 0, 1003, "Invalid option value", "Output file name can't be NULL");\r
         return 1;\r
-      } \r
+      }\r
       if (OutputPathInfo.Path[0] == '-') {\r
         Error (NULL, 0, 1003, "Invalid option value", "Output file is missing");\r
-        return 1;       \r
+        return 1;\r
       }\r
       ++Index;\r
       continue;\r
     }\r
-    \r
+\r
     if ((stricmp (argv[Index], "-h") == 0) || (stricmp (argv[Index], "--help") == 0)) {\r
       PrintUsage ();\r
       return 0;\r
     }\r
-    \r
+\r
     if (stricmp (argv[Index], "--version") == 0) {\r
       Version ();\r
       return 0;\r
-    } \r
-    \r
+    }\r
+\r
     if ((stricmp (argv[Index], "-v") == 0) || (stricmp (argv[Index], "--verbose") == 0)) {\r
       continue;\r
-    } \r
-    \r
+    }\r
+\r
     if ((stricmp (argv[Index], "-q") == 0) || (stricmp (argv[Index], "--quiet") == 0)) {\r
       continue;\r
-    } \r
-    \r
+    }\r
+\r
     if ((stricmp (argv[Index], "-d") == 0) || (stricmp (argv[Index], "--debug") == 0)) {\r
       EfiStatus = AsciiStringToUint64 (argv[Index + 1], FALSE, &LogLevel);\r
       if (EFI_ERROR (EfiStatus)) {\r
@@ -406,7 +406,7 @@ main (
     Error (NULL, 0, 1000, "Unknown option", "%s", argv[Index]);\r
     return 1;\r
   }\r
-  \r
+\r
   if (InputPathInfo.Path == NULL) {\r
     Error (NULL, 0, 1001, "Missing options", "Input file is missing");\r
     return 1;\r
@@ -416,7 +416,7 @@ main (
     Error (NULL, 0, 1001, "Missing options", "Output file is missing");\r
     return 1;\r
   }\r
-  \r
+\r
   if (GetPathInfo(&InputPathInfo) != ErrorSuccess) {\r
     Error (NULL, 0, 1003, "Invalid option value", "Input file can't be found.");\r
     return 1;\r
@@ -426,7 +426,7 @@ main (
     Error (NULL, 0, 1003, "Invalid option value", "Output file can't be found.");\r
     return 1;\r
   }\r
-  \r
+\r
   //\r
   // Process DBR (Patch or Read)\r
   //\r
@@ -434,21 +434,21 @@ main (
 \r
   if (Status == ErrorSuccess) {\r
     fprintf (\r
-      stdout, \r
-      "%s %s: successful!\n", \r
-      (OutputPathInfo.Type != PathFile) ? "Write" : "Read", \r
+      stdout,\r
+      "%s %s: successful!\n",\r
+      (OutputPathInfo.Type != PathFile) ? "Write" : "Read",\r
       ProcessMbr ? "MBR" : "DBR"\r
       );\r
     return 0;\r
   } else {\r
     fprintf (\r
-      stderr, \r
+      stderr,\r
       "%s: %s %s: failed - %s (LastError: 0x%x)!\n",\r
       (Status == ErrorNoMbr) ? "WARNING" : "ERROR",\r
-      (OutputPathInfo.Type != PathFile) ? "Write" : "Read", \r
-      ProcessMbr ? "MBR" : "DBR", \r
+      (OutputPathInfo.Type != PathFile) ? "Write" : "Read",\r
+      ProcessMbr ? "MBR" : "DBR",\r
       ErrorStatusDesc[Status],\r
-      errno \r
+      errno\r
       );\r
     return 1;\r
   }\r