/** @file
VfrCompiler main class and main function.
Copyright (c) 2004 - 2011, 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.
**/
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "VfrCompiler.h"
#include "CommonLib.h"
#include "EfiUtilityMsgs.h"
...
)
{
PrintMessage ((CHAR8 *) "ERROR", FileName, LineNumber, MessageCode, (CHAR8 *) Text, (CHAR8 *) MsgFmt, List);
}
)
{
mRunStatus = Status;
}
)
{
return mRunStatus == Status;
}
)
{
if (Argc == 1) {
Usage ();
return;
}
Usage ();
return;
Index++;
goto Fail;
}
} else if (stricmp(Argv[Index], "-o") == 0 || stricmp(Argv[Index], "--output-directory") == 0 || stricmp(Argv[Index], "-od") == 0) {
Index++;
goto Fail;
}
} else {
}
}
} else if (stricmp(Argv[Index], "-b") == 0 || stricmp(Argv[Index], "--create-ifr-package") == 0 || stricmp(Argv[Index], "-ibin") == 0) {
} else if (stricmp(Argv[Index], "-n") == 0 || stricmp(Argv[Index], "--no-pre-processing") == 0 || stricmp(Argv[Index], "-nopp") == 0) {
} else if (stricmp(Argv[Index], "-f") == 0 || stricmp(Argv[Index], "--pre-processing-flag") == 0 || stricmp(Argv[Index], "-ppflag") == 0) {
Index++;
goto Fail;
}
} else if (stricmp(Argv[Index], "-c") == 0 || stricmp(Argv[Index], "--compatible-framework") == 0) {
Index++;
goto Fail;
}
Index++;
goto Fail;
}
} else {
goto Fail;
}
}
goto Fail;
} else {
}
if (SetBaseFileName() != 0) {
goto Fail;
}
if (SetPkgOutputFileName () != 0) {
goto Fail;
}
if (SetCOutputFileName() != 0) {
goto Fail;
}
if (SetPreprocessorOutputFileName () != 0) {
goto Fail;
}
if (SetRecordListFileName () != 0) {
goto Fail;
}
return;
Fail:
delete mOptions.IncludePaths;
}
delete mOptions.CPreprocessorOptions;
}
}
)
{
}
if (IncludePaths == NULL) {
return;
}
IncludePaths[0] = '\0';
}
delete mOptions.IncludePaths;
}
}
)
{
}
return;
}
Opt[0] = 0;
}
delete mOptions.CPreprocessorOptions;
}
}
)
{
return -1;
}
while (
)
{
}
return -1;
}
return -1;
}
return 0;
}
)
{
return -1;
}
return 0;
}
)
{
return -1;
}
return 0;
}
)
{
return -1;
}
return 0;
}
)
{
return -1;
}
return 0;
}
)
{
return;
}
}
)
{
delete mOptions.IncludePaths;
}
delete mOptions.CPreprocessorOptions;
}
}
)
{
" ",
"Copyright (c) 2004-2011 Intel Corporation. All rights reserved.",
" ",
"Usage: VfrCompile [options] VfrFile",
" ",
"Options:",
" -h, --help prints this help",
" -l create an output IFR listing file",
" -o DIR, --output-directory DIR",
" deposit all output files to directory OutputDir",
" default is current directory",
" -b, --create-ifr-package",
" create an IFR HII pack file",
" -n, --no-pre-processing",
" do not preprocessing input file",
" -c, --compatible-framework",
" compatible framework vfr file",
" -s, --string-db",
" input uni string package file",
" -g, --guid",
" override class guid input",
" format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
};
}
}
)
{
if (!IS_RUN_STATUS(STATUS_INITIALIZED)) {
goto Fail;
}
goto Out;
}
goto Fail;
}
}
}
if (PreProcessCmd == NULL) {
goto Fail;
}
}
}
if (system (PreProcessCmd) != 0) {
DebugError (NULL, 0, 0003, "Error parsing file", "failed to spawn C preprocessor on VFR file %s\n", PreProcessCmd);
goto Fail;
}
delete PreProcessCmd;
Out:
return;
Fail:
if (!IS_RUN_STATUS(STATUS_DEAD)) {
}
delete PreProcessCmd;
}
)
{
if (!IS_RUN_STATUS(STATUS_PREPROCESSED)) {
goto Fail;
}
InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;
goto Fail;
}
if (mOptions.HasOverrideClassGuid) {
} else {
}
goto Fail;
}
goto Fail;
}
return;
Fail:
if (!IS_RUN_STATUS(STATUS_DEAD)) {
}
}
}
)
{
//
// Check Binary Code consistent between Form and IfrRecord
//
//
// Get Package Data and IfrRecord Data
//
//
// Compare Form and Record data
//
DebugError (NULL, 0, 0001, "Error parsing vfr file", " %s. FormBinary Size 0x%X is not same to RecordBuffer Size 0x%X", mOptions.VfrFileName, gCBuffer.Size, gRBuffer.Size);
}
break;
}
}
DebugError (NULL, 0, 0001, "Error parsing vfr file", " %s. the 0x%X byte is different between Form and Record", mOptions.VfrFileName, Index);
}
DebugMsg (NULL, 0, 9, (CHAR8 *) "IFR Buffer", (CHAR8 *) "Form Buffer same to Record Buffer and Size is 0x%X", Index);
//ok
} else {
DebugError (NULL, 0, 0001, "Error parsing vfr file", " %s.Buffer not allocated.", mOptions.VfrFileName);
}
//
// For UEFI mode, not do OpCode Adjust
//
if (mOptions.CompatibleMode) {
//
// Adjust Opcode to be compatible with framework vfr
//
if (Status != VFR_RETURN_SUCCESS) {
//
// Record List Adjust Failed
//
return;
}
//
// Re get the IfrRecord Buffer.
//
}
return;
}
)
{
if (!IS_RUN_STATUS(STATUS_COMPILEED)) {
goto Fail;
}
goto Fail;
}
goto Fail;
}
}
return;
Fail:
if (!IS_RUN_STATUS(STATUS_DEAD)) {
}
}
static const char *gSourceFileHeader[] = {
"//",
"// DO NOT EDIT -- auto-generated file",
"//",
"// This file is generated by the vfrcompiler utility",
"//",
};
)
{
if (!IS_RUN_STATUS(STATUS_GENBINARY)) {
goto Fail;
}
goto Fail;
}
}
if (mOptions.CompatibleMode) {
}
goto Fail;
}
}
return;
Fail:
if (!IS_RUN_STATUS(STATUS_DEAD)) {
}
}
)
{
InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;
return;
}
return;
}
goto Err1;
}
LineNo = 0;
LineNo++;
}
}
}
return;
Err1:
}
int
main (
)
{
return 2;
}
}
}
return GetUtilityStatus ();
}