/** @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
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:
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
//
//
// Utility version information
//
#define UTILITY_MAJOR_VERSION 0
Version (
)
/*++
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);
}
Usage (
)
/*++
Routine Description:
Displays the utility usage syntax to STDOUT
Arguments:
None
Returns:
None
--*/
{
//
// Summary usage
//
//
// Copyright declaration
//
//
// Details Option
//
File is the FvImage or CapImage to be created.\n");
File is the input FV.inf or Cap.inf to specify\n\
how to construct FvImage or CapImage.\n");
BlockSize is one HEX or DEC format value\n\
BlockSize is required by Fv Image.\n");
NumberBlock is one HEX or DEC format value\n\
NumberBlock is one optional parameter.\n");
FfsFile is placed into Fv Image\n\
multi files can input one by one\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");
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");
If value is TRUE, will always take rebase action\n\
If value is FALSE, will always not take reabse action\n\
If not specified, will take rebase action if rebase address greater than zero, \n\
will not take rebase action if rebase address is zero.\n");
AddressFile is one file used to record the child\n\
FV base address when current FV base address is set.\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");
GuidValue is one specific capsule guid value\n\
or fv file system guid value.\n\
Its format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n");
Its format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n");
or PopulateSystemTable or InitiateReset or not set\n");
HeadSize is one HEX or DEC format value\n\
HeadSize is required by Capsule Image.\n");
}
int
main (
)
/*++
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.
--*/
{
InfFileName = NULL;
AddrFileName = NULL;
InfFileImage = NULL;
OutFileName = NULL;
MapFileName = NULL;
InfFileSize = 0;
CapsuleFlag = FALSE;
DumpCapsule = FALSE;
LogLevel = 0;
TempNumber = 0;
Index = 0;
mFvTotalSize = 0;
mFvTakenSize = 0;
if (argc == 1) {
Usage ();
return STATUS_ERROR;
}
//
// Init global data to Zero
//
//
// Set the default FvGuid
//
//
// Parse command line
//
argc --;
argv ++;
Version ();
Usage ();
return STATUS_SUCCESS;
}
Version ();
return STATUS_SUCCESS;
}
while (argc > 0) {
if (InfFileName == NULL) {
return STATUS_ERROR;
}
argc -= 2;
argv += 2;
continue;
}
if (AddrFileName == NULL) {
return STATUS_ERROR;
}
argc -= 2;
argv += 2;
continue;
}
if (OutFileName == NULL) {
return STATUS_ERROR;
}
argc -= 2;
argv += 2;
continue;
}
return STATUS_ERROR;
}
argc -= 2;
argv += 2;
continue;
}
return STATUS_ERROR;
}
if (TempNumber == 0) {
return STATUS_ERROR;
}
DebugMsg (NULL, 0, 9, "FV Block Size", "%s = 0x%llx", EFI_BLOCK_SIZE_STRING, (unsigned long long) TempNumber);
argc -= 2;
argv += 2;
continue;
}
return STATUS_ERROR;
}
if (TempNumber == 0) {
return STATUS_ERROR;
}
DebugMsg (NULL, 0, 9, "FV Number Block", "%s = 0x%llx", EFI_NUM_BLOCKS_STRING, (unsigned long long) TempNumber);
argc -= 2;
argv += 2;
continue;
}
return STATUS_ERROR;
}
argc -= 2;
argv += 2;
if (argc > 0) {
return STATUS_ERROR;
}
return STATUS_ERROR;
}
DebugMsg (NULL, 0, 9, "FV component file size", "the %uth size is %s", (unsigned) Index + 1, argv[1]);
argc -= 2;
argv += 2;
}
}
Index ++;
continue;
}
Error (NULL, 0, 1003, "Invalid option", "It must be specified together with -f option to specify the file size.");
return STATUS_ERROR;
}
CapsuleFlag = TRUE;
argc --;
argv ++;
continue;
}
return STATUS_ERROR;
}
mFvDataInfo.ForceRebase = 0;
} else {
Error (NULL, 0, 1003, "Invalid option value", "froce rebase flag value must be \"TRUE\" or \"FALSE\"");
return STATUS_ERROR;
}
argc -= 2;
argv += 2;
continue;
}
//
// Get Capsule Image Header Size
//
return STATUS_ERROR;
}
DebugMsg (NULL, 0, 9, "Capsule Header size", "%s = 0x%llx", EFI_CAPSULE_HEADER_SIZE_STRING, (unsigned long long) TempNumber);
argc -= 2;
argv += 2;
continue;
}
//
// Get Capsule Header
//
return STATUS_ERROR;
}
} else {
return STATUS_ERROR;
}
argc -= 2;
argv += 2;
continue;
}
//
// Get the Capsule Guid
//
return STATUS_ERROR;
}
argc -= 2;
argv += 2;
continue;
}
//
// Get the Capsule or Fv Guid
//
return STATUS_ERROR;
}
argc -= 2;
argv += 2;
continue;
}
//
// Get Fv Name Guid
//
return STATUS_ERROR;
}
argc -= 2;
argv += 2;
continue;
}
DumpCapsule = TRUE;
argc --;
argv ++;
continue;
}
if (MapFileName == NULL) {
return STATUS_ERROR;
}
argc -= 2;
argv += 2;
continue;
}
VerboseMsg ("Verbose output Mode Set!");
argc --;
argv ++;
continue;
}
KeyMsg ("Quiet output Mode Set!");
argc --;
argv ++;
continue;
}
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;
}
argc -= 2;
argv += 2;
continue;
}
//
// Don't recognize the parameter.
//
return STATUS_ERROR;
}
//
// check input parameter, InfFileName can be NULL
//
return STATUS_ERROR;
}
return STATUS_ERROR;
}
if (OutFileName != NULL) {
}
//
// Read the INF file image
//
if (InfFileName != NULL) {
return STATUS_ERROR;
}
}
if (DumpCapsule) {
//
// Dump Capsule Image Header Information
//
if (OutFileName == NULL) {
} else {
return STATUS_ERROR;
}
}
} else if (CapsuleFlag) {
VerboseMsg ("Create capsule image");
//
// Call the GenerateCapImage to generate Capsule Image
//
}
);
} else {
VerboseMsg ("Create Fv image and its map file");
//
// Will take rebase action at below situation:
// 1. ForceRebase Flag specified to TRUE;
// 2. ForceRebase Flag not specified, BaseAddress greater than zero.
//
if (((mFvDataInfo.BaseAddress > 0) && (mFvDataInfo.ForceRebase == -1)) || (mFvDataInfo.ForceRebase == 1)) {
}
//
// Call the GenerateFvImage to generate Fv Image
//
);
}
//
// free InfFileImage memory
//
if (InfFileImage != NULL) {
free (InfFileImage);
}
//
// update boot driver address and runtime driver address in address file
//
return STATUS_ERROR;
}
fprintf (
"0x%llx\n",
(unsigned long long)mFvBaseAddress[Index]
);
}
}
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));
}
return GetUtilityStatus ();
}