]>
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 |
97fa0ee9 | 4 | Copyright (c) 1999 - 2014, 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 | |
86 | UINT16 DevId;\r | |
87 | UINT8 VendIdValid;\r | |
88 | UINT8 DevIdValid;\r | |
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 | |
120 | { 0, NULL }\r | |
121 | };\r | |
122 | \r | |
123 | //\r | |
124 | // Subsystem Types\r | |
125 | //\r | |
126 | static STRING_LOOKUP mSubsystemTypes[] = {\r | |
127 | { EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION, "EFI application" },\r | |
128 | { EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER, "EFI boot service driver" },\r | |
129 | { EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER, "EFI runtime driver" },\r | |
130 | { 0, NULL }\r | |
131 | };\r | |
132 | \r | |
133 | //\r | |
134 | // Function prototypes\r | |
135 | //\r | |
136 | static\r | |
137 | void\r | |
138 | Version (\r | |
139 | VOID\r | |
140 | )\r | |
141 | /*++\r | |
142 | \r | |
143 | Routine Description:\r | |
144 | \r | |
145 | Displays the utility version to STDOUT\r | |
146 | \r | |
147 | Arguments:\r | |
148 | \r | |
149 | None\r | |
150 | \r | |
151 | Returns:\r | |
152 | \r | |
153 | None\r | |
154 | \r | |
155 | --*/\r | |
156 | ;\r | |
157 | \r | |
158 | static\r | |
159 | void\r | |
160 | Usage (\r | |
161 | VOID\r | |
162 | )\r | |
163 | /*++\r | |
164 | \r | |
165 | Routine Description:\r | |
166 | \r | |
167 | Displays the utility usage syntax to STDOUT\r | |
168 | \r | |
169 | Arguments:\r | |
170 | \r | |
171 | None\r | |
172 | \r | |
173 | Returns:\r | |
174 | \r | |
175 | None\r | |
176 | \r | |
177 | --*/ \r | |
178 | ;\r | |
179 | \r | |
180 | static\r | |
181 | int\r | |
182 | ParseCommandLine (\r | |
183 | int Argc,\r | |
184 | char *Argv[],\r | |
185 | OPTIONS *Options\r | |
186 | )\r | |
187 | /*++\r | |
188 | \r | |
189 | Routine Description:\r | |
190 | \r | |
191 | Given the Argc/Argv program arguments, and a pointer to an options structure,\r | |
192 | parse the command-line options and check their validity.\r | |
193 | \r | |
194 | Arguments:\r | |
195 | \r | |
196 | Argc - standard C main() argument count\r | |
197 | Argv[] - standard C main() argument list\r | |
198 | Options - pointer to a structure to store the options in\r | |
199 | \r | |
200 | Returns:\r | |
201 | \r | |
202 | STATUS_SUCCESS success\r | |
203 | non-zero otherwise\r | |
204 | \r | |
205 | --*/\r | |
206 | ;\r | |
207 | \r | |
208 | static\r | |
209 | int\r | |
210 | CheckPE32File (\r | |
211 | FILE *Fptr,\r | |
212 | UINT16 *MachineType,\r | |
213 | UINT16 *SubSystem\r | |
214 | )\r | |
215 | /*++\r | |
216 | \r | |
217 | Routine Description:\r | |
218 | \r | |
219 | Given the Argc/Argv program arguments, and a pointer to an options structure,\r | |
220 | parse the command-line options and check their validity.\r | |
221 | \r | |
222 | Arguments:\r | |
223 | \r | |
224 | Argc - standard C main() argument count\r | |
225 | Argv[] - standard C main() argument list\r | |
226 | Options - pointer to a structure to store the options in\r | |
227 | \r | |
228 | Returns:\r | |
229 | \r | |
230 | STATUS_SUCCESS success\r | |
231 | non-zero otherwise\r | |
232 | \r | |
233 | --*/ \r | |
234 | ;\r | |
235 | \r | |
236 | static\r | |
237 | int\r | |
238 | ProcessEfiFile (\r | |
239 | FILE *OutFptr,\r | |
240 | FILE_LIST *InFile,\r | |
241 | UINT16 VendId,\r | |
242 | UINT16 DevId,\r | |
243 | UINT32 *Size\r | |
244 | )\r | |
245 | /*++\r | |
246 | \r | |
247 | Routine Description:\r | |
248 | \r | |
249 | Process a PE32 EFI file.\r | |
250 | \r | |
251 | Arguments:\r | |
252 | \r | |
253 | OutFptr - file pointer to output binary ROM image file we're creating\r | |
254 | InFile - structure contains information on the PE32 file to process\r | |
255 | VendId - vendor ID as required in the option ROM header\r | |
256 | DevId - device ID as required in the option ROM header\r | |
257 | Size - pointer to where to return the size added to the output file\r | |
258 | \r | |
259 | Returns:\r | |
260 | \r | |
261 | 0 - successful\r | |
262 | \r | |
263 | --*/\r | |
264 | ;\r | |
265 | \r | |
266 | static\r | |
267 | int\r | |
268 | ProcessBinFile (\r | |
269 | FILE *OutFptr,\r | |
270 | FILE_LIST *InFile,\r | |
271 | UINT32 *Size\r | |
272 | )\r | |
273 | /*++\r | |
274 | \r | |
275 | Routine Description:\r | |
276 | \r | |
277 | Process a binary input file.\r | |
278 | \r | |
279 | Arguments:\r | |
280 | \r | |
281 | OutFptr - file pointer to output binary ROM image file we're creating\r | |
282 | InFile - structure contains information on the binary file to process\r | |
283 | Size - pointer to where to return the size added to the output file\r | |
284 | \r | |
285 | Returns:\r | |
286 | \r | |
287 | 0 - successful\r | |
288 | \r | |
289 | --*/ \r | |
290 | ;\r | |
291 | \r | |
292 | static\r | |
293 | void\r | |
294 | DumpImage (\r | |
295 | FILE_LIST *InFile\r | |
296 | )\r | |
297 | /*++\r | |
298 | \r | |
299 | Routine Description:\r | |
300 | \r | |
301 | Dump the headers of an existing option ROM image\r | |
302 | \r | |
303 | Arguments:\r | |
304 | \r | |
305 | InFile - the file name of an existing option ROM image\r | |
306 | \r | |
307 | Returns:\r | |
308 | \r | |
309 | none\r | |
310 | \r | |
311 | --*/\r | |
312 | ;\r | |
313 | \r | |
314 | char *\r | |
315 | GetMachineTypeStr (\r | |
316 | UINT16 MachineType\r | |
317 | )\r | |
318 | /*++\r | |
319 | \r | |
320 | Routine Description:\r | |
321 | \r | |
322 | GC_TODO: Add function description\r | |
323 | \r | |
324 | Arguments:\r | |
325 | \r | |
326 | MachineType - GC_TODO: add argument description\r | |
327 | \r | |
328 | Returns:\r | |
329 | \r | |
330 | GC_TODO: add return values\r | |
331 | \r | |
332 | --*/\r | |
333 | ;\r | |
334 | \r | |
335 | static\r | |
336 | char *\r | |
337 | GetSubsystemTypeStr (\r | |
338 | UINT16 SubsystemType\r | |
339 | )\r | |
340 | /*++\r | |
341 | \r | |
342 | Routine Description:\r | |
343 | \r | |
344 | GC_TODO: Add function description\r | |
345 | \r | |
346 | Arguments:\r | |
347 | \r | |
348 | SubsystemType - GC_TODO: add argument description\r | |
349 | \r | |
350 | Returns:\r | |
351 | \r | |
352 | GC_TODO: add return values\r | |
353 | \r | |
354 | --*/\r | |
355 | ;\r | |
356 | \r | |
357 | #endif\r |