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