]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/C/GenVtf/GenVtf.h
Sync basetools' source and binary files with r1707 of the basetools project.
[mirror_edk2.git] / BaseTools / Source / C / GenVtf / GenVtf.h
CommitLineData
30fdf114
LG
1/** @file\r
2\r
3Copyright (c) 1999 - 2008 Intel Corporation. All rights reserved\r
4This software and associated documentation (if any) is furnished\r
5under a license and may only be used or copied in accordance\r
6with the terms of the license. Except as permitted by such\r
7license, no part of this software or documentation may be\r
8reproduced, stored in a retrieval system, or transmitted in any\r
9form or by any means without the express written consent of\r
10Intel Corporation.\r
11\r
12\r
13Module Name: \r
14\r
15 GenVtf.h\r
16\r
17Abstract:\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
123static BOOLEAN VerboseMode = FALSE;\r
124\r
125//\r
126// Internal Data Structure\r
127//\r
128typedef 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
135typedef 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
161typedef 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
174EFI_STATUS\r
175UpdateVtfBuffer(\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
183Routine Description:\r
184\r
185 Update the Firmware Volume Buffer with requested buffer data\r
186 \r
187Arguments:\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
196Returns:\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
204EFI_STATUS\r
205UpdateSymFile (\r
206 IN UINT64 BaseAddress,\r
207 IN CHAR8 *DestFileName,\r
208 IN CHAR8 *SourceFileName\r
209 )\r
210/*++\r
211\r
212Routine Description:\r
213\r
214 This function adds the SYM tokens in the source file to the destination file.\r
215 The SYM tokens are updated to reflect the base address.\r
216\r
217Arguments:\r
218\r
219 BaseAddress - The base address for the new SYM tokens.\r
220 DestFileName - The destination file.\r
221 SourceFileName - The source file.\r
222\r
223Returns:\r
224\r
225 EFI_SUCCESS - The function completed successfully.\r
226 EFI_INVALID_PARAMETER - One of the input parameters was invalid.\r
227 EFI_ABORTED - An error occurred.\r
228\r
229--*/\r
230;\r
231\r
232EFI_STATUS\r
233CalculateFitTableChecksum (\r
234 VOID\r
235 )\r
236/*++\r
237 \r
238Routine Description:\r
239\r
240 This function will perform byte checksum on the FIT table, if the the checksum required\r
241 field is set to CheckSum required. If the checksum is not required then checksum byte\r
242 will have value as 0;.\r
243 \r
244Arguments:\r
245\r
246 NONE\r
247 \r
248Returns:\r
249\r
250 Status - Value returned by call to CalculateChecksum8 ()\r
251 EFI_SUCCESS - The function completed successfully\r
252 \r
253--*/\r
254;\r
255\r
256EFI_STATUS\r
257GenerateVtfImage (\r
258 IN UINT64 StartAddress1,\r
259 IN UINT64 Size1,\r
260 IN UINT64 StartAddress2,\r
261 IN UINT64 Size2,\r
262 IN FILE *fp\r
263 )\r
264/*++\r
265\r
266Routine Description:\r
267\r
268 This is the main function which will be called from application.\r
269\r
270Arguments:\r
271\r
272 StartAddress1 - The start address of the first VTF \r
273 Size1 - The size of the first VTF\r
274 StartAddress2 - The start address of the second VTF \r
275 Size2 - The size of the second VTF\r
276\r
277Returns:\r
278 \r
279 EFI_OUT_OF_RESOURCES - Can not allocate memory\r
280 The return value can be any of the values \r
281 returned by the calls to following functions:\r
282 GetVtfRelatedInfoFromInfFile\r
283 ProcessAndCreateVtf\r
284 UpdateIA32ResetVector\r
285 UpdateFfsHeader\r
286 WriteVtfBinary\r
287 \r
288--*/\r
289;\r
290\r
291EFI_STATUS\r
292PeimFixupInFitTable (\r
293 IN UINT64 StartAddress\r
294 )\r
295/*++\r
296\r
297Routine Description:\r
298\r
299 This function is an entry point to fixup SAL-E entry point.\r
300\r
301Arguments:\r
302\r
303 StartAddress - StartAddress for PEIM.....\r
304 \r
305Returns:\r
306 \r
307 EFI_SUCCESS - The function completed successfully\r
308 EFI_ABORTED - Error Opening File \r
309\r
310--*/\r
311;\r
312\r
313VOID\r
314Usage (\r
315 VOID\r
316 )\r
317/*++\r
318\r
319Routine Description:\r
320\r
321 Displays the utility usage syntax to STDOUT\r
322\r
323Arguments:\r
324\r
325 None\r
326\r
327Returns:\r
328\r
329 None\r
330\r
331--*/\r
332;\r
333#endif\r