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 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_X64
, "X64" },
119 { EFI_IMAGE_MACHINE_EBC
, "EBC" },
120 { EFI_IMAGE_MACHINE_ARMT
, "ARM" },
121 { EFI_IMAGE_MACHINE_AARCH64
, "AA64" },
128 static STRING_LOOKUP mSubsystemTypes
[] = {
129 { EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION
, "EFI application" },
130 { EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
, "EFI boot service driver" },
131 { EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER
, "EFI runtime driver" },
136 // Function prototypes
147 Displays the utility version to STDOUT
169 Displays the utility usage syntax to STDOUT
193 Given the Argc/Argv program arguments, and a pointer to an options structure,
194 parse the command-line options and check their validity.
198 Argc - standard C main() argument count
199 Argv[] - standard C main() argument list
200 Options - pointer to a structure to store the options in
204 STATUS_SUCCESS success
221 Given the Argc/Argv program arguments, and a pointer to an options structure,
222 parse the command-line options and check their validity.
226 Argc - standard C main() argument count
227 Argv[] - standard C main() argument list
228 Options - pointer to a structure to store the options in
232 STATUS_SUCCESS success
251 Process a PE32 EFI file.
255 OutFptr - file pointer to output binary ROM image file we're creating
256 InFile - structure contains information on the PE32 file to process
257 VendId - vendor ID as required in the option ROM header
258 DevId - device ID as required in the option ROM header
259 Size - pointer to where to return the size added to the output file
279 Process a binary input file.
283 OutFptr - file pointer to output binary ROM image file we're creating
284 InFile - structure contains information on the binary file to process
285 Size - pointer to where to return the size added to the output file
303 Dump the headers of an existing option ROM image
307 InFile - the file name of an existing option ROM image
324 GC_TODO: Add function description
328 MachineType - GC_TODO: add argument description
332 GC_TODO: add return values
339 GetSubsystemTypeStr (
346 GC_TODO: Add function description
350 SubsystemType - GC_TODO: add argument description
354 GC_TODO: add return values