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