]> git.proxmox.com Git - mirror_edk2.git/commitdiff
File modified to add usage information and implement minor corrections.
authorywang <ywang@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 14 Nov 2006 22:01:45 +0000 (22:01 +0000)
committerywang <ywang@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 14 Nov 2006 22:01:45 +0000 (22:01 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1954 6f19259b-4bc3-4df7-8a09-765794883524

Tools/CCode/Source/CreateMtFile/CreateMtFile.c
Tools/CCode/Source/EfiCompress/EfiCompressMain.c
Tools/CCode/Source/GenDepex/GenDepex.c
Tools/CCode/Source/ModifyInf/ModifyInf.c
Tools/CCode/Source/Strip/Strip.c

index 1c17b3de23342db897695777e540883be22d8b8d..7d6d2d95bd8ac93e814c5d510eebe83b8b3f28dc 100644 (file)
@@ -26,7 +26,9 @@ Abstract:
 \r
 #include <Common/UefiBaseTypes.h>\r
 \r
-#define PROGRAM_NAME  "CreateMtFile"\r
+#define UTILITY_NAME "CreateMtFile"\r
+#define UTILITY_MAJOR_VERSION 1\r
+#define UTILITY_MINOR_VERSION 1\r
 \r
 typedef struct {\r
   INT8    *OutFileName;\r
@@ -44,7 +46,13 @@ ProcessArgs (
 \r
 static\r
 void\r
-Usage (\r
+CMFUsage (\r
+  VOID\r
+  );\r
+\r
+static\r
+void\r
+CMFVersion (\r
   VOID\r
   );\r
 \r
@@ -86,11 +94,7 @@ Returns:
   // Open the output file\r
   //\r
   if ((OutFptr = fopen (Options.OutFileName, "wb")) == NULL) {\r
-    fprintf (\r
-      stdout,\r
-      PROGRAM_NAME " ERROR: Could not open output file '%s' for writing\n",\r
-      Options.OutFileName\r
-      );\r
+      printf (" ERROR: Could not open output file '%s' for writing\n", Options.OutFileName);\r
     return EFI_DEVICE_ERROR;\r
   }\r
   //\r
@@ -99,7 +103,7 @@ Returns:
   while (Options.FileSize > 0) {\r
     if (fwrite (&Options.ByteValue, 1, 1, OutFptr) != 1) {\r
       fclose (OutFptr);\r
-      fprintf (stdout, PROGRAM_NAME " ERROR: Failed to write to output file\n");\r
+      printf (" ERROR: Failed to write to output file\n");\r
       return EFI_DEVICE_ERROR;\r
     }\r
 \r
@@ -151,15 +155,32 @@ Returns:
   //\r
   Argv++;\r
   Argc--;\r
+  \r
+  if (Argc < 1) {\r
+    CMFUsage();\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  if ((strcmp(Argv[0], "-h") == 0) || (strcmp(Argv[0], "--help") == 0) ||\r
+      (strcmp(Argv[0], "-?") == 0) || (strcmp(Argv[0], "/?") == 0)) {\r
+    CMFUsage();\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  if ((strcmp(Argv[0], "-V") == 0) || (strcmp(Argv[0], "--version") == 0)) {\r
+    CMFVersion();\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
\r
   if (Argc < 2) {\r
-    Usage ();\r
+    CMFUsage ();\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   //\r
   // If first arg is dash-option, then print usage.\r
   //\r
   if (Argv[0][0] == '-') {\r
-    Usage ();\r
+    CMFUsage ();\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   //\r
@@ -176,13 +197,22 @@ Returns:
   if ((Argv[0][strlen (Argv[0]) - 1] == 'k') || (Argv[0][strlen (Argv[0]) - 1] == 'K')) {\r
     Multiplier = 1024;\r
   }\r
+  \r
+  //\r
+  // Check for negtive size\r
+  //\r
+  if (Argv[0][0] == '-') {\r
+    printf("ERROR: File size should be non-negtive.\n");\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
   //\r
   // Look for 0x prefix on file size\r
   //\r
   if ((Argv[0][0] == '0') && ((Argv[0][1] == 'x') || (Argv[0][1] == 'X'))) {\r
     if (sscanf (Argv[0], "%x", &Options->FileSize) != 1) {\r
-      fprintf (stdout, PROGRAM_NAME " ERROR: Invalid file size '%s'\n", Argv[0]);\r
-      Usage ();\r
+      printf ("ERROR: Invalid file size '%s'\n", Argv[0]);\r
+      CMFUsage ();\r
       return EFI_INVALID_PARAMETER;\r
     }\r
     //\r
@@ -190,12 +220,12 @@ Returns:
     //\r
   } else {\r
     if (sscanf (Argv[0], "%d", &Options->FileSize) != 1) {\r
-      fprintf (stdout, PROGRAM_NAME " ERROR: Invalid file size '%s'\n", Argv[0]);\r
-      Usage ();\r
+      printf ("ERROR: Invalid file size '%s'\n", Argv[0]);\r
+      CMFUsage ();\r
       return EFI_INVALID_PARAMETER;\r
     }\r
   }\r
-\r
+  \r
   Options->FileSize *= Multiplier;\r
   //\r
   // Assume byte value of 0xff\r
@@ -203,12 +233,39 @@ Returns:
   Options->ByteValue = (INT8) (UINT8) 0xFF;\r
   return EFI_SUCCESS;\r
 }\r
+\r
+\r
+static\r
+void \r
+CMFVersion(\r
+  void\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print out version information for Strip.\r
+\r
+Arguments:\r
+\r
+  None\r
+  \r
+Returns:\r
+\r
+  None\r
+  \r
+--*/ \r
+{\r
+  printf ("%s v%d.%d -EDK utility to create a pad file containing fixed data\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);\r
+  printf ("Copyright (c) 1999-2006 Intel Corporation. All rights reserved.\n");\r
+}\r
+\r
 //\r
 // Print utility usage info\r
 //\r
 static\r
 void\r
-Usage (\r
+CMFUsage (\r
   VOID\r
   )\r
 /*++\r
@@ -226,22 +283,15 @@ Returns:
   GC_TODO: add return values\r
 \r
 --*/\r
-{\r
-  UINT32            Index;\r
-  static const INT8 *Text[] = {\r
-    " ",\r
-    "Usage:  "PROGRAM_NAME " OutFileName FileSize",\r
-    "  where:",\r
-    "    OutFileName is the name of the output file to generate",\r
-    "    FileSize is the size of the file to create",\r
-    "  Examples:",\r
-    "    "PROGRAM_NAME " OutFile.bin 32K",\r
-    "    "PROGRAM_NAME " OutFile.bin 0x1000",\r
-    " ",\r
-    NULL\r
-  };\r
-\r
-  for (Index = 0; Text[Index] != NULL; Index++) {\r
-    fprintf (stdout, "%s\n", Text[Index]);\r
-  }\r
-}\r
+{ \r
+  CMFVersion();\r
+  \r
+  printf ("\n  Usage: %s OutFileName FileSize \n\\r
+      where: \n\\r
+        OutFileName is the name of the output file to generate \n\\r
+        FileSize is the size of the file to create \n\\r
+      Examples: \n\\r
+        %s OutFile.bin 32K \n\\r
+        %s OutFile.bin 0x1000 \n",UTILITY_NAME, UTILITY_NAME, UTILITY_NAME);\r
+} \r
+\r
index 492210f67c3e8a7f074eb6437880bfcf406e6eea..f745ea2b46a105a0fe807ea099f668d20cb96aab 100644 (file)
@@ -27,9 +27,61 @@ Abstract:
 #include <stdio.h>\r
 \r
 #include <Common/UefiBaseTypes.h>\r
-\r
 #include "EfiCompress.h"\r
 \r
+#define UTILITY_NAME "EfiCompress"\r
+#define UTILITY_MAJOR_VERSION 1\r
+#define UTILITY_MINOR_VERSION 1\r
+\r
+void \r
+ECVersion(\r
+  void\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print out version information for EfiCompress.\r
+\r
+Arguments:\r
+\r
+  None\r
+  \r
+Returns:\r
+\r
+  None\r
+  \r
+--*/ \r
+{\r
+  printf ("%s v%d.%d -EDK Efi Compress Utility\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);\r
+  printf ("Copyright (c) 2005-2006 Intel Corporation. All rights reserved.\n");\r
+}\r
+\r
+void \r
+ECUsage(\r
+  void\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print out usage information for EfiCompress.\r
+\r
+Arguments:\r
+\r
+  None\r
+  \r
+Returns:\r
+\r
+  None\r
+  \r
+--*/ \r
+{\r
+  ECVersion();\r
+  printf ("\n  Usage: %s Inputfile Outputfile\n", UTILITY_NAME);\r
+}\r
+\r
+\r
 int\r
 main (\r
   INT32 argc,\r
@@ -65,19 +117,28 @@ Returns:
   //  Added for makefile debug - KCE\r
   //\r
   INT32       arg_counter;\r
-  printf ("\n\n");\r
-  for (arg_counter = 0; arg_counter < argc; arg_counter++) {\r
-    printf ("%s ", argv[arg_counter]);\r
-  }\r
-\r
-  printf ("\n\n");\r
-\r
\r
   SrcBuffer             = DstBuffer = NULL;\r
-\r
   infile                = outfile = NULL;\r
 \r
+  if (argc < 1) {\r
+    ECUsage();\r
+    goto Done;\r
+  }\r
+  \r
+  if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0) ||\r
+      (strcmp(argv[1], "-?") == 0) || (strcmp(argv[1], "/?") == 0)) {\r
+    ECUsage();\r
+    goto Done;\r
+  }\r
+  \r
+  if ((strcmp(argv[1], "-V") == 0) || (strcmp(argv[1], "--version") == 0)) {\r
+    ECVersion();\r
+    goto Done;\r
+  }\r
+  \r
   if (argc != 3) {\r
-    printf ("Usage: EFICOMPRESS <infile> <outfile>\n");\r
+    ECUsage();\r
     goto Done;\r
   }\r
 \r
index 3818649330555051e951ae5883c11833d6b76d13..b010102e260c99b3735d7bf74157e3e5f2b3bf34 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation                                                         \r
+Copyright (c) 2004-2006, Intel Corporation                                                         \r
 All rights reserved. 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
@@ -86,7 +86,7 @@ ParseDepex (
   );\r
 \r
 VOID\r
-PrintGenDepexUtilityInfo (\r
+GDVersion (\r
   VOID\r
   )\r
 /*++\r
@@ -111,11 +111,11 @@ Returns:
     UTILITY_MAJOR_VERSION,\r
     UTILITY_MINOR_VERSION\r
     );\r
-  printf ("Copyright (C) 1996-2002 Intel Corporation.  All rights reserved.\n\n");\r
+  printf ("Copyright (C) 1996-2006 Intel Corporation. All rights reserved.\n");\r
 }\r
 \r
 VOID\r
-PrintGenDepexUsageInfo (\r
+GDUsage (\r
   VOID\r
   )\r
 /*++\r
@@ -134,15 +134,16 @@ Returns:
 \r
 --*/\r
 {\r
+  GDVersion();\r
   printf (\r
-    "Usage: %s -I <INFILE> -O <OUTFILE> [-P <Optional Boundary for padding up>] \n",\r
+    "\n  Usage: %s -I InputFile -O OutputFile [-P <Optional Boundary for padding up>] \n",\r
     UTILITY_NAME\r
     );\r
-  printf (" Where:\n");\r
-  printf ("  <INFILE> is the input pre-processed dependency text files name.\n");\r
-  printf ("  <OUTFILE> is the output binary dependency files name.\n");\r
-  printf ("  <Optional Boundary for padding up> is the padding integer value.\n");\r
-  printf ("    This is the boundary to align the output file size to.\n");\r
+  printf ("  Where:\n");\r
+  printf ("    InputFile is the input pre-processed dependency text files name.\n");\r
+  printf ("    OutputFile is the output binary dependency files name.\n");\r
+  printf ("    <Optional Boundary for padding up> is the padding integer value.\n");\r
+  printf ("       This is the boundary to align the output file size to.\n");\r
 }\r
 \r
 DEPENDENCY_OPCODE\r
@@ -855,9 +856,25 @@ Returns:
   Output_Flag = FALSE;\r
   Pad_Flag    = FALSE;\r
 \r
+  if (argc < 1) {\r
+    GDUsage();\r
+    return -1;\r
+  }\r
+  \r
+  if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0) ||\r
+      (strcmp(argv[1], "-?") == 0) || (strcmp(argv[1], "/?") == 0)) {\r
+    GDUsage();\r
+    return 0;\r
+  }\r
+  \r
+  if ((strcmp(argv[1], "-V") == 0) || (strcmp(argv[1], "--version") == 0)) {\r
+    GDVersion();\r
+    return 0;\r
+  }\r
+  \r
   if (argc < 5) {\r
     printf ("Not enough arguments\n");\r
-    PrintGenDepexUsageInfo ();\r
+    GDUsage();\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -901,17 +918,15 @@ Returns:
     }\r
   }\r
 \r
-  PrintGenDepexUtilityInfo ();\r
-\r
   if (InFile == NULL) {\r
     printf ("Can not open <INFILE> for reading.\n");\r
-    PrintGenDepexUsageInfo ();\r
+    GDUsage();\r
     return EFI_ABORTED;\r
   }\r
 \r
   if (OutFile == NULL) {\r
     printf ("Can not open <OUTFILE> for writting.\n");\r
-    PrintGenDepexUsageInfo ();\r
+    GDUsage();\r
     return EFI_ABORTED;\r
   }\r
 \r
index 6008feb9813a4564dcdfe72b3593900dec651f47..5e3d17ddf431d6af19c5a3d92538f5b5fa392570 100755 (executable)
@@ -24,6 +24,10 @@ Abstract:
 #include "stdio.h"\r
 #include "string.h"\r
 \r
+#define UTILITY_NAME "ModifyInf"\r
+#define UTILITY_MAJOR_VERSION 1\r
+#define UTILITY_MINOR_VERSION 1\r
+\r
 //\r
 // Read a line into buffer including '\r\n'\r
 //\r
@@ -242,29 +246,67 @@ Returns:
   return 0;\r
 }\r
 \r
-void\r
-Usage (\r
+void \r
+MIVersion(\r
   void\r
   )\r
 /*++\r
 \r
 Routine Description:\r
 \r
-  GC_TODO: Add function description\r
+  Print out version information for Strip.\r
 \r
 Arguments:\r
 \r
   None\r
-\r
+  \r
 Returns:\r
 \r
-  GC_TODO: add return values\r
+  None\r
+  \r
+--*/ \r
+{\r
+  printf ("%s v%d.%d -EDK Modify fields in FV inf files.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);\r
+  printf ("Copyright (c) 2005-2006 Intel Corporation. All rights reserved.\n");\r
+}\r
 \r
---*/\r
+void \r
+MIUsage(\r
+  void\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print out usage information for Strip.\r
+\r
+Arguments:\r
+\r
+  None\r
+  \r
+Returns:\r
+\r
+  None\r
+  \r
+--*/ \r
 {\r
-  printf ("ModifyInf InputFVInfFileName OutputFVInfFileName [Pattern strings]\r\n");\r
+  MIVersion();\r
+  printf ("\n Usage: %s InputFile OutputFile Pattern_String [Pattern_String ¡­]\n\\r
+   Where: \n\\r
+     Pattern_String is of the format (note that the section name must be \n\\r
+     enclosed within square brackets):\n\\r
+         [section]FieldKey<op>Value [(FieldKey<op>Value) ¡­] \n\\r
+     The operator, <op>, must be one of the following: \n\\r
+         '==' replace a field value with a new value \n\\r
+         '+=' append a string at the end of original line \n\\r
+         '-'  prevent the line from applying any patterns \n\\r
+     Example: \n\\r
+         ModifyInf BuildRootFvFvMain.inf BuildRootFvFvMainEXP.inf \\ \n\\r
+               [files]EFI_FILE_NAME+=.Org EFI_NUM_BLOCKS==0x20 \\ \n\\r
+               [options]EFI_FILENAME==FcMainCompact.fv -DpsdSignature.dxe \n", UTILITY_NAME);\r
 }\r
 \r
+\r
 int\r
 main (\r
   int argc,\r
@@ -291,8 +333,24 @@ Returns:
   FILE  *fpin;\r
   FILE  *fpout;\r
 \r
+  if (argc < 1) {\r
+    MIUsage();\r
+    return -1;\r
+  }\r
+  \r
+  if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0) ||\r
+      (strcmp(argv[1], "-?") == 0) || (strcmp(argv[1], "/?") == 0)) {\r
+    MIUsage();\r
+    return 0;\r
+  }\r
+  \r
+  if ((strcmp(argv[1], "-V") == 0) || (strcmp(argv[1], "--version") == 0)) {\r
+    MIVersion();\r
+    return 0;\r
+  }\r
+  \r
   if (argc < 3) {\r
-    Usage ();\r
+    MIUsage();\r
     return -1;\r
   }\r
 \r
index bccdffb55aeaf95547bf85a4c062a55ad44a1148..a89bcf9a8ab1a9bae67fa6b7678f9cbc6b0c5968 100644 (file)
@@ -25,6 +25,59 @@ Abstract:
 #include <string.h>\r
 #include <stdlib.h>\r
 \r
+#define UTILITY_NAME  "Strip"\r
+#define UTILITY_MAJOR_VERSION 1\r
+#define UTILITY_MINOR_VERSION 1\r
+\r
+\r
+void \r
+StripVersion(\r
+  void\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print out version information for Strip.\r
+\r
+Arguments:\r
+\r
+  None\r
+  \r
+Returns:\r
+\r
+  None\r
+  \r
+--*/ \r
+{\r
+  printf ("%s v%d.%d -EDK Convert EXE to BIN\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);\r
+  printf ("Copyright (c) 2005-2006 Intel Corporation. All rights reserved.\n");\r
+}\r
+\r
+void \r
+StripUsage(\r
+  void\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print out usage information for Strip.\r
+\r
+Arguments:\r
+\r
+  None\r
+  \r
+Returns:\r
+\r
+  None\r
+  \r
+--*/ \r
+{\r
+  StripVersion();\r
+  printf ("\n  Usage: %s InputFile OutputFile\n", UTILITY_NAME);\r
+}\r
+\r
 int\r
 main (\r
   int  argc,\r
@@ -54,9 +107,25 @@ Returns:
   int   FileSize;\r
   char  *Buffer;\r
   char  *Ptrx;\r
-\r
+  \r
+  if (argc < 1) {\r
+    StripUsage();\r
+    return -1;\r
+  }\r
+  \r
+  if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0) ||\r
+      (strcmp(argv[1], "-?") == 0) || (strcmp(argv[1], "/?") == 0)) {\r
+    StripUsage();\r
+    return 0;\r
+  }\r
+  \r
+  if ((strcmp(argv[1], "-V") == 0) || (strcmp(argv[1], "--version") == 0)) {\r
+    StripVersion();\r
+    return 0;\r
+  }\r
+  \r
   if (argc < 3) {\r
-    printf ("Need more args, such as file name to convert and output name\n");\r
+    StripUsage();\r
     return -1;\r
   }\r
 \r
@@ -64,12 +133,12 @@ Returns:
   OutFile = fopen (argv[2], "wb");\r
 \r
   if (!InFile) {\r
-    printf ("no file, exit\n");\r
+    printf ("Unable to open input file, exit\n");\r
     return -1;\r
   }\r
 \r
   if (OutFile == NULL) {\r
-    printf ("Unable to open output file.\n");\r
+    printf ("Unable to open output file, exit.\n");\r
     return -1;\r
   }\r
 \r
@@ -77,7 +146,7 @@ Returns:
   FileSize = ftell (InFile);\r
 \r
   if (FileSize < 0x200) {\r
-    printf ("%d is not a legal size, exit\n", FileSize);\r
+    printf ("%d is not a legal file size, exit\n", FileSize);\r
     return -1;\r
   }\r
 \r