]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c
EdkCompatibilityPkg: Remove EdkCompatibilityPkg
[mirror_edk2.git] / EdkCompatibilityPkg / Sample / Tools / Source / GenFvImage / GenFvImageExe.c
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c
deleted file mode 100644 (file)
index 6e45c86..0000000
+++ /dev/null
@@ -1,316 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004 - 2010, 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
-Module Name:\r
-\r
-  GenFvImageExe.c\r
-\r
-Abstract:\r
-\r
-  This contains all code necessary to build the GenFvImage.exe utility.       \r
-  This utility relies heavily on the GenFvImage Lib.  Definitions for both\r
-  can be found in the Tiano Firmware Volume Generation Utility \r
-  Specification, review draft.\r
-\r
---*/\r
-\r
-//\r
-// File included in build\r
-//\r
-#include "GenFvImageExe.h"\r
-#include "CommonLib.h"\r
-#include "EfiUtilityMsgs.h"\r
-\r
-VOID\r
-PrintUtilityInfo (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Displays the standard utility information to SDTOUT\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  int         Index;\r
-  const char  *Str[] = {\r
-    UTILITY_NAME" "UTILITY_VERSION" - Intel Generate Firmware Volume Utility",\r
-    "  Copyright (C), 2004 - 2009 Intel Corporation",\r
-    \r
-#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
-    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
-#endif\r
-    NULL\r
-  };\r
-  for (Index = 0; Str[Index] != NULL; Index++) {\r
-    fprintf (stdout, "%s\n", Str[Index]);\r
-  }\r
-}\r
-\r
-VOID\r
-PrintUsage (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Displays the utility usage syntax to STDOUT\r
-\r
-Arguments:\r
-\r
-  None\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  int         Index;\r
-  const char  *Str[] = {\r
-    "",\r
-    "Usage:",\r
-    "  "UTILITY_NAME" [OPTION]",\r
-    "Options:",\r
-    "  -I FvInfFileName  The name of the image description file.",\r
-    NULL\r
-  };\r
-\r
-  for (Index = 0; Str[Index] != NULL; Index++) {\r
-    fprintf (stdout, "%s\n", Str[Index]);\r
-  }\r
-}\r
-\r
-EFI_STATUS\r
-main (\r
-  IN INTN   argc,\r
-  IN CHAR8  **argv\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This utility uses GenFvImage.Lib to build a firmware volume image.\r
-\r
-Arguments:\r
-\r
-  FvInfFileName      The name of an FV image description file.\r
-\r
-  Arguments come in pair in any order.\r
-    -I FvInfFileName \r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS            No error conditions detected.\r
-  EFI_INVALID_PARAMETER  One or more of the input parameters is invalid.\r
-  EFI_OUT_OF_RESOURCES   A resource required by the utility was unavailable.  \r
-                         Most commonly this will be memory allocation \r
-                         or file creation.\r
-  EFI_LOAD_ERROR         GenFvImage.lib could not be loaded.\r
-  EFI_ABORTED            Error executing the GenFvImage lib.\r
-\r
---*/\r
-{\r
-  EFI_STATUS  Status;\r
-  CHAR8       InfFileName[_MAX_PATH];\r
-  CHAR8       *InfFileImage;\r
-  UINTN       InfFileSize;\r
-  UINT8       *FvImage;\r
-  UINTN       FvImageSize;\r
-  UINT8       Index;\r
-  CHAR8       FvFileNameBuffer[_MAX_PATH];\r
-  CHAR8       *FvFileName;\r
-  FILE        *FvFile;\r
-  FILE        *SymFile;\r
-  CHAR8       SymFileNameBuffer[_MAX_PATH];\r
-  CHAR8       *SymFileName;\r
-  UINT8       *SymImage;\r
-  UINTN       SymImageSize;\r
-  CHAR8       *CurrentSymString;\r
-\r
-  FvFileName  = FvFileNameBuffer;\r
-  SymFileName = SymFileNameBuffer;\r
-\r
-  SetUtilityName (UTILITY_NAME);\r
-  //\r
-  // Display utility information\r
-  //\r
-  PrintUtilityInfo ();\r
-\r
-  //\r
-  // Verify the correct number of arguments\r
-  //\r
-  if (argc != MAX_ARGS) {\r
-    Error (NULL, 0, 0, "invalid number of input parameters specified", NULL);\r
-    PrintUsage ();\r
-    return GetUtilityStatus ();\r
-  }\r
-  //\r
-  // Initialize variables\r
-  //\r
-  strcpy (InfFileName, "");\r
-\r
-  //\r
-  // Parse the command line arguments\r
-  //\r
-  for (Index = 1; Index < MAX_ARGS; Index += 2) {\r
-    //\r
-    // Make sure argument pair begin with - or /\r
-    //\r
-    if (argv[Index][0] != '-' && argv[Index][0] != '/') {\r
-      Error (NULL, 0, 0, argv[Index], "argument pair must begin with \"-\" or \"/\"");\r
-      PrintUsage ();\r
-      return GetUtilityStatus ();\r
-    }\r
-    //\r
-    // Make sure argument specifier is only one letter\r
-    //\r
-    if (argv[Index][2] != 0) {\r
-      Error (NULL, 0, 0, argv[Index], "unrecognized argument");\r
-      PrintUsage ();\r
-      return GetUtilityStatus ();\r
-    }\r
-    //\r
-    // Determine argument to read\r
-    //\r
-    switch (argv[Index][1]) {\r
-\r
-    case 'I':\r
-    case 'i':\r
-      if (strlen (InfFileName) == 0) {\r
-        strcpy (InfFileName, argv[Index + 1]);\r
-      } else {\r
-        Error (NULL, 0, 0, argv[Index + 1], "FvInfFileName may only be specified once");\r
-        PrintUsage ();\r
-        return GetUtilityStatus ();\r
-      }\r
-      break;\r
-\r
-    default:\r
-      Error (NULL, 0, 0, argv[Index], "unrecognized argument");\r
-      PrintUsage ();\r
-      return GetUtilityStatus ();\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // Read the INF file image\r
-  //\r
-  Status = GetFileImage (InfFileName, &InfFileImage, &InfFileSize);\r
-  if (EFI_ERROR (Status)) {\r
-    return STATUS_ERROR;\r
-  }\r
-  //\r
-  // Call the GenFvImage lib\r
-  //\r
-  Status = GenerateFvImage (\r
-            InfFileImage,\r
-            InfFileSize,\r
-            &FvImage,\r
-            &FvImageSize,\r
-            &FvFileName,\r
-            &SymImage,\r
-            &SymImageSize,\r
-            &SymFileName\r
-            );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    switch (Status) {\r
-\r
-    case EFI_INVALID_PARAMETER:\r
-      Error (NULL, 0, 0, "invalid parameter passed to GenFvImage Lib", NULL);\r
-      return GetUtilityStatus ();\r
-      break;\r
-\r
-    case EFI_ABORTED:\r
-      Error (NULL, 0, 0, "error detected while creating the file image", NULL);\r
-      return GetUtilityStatus ();\r
-      break;\r
-\r
-    case EFI_OUT_OF_RESOURCES:\r
-      Error (NULL, 0, 0, "GenFvImage Lib could not allocate required resources", NULL);\r
-      return GetUtilityStatus ();\r
-      break;\r
-\r
-    case EFI_VOLUME_CORRUPTED:\r
-      Error (NULL, 0, 0, "no base address was specified, but the FV.INF included a PEI or BSF file", NULL);\r
-      return GetUtilityStatus ();\r
-      break;\r
-\r
-    case EFI_LOAD_ERROR:\r
-      Error (NULL, 0, 0, "could not load FV image generation library", NULL);\r
-      return GetUtilityStatus ();\r
-      break;\r
-\r
-    default:\r
-      Error (NULL, 0, 0, "GenFvImage Lib returned unknown status", "status returned = 0x%X", Status);\r
-      return GetUtilityStatus ();\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // Write file\r
-  //\r
-  FvFile = fopen (FvFileName, "wb");\r
-  if (FvFile == NULL) {\r
-    Error (NULL, 0, 0, FvFileName, "could not open output file");\r
-    free (FvImage);\r
-    free (SymImage);\r
-    return GetUtilityStatus ();\r
-  }\r
-\r
-  if (fwrite (FvImage, 1, FvImageSize, FvFile) != FvImageSize) {\r
-    Error (NULL, 0, 0, FvFileName, "failed to write to output file");\r
-    free (FvImage);\r
-    free (SymImage);\r
-    fclose (FvFile);\r
-    return GetUtilityStatus ();\r
-  }\r
-\r
-  fclose (FvFile);\r
-  free (FvImage);\r
-\r
-  //\r
-  // Write symbol file\r
-  //\r
-  if (strcmp (SymFileName, "")) {\r
-    SymFile = fopen (SymFileName, "wt");\r
-    if (SymFile == NULL) {\r
-      Error (NULL, 0, 0, SymFileName, "could not open output symbol file");\r
-      free (SymImage);\r
-      return GetUtilityStatus ();\r
-    }\r
-\r
-    fprintf (SymFile, "TEXTSYM format | V1.0\n");\r
-\r
-    CurrentSymString = SymImage;\r
-    while (((UINTN) CurrentSymString - (UINTN) SymImage) < SymImageSize) {\r
-      fprintf (SymFile, "%s", CurrentSymString);\r
-      CurrentSymString = (CHAR8 *) (((UINTN) CurrentSymString) + strlen (CurrentSymString) + 1);\r
-    }\r
-\r
-    fclose (SymFile);\r
-  }\r
-\r
-  free (SymImage);\r
-\r
-  return GetUtilityStatus ();\r
-}\r