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
40 #include <Common/PiFirmwareFile.h>
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)
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_ "
60 #define COMP_TYPE_FIT_HEADER 0x00
61 #define COMP_TYPE_FIT_PAL_B 0x01
64 // This is generic PAL_A
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
72 //This is processor Specific PAL_A
74 #define COMP_TYPE_FIT_PAL_A_SPECIFIC 0x0E
75 #define COMP_TYPE_FIT_UNUSED 0x7F
77 #define FIT_TYPE_MASK 0x7F
78 #define CHECKSUM_BIT_MASK 0x80
81 // IPF processor address is cached bit
83 #define IPF_CACHE_BIT 0x8000000000000000ULL
86 // Size definition to calculate the location from top of address for
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
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 + \
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)
102 #define SIZE_OF_PAL_HEADER 0x40 //PAL has 64 byte header
107 #define UTILITY_NAME "GenVtf"
110 // Utility version information
112 #define UTILITY_MAJOR_VERSION 0
113 #define UTILITY_MINOR_VERSION 1
114 #define UTILITY_DATE __DATE__
117 // The maximum number of arguments accepted from the command line.
119 #define ONE_VTF_ARGS 10
120 #define TWO_VTF_ARGS 12
121 #define THREE_VTF_ARGS 16
123 static BOOLEAN VerboseMode
= FALSE
;
126 // Internal Data Structure
128 typedef enum _LOC_TYPE
130 NONE
, // In case there is - INF file
131 FIRST_VTF
, // First VTF
132 SECOND_VTF
, // Outside VTF
135 typedef struct _PARSED_VTF_INFO
{
136 CHAR8 CompName
[COMPONENT_NAME_SIZE
];
137 LOC_TYPE LocationType
;
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
];
148 UINT64 CompPreferredAddress
;
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 *'
157 struct _PARSED_VTF_INFO
*NextVtfInfo
;
171 // Function Prototype Declarations
176 IN UINT64 StartAddress
,
185 Update the Firmware Volume Buffer with requested buffer data
189 StartAddress - StartAddress in buffer. This number will automatically
190 point to right address in buffer where data needed
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
198 EFI_ABORTED - The input parameter is error
199 EFI_SUCCESS - The function completed successfully
206 IN UINT64 BaseAddress
,
207 IN CHAR8
*DestFileName
,
208 IN CHAR8
*SourceFileName
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.
219 BaseAddress - The base address for the new SYM tokens.
220 DestFileName - The destination file.
221 SourceFileName - The source file.
225 EFI_SUCCESS - The function completed successfully.
226 EFI_INVALID_PARAMETER - One of the input parameters was invalid.
227 EFI_ABORTED - An error occurred.
233 CalculateFitTableChecksum (
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;.
250 Status - Value returned by call to CalculateChecksum8 ()
251 EFI_SUCCESS - The function completed successfully
258 IN UINT64 StartAddress1
,
260 IN UINT64 StartAddress2
,
268 This is the main function which will be called from application.
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
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
284 UpdateIA32ResetVector
292 PeimFixupInFitTable (
293 IN UINT64 StartAddress
299 This function is an entry point to fixup SAL-E entry point.
303 StartAddress - StartAddress for PEIM.....
307 EFI_SUCCESS - The function completed successfully
308 EFI_ABORTED - Error Opening File
321 Displays the utility usage syntax to STDOUT