2 This file contains the relevant declarations required to generate Boot Strap File
4 Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available
6 under the terms and conditions of the BSD License which accompanies this
7 distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 // Module Coded to EFI 2.0 Coding Conventions
22 // External Files Referenced
31 #include <Common/PiFirmwareFile.h>
37 #define CV_N_TYPE(a,b) (UINT8)(((UINT8)a << 7) + (UINT8)b) // Keeps the CV and Type in same byte field
38 #define MAKE_VERSION(a,b) (UINT16)(((UINT16)a << 8) + (UINT16)b)
40 #define FILE_NAME_SIZE 256
41 #define COMPONENT_NAME_SIZE 128
42 #define VTF_INPUT_FILE "VTF.INF"
43 #define VTF_OUTPUT_FILE1 "VTF1.RAW"
44 #define VTF_OUTPUT_FILE2 "VTF2.RAW"
45 #define VTF_SYM_FILE "Vtf.SYM"
46 #define FIT_SIGNATURE "_FIT_ "
51 #define COMP_TYPE_FIT_HEADER 0x00
52 #define COMP_TYPE_FIT_PAL_B 0x01
55 // This is generic PAL_A
57 #define COMP_TYPE_FIT_PAL_A 0x0F
58 #define COMP_TYPE_FIT_PEICORE 0x10
59 #define COMP_TYPE_FIT_AUTOSCAN 0x30
60 #define COMP_TYPE_FIT_FV_BOOT 0x7E
63 //This is processor Specific PAL_A
65 #define COMP_TYPE_FIT_PAL_A_SPECIFIC 0x0E
66 #define COMP_TYPE_FIT_UNUSED 0x7F
68 #define FIT_TYPE_MASK 0x7F
69 #define CHECKSUM_BIT_MASK 0x80
72 // IPF processor address is cached bit
74 #define IPF_CACHE_BIT 0x8000000000000000ULL
77 // Size definition to calculate the location from top of address for
80 #define SIZE_IA32_RESET_VECT 0x10 // 16 Bytes
81 #define SIZE_SALE_ENTRY_POINT 0x08 // 8 Byte
82 #define SIZE_FIT_TABLE_ADD 0x08 // 8 Byte
83 #define SIZE_FIT_TABLE_PAL_A 0x10
84 #define SIZE_RESERVED 0x10
87 #define SIZE_TO_OFFSET_PAL_A_END (SIZE_IA32_RESET_VECT + SIZE_SALE_ENTRY_POINT + \
88 SIZE_FIT_TABLE_ADD + SIZE_FIT_TABLE_PAL_A + \
90 #define SIZE_TO_PAL_A_FIT (SIZE_IA32_RESET_VECT + SIZE_SALE_ENTRY_POINT + \
91 SIZE_FIT_TABLE_ADD + SIZE_FIT_TABLE_PAL_A)
93 #define SIZE_OF_PAL_HEADER 0x40 //PAL has 64 byte header
98 #define UTILITY_NAME "GenVtf"
101 // Utility version information
103 #define UTILITY_MAJOR_VERSION 0
104 #define UTILITY_MINOR_VERSION 1
105 #define UTILITY_DATE __DATE__
108 // The maximum number of arguments accepted from the command line.
110 #define ONE_VTF_ARGS 10
111 #define TWO_VTF_ARGS 12
112 #define THREE_VTF_ARGS 16
114 static BOOLEAN VerboseMode
= FALSE
;
117 // Internal Data Structure
119 typedef enum _LOC_TYPE
121 NONE
, // In case there is - INF file
122 FIRST_VTF
, // First VTF
123 SECOND_VTF
, // Outside VTF
126 typedef struct _PARSED_VTF_INFO
{
127 CHAR8 CompName
[COMPONENT_NAME_SIZE
];
128 LOC_TYPE LocationType
;
132 UINT8 CheckSumRequired
;
133 BOOLEAN VersionPresent
; // If it is TRUE, then, Version is in INF file
134 BOOLEAN PreferredSize
;
135 BOOLEAN PreferredAddress
;
136 CHAR8 CompBinName
[FILE_NAME_SIZE
];
137 CHAR8 CompSymName
[FILE_NAME_SIZE
];
139 UINT64 CompPreferredAddress
;
143 // Fixed - warning C4133: '=' : incompatible types - from 'struct _ParsedVtfInfo *' to 'struct _PARSED_VTF_INFO *'
144 // Fixed - warning C4133: '=' : incompatible types - from 'struct _ParsedVtfInfo *' to 'struct _PARSED_VTF_INFO *'
145 // Fixed - warning C4133: '=' : incompatible types - from 'struct _ParsedVtfInfo *' to 'struct _PARSED_VTF_INFO *'
146 // Fixed - warning C4133: '=' : incompatible types - from 'struct _ParsedVtfInfo *' to 'struct _PARSED_VTF_INFO *'
148 struct _PARSED_VTF_INFO
*NextVtfInfo
;
162 // Function Prototype Declarations
167 IN UINT64 StartAddress
,
176 Update the Firmware Volume Buffer with requested buffer data
180 StartAddress - StartAddress in buffer. This number will automatically
181 point to right address in buffer where data needed
183 Buffer - Buffer pointer from data will be copied to memory mapped buffer.
184 DataSize - Size of the data needed to be copied.
185 LocType - The type of the VTF
189 EFI_ABORTED - The input parameter is error
190 EFI_SUCCESS - The function completed successfully
197 IN UINT64 BaseAddress
,
198 IN CHAR8
*DestFileName
,
199 IN CHAR8
*SourceFileName
,
206 This function adds the SYM tokens in the source file to the destination file.
207 The SYM tokens are updated to reflect the base address.
211 BaseAddress - The base address for the new SYM tokens.
212 DestFileName - The destination file.
213 SourceFileName - The source file.
214 FileSize - Size of bin file.
218 EFI_SUCCESS - The function completed successfully.
219 EFI_INVALID_PARAMETER - One of the input parameters was invalid.
220 EFI_ABORTED - An error occurred.
226 CalculateFitTableChecksum (
233 This function will perform byte checksum on the FIT table, if the the checksum required
234 field is set to CheckSum required. If the checksum is not required then checksum byte
235 will have value as 0;.
243 Status - Value returned by call to CalculateChecksum8 ()
244 EFI_SUCCESS - The function completed successfully
251 IN UINT64 StartAddress1
,
253 IN UINT64 StartAddress2
,
261 This is the main function which will be called from application.
265 StartAddress1 - The start address of the first VTF
266 Size1 - The size of the first VTF
267 StartAddress2 - The start address of the second VTF
268 Size2 - The size of the second VTF
272 EFI_OUT_OF_RESOURCES - Can not allocate memory
273 The return value can be any of the values
274 returned by the calls to following functions:
275 GetVtfRelatedInfoFromInfFile
277 UpdateIA32ResetVector
285 PeimFixupInFitTable (
286 IN UINT64 StartAddress
292 This function is an entry point to fixup SAL-E entry point.
296 StartAddress - StartAddress for PEIM.....
300 EFI_SUCCESS - The function completed successfully
301 EFI_ABORTED - Error Opening File
314 Displays the utility usage syntax to STDOUT