3 Copyright (c) 1999 - 2008 Intel Corporation. All rights reserved
\r
4 This software and associated documentation (if any) is furnished
\r
5 under a license and may only be used or copied in accordance
\r
6 with the terms of the license. Except as permitted by such
\r
7 license, no part of this software or documentation may be
\r
8 reproduced, stored in a retrieval system, or transmitted in any
\r
9 form or by any means without the express written consent of
\r
19 This file contains the relevant declarations required
\r
20 to generate Option Rom File
\r
24 #ifndef __EFI_ROM_H__
\r
25 #define __EFI_ROM_H__
\r
31 #include <Common/UefiBaseTypes.h>
\r
32 #include <IndustryStandard/PeImage.h> // for PE32 structure definitions
\r
34 #include <IndustryStandard/pci22.h> // for option ROM header structures
\r
35 #include <IndustryStandard/pci30.h>
\r
37 #include "Compress.h"
\r
38 #include "CommonLib.h"
\r
41 // Version of this utility
\r
43 #define UTILITY_NAME "EfiRom"
\r
44 #define UTILITY_MAJOR_VERSION 0
\r
45 #define UTILITY_MINOR_VERSION 1
\r
48 // Define some status return values
\r
50 #define STATUS_SUCCESS 0
\r
51 #define STATUS_WARNING 1
\r
52 #define STATUS_ERROR 2
\r
55 // Define the max length of a filename
\r
57 #define MAX_PATH 200
\r
60 // Define the default file extension name
\r
62 #define DEFAULT_OUTPUT_EXTENSION ".rom"
\r
65 // Max size for an option ROM image
\r
67 #define MAX_OPTION_ROM_SIZE (1024 * 1024 * 16) // 16MB
\r
70 // Values for the indicator field in the PCI data structure
\r
72 #define INDICATOR_LAST 0x80 // last file in series of files
\r
75 // Masks for the FILE_LIST.FileFlags field
\r
77 #define FILE_FLAG_BINARY 0x01
\r
78 #define FILE_FLAG_EFI 0x02
\r
79 #define FILE_FLAG_COMPRESS 0x04
\r
82 // Use this linked list structure to keep track of all the filenames
\r
83 // specified on the command line.
\r
85 typedef struct _FILE_LIST {
\r
86 struct _FILE_LIST *Next;
\r
90 UINT16 CodeRevision;
\r
94 // Use this to track our command-line options
\r
97 CHAR8 OutFileName[MAX_PATH];
\r
100 UINT16 PciRevision;
\r
113 FILE_LIST *FileList;
\r
117 // Make a global structure to keep track of command-line options
\r
119 static OPTIONS mOptions;
\r
122 // Use these to convert from machine type value to a named type
\r
132 static STRING_LOOKUP mMachineTypes[] = {
\r
133 { EFI_IMAGE_MACHINE_IA32, "IA32" },
\r
134 { EFI_IMAGE_MACHINE_IA64, "IA64" },
\r
135 { EFI_IMAGE_MACHINE_EBC, "EBC" },
\r
142 static STRING_LOOKUP mSubsystemTypes[] = {
\r
143 { EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION, "EFI application" },
\r
144 { EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER, "EFI boot service driver" },
\r
145 { EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER, "EFI runtime driver" },
\r
150 // Function prototypes
\r
159 Routine Description:
\r
161 Displays the utility version to STDOUT
\r
181 Routine Description:
\r
183 Displays the utility usage syntax to STDOUT
\r
205 Routine Description:
\r
207 Given the Argc/Argv program arguments, and a pointer to an options structure,
\r
208 parse the command-line options and check their validity.
\r
212 Argc - standard C main() argument count
\r
213 Argv[] - standard C main() argument list
\r
214 Options - pointer to a structure to store the options in
\r
218 STATUS_SUCCESS success
\r
228 UINT16 *MachineType,
\r
233 Routine Description:
\r
235 Given the Argc/Argv program arguments, and a pointer to an options structure,
\r
236 parse the command-line options and check their validity.
\r
240 Argc - standard C main() argument count
\r
241 Argv[] - standard C main() argument list
\r
242 Options - pointer to a structure to store the options in
\r
246 STATUS_SUCCESS success
\r
263 Routine Description:
\r
265 Process a PE32 EFI file.
\r
269 OutFptr - file pointer to output binary ROM image file we're creating
\r
270 InFile - structure contains information on the PE32 file to process
\r
271 VendId - vendor ID as required in the option ROM header
\r
272 DevId - device ID as required in the option ROM header
\r
273 Size - pointer to where to return the size added to the output file
\r
291 Routine Description:
\r
293 Process a binary input file.
\r
297 OutFptr - file pointer to output binary ROM image file we're creating
\r
298 InFile - structure contains information on the binary file to process
\r
299 Size - pointer to where to return the size added to the output file
\r
315 Routine Description:
\r
317 Dump the headers of an existing option ROM image
\r
321 InFile - the file name of an existing option ROM image
\r
331 GetMachineTypeStr (
\r
336 Routine Description:
\r
338 GC_TODO: Add function description
\r
342 MachineType - GC_TODO: add argument description
\r
346 GC_TODO: add return values
\r
353 GetSubsystemTypeStr (
\r
354 UINT16 SubsystemType
\r
358 Routine Description:
\r
360 GC_TODO: Add function description
\r
364 SubsystemType - GC_TODO: add argument description
\r
368 GC_TODO: add return values
\r