2 This file contains the relevant declarations required to generate Option Rom File
4 Copyright (c) 1999 - 2014, 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" },
126 static STRING_LOOKUP mSubsystemTypes
[] = {
127 { EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION
, "EFI application" },
128 { EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
, "EFI boot service driver" },
129 { EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER
, "EFI runtime driver" },
134 // Function prototypes
145 Displays the utility version to STDOUT
167 Displays the utility usage syntax to STDOUT
191 Given the Argc/Argv program arguments, and a pointer to an options structure,
192 parse the command-line options and check their validity.
196 Argc - standard C main() argument count
197 Argv[] - standard C main() argument list
198 Options - pointer to a structure to store the options in
202 STATUS_SUCCESS success
219 Given the Argc/Argv program arguments, and a pointer to an options structure,
220 parse the command-line options and check their validity.
224 Argc - standard C main() argument count
225 Argv[] - standard C main() argument list
226 Options - pointer to a structure to store the options in
230 STATUS_SUCCESS success
249 Process a PE32 EFI file.
253 OutFptr - file pointer to output binary ROM image file we're creating
254 InFile - structure contains information on the PE32 file to process
255 VendId - vendor ID as required in the option ROM header
256 DevId - device ID as required in the option ROM header
257 Size - pointer to where to return the size added to the output file
277 Process a binary input file.
281 OutFptr - file pointer to output binary ROM image file we're creating
282 InFile - structure contains information on the binary file to process
283 Size - pointer to where to return the size added to the output file
301 Dump the headers of an existing option ROM image
305 InFile - the file name of an existing option ROM image
322 GC_TODO: Add function description
326 MachineType - GC_TODO: add argument description
330 GC_TODO: add return values
337 GetSubsystemTypeStr (
344 GC_TODO: Add function description
348 SubsystemType - GC_TODO: add argument description
352 GC_TODO: add return values