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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
|
/** @file
Copyright (c) 2007 - 2010, 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:
GenFv.c
Abstract:
This contains all code necessary to build the GenFvImage.exe utility.
This utility relies heavily on the GenFvImage Lib. Definitions for both
can be found in the Tiano Firmware Volume Generation Utility
Specification, review draft.
**/
//
// File included in build
//
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "GenFvInternalLib.h"
//
// Utility Name
//
#define UTILITY_NAME "GenFv"
//
// Utility version information
//
#define UTILITY_MAJOR_VERSION 0
#define UTILITY_MINOR_VERSION 1
EFI_GUID mEfiFirmwareFileSystem2Guid = EFI_FIRMWARE_FILE_SYSTEM2_GUID;
STATIC
VOID
Version (
VOID
)
/*++
Routine Description:
Displays the standard utility information to SDTOUT
Arguments:
None
Returns:
None
--*/
{
fprintf (stdout, "%s Version %d.%d %s \n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);
}
STATIC
VOID
Usage (
VOID
)
/*++
Routine Description:
Displays the utility usage syntax to STDOUT
Arguments:
None
Returns:
None
--*/
{
//
// Summary usage
//
fprintf (stdout, "\nUsage: %s [options]\n\n", UTILITY_NAME);
//
// Copyright declaration
//
fprintf (stdout, "Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.\n\n");
//
// Details Option
//
fprintf (stdout, "Options:\n");
fprintf (stdout, " -o FileName, --outputfile FileName\n\
File is the FvImage or CapImage to be created.\n");
fprintf (stdout, " -i FileName, --inputfile FileName\n\
File is the input FV.inf or Cap.inf to specify\n\
how to construct FvImage or CapImage.\n");
fprintf (stdout, " -b BlockSize, --blocksize BlockSize\n\
BlockSize is one HEX or DEC format value\n\
BlockSize is required by Fv Image.\n");
fprintf (stdout, " -n NumberBlock, --numberblock NumberBlock\n\
NumberBlock is one HEX or DEC format value\n\
NumberBlock is one optional parameter.\n");
fprintf (stdout, " -f FfsFile, --ffsfile FfsFile\n\
FfsFile is placed into Fv Image\n\
multi files can input one by one\n");
fprintf (stdout, " -s FileTakenSize, --filetakensize FileTakenSize\n\
FileTakenSize specifies the size of the required\n\
space that the input file is placed in Fvimage.\n\
It is specified together with the input file.\n");
fprintf (stdout, " -r Address, --baseaddr Address\n\
Address is the rebase start address for drivers that\n\
run in Flash. It supports DEC or HEX digital format.\n\
If it is set to zero, no rebase action will be taken\n");
fprintf (stdout, " -a AddressFile, --addrfile AddressFile\n\
AddressFile is one file used to record the child\n\
FV base address when current FV base address is set.\n");
fprintf (stdout, " -m logfile, --map logfile\n\
Logfile is the output fv map file name. if it is not\n\
given, the FvName.map will be the default map file name\n");
fprintf (stdout, " -g Guid, --guid Guid\n\
GuidValue is one specific capsule guid value\n\
or fv file system guid value.\n\
Its format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n");
fprintf (stdout, " --FvNameGuid Guid Guid is used to specify Fv Name.\n\
Its format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n");
fprintf (stdout, " --capflag CapFlag Capsule Reset Flag can be PersistAcrossReset,\n\
or PopulateSystemTable or InitiateReset or not set\n");
fprintf (stdout, " --capheadsize HeadSize\n\
HeadSize is one HEX or DEC format value\n\
HeadSize is required by Capsule Image.\n");
fprintf (stdout, " -c, --capsule Create Capsule Image.\n");
fprintf (stdout, " -p, --dump Dump Capsule Image header.\n");
fprintf (stdout, " -v, --verbose Turn on verbose output with informational messages.\n");
fprintf (stdout, " -q, --quiet Disable all messages except key message and fatal error\n");
fprintf (stdout, " -d, --debug level Enable debug messages, at input debug level.\n");
fprintf (stdout, " --version Show program's version number and exit.\n");
fprintf (stdout, " -h, --help Show this help message and exit.\n");
}
UINT32 mFvTotalSize;
UINT32 mFvTakenSize;
int
main (
IN int argc,
IN char **argv
)
/*++
Routine Description:
This utility uses GenFvImage.Lib to build a firmware volume image.
Arguments:
FvInfFileName The name of an FV image description file or Capsule Image.
Arguments come in pair in any order.
-I FvInfFileName
Returns:
EFI_SUCCESS No error conditions detected.
EFI_INVALID_PARAMETER One or more of the input parameters is invalid.
EFI_OUT_OF_RESOURCES A resource required by the utility was unavailable.
Most commonly this will be memory allocation
or file creation.
EFI_LOAD_ERROR GenFvImage.lib could not be loaded.
EFI_ABORTED Error executing the GenFvImage lib.
--*/
{
EFI_STATUS Status;
CHAR8 *InfFileName;
CHAR8 *AddrFileName;
CHAR8 *MapFileName;
CHAR8 *InfFileImage;
UINT32 InfFileSize;
CHAR8 *OutFileName;
BOOLEAN CapsuleFlag;
BOOLEAN DumpCapsule;
FILE *FpFile;
EFI_CAPSULE_HEADER *CapsuleHeader;
UINT64 LogLevel, TempNumber;
UINT32 Index;
InfFileName = NULL;
AddrFileName = NULL;
InfFileImage = NULL;
OutFileName = NULL;
MapFileName = NULL;
InfFileSize = 0;
CapsuleFlag = FALSE;
DumpCapsule = FALSE;
FpFile = NULL;
CapsuleHeader = NULL;
LogLevel = 0;
TempNumber = 0;
Index = 0;
mFvTotalSize = 0;
mFvTakenSize = 0;
Status = EFI_SUCCESS;
SetUtilityName (UTILITY_NAME);
if (argc == 1) {
Error (NULL, 0, 1001, "Missing options", "No input options specified.");
Usage ();
return STATUS_ERROR;
}
//
// Init global data to Zero
//
memset (&mFvDataInfo, 0, sizeof (FV_INFO));
memset (&mCapDataInfo, 0, sizeof (CAP_INFO));
//
// Set the default FvGuid
//
memcpy (&mFvDataInfo.FvFileSystemGuid, &mEfiFirmwareFileSystem2Guid, sizeof (EFI_GUID));
//
// Parse command line
//
argc --;
argv ++;
if ((stricmp (argv[0], "-h") == 0) || (stricmp (argv[0], "--help") == 0)) {
Version ();
Usage ();
return STATUS_SUCCESS;
}
if (stricmp (argv[0], "--version") == 0) {
Version ();
return STATUS_SUCCESS;
}
while (argc > 0) {
if ((stricmp (argv[0], "-i") == 0) || (stricmp (argv[0], "--inputfile") == 0)) {
InfFileName = argv[1];
if (InfFileName == NULL) {
Error (NULL, 0, 1003, "Invalid option value", "Input file can't be null");
return STATUS_ERROR;
}
argc -= 2;
argv += 2;
continue;
}
if ((stricmp (argv[0], "-a") == 0) || (stricmp (argv[0], "--addrfile") == 0)) {
AddrFileName = argv[1];
if (AddrFileName == NULL) {
Error (NULL, 0, 1003, "Invalid option value", "Address file can't be null");
return STATUS_ERROR;
}
argc -= 2;
argv += 2;
continue;
}
if ((stricmp (argv[0], "-o") == 0) || (stricmp (argv[0], "--outputfile") == 0)) {
OutFileName = argv[1];
if (OutFileName == NULL) {
Error (NULL, 0, 1003, "Invalid option value", "Output file can't be null");
return STATUS_ERROR;
}
argc -= 2;
argv += 2;
continue;
}
if ((stricmp (argv[0], "-r") == 0) || (stricmp (argv[0], "--baseaddr") == 0)) {
Status = AsciiStringToUint64 (argv[1], FALSE, &TempNumber);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);
return STATUS_ERROR;
}
mFvDataInfo.BaseAddress = TempNumber;
mFvDataInfo.BaseAddressSet = TRUE;
argc -= 2;
argv += 2;
continue;
}
if ((stricmp (argv[0], "-b") == 0) || (stricmp (argv[0], "--blocksize") == 0)) {
Status = AsciiStringToUint64 (argv[1], FALSE, &TempNumber);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);
return STATUS_ERROR;
}
if (TempNumber == 0) {
Error (NULL, 0, 1003, "Invalid option value", "Fv block size can't be be set to zero");
return STATUS_ERROR;
}
mFvDataInfo.FvBlocks[0].Length = (UINT32) TempNumber;
DebugMsg (NULL, 0, 9, "FV Block Size", "%s = 0x%llx", EFI_BLOCK_SIZE_STRING, (unsigned long long) TempNumber);
argc -= 2;
argv += 2;
continue;
}
if ((stricmp (argv[0], "-n") == 0) || (stricmp (argv[0], "--numberblock") == 0)) {
Status = AsciiStringToUint64 (argv[1], FALSE, &TempNumber);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);
return STATUS_ERROR;
}
if (TempNumber == 0) {
Error (NULL, 0, 1003, "Invalid option value", "Fv block number can't be set to zero");
return STATUS_ERROR;
}
mFvDataInfo.FvBlocks[0].NumBlocks = (UINT32) TempNumber;
DebugMsg (NULL, 0, 9, "FV Number Block", "%s = 0x%llx", EFI_NUM_BLOCKS_STRING, (unsigned long long) TempNumber);
argc -= 2;
argv += 2;
continue;
}
if ((stricmp (argv[0], "-f") == 0) || (stricmp (argv[0], "--ffsfile") == 0)) {
if (argv[1] == NULL) {
Error (NULL, 0, 1003, "Invalid option value", "Input Ffsfile can't be null");
return STATUS_ERROR;
}
strcpy (mFvDataInfo.FvFiles[Index], argv[1]);
DebugMsg (NULL, 0, 9, "FV component file", "the %uth name is %s", (unsigned) Index + 1, argv[1]);
argc -= 2;
argv += 2;
if (argc > 0) {
if ((stricmp (argv[0], "-s") == 0) || (stricmp (argv[0], "--filetakensize") == 0)) {
if (argv[1] == NULL) {
Error (NULL, 0, 1003, "Invalid option value", "Ffsfile Size can't be null");
return STATUS_ERROR;
}
Status = AsciiStringToUint64 (argv[1], FALSE, &TempNumber);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);
return STATUS_ERROR;
}
mFvDataInfo.SizeofFvFiles[Index] = (UINT32) TempNumber;
DebugMsg (NULL, 0, 9, "FV component file size", "the %uth size is %s", (unsigned) Index + 1, argv[1]);
argc -= 2;
argv += 2;
}
}
Index ++;
continue;
}
if ((stricmp (argv[0], "-s") == 0) || (stricmp (argv[0], "--filetakensize") == 0)) {
Error (NULL, 0, 1003, "Invalid option", "It must be specified together with -f option to specify the file size.");
return STATUS_ERROR;
}
if ((stricmp (argv[0], "-c") == 0) || (stricmp (argv[0], "--capsule") == 0)) {
CapsuleFlag = TRUE;
argc --;
argv ++;
continue;
}
if (stricmp (argv[0], "--capheadsize") == 0) {
//
// Get Capsule Image Header Size
//
Status = AsciiStringToUint64 (argv[1], FALSE, &TempNumber);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);
return STATUS_ERROR;
}
mCapDataInfo.HeaderSize = (UINT32) TempNumber;
DebugMsg (NULL, 0, 9, "Capsule Header size", "%s = 0x%llx", EFI_CAPSULE_HEADER_SIZE_STRING, (unsigned long long) TempNumber);
argc -= 2;
argv += 2;
continue;
}
if (stricmp (argv[0], "--capflag") == 0) {
//
// Get Capsule Header
//
if (argv[1] == NULL) {
Error (NULL, 0, 1003, "Option value is not set", "%s = %s", argv[0], argv[1]);
return STATUS_ERROR;
}
if (strcmp (argv[1], "PopulateSystemTable") == 0) {
mCapDataInfo.Flags |= CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE;
} else if (strcmp (argv[1], "PersistAcrossReset") == 0) {
mCapDataInfo.Flags |= CAPSULE_FLAGS_PERSIST_ACROSS_RESET;
} else if (strcmp (argv[1], "InitiateReset") == 0) {
mCapDataInfo.Flags |= CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_INITIATE_RESET;
} else {
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);
return STATUS_ERROR;
}
DebugMsg (NULL, 0, 9, "Capsule Flag", argv[1]);
argc -= 2;
argv += 2;
continue;
}
if (stricmp (argv[0], "--capguid") == 0) {
//
// Get the Capsule Guid
//
Status = StringToGuid (argv[1], &mCapDataInfo.CapGuid);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", EFI_CAPSULE_GUID_STRING, argv[1]);
return STATUS_ERROR;
}
DebugMsg (NULL, 0, 9, "Capsule Guid", "%s = %s", EFI_CAPSULE_GUID_STRING, argv[1]);
argc -= 2;
argv += 2;
continue;
}
if ((stricmp (argv[0], "-g") == 0) || (stricmp (argv[0], "--guid") == 0)) {
//
// Get the Capsule or Fv Guid
//
Status = StringToGuid (argv[1], &mCapDataInfo.CapGuid);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", EFI_GUID_STRING, argv[1]);
return STATUS_ERROR;
}
memcpy (&mFvDataInfo.FvFileSystemGuid, &mCapDataInfo.CapGuid, sizeof (EFI_GUID));
mFvDataInfo.FvFileSystemGuidSet = TRUE;
DebugMsg (NULL, 0, 9, "Capsule Guid", "%s = %s", EFI_CAPSULE_GUID_STRING, argv[1]);
DebugMsg (NULL, 0, 9, "FV Guid", "%s = %s", EFI_FV_FILESYSTEMGUID_STRING, argv[1]);
argc -= 2;
argv += 2;
continue;
}
if (stricmp (argv[0], "--FvNameGuid") == 0) {
//
// Get Fv Name Guid
//
Status = StringToGuid (argv[1], &mFvDataInfo.FvNameGuid);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", EFI_GUID_STRING, argv[1]);
return STATUS_ERROR;
}
mFvDataInfo.FvNameGuidSet = TRUE;
DebugMsg (NULL, 0, 9, "FV Name Guid", "%s = %s", EFI_FV_NAMEGUID_STRING, argv[1]);
argc -= 2;
argv += 2;
continue;
}
if ((stricmp (argv[0], "-p") == 0) || (stricmp (argv[0], "--dump") == 0)) {
DumpCapsule = TRUE;
argc --;
argv ++;
continue;
}
if ((stricmp (argv[0], "-m") == 0) || (stricmp (argv[0], "--map") == 0)) {
MapFileName = argv[1];
if (MapFileName == NULL) {
Error (NULL, 0, 1003, "Invalid option value", "Map file can't be null");
return STATUS_ERROR;
}
argc -= 2;
argv += 2;
continue;
}
if ((stricmp (argv[0], "-v") == 0) || (stricmp (argv[0], "--verbose") == 0)) {
SetPrintLevel (VERBOSE_LOG_LEVEL);
VerboseMsg ("Verbose output Mode Set!");
argc --;
argv ++;
continue;
}
if ((stricmp (argv[0], "-q") == 0) || (stricmp (argv[0], "--quiet") == 0)) {
SetPrintLevel (KEY_LOG_LEVEL);
KeyMsg ("Quiet output Mode Set!");
argc --;
argv ++;
continue;
}
if ((stricmp (argv[0], "-d") == 0) || (stricmp (argv[0], "--debug") == 0)) {
Status = AsciiStringToUint64 (argv[1], FALSE, &LogLevel);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);
return STATUS_ERROR;
}
if (LogLevel > 9) {
Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, current input level is %d", (int) LogLevel);
return STATUS_ERROR;
}
SetPrintLevel (LogLevel);
DebugMsg (NULL, 0, 9, "Debug Mode Set", "Debug Output Mode Level %s is set!", argv[1]);
argc -= 2;
argv += 2;
continue;
}
//
// Don't recognize the parameter.
//
Error (NULL, 0, 1000, "Unknown option", "%s", argv[0]);
return STATUS_ERROR;
}
VerboseMsg ("%s tool start.", UTILITY_NAME);
//
// check input parameter, InfFileName can be NULL
//
if (InfFileName == NULL && DumpCapsule) {
Error (NULL, 0, 1001, "Missing option", "Input Capsule Image");
return STATUS_ERROR;
}
VerboseMsg ("the input FvInf or CapInf file name is %s", InfFileName);
if (!DumpCapsule && OutFileName == NULL) {
Error (NULL, 0, 1001, "Missing option", "Output File");
return STATUS_ERROR;
}
if (OutFileName != NULL) {
VerboseMsg ("the output file name is %s", OutFileName);
}
//
// Read the INF file image
//
if (InfFileName != NULL) {
Status = GetFileImage (InfFileName, &InfFileImage, &InfFileSize);
if (EFI_ERROR (Status)) {
return STATUS_ERROR;
}
}
if (DumpCapsule) {
VerboseMsg ("Dump the capsule header information for the input capsule image %s", InfFileName);
//
// Dump Capsule Image Header Information
//
CapsuleHeader = (EFI_CAPSULE_HEADER *) InfFileImage;
if (OutFileName == NULL) {
FpFile = stdout;
} else {
FpFile = fopen (OutFileName, "w");
if (FpFile == NULL) {
Error (NULL, 0, 0001, "Error opening file", OutFileName);
return STATUS_ERROR;
}
}
fprintf (FpFile, "Capsule %s Image Header Information\n", InfFileName);
fprintf (FpFile, " GUID %08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X\n",
(unsigned) CapsuleHeader->CapsuleGuid.Data1,
(unsigned) CapsuleHeader->CapsuleGuid.Data2,
(unsigned) CapsuleHeader->CapsuleGuid.Data3,
(unsigned) CapsuleHeader->CapsuleGuid.Data4[0],
(unsigned) CapsuleHeader->CapsuleGuid.Data4[1],
(unsigned) CapsuleHeader->CapsuleGuid.Data4[2],
(unsigned) CapsuleHeader->CapsuleGuid.Data4[3],
(unsigned) CapsuleHeader->CapsuleGuid.Data4[4],
(unsigned) CapsuleHeader->CapsuleGuid.Data4[5],
(unsigned) CapsuleHeader->CapsuleGuid.Data4[6],
(unsigned) CapsuleHeader->CapsuleGuid.Data4[7]);
fprintf (FpFile, " Header size 0x%08X\n", (unsigned) CapsuleHeader->HeaderSize);
fprintf (FpFile, " Flags 0x%08X\n", (unsigned) CapsuleHeader->Flags);
fprintf (FpFile, " Capsule image size 0x%08X\n", (unsigned) CapsuleHeader->CapsuleImageSize);
fclose (FpFile);
} else if (CapsuleFlag) {
VerboseMsg ("Create capsule image");
//
// Call the GenerateCapImage to generate Capsule Image
//
for (Index = 0; mFvDataInfo.FvFiles[Index][0] != '\0'; Index ++) {
strcpy (mCapDataInfo.CapFiles[Index], mFvDataInfo.FvFiles[Index]);
}
Status = GenerateCapImage (
InfFileImage,
InfFileSize,
OutFileName
);
} else {
VerboseMsg ("Create Fv image and its map file");
if (mFvDataInfo.BaseAddress != 0) {
VerboseMsg ("FvImage Rebase Address is 0x%llX", (unsigned long long) mFvDataInfo.BaseAddress);
}
//
// Call the GenerateFvImage to generate Fv Image
//
Status = GenerateFvImage (
InfFileImage,
InfFileSize,
OutFileName,
MapFileName
);
}
//
// free InfFileImage memory
//
if (InfFileImage != NULL) {
free (InfFileImage);
}
//
// update boot driver address and runtime driver address in address file
//
if (Status == EFI_SUCCESS && AddrFileName != NULL && mFvBaseAddressNumber > 0) {
FpFile = fopen (AddrFileName, "w");
if (FpFile == NULL) {
Error (NULL, 0, 0001, "Error opening file", AddrFileName);
return STATUS_ERROR;
}
fprintf (FpFile, FV_BASE_ADDRESS_STRING);
fprintf (FpFile, "\n");
for (Index = 0; Index < mFvBaseAddressNumber; Index ++) {
fprintf (
FpFile,
"0x%llx\n",
(unsigned long long)mFvBaseAddress[Index]
);
}
fflush (FpFile);
fclose (FpFile);
}
if (Status == EFI_SUCCESS) {
DebugMsg (NULL, 0, 9, "The Total Fv Size", "%s = 0x%x", EFI_FV_TOTAL_SIZE_STRING, (unsigned) mFvTotalSize);
DebugMsg (NULL, 0, 9, "The used Fv Size", "%s = 0x%x", EFI_FV_TAKEN_SIZE_STRING, (unsigned) mFvTakenSize);
DebugMsg (NULL, 0, 9, "The space Fv size", "%s = 0x%x", EFI_FV_SPACE_SIZE_STRING, (unsigned) (mFvTotalSize - mFvTakenSize));
}
VerboseMsg ("%s tool done with return code is 0x%x.", UTILITY_NAME, GetUtilityStatus ());
return GetUtilityStatus ();
}
|