]>
Commit | Line | Data |
---|---|---|
30fdf114 LG |
1 | /** @file\r |
2 | \r | |
40d841f6 | 3 | Copyright (c) 1999 - 2008, Intel Corporation. All rights reserved.<BR>\r |
a709adfa LG |
4 | This program and the accompanying materials are licensed and made available \r |
5 | under the terms and conditions of the BSD License which accompanies this \r | |
6 | distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
30fdf114 LG |
11 | \r |
12 | \r | |
13 | Module Name: \r | |
14 | \r | |
15 | GenVtf.h\r | |
16 | \r | |
17 | Abstract:\r | |
18 | \r | |
19 | This file contains the relevant declarations required\r | |
20 | to generate Boot Strap File\r | |
21 | \r | |
22 | **/\r | |
23 | \r | |
24 | //\r | |
25 | // Module Coded to EFI 2.0 Coding Conventions\r | |
26 | //\r | |
27 | #ifndef __GEN_VTF_H__\r | |
28 | #define __GEN_VTF_H__\r | |
29 | \r | |
30 | //\r | |
31 | // External Files Referenced\r | |
32 | //\r | |
33 | #include <stdio.h>\r | |
34 | #include <stdlib.h>\r | |
35 | #include <string.h>\r | |
fd171542 | 36 | #ifndef __GNUC__\r |
37 | #include <io.h>\r | |
38 | #endif\r | |
30fdf114 LG |
39 | #include "assert.h"\r |
40 | #include <Common/PiFirmwareFile.h>\r | |
41 | #include "ParseInf.h"\r | |
42 | \r | |
43 | //\r | |
44 | // Internal Constants\r | |
45 | //\r | |
46 | #define CV_N_TYPE(a,b) (UINT8)(((UINT8)a << 7) + (UINT8)b) // Keeps the CV and Type in same byte field\r | |
47 | #define MAKE_VERSION(a,b) (UINT16)(((UINT16)a << 8) + (UINT16)b)\r | |
48 | \r | |
49 | #define FILE_NAME_SIZE 256\r | |
50 | #define COMPONENT_NAME_SIZE 128\r | |
51 | #define VTF_INPUT_FILE "VTF.INF"\r | |
52 | #define VTF_OUTPUT_FILE1 "VTF1.RAW"\r | |
53 | #define VTF_OUTPUT_FILE2 "VTF2.RAW"\r | |
54 | #define VTF_SYM_FILE "Vtf.SYM"\r | |
55 | #define FIT_SIGNATURE "_FIT_ "\r | |
56 | \r | |
57 | //\r | |
58 | //Fit Type Definition\r | |
59 | //\r | |
60 | #define COMP_TYPE_FIT_HEADER 0x00\r | |
61 | #define COMP_TYPE_FIT_PAL_B 0x01\r | |
62 | \r | |
63 | //\r | |
64 | // This is generic PAL_A\r | |
65 | //\r | |
66 | #define COMP_TYPE_FIT_PAL_A 0x0F\r | |
67 | #define COMP_TYPE_FIT_PEICORE 0x10\r | |
68 | #define COMP_TYPE_FIT_AUTOSCAN 0x30\r | |
69 | #define COMP_TYPE_FIT_FV_BOOT 0x7E\r | |
70 | \r | |
71 | //\r | |
72 | //This is processor Specific PAL_A\r | |
73 | //\r | |
74 | #define COMP_TYPE_FIT_PAL_A_SPECIFIC 0x0E\r | |
75 | #define COMP_TYPE_FIT_UNUSED 0x7F\r | |
76 | \r | |
77 | #define FIT_TYPE_MASK 0x7F\r | |
78 | #define CHECKSUM_BIT_MASK 0x80\r | |
79 | \r | |
80 | //\r | |
81 | // IPF processor address is cached bit\r | |
82 | //\r | |
83 | #define IPF_CACHE_BIT 0x8000000000000000ULL\r | |
84 | \r | |
85 | //\r | |
86 | // Size definition to calculate the location from top of address for\r | |
87 | // each component\r | |
88 | //\r | |
89 | #define SIZE_IA32_RESET_VECT 0x10 // 16 Bytes\r | |
90 | #define SIZE_SALE_ENTRY_POINT 0x08 // 8 Byte\r | |
91 | #define SIZE_FIT_TABLE_ADD 0x08 // 8 Byte\r | |
92 | #define SIZE_FIT_TABLE_PAL_A 0x10 \r | |
93 | #define SIZE_RESERVED 0x10\r | |
94 | \r | |
95 | \r | |
96 | #define SIZE_TO_OFFSET_PAL_A_END (SIZE_IA32_RESET_VECT + SIZE_SALE_ENTRY_POINT + \\r | |
97 | SIZE_FIT_TABLE_ADD + SIZE_FIT_TABLE_PAL_A + \\r | |
98 | SIZE_RESERVED)\r | |
99 | #define SIZE_TO_PAL_A_FIT (SIZE_IA32_RESET_VECT + SIZE_SALE_ENTRY_POINT + \\r | |
100 | SIZE_FIT_TABLE_ADD + SIZE_FIT_TABLE_PAL_A)\r | |
101 | \r | |
102 | #define SIZE_OF_PAL_HEADER 0x40 //PAL has 64 byte header\r | |
103 | \r | |
104 | //\r | |
105 | // Utility Name\r | |
106 | //\r | |
107 | #define UTILITY_NAME "GenVtf"\r | |
108 | \r | |
109 | //\r | |
110 | // Utility version information\r | |
111 | //\r | |
112 | #define UTILITY_MAJOR_VERSION 0\r | |
113 | #define UTILITY_MINOR_VERSION 1\r | |
114 | #define UTILITY_DATE __DATE__\r | |
115 | \r | |
116 | //\r | |
117 | // The maximum number of arguments accepted from the command line.\r | |
118 | //\r | |
119 | #define ONE_VTF_ARGS 10\r | |
120 | #define TWO_VTF_ARGS 12\r | |
121 | #define THREE_VTF_ARGS 16\r | |
122 | \r | |
123 | static BOOLEAN VerboseMode = FALSE;\r | |
124 | \r | |
125 | //\r | |
126 | // Internal Data Structure\r | |
127 | //\r | |
128 | typedef enum _LOC_TYPE \r | |
129 | {\r | |
130 | NONE, // In case there is - INF file\r | |
131 | FIRST_VTF, // First VTF\r | |
132 | SECOND_VTF, // Outside VTF\r | |
133 | } LOC_TYPE;\r | |
134 | \r | |
135 | typedef struct _PARSED_VTF_INFO {\r | |
136 | CHAR8 CompName[COMPONENT_NAME_SIZE];\r | |
137 | LOC_TYPE LocationType;\r | |
138 | UINT8 CompType;\r | |
139 | UINT8 MajorVer;\r | |
140 | UINT8 MinorVer;\r | |
141 | UINT8 CheckSumRequired;\r | |
142 | BOOLEAN VersionPresent; // If it is TRUE, then, Version is in INF file\r | |
143 | BOOLEAN PreferredSize;\r | |
144 | BOOLEAN PreferredAddress;\r | |
145 | CHAR8 CompBinName[FILE_NAME_SIZE];\r | |
146 | CHAR8 CompSymName[FILE_NAME_SIZE];\r | |
147 | UINTN CompSize;\r | |
148 | UINT64 CompPreferredAddress;\r | |
149 | UINT32 Align;\r | |
150 | \r | |
151 | //\r | |
152 | // Fixed - warning C4133: '=' : incompatible types - from 'struct _ParsedVtfInfo *' to 'struct _PARSED_VTF_INFO *'\r | |
153 | // Fixed - warning C4133: '=' : incompatible types - from 'struct _ParsedVtfInfo *' to 'struct _PARSED_VTF_INFO *'\r | |
154 | // Fixed - warning C4133: '=' : incompatible types - from 'struct _ParsedVtfInfo *' to 'struct _PARSED_VTF_INFO *'\r | |
155 | // Fixed - warning C4133: '=' : incompatible types - from 'struct _ParsedVtfInfo *' to 'struct _PARSED_VTF_INFO *'\r | |
156 | //\r | |
157 | struct _PARSED_VTF_INFO *NextVtfInfo;\r | |
158 | } PARSED_VTF_INFO;\r | |
159 | \r | |
160 | #pragma pack (1)\r | |
161 | typedef struct {\r | |
162 | UINT64 CompAddress;\r | |
163 | UINT32 CompSize;\r | |
164 | UINT16 CompVersion;\r | |
165 | UINT8 CvAndType;\r | |
166 | UINT8 CheckSum;\r | |
167 | } FIT_TABLE;\r | |
168 | #pragma pack ()\r | |
169 | \r | |
170 | //\r | |
171 | // Function Prototype Declarations\r | |
172 | //\r | |
173 | \r | |
174 | EFI_STATUS\r | |
175 | UpdateVtfBuffer(\r | |
176 | IN UINT64 StartAddress,\r | |
177 | IN UINT8 *Buffer,\r | |
178 | IN UINT64 DataSize,\r | |
179 | IN LOC_TYPE LocType\r | |
180 | )\r | |
181 | /*++\r | |
182 | \r | |
183 | Routine Description:\r | |
184 | \r | |
185 | Update the Firmware Volume Buffer with requested buffer data\r | |
186 | \r | |
187 | Arguments:\r | |
188 | \r | |
189 | StartAddress - StartAddress in buffer. This number will automatically\r | |
190 | point to right address in buffer where data needed \r | |
191 | to be updated.\r | |
192 | Buffer - Buffer pointer from data will be copied to memory mapped buffer.\r | |
193 | DataSize - Size of the data needed to be copied.\r | |
194 | LocType - The type of the VTF\r | |
195 | \r | |
196 | Returns:\r | |
197 | \r | |
198 | EFI_ABORTED - The input parameter is error\r | |
199 | EFI_SUCCESS - The function completed successfully\r | |
200 | \r | |
201 | --*/\r | |
202 | ;\r | |
203 | \r | |
204 | EFI_STATUS\r | |
205 | UpdateSymFile (\r | |
206 | IN UINT64 BaseAddress,\r | |
207 | IN CHAR8 *DestFileName,\r | |
b303ea72 LG |
208 | IN CHAR8 *SourceFileName,\r |
209 | IN UINT64 FileSize\r | |
30fdf114 LG |
210 | )\r |
211 | /*++\r | |
212 | \r | |
213 | Routine Description:\r | |
214 | \r | |
215 | This function adds the SYM tokens in the source file to the destination file.\r | |
216 | The SYM tokens are updated to reflect the base address.\r | |
217 | \r | |
218 | Arguments:\r | |
219 | \r | |
220 | BaseAddress - The base address for the new SYM tokens.\r | |
221 | DestFileName - The destination file.\r | |
222 | SourceFileName - The source file.\r | |
b303ea72 | 223 | FileSize - Size of bin file.\r |
30fdf114 LG |
224 | \r |
225 | Returns:\r | |
226 | \r | |
227 | EFI_SUCCESS - The function completed successfully.\r | |
228 | EFI_INVALID_PARAMETER - One of the input parameters was invalid.\r | |
229 | EFI_ABORTED - An error occurred.\r | |
230 | \r | |
231 | --*/\r | |
232 | ;\r | |
233 | \r | |
234 | EFI_STATUS\r | |
235 | CalculateFitTableChecksum (\r | |
236 | VOID\r | |
237 | )\r | |
238 | /*++\r | |
239 | \r | |
240 | Routine Description:\r | |
241 | \r | |
242 | This function will perform byte checksum on the FIT table, if the the checksum required\r | |
243 | field is set to CheckSum required. If the checksum is not required then checksum byte\r | |
244 | will have value as 0;.\r | |
245 | \r | |
246 | Arguments:\r | |
247 | \r | |
248 | NONE\r | |
249 | \r | |
250 | Returns:\r | |
251 | \r | |
252 | Status - Value returned by call to CalculateChecksum8 ()\r | |
253 | EFI_SUCCESS - The function completed successfully\r | |
254 | \r | |
255 | --*/\r | |
256 | ;\r | |
257 | \r | |
258 | EFI_STATUS\r | |
259 | GenerateVtfImage (\r | |
260 | IN UINT64 StartAddress1,\r | |
261 | IN UINT64 Size1,\r | |
262 | IN UINT64 StartAddress2,\r | |
263 | IN UINT64 Size2,\r | |
264 | IN FILE *fp\r | |
265 | )\r | |
266 | /*++\r | |
267 | \r | |
268 | Routine Description:\r | |
269 | \r | |
270 | This is the main function which will be called from application.\r | |
271 | \r | |
272 | Arguments:\r | |
273 | \r | |
274 | StartAddress1 - The start address of the first VTF \r | |
275 | Size1 - The size of the first VTF\r | |
276 | StartAddress2 - The start address of the second VTF \r | |
277 | Size2 - The size of the second VTF\r | |
278 | \r | |
279 | Returns:\r | |
280 | \r | |
281 | EFI_OUT_OF_RESOURCES - Can not allocate memory\r | |
282 | The return value can be any of the values \r | |
283 | returned by the calls to following functions:\r | |
284 | GetVtfRelatedInfoFromInfFile\r | |
285 | ProcessAndCreateVtf\r | |
286 | UpdateIA32ResetVector\r | |
287 | UpdateFfsHeader\r | |
288 | WriteVtfBinary\r | |
289 | \r | |
290 | --*/\r | |
291 | ;\r | |
292 | \r | |
293 | EFI_STATUS\r | |
294 | PeimFixupInFitTable (\r | |
295 | IN UINT64 StartAddress\r | |
296 | )\r | |
297 | /*++\r | |
298 | \r | |
299 | Routine Description:\r | |
300 | \r | |
301 | This function is an entry point to fixup SAL-E entry point.\r | |
302 | \r | |
303 | Arguments:\r | |
304 | \r | |
305 | StartAddress - StartAddress for PEIM.....\r | |
306 | \r | |
307 | Returns:\r | |
308 | \r | |
309 | EFI_SUCCESS - The function completed successfully\r | |
310 | EFI_ABORTED - Error Opening File \r | |
311 | \r | |
312 | --*/\r | |
313 | ;\r | |
314 | \r | |
315 | VOID\r | |
316 | Usage (\r | |
317 | VOID\r | |
318 | )\r | |
319 | /*++\r | |
320 | \r | |
321 | Routine Description:\r | |
322 | \r | |
323 | Displays the utility usage syntax to STDOUT\r | |
324 | \r | |
325 | Arguments:\r | |
326 | \r | |
327 | None\r | |
328 | \r | |
329 | Returns:\r | |
330 | \r | |
331 | None\r | |
332 | \r | |
333 | --*/\r | |
334 | ;\r | |
335 | #endif\r |