2 This file contains the relevant declarations required to generate Option Rom File
4 Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
16 #include <Common/UefiBaseTypes.h>
17 #include <IndustryStandard/PeImage.h> // for PE32 structure definitions
19 #include <IndustryStandard/pci22.h> // for option ROM header structures
20 #include <IndustryStandard/pci30.h>
23 #include "CommonLib.h"
26 // Version of this utility
28 #define UTILITY_NAME "EfiRom"
29 #define UTILITY_MAJOR_VERSION 0
30 #define UTILITY_MINOR_VERSION 1
33 // Define the max length of a filename
38 // Define the default file extension name
40 #define DEFAULT_OUTPUT_EXTENSION ".rom"
43 // Max size for an option ROM image
45 #define MAX_OPTION_ROM_SIZE (1024 * 1024 * 16) // 16MB
48 // Values for the indicator field in the PCI data structure
50 #define INDICATOR_LAST 0x80 // last file in series of files
53 // Masks for the FILE_LIST.FileFlags field
55 #define FILE_FLAG_BINARY 0x01
56 #define FILE_FLAG_EFI 0x02
57 #define FILE_FLAG_COMPRESS 0x04
60 // Use this linked list structure to keep track of all the filenames
61 // specified on the command line.
63 typedef struct _FILE_LIST
{
64 struct _FILE_LIST
*Next
;
72 // Use this to track our command-line options
75 CHAR8 OutFileName
[MAX_PATH
];
95 // Make a global structure to keep track of command-line options
97 static OPTIONS mOptions
;
100 // Use these to convert from machine type value to a named type
110 static STRING_LOOKUP mMachineTypes
[] = {
111 { EFI_IMAGE_MACHINE_IA32
, "IA32" },
112 { EFI_IMAGE_MACHINE_X64
, "X64" },
113 { EFI_IMAGE_MACHINE_EBC
, "EBC" },
114 { EFI_IMAGE_MACHINE_ARMT
, "ARM" },
115 { EFI_IMAGE_MACHINE_AARCH64
, "AA64" },
122 static STRING_LOOKUP mSubsystemTypes
[] = {
123 { EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION
, "EFI application" },
124 { EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
, "EFI boot service driver" },
125 { EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER
, "EFI runtime driver" },
130 // Function prototypes
141 Displays the utility version to STDOUT
163 Displays the utility usage syntax to STDOUT
187 Given the Argc/Argv program arguments, and a pointer to an options structure,
188 parse the command-line options and check their validity.
192 Argc - standard C main() argument count
193 Argv[] - standard C main() argument list
194 Options - pointer to a structure to store the options in
198 STATUS_SUCCESS success
215 Given the Argc/Argv program arguments, and a pointer to an options structure,
216 parse the command-line options and check their validity.
220 Argc - standard C main() argument count
221 Argv[] - standard C main() argument list
222 Options - pointer to a structure to store the options in
226 STATUS_SUCCESS success
245 Process a PE32 EFI file.
249 OutFptr - file pointer to output binary ROM image file we're creating
250 InFile - structure contains information on the PE32 file to process
251 VendId - vendor ID as required in the option ROM header
252 DevId - device ID as required in the option ROM header
253 Size - pointer to where to return the size added to the output file
273 Process a binary input file.
277 OutFptr - file pointer to output binary ROM image file we're creating
278 InFile - structure contains information on the binary file to process
279 Size - pointer to where to return the size added to the output file
297 Dump the headers of an existing option ROM image
301 InFile - the file name of an existing option ROM image
318 GC_TODO: Add function description
322 MachineType - GC_TODO: add argument description
326 GC_TODO: add return values
333 GetSubsystemTypeStr (
340 GC_TODO: Add function description
344 SubsystemType - GC_TODO: add argument description
348 GC_TODO: add return values