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
84 UINTN DebugLevel = 0;
\r
87 // Use this linked list structure to keep track of all the filenames
\r
88 // specified on the command line.
\r
90 typedef struct _FILE_LIST {
\r
91 struct _FILE_LIST *Next;
\r
95 UINT16 CodeRevision;
\r
99 // Use this to track our command-line options
\r
102 INT8 OutFileName[MAX_PATH];
\r
108 UINT16 PciRevision;
\r
121 FILE_LIST *FileList;
\r
125 // Make a global structure to keep track of command-line options
\r
127 static OPTIONS mOptions;
\r
130 // Use these to convert from machine type value to a named type
\r
140 static STRING_LOOKUP mMachineTypes[] = {
\r
141 EFI_IMAGE_MACHINE_IA32,
\r
143 EFI_IMAGE_MACHINE_IA64,
\r
145 EFI_IMAGE_MACHINE_EBC,
\r
154 static STRING_LOOKUP mSubsystemTypes[] = {
\r
155 EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION,
\r
157 EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER,
\r
158 "EFI boot service driver",
\r
159 EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER,
\r
160 "EFI runtime driver",
\r
166 // Function prototypes
\r
175 Routine Description:
\r
177 Displays the utility version to STDOUT
\r
197 Routine Description:
\r
199 Displays the utility usage syntax to STDOUT
\r
221 Routine Description:
\r
223 Given the Argc/Argv program arguments, and a pointer to an options structure,
\r
224 parse the command-line options and check their validity.
\r
228 Argc - standard C main() argument count
\r
229 Argv[] - standard C main() argument list
\r
230 Options - pointer to a structure to store the options in
\r
234 STATUS_SUCCESS success
\r
244 UINT16 *MachineType,
\r
249 Routine Description:
\r
251 Given the Argc/Argv program arguments, and a pointer to an options structure,
\r
252 parse the command-line options and check their validity.
\r
256 Argc - standard C main() argument count
\r
257 Argv[] - standard C main() argument list
\r
258 Options - pointer to a structure to store the options in
\r
262 STATUS_SUCCESS success
\r
279 Routine Description:
\r
281 Process a PE32 EFI file.
\r
285 OutFptr - file pointer to output binary ROM image file we're creating
\r
286 InFile - structure contains information on the PE32 file to process
\r
287 VendId - vendor ID as required in the option ROM header
\r
288 DevId - device ID as required in the option ROM header
\r
289 Size - pointer to where to return the size added to the output file
\r
307 Routine Description:
\r
309 Process a binary input file.
\r
313 OutFptr - file pointer to output binary ROM image file we're creating
\r
314 InFile - structure contains information on the binary file to process
\r
315 Size - pointer to where to return the size added to the output file
\r
331 Routine Description:
\r
333 Dump the headers of an existing option ROM image
\r
337 InFile - the file name of an existing option ROM image
\r
347 GetMachineTypeStr (
\r
352 Routine Description:
\r
354 GC_TODO: Add function description
\r
358 MachineType - GC_TODO: add argument description
\r
362 GC_TODO: add return values
\r
369 GetSubsystemTypeStr (
\r
370 UINT16 SubsystemType
\r
374 Routine Description:
\r
376 GC_TODO: Add function description
\r
380 SubsystemType - GC_TODO: add argument description
\r
384 GC_TODO: add return values
\r