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