]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/C/EfiRom/EfiRom.h
Check In tool source code based on Build tool project revision r1655.
[mirror_edk2.git] / BaseTools / Source / C / EfiRom / EfiRom.h
CommitLineData
30fdf114
LG
1/** @file\r
2\r
3Copyright (c) 1999 - 2008 Intel Corporation. All rights reserved\r
4This software and associated documentation (if any) is furnished\r
5under a license and may only be used or copied in accordance\r
6with the terms of the license. Except as permitted by such\r
7license, no part of this software or documentation may be\r
8reproduced, stored in a retrieval system, or transmitted in any\r
9form or by any means without the express written consent of\r
10Intel Corporation.\r
11\r
12\r
13Module Name: \r
14\r
15 EfiRom.h\r
16\r
17Abstract:\r
18\r
19 This file contains the relevant declarations required\r
20 to generate Option Rom File\r
21\r
22**/\r
23\r
24#ifndef __EFI_ROM_H__\r
25#define __EFI_ROM_H__\r
26\r
27#include <stdio.h>\r
28#include <string.h>\r
29#include <stdlib.h>\r
30\r
31#include <Common/UefiBaseTypes.h>\r
32#include <IndustryStandard/PeImage.h> // for PE32 structure definitions\r
33\r
34#include <IndustryStandard/pci22.h> // for option ROM header structures\r
35#include <IndustryStandard/pci30.h>\r
36\r
37#include "Compress.h"\r
38#include "CommonLib.h"\r
39\r
40//\r
41// Version of this utility\r
42//\r
43#define UTILITY_NAME "EfiRom"\r
44#define UTILITY_MAJOR_VERSION 0\r
45#define UTILITY_MINOR_VERSION 1\r
46\r
47//\r
48// Define the max length of a filename\r
49//\r
50#define MAX_PATH 200\r
51\r
52//\r
53// Define the default file extension name\r
54//\r
55#define DEFAULT_OUTPUT_EXTENSION ".rom"\r
56\r
57//\r
58// Max size for an option ROM image\r
59//\r
60#define MAX_OPTION_ROM_SIZE (1024 * 1024 * 16) // 16MB\r
61\r
62//\r
63// Values for the indicator field in the PCI data structure\r
64//\r
65#define INDICATOR_LAST 0x80 // last file in series of files\r
66\r
67//\r
68// Masks for the FILE_LIST.FileFlags field\r
69//\r
70#define FILE_FLAG_BINARY 0x01\r
71#define FILE_FLAG_EFI 0x02\r
72#define FILE_FLAG_COMPRESS 0x04\r
73\r
74//\r
75// Use this linked list structure to keep track of all the filenames\r
76// specified on the command line.\r
77//\r
78typedef struct _FILE_LIST {\r
79 struct _FILE_LIST *Next;\r
80 CHAR8 *FileName;\r
81 UINT32 FileFlags;\r
82 UINT32 ClassCode;\r
83 UINT16 CodeRevision;\r
84} FILE_LIST;\r
85\r
86//\r
87// Use this to track our command-line options\r
88//\r
89typedef struct {\r
90 CHAR8 OutFileName[MAX_PATH];\r
91 INT8 NoLast;\r
92 UINT16 ClassCode;\r
93 UINT16 PciRevision;\r
94 UINT16 VendId;\r
95 UINT16 DevId;\r
96 UINT8 VendIdValid;\r
97 UINT8 DevIdValid;\r
98 INT8 Verbose;\r
99 INT8 Quiet;\r
100 INT8 Debug;\r
101 INT8 Pci23;\r
102 INT8 Pci30;\r
103 INT8 DumpOption;\r
104// INT8 Help;\r
105// INT8 Version; \r
106 FILE_LIST *FileList;\r
107} OPTIONS;\r
108\r
109//\r
110// Make a global structure to keep track of command-line options\r
111//\r
112static OPTIONS mOptions;\r
113\r
114//\r
115// Use these to convert from machine type value to a named type\r
116//\r
117typedef struct {\r
118 UINT16 Value;\r
119 CHAR8 *Name;\r
120} STRING_LOOKUP;\r
121\r
122//\r
123// Machine Types\r
124//\r
125static STRING_LOOKUP mMachineTypes[] = {\r
126 { EFI_IMAGE_MACHINE_IA32, "IA32" },\r
127 { EFI_IMAGE_MACHINE_IA64, "IA64" },\r
128 { EFI_IMAGE_MACHINE_EBC, "EBC" },\r
129 { 0, NULL }\r
130};\r
131\r
132//\r
133// Subsystem Types\r
134//\r
135static STRING_LOOKUP mSubsystemTypes[] = {\r
136 { EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION, "EFI application" },\r
137 { EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER, "EFI boot service driver" },\r
138 { EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER, "EFI runtime driver" },\r
139 { 0, NULL }\r
140};\r
141\r
142//\r
143// Function prototypes\r
144//\r
145static\r
146void\r
147Version (\r
148 VOID\r
149 )\r
150/*++\r
151\r
152Routine Description:\r
153\r
154 Displays the utility version to STDOUT\r
155\r
156Arguments:\r
157\r
158 None\r
159\r
160Returns:\r
161\r
162 None\r
163\r
164--*/\r
165;\r
166\r
167static\r
168void\r
169Usage (\r
170 VOID\r
171 )\r
172/*++\r
173\r
174Routine Description:\r
175\r
176 Displays the utility usage syntax to STDOUT\r
177\r
178Arguments:\r
179\r
180 None\r
181\r
182Returns:\r
183\r
184 None\r
185\r
186--*/ \r
187;\r
188\r
189static\r
190int\r
191ParseCommandLine (\r
192 int Argc,\r
193 char *Argv[],\r
194 OPTIONS *Options\r
195 )\r
196/*++\r
197\r
198Routine Description:\r
199 \r
200 Given the Argc/Argv program arguments, and a pointer to an options structure,\r
201 parse the command-line options and check their validity.\r
202\r
203Arguments:\r
204\r
205 Argc - standard C main() argument count\r
206 Argv[] - standard C main() argument list\r
207 Options - pointer to a structure to store the options in\r
208\r
209Returns:\r
210\r
211 STATUS_SUCCESS success\r
212 non-zero otherwise\r
213\r
214--*/\r
215;\r
216\r
217static\r
218int\r
219CheckPE32File (\r
220 FILE *Fptr,\r
221 UINT16 *MachineType,\r
222 UINT16 *SubSystem\r
223 )\r
224/*++\r
225\r
226Routine Description:\r
227 \r
228 Given the Argc/Argv program arguments, and a pointer to an options structure,\r
229 parse the command-line options and check their validity.\r
230\r
231Arguments:\r
232\r
233 Argc - standard C main() argument count\r
234 Argv[] - standard C main() argument list\r
235 Options - pointer to a structure to store the options in\r
236\r
237Returns:\r
238\r
239 STATUS_SUCCESS success\r
240 non-zero otherwise\r
241\r
242--*/ \r
243;\r
244\r
245static\r
246int\r
247ProcessEfiFile (\r
248 FILE *OutFptr,\r
249 FILE_LIST *InFile,\r
250 UINT16 VendId,\r
251 UINT16 DevId,\r
252 UINT32 *Size\r
253 )\r
254/*++\r
255\r
256Routine Description:\r
257 \r
258 Process a PE32 EFI file.\r
259\r
260Arguments:\r
261\r
262 OutFptr - file pointer to output binary ROM image file we're creating\r
263 InFile - structure contains information on the PE32 file to process\r
264 VendId - vendor ID as required in the option ROM header\r
265 DevId - device ID as required in the option ROM header\r
266 Size - pointer to where to return the size added to the output file\r
267\r
268Returns:\r
269\r
270 0 - successful\r
271\r
272--*/\r
273;\r
274\r
275static\r
276int\r
277ProcessBinFile (\r
278 FILE *OutFptr,\r
279 FILE_LIST *InFile,\r
280 UINT32 *Size\r
281 )\r
282/*++\r
283\r
284Routine Description:\r
285 \r
286 Process a binary input file.\r
287\r
288Arguments:\r
289\r
290 OutFptr - file pointer to output binary ROM image file we're creating\r
291 InFile - structure contains information on the binary file to process\r
292 Size - pointer to where to return the size added to the output file\r
293\r
294Returns:\r
295\r
296 0 - successful\r
297\r
298--*/ \r
299;\r
300\r
301static\r
302void\r
303DumpImage (\r
304 FILE_LIST *InFile\r
305 )\r
306/*++\r
307\r
308Routine Description:\r
309\r
310 Dump the headers of an existing option ROM image\r
311\r
312Arguments:\r
313\r
314 InFile - the file name of an existing option ROM image\r
315\r
316Returns:\r
317\r
318 none\r
319\r
320--*/\r
321;\r
322\r
323char *\r
324GetMachineTypeStr (\r
325 UINT16 MachineType\r
326 )\r
327/*++\r
328\r
329Routine Description:\r
330\r
331 GC_TODO: Add function description\r
332\r
333Arguments:\r
334\r
335 MachineType - GC_TODO: add argument description\r
336\r
337Returns:\r
338\r
339 GC_TODO: add return values\r
340\r
341--*/\r
342;\r
343\r
344static\r
345char *\r
346GetSubsystemTypeStr (\r
347 UINT16 SubsystemType\r
348 )\r
349/*++\r
350\r
351Routine Description:\r
352\r
353 GC_TODO: Add function description\r
354\r
355Arguments:\r
356\r
357 SubsystemType - GC_TODO: add argument description\r
358\r
359Returns:\r
360\r
361 GC_TODO: add return values\r
362\r
363--*/\r
364;\r
365\r
366#endif\r