3 Copyright (c) 1999 - 2007 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
85 BOOLEAN DebugMode = FALSE;
\r
86 BOOLEAN QuietMode = FALSE;
\r
89 // Use this linked list structure to keep track of all the filenames
\r
90 // specified on the command line.
\r
92 typedef struct _FILE_LIST {
\r
93 struct _FILE_LIST *Next;
\r
97 UINT16 CodeRevision;
\r
101 // Use this to track our command-line options
\r
104 INT8 OutFileName[MAX_PATH];
\r
110 UINT16 PciRevision;
\r
123 FILE_LIST *FileList;
\r
127 // Make a global structure to keep track of command-line options
\r
129 static OPTIONS mOptions;
\r
132 // Use these to convert from machine type value to a named type
\r
142 static STRING_LOOKUP mMachineTypes[] = {
\r
143 EFI_IMAGE_MACHINE_IA32,
\r
145 EFI_IMAGE_MACHINE_IA64,
\r
147 EFI_IMAGE_MACHINE_EBC,
\r
156 static STRING_LOOKUP mSubsystemTypes[] = {
\r
157 EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION,
\r
159 EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER,
\r
160 "EFI boot service driver",
\r
161 EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER,
\r
162 "EFI runtime driver",
\r
168 // Function prototypes
\r
177 Routine Description:
\r
179 Displays the utility version to STDOUT
\r
199 Routine Description:
\r
201 Displays the utility usage syntax to STDOUT
\r
223 Routine Description:
\r
225 Given the Argc/Argv program arguments, and a pointer to an options structure,
\r
226 parse the command-line options and check their validity.
\r
230 Argc - standard C main() argument count
\r
231 Argv[] - standard C main() argument list
\r
232 Options - pointer to a structure to store the options in
\r
236 STATUS_SUCCESS success
\r
246 UINT16 *MachineType,
\r
251 Routine Description:
\r
253 Given the Argc/Argv program arguments, and a pointer to an options structure,
\r
254 parse the command-line options and check their validity.
\r
258 Argc - standard C main() argument count
\r
259 Argv[] - standard C main() argument list
\r
260 Options - pointer to a structure to store the options in
\r
264 STATUS_SUCCESS success
\r
281 Routine Description:
\r
283 Process a PE32 EFI file.
\r
287 OutFptr - file pointer to output binary ROM image file we're creating
\r
288 InFile - structure contains information on the PE32 file to process
\r
289 VendId - vendor ID as required in the option ROM header
\r
290 DevId - device ID as required in the option ROM header
\r
291 Size - pointer to where to return the size added to the output file
\r
309 Routine Description:
\r
311 Process a binary input file.
\r
315 OutFptr - file pointer to output binary ROM image file we're creating
\r
316 InFile - structure contains information on the binary file to process
\r
317 Size - pointer to where to return the size added to the output file
\r
333 Routine Description:
\r
335 Dump the headers of an existing option ROM image
\r
339 InFile - the file name of an existing option ROM image
\r
349 GetMachineTypeStr (
\r
354 Routine Description:
\r
356 GC_TODO: Add function description
\r
360 MachineType - GC_TODO: add argument description
\r
364 GC_TODO: add return values
\r
371 GetSubsystemTypeStr (
\r
372 UINT16 SubsystemType
\r
376 Routine Description:
\r
378 GC_TODO: Add function description
\r
382 SubsystemType - GC_TODO: add argument description
\r
386 GC_TODO: add return values
\r