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