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
19 This file contains the relevant declarations required
20 to generate Boot Strap File
25 // Module Coded to EFI 2.0 Coding Conventions
31 // External Files Referenced
37 #include <Common/PiFirmwareFile.h>
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)
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_ "
57 #define COMP_TYPE_FIT_HEADER 0x00
58 #define COMP_TYPE_FIT_PAL_B 0x01
61 // This is generic PAL_A
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
69 //This is processor Specific PAL_A
71 #define COMP_TYPE_FIT_PAL_A_SPECIFIC 0x0E
72 #define COMP_TYPE_FIT_UNUSED 0x7F
74 #define FIT_TYPE_MASK 0x7F
75 #define CHECKSUM_BIT_MASK 0x80
78 // IPF processor address is cached bit
80 #define IPF_CACHE_BIT 0x8000000000000000ULL
83 // Size definition to calculate the location from top of address for
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
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 + \
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)
99 #define SIZE_OF_PAL_HEADER 0x40 //PAL has 64 byte header
104 #define UTILITY_NAME "GenVtf"
107 // Utility version information
109 #define UTILITY_MAJOR_VERSION 0
110 #define UTILITY_MINOR_VERSION 1
111 #define UTILITY_DATE __DATE__
114 // The maximum number of arguments accepted from the command line.
116 #define ONE_VTF_ARGS 10
117 #define TWO_VTF_ARGS 12
118 #define THREE_VTF_ARGS 16
120 static BOOLEAN VerboseMode
= FALSE
;
123 // Internal Data Structure
125 typedef enum _LOC_TYPE
127 NONE
, // In case there is - INF file
128 FIRST_VTF
, // First VTF
129 SECOND_VTF
, // Outside VTF
132 typedef struct _PARSED_VTF_INFO
{
133 CHAR8 CompName
[COMPONENT_NAME_SIZE
];
134 LOC_TYPE LocationType
;
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
];
145 UINT64 CompPreferredAddress
;
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 *'
154 struct _PARSED_VTF_INFO
*NextVtfInfo
;
168 // Function Prototype Declarations
173 IN UINT64 StartAddress
,
182 Update the Firmware Volume Buffer with requested buffer data
186 StartAddress - StartAddress in buffer. This number will automatically
187 point to right address in buffer where data needed
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
195 EFI_ABORTED - The input parameter is error
196 EFI_SUCCESS - The function completed successfully
203 IN UINT64 BaseAddress
,
204 IN CHAR8
*DestFileName
,
205 IN CHAR8
*SourceFileName
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.
216 BaseAddress - The base address for the new SYM tokens.
217 DestFileName - The destination file.
218 SourceFileName - The source file.
222 EFI_SUCCESS - The function completed successfully.
223 EFI_INVALID_PARAMETER - One of the input parameters was invalid.
224 EFI_ABORTED - An error occurred.
230 CalculateFitTableChecksum (
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;.
247 Status - Value returned by call to CalculateChecksum8 ()
248 EFI_SUCCESS - The function completed successfully
255 IN UINT64 StartAddress1
,
257 IN UINT64 StartAddress2
,
265 This is the main function which will be called from application.
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
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
281 UpdateIA32ResetVector
289 PeimFixupInFitTable (
290 IN UINT64 StartAddress
296 This function is an entry point to fixup SAL-E entry point.
300 StartAddress - StartAddress for PEIM.....
304 EFI_SUCCESS - The function completed successfully
305 EFI_ABORTED - Error Opening File
318 Displays the utility usage syntax to STDOUT