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