2 This file contains the relevant declarations required to generate Option Rom File
4 Copyright (c) 1999 - 2017, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available
6 under the terms and conditions of the BSD License which accompanies this
7 distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 #include <Common/UefiBaseTypes.h>
23 #include <IndustryStandard/PeImage.h> // for PE32 structure definitions
25 #include <IndustryStandard/pci22.h> // for option ROM header structures
26 #include <IndustryStandard/pci30.h>
29 #include "CommonLib.h"
32 // Version of this utility
34 #define UTILITY_NAME "EfiRom"
35 #define UTILITY_MAJOR_VERSION 0
36 #define UTILITY_MINOR_VERSION 1
39 // Define the max length of a filename
44 // Define the default file extension name
46 #define DEFAULT_OUTPUT_EXTENSION ".rom"
49 // Max size for an option ROM image
51 #define MAX_OPTION_ROM_SIZE (1024 * 1024 * 16) // 16MB
54 // Values for the indicator field in the PCI data structure
56 #define INDICATOR_LAST 0x80 // last file in series of files
59 // Masks for the FILE_LIST.FileFlags field
61 #define FILE_FLAG_BINARY 0x01
62 #define FILE_FLAG_EFI 0x02
63 #define FILE_FLAG_COMPRESS 0x04
66 // Use this linked list structure to keep track of all the filenames
67 // specified on the command line.
69 typedef struct _FILE_LIST
{
70 struct _FILE_LIST
*Next
;
78 // Use this to track our command-line options
81 CHAR8 OutFileName
[MAX_PATH
];
101 // Make a global structure to keep track of command-line options
103 static OPTIONS mOptions
;
106 // Use these to convert from machine type value to a named type
116 static STRING_LOOKUP mMachineTypes
[] = {
117 { EFI_IMAGE_MACHINE_IA32
, "IA32" },
118 { EFI_IMAGE_MACHINE_IA64
, "IA64" },
119 { EFI_IMAGE_MACHINE_EBC
, "EBC" },
120 { EFI_IMAGE_MACHINE_X64
, "X64" },
121 { EFI_IMAGE_MACHINE_ARMT
, "ARM" },
122 { EFI_IMAGE_MACHINE_AARCH64
, "AA64" },
129 static STRING_LOOKUP mSubsystemTypes
[] = {
130 { EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION
, "EFI application" },
131 { EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
, "EFI boot service driver" },
132 { EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER
, "EFI runtime driver" },
137 // Function prototypes
148 Displays the utility version to STDOUT
170 Displays the utility usage syntax to STDOUT
194 Given the Argc/Argv program arguments, and a pointer to an options structure,
195 parse the command-line options and check their validity.
199 Argc - standard C main() argument count
200 Argv[] - standard C main() argument list
201 Options - pointer to a structure to store the options in
205 STATUS_SUCCESS success
222 Given the Argc/Argv program arguments, and a pointer to an options structure,
223 parse the command-line options and check their validity.
227 Argc - standard C main() argument count
228 Argv[] - standard C main() argument list
229 Options - pointer to a structure to store the options in
233 STATUS_SUCCESS success
252 Process a PE32 EFI file.
256 OutFptr - file pointer to output binary ROM image file we're creating
257 InFile - structure contains information on the PE32 file to process
258 VendId - vendor ID as required in the option ROM header
259 DevId - device ID as required in the option ROM header
260 Size - pointer to where to return the size added to the output file
280 Process a binary input file.
284 OutFptr - file pointer to output binary ROM image file we're creating
285 InFile - structure contains information on the binary file to process
286 Size - pointer to where to return the size added to the output file
304 Dump the headers of an existing option ROM image
308 InFile - the file name of an existing option ROM image
325 GC_TODO: Add function description
329 MachineType - GC_TODO: add argument description
333 GC_TODO: add return values
340 GetSubsystemTypeStr (
347 GC_TODO: Add function description
351 SubsystemType - GC_TODO: add argument description
355 GC_TODO: add return values