]> git.proxmox.com Git - mirror_edk2.git/blob - 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
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 )
210 /*++
211
212 Routine Description:
213
214 This function adds the SYM tokens in the source file to the destination file.
215 The SYM tokens are updated to reflect the base address.
216
217 Arguments:
218
219 BaseAddress - The base address for the new SYM tokens.
220 DestFileName - The destination file.
221 SourceFileName - The source file.
222
223 Returns:
224
225 EFI_SUCCESS - The function completed successfully.
226 EFI_INVALID_PARAMETER - One of the input parameters was invalid.
227 EFI_ABORTED - An error occurred.
228
229 --*/
230 ;
231
232 EFI_STATUS
233 CalculateFitTableChecksum (
234 VOID
235 )
236 /*++
237
238 Routine Description:
239
240 This function will perform byte checksum on the FIT table, if the the checksum required
241 field is set to CheckSum required. If the checksum is not required then checksum byte
242 will have value as 0;.
243
244 Arguments:
245
246 NONE
247
248 Returns:
249
250 Status - Value returned by call to CalculateChecksum8 ()
251 EFI_SUCCESS - The function completed successfully
252
253 --*/
254 ;
255
256 EFI_STATUS
257 GenerateVtfImage (
258 IN UINT64 StartAddress1,
259 IN UINT64 Size1,
260 IN UINT64 StartAddress2,
261 IN UINT64 Size2,
262 IN FILE *fp
263 )
264 /*++
265
266 Routine Description:
267
268 This is the main function which will be called from application.
269
270 Arguments:
271
272 StartAddress1 - The start address of the first VTF
273 Size1 - The size of the first VTF
274 StartAddress2 - The start address of the second VTF
275 Size2 - The size of the second VTF
276
277 Returns:
278
279 EFI_OUT_OF_RESOURCES - Can not allocate memory
280 The return value can be any of the values
281 returned by the calls to following functions:
282 GetVtfRelatedInfoFromInfFile
283 ProcessAndCreateVtf
284 UpdateIA32ResetVector
285 UpdateFfsHeader
286 WriteVtfBinary
287
288 --*/
289 ;
290
291 EFI_STATUS
292 PeimFixupInFitTable (
293 IN UINT64 StartAddress
294 )
295 /*++
296
297 Routine Description:
298
299 This function is an entry point to fixup SAL-E entry point.
300
301 Arguments:
302
303 StartAddress - StartAddress for PEIM.....
304
305 Returns:
306
307 EFI_SUCCESS - The function completed successfully
308 EFI_ABORTED - Error Opening File
309
310 --*/
311 ;
312
313 VOID
314 Usage (
315 VOID
316 )
317 /*++
318
319 Routine Description:
320
321 Displays the utility usage syntax to STDOUT
322
323 Arguments:
324
325 None
326
327 Returns:
328
329 None
330
331 --*/
332 ;
333 #endif