]>
Commit | Line | Data |
---|---|---|
30fdf114 | 1 | /** @file\r |
97fa0ee9 | 2 | This file contains the relevant declarations required to generate Option Rom File\r |
30fdf114 | 3 | \r |
9f3a38cd | 4 | Copyright (c) 1999 - 2017, Intel Corporation. All rights reserved.<BR>\r |
a709adfa LG |
5 | This program and the accompanying materials are licensed and made available \r |
6 | under the terms and conditions of the BSD License which accompanies this \r | |
7 | distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT 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 | |
69 | typedef 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 | |
80 | typedef 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 | |
96 | // INT8 Version; \r | |
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 | |
103 | static OPTIONS mOptions;\r | |
104 | \r | |
105 | //\r | |
106 | // Use these to convert from machine type value to a named type\r | |
107 | //\r | |
108 | typedef struct {\r | |
109 | UINT16 Value;\r | |
110 | CHAR8 *Name;\r | |
111 | } STRING_LOOKUP;\r | |
112 | \r | |
113 | //\r | |
114 | // Machine Types\r | |
115 | //\r | |
116 | static 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 | |
129 | static 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 | |
139 | static\r | |
140 | void\r | |
141 | Version (\r | |
142 | VOID\r | |
143 | )\r | |
144 | /*++\r | |
145 | \r | |
146 | Routine Description:\r | |
147 | \r | |
148 | Displays the utility version to STDOUT\r | |
149 | \r | |
150 | Arguments:\r | |
151 | \r | |
152 | None\r | |
153 | \r | |
154 | Returns:\r | |
155 | \r | |
156 | None\r | |
157 | \r | |
158 | --*/\r | |
159 | ;\r | |
160 | \r | |
161 | static\r | |
162 | void\r | |
163 | Usage (\r | |
164 | VOID\r | |
165 | )\r | |
166 | /*++\r | |
167 | \r | |
168 | Routine Description:\r | |
169 | \r | |
170 | Displays the utility usage syntax to STDOUT\r | |
171 | \r | |
172 | Arguments:\r | |
173 | \r | |
174 | None\r | |
175 | \r | |
176 | Returns:\r | |
177 | \r | |
178 | None\r | |
179 | \r | |
180 | --*/ \r | |
181 | ;\r | |
182 | \r | |
183 | static\r | |
184 | int\r | |
185 | ParseCommandLine (\r | |
186 | int Argc,\r | |
187 | char *Argv[],\r | |
188 | OPTIONS *Options\r | |
189 | )\r | |
190 | /*++\r | |
191 | \r | |
192 | Routine Description:\r | |
193 | \r | |
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 | |
197 | Arguments:\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 | |
203 | Returns:\r | |
204 | \r | |
205 | STATUS_SUCCESS success\r | |
206 | non-zero otherwise\r | |
207 | \r | |
208 | --*/\r | |
209 | ;\r | |
210 | \r | |
211 | static\r | |
212 | int\r | |
213 | CheckPE32File (\r | |
214 | FILE *Fptr,\r | |
215 | UINT16 *MachineType,\r | |
216 | UINT16 *SubSystem\r | |
217 | )\r | |
218 | /*++\r | |
219 | \r | |
220 | Routine Description:\r | |
221 | \r | |
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 | |
225 | Arguments:\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 | |
231 | Returns:\r | |
232 | \r | |
233 | STATUS_SUCCESS success\r | |
234 | non-zero otherwise\r | |
235 | \r | |
236 | --*/ \r | |
237 | ;\r | |
238 | \r | |
239 | static\r | |
240 | int\r | |
241 | ProcessEfiFile (\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 | |
250 | Routine Description:\r | |
251 | \r | |
252 | Process a PE32 EFI file.\r | |
253 | \r | |
254 | Arguments:\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 | |
262 | Returns:\r | |
263 | \r | |
264 | 0 - successful\r | |
265 | \r | |
266 | --*/\r | |
267 | ;\r | |
268 | \r | |
269 | static\r | |
270 | int\r | |
271 | ProcessBinFile (\r | |
272 | FILE *OutFptr,\r | |
273 | FILE_LIST *InFile,\r | |
274 | UINT32 *Size\r | |
275 | )\r | |
276 | /*++\r | |
277 | \r | |
278 | Routine Description:\r | |
279 | \r | |
280 | Process a binary input file.\r | |
281 | \r | |
282 | Arguments:\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 | |
288 | Returns:\r | |
289 | \r | |
290 | 0 - successful\r | |
291 | \r | |
292 | --*/ \r | |
293 | ;\r | |
294 | \r | |
295 | static\r | |
296 | void\r | |
297 | DumpImage (\r | |
298 | FILE_LIST *InFile\r | |
299 | )\r | |
300 | /*++\r | |
301 | \r | |
302 | Routine Description:\r | |
303 | \r | |
304 | Dump the headers of an existing option ROM image\r | |
305 | \r | |
306 | Arguments:\r | |
307 | \r | |
308 | InFile - the file name of an existing option ROM image\r | |
309 | \r | |
310 | Returns:\r | |
311 | \r | |
312 | none\r | |
313 | \r | |
314 | --*/\r | |
315 | ;\r | |
316 | \r | |
317 | char *\r | |
318 | GetMachineTypeStr (\r | |
319 | UINT16 MachineType\r | |
320 | )\r | |
321 | /*++\r | |
322 | \r | |
323 | Routine Description:\r | |
324 | \r | |
325 | GC_TODO: Add function description\r | |
326 | \r | |
327 | Arguments:\r | |
328 | \r | |
329 | MachineType - GC_TODO: add argument description\r | |
330 | \r | |
331 | Returns:\r | |
332 | \r | |
333 | GC_TODO: add return values\r | |
334 | \r | |
335 | --*/\r | |
336 | ;\r | |
337 | \r | |
338 | static\r | |
339 | char *\r | |
340 | GetSubsystemTypeStr (\r | |
341 | UINT16 SubsystemType\r | |
342 | )\r | |
343 | /*++\r | |
344 | \r | |
345 | Routine Description:\r | |
346 | \r | |
347 | GC_TODO: Add function description\r | |
348 | \r | |
349 | Arguments:\r | |
350 | \r | |
351 | SubsystemType - GC_TODO: add argument description\r | |
352 | \r | |
353 | Returns:\r | |
354 | \r | |
355 | GC_TODO: add return values\r | |
356 | \r | |
357 | --*/\r | |
358 | ;\r | |
359 | \r | |
360 | #endif\r |