3 Copyright (c) 1999 - 2008 Intel Corporation. All rights reserved
4 This software and associated documentation (if any) is furnished
5 under a license and may only be used or copied in accordance
6 with the terms of the license. Except as permitted by such
7 license, no part of this software or documentation may be
8 reproduced, stored in a retrieval system, or transmitted in any
9 form or by any means without the express written consent of
19 This file contains the relevant declarations required
20 to generate Option Rom File
31 #include <Common/UefiBaseTypes.h>
32 #include <IndustryStandard/PeImage.h> // for PE32 structure definitions
34 #include <IndustryStandard/pci22.h> // for option ROM header structures
35 #include <IndustryStandard/pci30.h>
38 #include "CommonLib.h"
41 // Version of this utility
43 #define UTILITY_NAME "EfiRom"
44 #define UTILITY_MAJOR_VERSION 0
45 #define UTILITY_MINOR_VERSION 1
48 // Define the max length of a filename
53 // Define the default file extension name
55 #define DEFAULT_OUTPUT_EXTENSION ".rom"
58 // Max size for an option ROM image
60 #define MAX_OPTION_ROM_SIZE (1024 * 1024 * 16) // 16MB
63 // Values for the indicator field in the PCI data structure
65 #define INDICATOR_LAST 0x80 // last file in series of files
68 // Masks for the FILE_LIST.FileFlags field
70 #define FILE_FLAG_BINARY 0x01
71 #define FILE_FLAG_EFI 0x02
72 #define FILE_FLAG_COMPRESS 0x04
75 // Use this linked list structure to keep track of all the filenames
76 // specified on the command line.
78 typedef struct _FILE_LIST
{
79 struct _FILE_LIST
*Next
;
87 // Use this to track our command-line options
90 CHAR8 OutFileName
[MAX_PATH
];
110 // Make a global structure to keep track of command-line options
112 static OPTIONS mOptions
;
115 // Use these to convert from machine type value to a named type
125 static STRING_LOOKUP mMachineTypes
[] = {
126 { EFI_IMAGE_MACHINE_IA32
, "IA32" },
127 { EFI_IMAGE_MACHINE_IA64
, "IA64" },
128 { EFI_IMAGE_MACHINE_EBC
, "EBC" },
135 static STRING_LOOKUP mSubsystemTypes
[] = {
136 { EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION
, "EFI application" },
137 { EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
, "EFI boot service driver" },
138 { EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER
, "EFI runtime driver" },
143 // Function prototypes
154 Displays the utility version to STDOUT
176 Displays the utility usage syntax to STDOUT
200 Given the Argc/Argv program arguments, and a pointer to an options structure,
201 parse the command-line options and check their validity.
205 Argc - standard C main() argument count
206 Argv[] - standard C main() argument list
207 Options - pointer to a structure to store the options in
211 STATUS_SUCCESS success
228 Given the Argc/Argv program arguments, and a pointer to an options structure,
229 parse the command-line options and check their validity.
233 Argc - standard C main() argument count
234 Argv[] - standard C main() argument list
235 Options - pointer to a structure to store the options in
239 STATUS_SUCCESS success
258 Process a PE32 EFI file.
262 OutFptr - file pointer to output binary ROM image file we're creating
263 InFile - structure contains information on the PE32 file to process
264 VendId - vendor ID as required in the option ROM header
265 DevId - device ID as required in the option ROM header
266 Size - pointer to where to return the size added to the output file
286 Process a binary input file.
290 OutFptr - file pointer to output binary ROM image file we're creating
291 InFile - structure contains information on the binary file to process
292 Size - pointer to where to return the size added to the output file
310 Dump the headers of an existing option ROM image
314 InFile - the file name of an existing option ROM image
331 GC_TODO: Add function description
335 MachineType - GC_TODO: add argument description
339 GC_TODO: add return values
346 GetSubsystemTypeStr (
353 GC_TODO: Add function description
357 SubsystemType - GC_TODO: add argument description
361 GC_TODO: add return values