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