VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/BaseTools/Source/C/EfiRom/EfiRom.h

Last change on this file was 101291, checked in by vboxsync, 20 months ago

EFI/FirmwareNew: Make edk2-stable202308 build on all supported platforms (using gcc at least, msvc not tested yet), bugref:4643

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette