Add in the 1st version of ECP.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2832 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
178
EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h
Normal file
178
EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h
Normal file
@@ -0,0 +1,178 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2005, Intel Corporation
|
||||
All rights reserved. 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:
|
||||
|
||||
EfiVfr.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Defines and prototypes for the EFI internal forms representation
|
||||
setup protocol and drivers
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _EFI_VFR_H_
|
||||
#define _EFI_VFR_H_
|
||||
|
||||
#include "Tiano.h"
|
||||
#include "EfiInternalFormRepresentation.h"
|
||||
#include <string.h>
|
||||
|
||||
//
|
||||
// This number should be incremented with each change to the VFR compiler.
|
||||
// We write the version to the output list file for debug purposes.
|
||||
//
|
||||
#define VFR_COMPILER_VERSION "1.88"
|
||||
|
||||
//
|
||||
// Maximum file path for filenames
|
||||
//
|
||||
#define MAX_PATH 255
|
||||
#define MAX_QUEUE_COUNT 255
|
||||
#define MAX_LINE_LEN 1024
|
||||
#define PROGRAM_NAME "VfrCompile"
|
||||
|
||||
//
|
||||
// We parse C-style structure definitions which can then be referenced
|
||||
// in VFR statements.
|
||||
// We need to define an internal structure that can be used to
|
||||
// track the fields in a structure definition, and another structure
|
||||
// to keep track of the structure name and subfields.
|
||||
//
|
||||
typedef struct _STRUCT_FIELD_DEFINITION {
|
||||
struct _STRUCT_FIELD_DEFINITION *Next;
|
||||
int DataSize;
|
||||
int Offset; // from the start of the structure
|
||||
int ArrayLength;
|
||||
char IsArray;
|
||||
char *Name;
|
||||
} STRUCT_FIELD_DEFINITION;
|
||||
|
||||
typedef struct _STRUCT_DEFINITION {
|
||||
struct _STRUCT_DEFINITION *Next;
|
||||
int Size;
|
||||
int LineNum; // line number where the structure was defined
|
||||
int IsNonNV; // if this is the non-NV data structure definition
|
||||
int Referenced; // if it's referenced anywhere in the VFR
|
||||
int VarStoreIdValid; // found a 'varstore' statement for it in the VFR
|
||||
unsigned short VarStoreId; // key from a varstore IFR statement
|
||||
int VarStoreLineNum; // line number where VARSTORE was defined
|
||||
char *Name;
|
||||
STRUCT_FIELD_DEFINITION *Field;
|
||||
STRUCT_FIELD_DEFINITION *LastField;
|
||||
} STRUCT_DEFINITION;
|
||||
|
||||
//
|
||||
// For the IdEqValList variable list of UINT16's, keep track of them using
|
||||
// a linked list until we know how many there are.
|
||||
// We also use a linked list of these to keep track of labels used in
|
||||
// the VFR script so we can catch duplicates.
|
||||
// We'll also use it to keep track of defined varstore id's so we can
|
||||
// detect duplicate definitions.
|
||||
//
|
||||
typedef struct _UINT16_LIST {
|
||||
struct _UINT16_LIST *Next;
|
||||
UINT16 Value;
|
||||
UINT32 LineNum;
|
||||
} UINT16_LIST;
|
||||
|
||||
typedef struct _GOTO_REFERENCE {
|
||||
struct _GOTO_REFERENCE *Next;
|
||||
UINT32 RefLineNum; // line number of source file where referenced
|
||||
UINT16 Value;
|
||||
} GOTO_REFERENCE;
|
||||
|
||||
typedef struct _FORM_ID_VALUE {
|
||||
struct _FORM_ID_VALUE *Next;
|
||||
UINT32 LineNum;
|
||||
UINT16 Value;
|
||||
} FORM_ID_VALUE;
|
||||
|
||||
//
|
||||
// We keep track in the parser of all "#line 4 "x.y"" strings so we
|
||||
// can cross-reference the line numbers in the preprocessor output .i file
|
||||
// to the original input files.
|
||||
//
|
||||
typedef struct _PARSER_LINE_DEFINITION {
|
||||
struct _PARSER_LINE_DEFINITION *Next;
|
||||
UINT32 HashLineNum; // from the #line stmt
|
||||
UINT32 TokenLineNum; // line number in the .i file
|
||||
INT8 *FileName; // from the #line stmt
|
||||
} PARSER_LINE_DEFINITION;
|
||||
|
||||
extern PARSER_LINE_DEFINITION *gLineDefinition;
|
||||
extern PARSER_LINE_DEFINITION *gLastLineDefinition;
|
||||
|
||||
extern
|
||||
char *
|
||||
ConvertLineNumber (
|
||||
UINT32 *LineNum
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Given the line number in the preprocessor-output file, use the line number
|
||||
information we've saved to determine the source file name and line number
|
||||
where the code originally came from. This is required for error reporting.
|
||||
|
||||
Arguments:
|
||||
LineNum - the line number in the preprocessor-output file.
|
||||
|
||||
Returns:
|
||||
Returns a pointer to the source file name. Also returns the line number
|
||||
in the provided LineNum argument
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
typedef struct _IFR_BYTE {
|
||||
struct _IFR_BYTE *Next;
|
||||
UINT32 LineNum;
|
||||
UINT8 OpcodeByte;
|
||||
UINT8 KeyByte;
|
||||
} IFR_BYTE;
|
||||
|
||||
typedef struct {
|
||||
INT8 VfrFileName[MAX_PATH];
|
||||
INT8 VfrListFileName[MAX_PATH];
|
||||
INT8 CreateListFile;
|
||||
INT8 CreateIfrBinFile;
|
||||
INT8 IfrOutputFileName[MAX_PATH];
|
||||
INT8 OutputDirectory[MAX_PATH];
|
||||
INT8 PreprocessorOutputFileName[MAX_PATH];
|
||||
INT8 VfrBaseFileName[MAX_PATH]; // name of input VFR file with no path or extension
|
||||
INT8 *IncludePaths;
|
||||
INT8 *CPreprocessorOptions;
|
||||
} OPTIONS;
|
||||
|
||||
extern OPTIONS gOptions;
|
||||
|
||||
VOID
|
||||
WriteStandardFileHeader (
|
||||
FILE *OutFptr
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This function is invoked to emit a standard header to an
|
||||
output text file.
|
||||
|
||||
Arguments:
|
||||
OutFptr - file to write the header to
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
#endif // #ifndef _EFI_VFR_H_
|
3463
EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g
Normal file
3463
EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,754 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation
|
||||
All rights reserved. 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:
|
||||
|
||||
VfrServices.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
Support routines for the VFR compiler
|
||||
|
||||
--*/
|
||||
|
||||
#include <stdio.h> // for FILE routines
|
||||
#include <stdlib.h> // for malloc() and free()
|
||||
|
||||
#include "Tiano.h"
|
||||
#include "EfiUtilityMsgs.h"
|
||||
#include "EfiVfr.h"
|
||||
#include "VfrServices.h"
|
||||
|
||||
#include EFI_PROTOCOL_DEFINITION (Hii)
|
||||
|
||||
static const char *mSourceFileHeader[] = {
|
||||
"//",
|
||||
"// DO NOT EDIT -- auto-generated file",
|
||||
"//",
|
||||
"// This file is generated by the VFR compiler.",
|
||||
"//",
|
||||
NULL
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
INT8 *Name;
|
||||
INT32 Size;
|
||||
} IFR_OPCODE_SIZES;
|
||||
|
||||
//
|
||||
// Create a table that can be used to do internal checking on the IFR
|
||||
// bytes we emit.
|
||||
//
|
||||
static const IFR_OPCODE_SIZES mOpcodeSizes[] = {
|
||||
{ 0, 0 }, // invalid
|
||||
{ "EFI_IFR_FORM", sizeof (EFI_IFR_FORM) },
|
||||
{ "EFI_IFR_SUBTITLE", sizeof (EFI_IFR_SUBTITLE) },
|
||||
{ "EFI_IFR_TEXT", -6 }, //sizeof (EFI_IFR_TEXT) },
|
||||
{ "unused 0x04 opcode", 0 }, // EFI_IFR_GRAPHIC_OP
|
||||
{ "EFI_IFR_ONE_OF", sizeof (EFI_IFR_ONE_OF) },
|
||||
{ "EFI_IFR_CHECK_BOX", sizeof (EFI_IFR_CHECK_BOX) },
|
||||
{ "EFI_IFR_NUMERIC", sizeof (EFI_IFR_NUMERIC) },
|
||||
{ "EFI_IFR_PASSWORD", sizeof (EFI_IFR_PASSWORD) },
|
||||
{ "EFI_IFR_ONE_OF_OPTION", sizeof (EFI_IFR_ONE_OF_OPTION) },
|
||||
{ "EFI_IFR_SUPPRESS", sizeof (EFI_IFR_SUPPRESS) },
|
||||
{ "EFI_IFR_END_FORM", sizeof (EFI_IFR_END_FORM) },
|
||||
{ "EFI_IFR_HIDDEN", sizeof (EFI_IFR_HIDDEN) },
|
||||
{ "EFI_IFR_END_FORM_SET", sizeof (EFI_IFR_END_FORM_SET) },
|
||||
{ "EFI_IFR_FORM_SET", sizeof (EFI_IFR_FORM_SET) },
|
||||
{ "EFI_IFR_REF", sizeof (EFI_IFR_REF) },
|
||||
{ "EFI_IFR_END_ONE_OF", sizeof (EFI_IFR_END_ONE_OF) },
|
||||
{ "EFI_IFR_INCONSISTENT", sizeof (EFI_IFR_INCONSISTENT) },
|
||||
{ "EFI_IFR_EQ_ID_VAL", sizeof (EFI_IFR_EQ_ID_VAL) },
|
||||
{ "EFI_IFR_EQ_ID_ID", sizeof (EFI_IFR_EQ_ID_ID) },
|
||||
{ "EFI_IFR_EQ_ID_LIST", -sizeof (EFI_IFR_EQ_ID_LIST) },
|
||||
{ "EFI_IFR_AND", sizeof (EFI_IFR_AND) },
|
||||
{ "EFI_IFR_OR", sizeof (EFI_IFR_OR) },
|
||||
{ "EFI_IFR_NOT", sizeof (EFI_IFR_NOT) },
|
||||
{ "EFI_IFR_END_IF", sizeof (EFI_IFR_END_IF) },
|
||||
{ "EFI_IFR_GRAYOUT", sizeof (EFI_IFR_GRAYOUT) },
|
||||
{ "EFI_IFR_DATE", sizeof (EFI_IFR_DATE) / 3 },
|
||||
{ "EFI_IFR_TIME", sizeof (EFI_IFR_TIME) / 3 },
|
||||
{ "EFI_IFR_STRING", sizeof (EFI_IFR_STRING) },
|
||||
{ "EFI_IFR_LABEL", sizeof (EFI_IFR_LABEL) },
|
||||
{ "EFI_IFR_SAVE_DEFAULTS", sizeof (EFI_IFR_SAVE_DEFAULTS) },
|
||||
{ "EFI_IFR_RESTORE_DEFAULTS", sizeof (EFI_IFR_RESTORE_DEFAULTS) },
|
||||
{ "EFI_IFR_BANNER", sizeof (EFI_IFR_BANNER) },
|
||||
{ "EFI_IFR_INVENTORY", sizeof (EFI_IFR_INVENTORY) },
|
||||
{ "EFI_IFR_EQ_VAR_VAL_OP", sizeof (EFI_IFR_EQ_VAR_VAL) },
|
||||
{ "EFI_IFR_ORDERED_LIST_OP", sizeof (EFI_IFR_ORDERED_LIST) },
|
||||
{ "EFI_IFR_VARSTORE_OP", -sizeof (EFI_IFR_VARSTORE) },
|
||||
{ "EFI_IFR_VARSTORE_SELECT_OP", sizeof (EFI_IFR_VARSTORE_SELECT) },
|
||||
{ "EFI_IFR_VARSTORE_SELECT_PAIR_OP", sizeof (EFI_IFR_VARSTORE_SELECT_PAIR) },
|
||||
{ "EFI_IFR_TRUE", sizeof (EFI_IFR_TRUE)},
|
||||
{ "EFI_IFR_FALSE", sizeof (EFI_IFR_FALSE)},
|
||||
{ "EFI_IFR_GT", sizeof (EFI_IFR_GT)},
|
||||
{ "EFI_IFR_GE", sizeof (EFI_IFR_GE)},
|
||||
{ "EFI_IFR_OEM_DEFINED_OP", -2 },
|
||||
};
|
||||
|
||||
|
||||
VfrOpcodeHandler::VfrOpcodeHandler (
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Constructor for the VFR opcode handling class.
|
||||
|
||||
Arguments:
|
||||
None
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
mIfrBytes = NULL;
|
||||
mLastIfrByte = NULL;
|
||||
mBytesWritten = 0;
|
||||
mQueuedByteCount = 0;
|
||||
mQueuedOpcodeByteValid = 0;
|
||||
mPrimaryVarStoreId = 0;
|
||||
mSecondaryVarStoreId = 0;
|
||||
mSecondaryVarStoreIdSet = 0;
|
||||
mPrimaryVarStoreIdSet = 0;
|
||||
mDefaultVarStoreId = 0;
|
||||
}
|
||||
|
||||
VOID
|
||||
VfrOpcodeHandler::SetVarStoreId (
|
||||
UINT16 VarStoreId
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This function is invoked by the parser when a variable is referenced in the
|
||||
VFR. Save the variable store (and set a flag) so that we can later determine
|
||||
if we need to emit a varstore-select or varstore-select-pair opcode.
|
||||
|
||||
Arguments:
|
||||
VarStoreId - ID of the variable store referenced in the VFR
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
mPrimaryVarStoreId = VarStoreId;
|
||||
mPrimaryVarStoreIdSet = 1;
|
||||
}
|
||||
|
||||
VOID
|
||||
VfrOpcodeHandler::SetSecondaryVarStoreId (
|
||||
UINT16 VarStoreId
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This function is invoked by the parser when a secondary variable is
|
||||
referenced in the VFR. Save the variable store (and set a flag) so
|
||||
that we can later determine if we need to emit a varstore-select or
|
||||
varstore-pair opcode.
|
||||
|
||||
Arguments:
|
||||
VarStoreId - ID of the variable store referenced in the VFR
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
mSecondaryVarStoreId = VarStoreId;
|
||||
mSecondaryVarStoreIdSet = 1;
|
||||
}
|
||||
|
||||
VOID
|
||||
VfrOpcodeHandler::WriteIfrBytes (
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This function is invoked at the end of parsing. Its purpose
|
||||
is to write out all the IFR bytes that were queued up while
|
||||
parsing.
|
||||
|
||||
Arguments:
|
||||
None
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
IFR_BYTE *Curr;
|
||||
IFR_BYTE *Next;
|
||||
UINT32 Count;
|
||||
UINT32 LineCount;
|
||||
UINT32 PoundLines;
|
||||
UINT32 ByteCount;
|
||||
INT8 Line[MAX_LINE_LEN];
|
||||
INT8 *Cptr;
|
||||
FILE *InFptr;
|
||||
FILE *OutFptr;
|
||||
UINT32 ListFile;
|
||||
EFI_HII_IFR_PACK_HEADER IfrHeader;
|
||||
UINT8 *Ptr;
|
||||
FILE *IfrBinFptr;
|
||||
UINT32 BytesLeftThisOpcode;
|
||||
//
|
||||
// If someone added a new opcode and didn't update our opcode sizes structure, error out.
|
||||
//
|
||||
if (sizeof(mOpcodeSizes) / sizeof (mOpcodeSizes[0]) != EFI_IFR_LAST_OPCODE + 1) {
|
||||
Error (__FILE__, __LINE__, 0, "application error", "internal IFR binary table size is incorrect");
|
||||
return;
|
||||
}
|
||||
//
|
||||
// Flush the queue
|
||||
//
|
||||
FlushQueue ();
|
||||
//
|
||||
// If there have been any errors to this point, then skip dumping the IFR
|
||||
// binary data. This way doing an nmake again will try to build it again, and
|
||||
// the build will fail if they did not fix the problem.
|
||||
//
|
||||
if (GetUtilityStatus () != STATUS_ERROR) {
|
||||
if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "w")) == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");
|
||||
return;
|
||||
}
|
||||
//
|
||||
// Write the standard file header to the output file
|
||||
//
|
||||
WriteStandardFileHeader (IfrBinFptr);
|
||||
//
|
||||
// Write the structure header
|
||||
//
|
||||
fprintf (IfrBinFptr, "\nunsigned char %sBin[] = {", gOptions.VfrBaseFileName);
|
||||
//
|
||||
// Write the header
|
||||
//
|
||||
memset ((char *)&IfrHeader, 0, sizeof (IfrHeader));
|
||||
IfrHeader.Header.Type = EFI_HII_IFR;
|
||||
IfrHeader.Header.Length = mBytesWritten + sizeof (IfrHeader);
|
||||
Ptr = (UINT8 *)&IfrHeader;
|
||||
for (Count = 0; Count < sizeof (IfrHeader); Count++, Ptr++) {
|
||||
if ((Count & 0x03) == 0) {
|
||||
fprintf (IfrBinFptr, "\n ");
|
||||
}
|
||||
fprintf (IfrBinFptr, "0x%02X, ", *Ptr);
|
||||
}
|
||||
//
|
||||
//
|
||||
// Write all the IFR bytes
|
||||
//
|
||||
fprintf (IfrBinFptr, "\n // start of IFR data");
|
||||
Curr = mIfrBytes;
|
||||
Count = 0;
|
||||
while (Curr != NULL) {
|
||||
if ((Count & 0x0F) == 0) {
|
||||
fprintf (IfrBinFptr, "\n ");
|
||||
}
|
||||
if (Curr->KeyByte != 0) {
|
||||
fprintf (IfrBinFptr, "/*%c*/ ", Curr->KeyByte);
|
||||
}
|
||||
fprintf (IfrBinFptr, "0x%02X, ", Curr->OpcodeByte);
|
||||
Count++;
|
||||
Curr = Curr->Next;
|
||||
}
|
||||
fprintf (IfrBinFptr, "\n};\n\n");
|
||||
//
|
||||
//
|
||||
// Close the file
|
||||
//
|
||||
fclose (IfrBinFptr);
|
||||
IfrBinFptr = NULL;
|
||||
}
|
||||
//
|
||||
// Write the bytes as binary data if the user specified to do so
|
||||
//
|
||||
if ((GetUtilityStatus () != STATUS_ERROR) && (gOptions.CreateIfrBinFile != 0)) {
|
||||
//
|
||||
// Use the Ifr output file name with a ".hpk" extension.
|
||||
//
|
||||
for (Cptr = gOptions.IfrOutputFileName + strlen (gOptions.IfrOutputFileName) - 1;
|
||||
(*Cptr != '.') && (Cptr > gOptions.IfrOutputFileName) && (*Cptr != '\\');
|
||||
Cptr--) {
|
||||
//
|
||||
// do nothing
|
||||
//
|
||||
}
|
||||
if (*Cptr == '.') {
|
||||
strcpy (Cptr, ".hpk");
|
||||
} else {
|
||||
strcat (gOptions.IfrOutputFileName, ".hpk");
|
||||
}
|
||||
if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "wb")) == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");
|
||||
return;
|
||||
}
|
||||
//
|
||||
// Write the structure header
|
||||
//
|
||||
memset ((char *)&IfrHeader, 0, sizeof (IfrHeader));
|
||||
IfrHeader.Header.Type = EFI_HII_IFR;
|
||||
IfrHeader.Header.Length = mBytesWritten + sizeof (IfrHeader);
|
||||
Ptr = (UINT8 *)&IfrHeader;
|
||||
for (Count = 0; Count < sizeof (IfrHeader); Count++, Ptr++) {
|
||||
fwrite (Ptr, 1, 1, IfrBinFptr);
|
||||
}
|
||||
//
|
||||
//
|
||||
// Write all the IFR bytes
|
||||
//
|
||||
Curr = mIfrBytes;
|
||||
Count = 0;
|
||||
while (Curr != NULL) {
|
||||
fwrite (&Curr->OpcodeByte, 1, 1, IfrBinFptr);
|
||||
Curr = Curr->Next;
|
||||
}
|
||||
//
|
||||
//
|
||||
// Close the file
|
||||
//
|
||||
fclose (IfrBinFptr);
|
||||
IfrBinFptr = NULL;
|
||||
}
|
||||
//
|
||||
// If creating a listing file, then open the input and output files
|
||||
//
|
||||
ListFile = 0;
|
||||
if (gOptions.CreateListFile) {
|
||||
//
|
||||
// Open the input VFR file and the output list file
|
||||
//
|
||||
if ((InFptr = fopen (gOptions.PreprocessorOutputFileName, "r")) == NULL) {
|
||||
Warning (PROGRAM_NAME, 0, 0, gOptions.PreprocessorOutputFileName, "could not open file for creating a list file");
|
||||
} else {
|
||||
if ((OutFptr = fopen (gOptions.VfrListFileName, "w")) == NULL) {
|
||||
Warning (PROGRAM_NAME, 0, 0, gOptions.VfrListFileName, "could not open output list file for writing");
|
||||
fclose (InFptr);
|
||||
InFptr = NULL;
|
||||
} else {
|
||||
LineCount = 0;
|
||||
ListFile = 1;
|
||||
PoundLines = 0;
|
||||
ByteCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// Write the list file
|
||||
//
|
||||
if (ListFile) {
|
||||
//
|
||||
// Write out the VFR compiler version
|
||||
//
|
||||
fprintf (OutFptr, "//\n// VFR compiler version " VFR_COMPILER_VERSION "\n//\n");
|
||||
Curr = mIfrBytes;
|
||||
while (Curr != NULL) {
|
||||
//
|
||||
// Print lines until we reach the line of the current opcode
|
||||
//
|
||||
while (LineCount < PoundLines + Curr->LineNum) {
|
||||
if (fgets (Line, sizeof (Line), InFptr) != NULL) {
|
||||
//
|
||||
// We should check for line length exceeded on the fgets(). Otherwise it
|
||||
// throws the listing file output off. Future enhancement perhaps.
|
||||
//
|
||||
fprintf (OutFptr, "%s", Line);
|
||||
if (strncmp (Line, "#line", 5) == 0) {
|
||||
PoundLines++;
|
||||
}
|
||||
}
|
||||
LineCount++;
|
||||
}
|
||||
//
|
||||
// Print all opcodes with line numbers less than where we are now
|
||||
//
|
||||
BytesLeftThisOpcode = 0;
|
||||
while ((Curr != NULL) && ((Curr->LineNum == 0) || (LineCount >= PoundLines + Curr->LineNum))) {
|
||||
if (BytesLeftThisOpcode == 0) {
|
||||
fprintf (OutFptr, ">%08X: ", ByteCount);
|
||||
if (Curr->Next != NULL) {
|
||||
BytesLeftThisOpcode = (UINT32)Curr->Next->OpcodeByte;
|
||||
}
|
||||
}
|
||||
fprintf (OutFptr, "%02X ", (UINT32)Curr->OpcodeByte);
|
||||
ByteCount++;
|
||||
BytesLeftThisOpcode--;
|
||||
if (BytesLeftThisOpcode == 0) {
|
||||
fprintf (OutFptr, "\n");
|
||||
}
|
||||
Curr = Curr->Next;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Dump any remaining lines from the input file
|
||||
//
|
||||
while (fgets (Line, sizeof (Line), InFptr) != NULL) {
|
||||
fprintf (OutFptr, "%s", Line);
|
||||
}
|
||||
fclose (InFptr);
|
||||
fclose (OutFptr);
|
||||
}
|
||||
//
|
||||
// Debug code to make sure that each opcode we write out has as many
|
||||
// bytes as the IFR structure requires. If there were errors, then
|
||||
// don't do this step.
|
||||
//
|
||||
if (GetUtilityStatus () != STATUS_ERROR) {
|
||||
Curr = mIfrBytes;
|
||||
ByteCount = 0;
|
||||
while (Curr != NULL) {
|
||||
//
|
||||
// First byte is the opcode, second byte is the length
|
||||
//
|
||||
if (Curr->Next == NULL) {
|
||||
Error (__FILE__, __LINE__, 0, "application error", "last opcode written does not contain a length byte");
|
||||
break;
|
||||
}
|
||||
Count = (UINT32)Curr->Next->OpcodeByte;
|
||||
if (Count == 0) {
|
||||
Error (
|
||||
__FILE__,
|
||||
__LINE__,
|
||||
0,
|
||||
"application error",
|
||||
"opcode with 0 length specified in output at offset 0x%X",
|
||||
ByteCount
|
||||
);
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Check the length
|
||||
//
|
||||
if ((Curr->OpcodeByte > EFI_IFR_LAST_OPCODE) || (Curr->OpcodeByte == 0)) {
|
||||
Error (
|
||||
__FILE__,
|
||||
__LINE__,
|
||||
0,
|
||||
"application error",
|
||||
"invalid opcode 0x%X in output at offset 0x%X",
|
||||
(UINT32) Curr->OpcodeByte, ByteCount
|
||||
);
|
||||
} else if (mOpcodeSizes[Curr->OpcodeByte].Size < 0) {
|
||||
//
|
||||
// For those cases where the length is variable, the size is negative, and indicates
|
||||
// the miniumum size.
|
||||
//
|
||||
if ((mOpcodeSizes[Curr->OpcodeByte].Size * -1) > Count) {
|
||||
Error (
|
||||
__FILE__,
|
||||
__LINE__,
|
||||
0,
|
||||
"application error",
|
||||
"insufficient number of bytes written for %s at offset 0x%X",
|
||||
mOpcodeSizes[Curr->OpcodeByte].Name,
|
||||
ByteCount
|
||||
);
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// Check for gaps
|
||||
//
|
||||
if (mOpcodeSizes[Curr->OpcodeByte].Size == 0) {
|
||||
Error (
|
||||
__FILE__,
|
||||
__LINE__,
|
||||
0,
|
||||
"application error",
|
||||
"invalid opcode 0x%X in output at offset 0x%X",
|
||||
(UINT32)Curr->OpcodeByte,
|
||||
ByteCount
|
||||
);
|
||||
} else {
|
||||
//
|
||||
// Check size
|
||||
//
|
||||
if (mOpcodeSizes[Curr->OpcodeByte].Size != Count) {
|
||||
Error (
|
||||
__FILE__,
|
||||
__LINE__,
|
||||
0,
|
||||
"application error",
|
||||
"invalid number of bytes (%d written s/b %d) written for %s at offset 0x%X",
|
||||
Count,
|
||||
mOpcodeSizes[Curr->OpcodeByte].Size,
|
||||
mOpcodeSizes[Curr->OpcodeByte].Name,
|
||||
ByteCount
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// Skip to next opcode
|
||||
//
|
||||
while (Count > 0) {
|
||||
ByteCount++;
|
||||
if (Curr == NULL) {
|
||||
Error (__FILE__, __LINE__, 0, "application error", "last opcode written has invalid length");
|
||||
break;
|
||||
}
|
||||
Curr = Curr->Next;
|
||||
Count--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VfrOpcodeHandler::~VfrOpcodeHandler(
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Destructor for the VFR opcode handler. Free up memory allocated
|
||||
while parsing the VFR script.
|
||||
|
||||
Arguments:
|
||||
None
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
IFR_BYTE *Curr;
|
||||
IFR_BYTE *Next;
|
||||
//
|
||||
// Free up the IFR bytes
|
||||
//
|
||||
Curr = mIfrBytes;
|
||||
while (Curr != NULL) {
|
||||
Next = Curr->Next;
|
||||
free (Curr);
|
||||
Curr = Next;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
VfrOpcodeHandler::AddOpcodeByte (
|
||||
UINT8 OpcodeByte,
|
||||
UINT32 LineNum
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This function is invoked by the parser when a new IFR
|
||||
opcode should be emitted.
|
||||
|
||||
Arguments:
|
||||
OpcodeByte - the IFR opcode
|
||||
LineNum - the line number from the source file that resulted
|
||||
in the opcode being emitted.
|
||||
|
||||
Returns:
|
||||
0 always
|
||||
|
||||
--*/
|
||||
{
|
||||
UINT32 Count;
|
||||
|
||||
FlushQueue();
|
||||
//
|
||||
// Now add this new byte
|
||||
//
|
||||
mQueuedOpcodeByte = OpcodeByte;
|
||||
mQueuedLineNum = LineNum;
|
||||
mQueuedOpcodeByteValid = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID
|
||||
VfrOpcodeHandler::AddByte (
|
||||
UINT8 ByteVal,
|
||||
UINT8 KeyByte
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This function is invoked by the parser when it determines
|
||||
that more raw IFR bytes should be emitted to the output stream.
|
||||
Here we just queue them up into an output buffer.
|
||||
|
||||
Arguments:
|
||||
ByteVal - the raw byte to emit to the output IFR stream
|
||||
KeyByte - a value that can be used for debug.
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
//
|
||||
// Check for buffer overflow
|
||||
//
|
||||
if (mQueuedByteCount >= MAX_QUEUE_COUNT) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "opcode queue overflow");
|
||||
} else {
|
||||
mQueuedBytes[mQueuedByteCount] = ByteVal;
|
||||
mQueuedKeyBytes[mQueuedByteCount] = KeyByte;
|
||||
mQueuedByteCount++;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
VfrOpcodeHandler::FlushQueue (
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This function is invoked to flush the internal IFR buffer.
|
||||
|
||||
Arguments:
|
||||
None
|
||||
|
||||
Returns:
|
||||
0 always
|
||||
|
||||
--*/
|
||||
{
|
||||
UINT32 Count;
|
||||
UINT32 EmitNoneOnePair;
|
||||
|
||||
EmitNoneOnePair = 0;
|
||||
//
|
||||
// If the secondary varstore was specified, then we have to emit
|
||||
// a varstore-select-pair opcode, which only applies to the following
|
||||
// statement.
|
||||
//
|
||||
if (mSecondaryVarStoreIdSet) {
|
||||
mSecondaryVarStoreIdSet = 0;
|
||||
//
|
||||
// If primary and secondary are the same as the current default
|
||||
// varstore, then we don't have to do anything.
|
||||
// Note that the varstore-select-pair only applies to the following
|
||||
// opcode.
|
||||
//
|
||||
if ((mPrimaryVarStoreId != mSecondaryVarStoreId) || (mPrimaryVarStoreId != mDefaultVarStoreId)) {
|
||||
IAddByte (EFI_IFR_VARSTORE_SELECT_PAIR_OP, 'O', mQueuedLineNum);
|
||||
IAddByte ((UINT8)sizeof (EFI_IFR_VARSTORE_SELECT_PAIR), 'L', 0);
|
||||
IAddByte ((UINT8)mPrimaryVarStoreId, 0, 0);
|
||||
IAddByte ((UINT8)(mPrimaryVarStoreId >> 8), 0, 0);
|
||||
IAddByte ((UINT8)mSecondaryVarStoreId, 0, 0);
|
||||
IAddByte ((UINT8)(mSecondaryVarStoreId >> 8), 0, 0);
|
||||
}
|
||||
} else if (mPrimaryVarStoreIdSet != 0) {
|
||||
mPrimaryVarStoreIdSet = 0;
|
||||
if (mDefaultVarStoreId != mPrimaryVarStoreId) {
|
||||
//
|
||||
// The VFR statement referenced a different variable store
|
||||
// than the last one we reported. Insert a new varstore select
|
||||
// statement.
|
||||
//
|
||||
IAddByte (EFI_IFR_VARSTORE_SELECT_OP, 'O', mQueuedLineNum);
|
||||
IAddByte ((UINT8)sizeof (EFI_IFR_VARSTORE_SELECT), 'L', 0);
|
||||
IAddByte ((UINT8)mPrimaryVarStoreId, 0, 0);
|
||||
IAddByte ((UINT8)(mPrimaryVarStoreId >> 8), 0, 0);
|
||||
mDefaultVarStoreId = mPrimaryVarStoreId;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Likely a new opcode is being added. Since each opcode item in the IFR has
|
||||
// a header that specifies the size of the opcode item (which we don't
|
||||
// know until we find the next opcode in the VFR), we queue up bytes
|
||||
// until we know the size. Then we write them out. So flush the queue
|
||||
// now.
|
||||
//
|
||||
if (mQueuedOpcodeByteValid != 0) {
|
||||
//
|
||||
// Add the previous opcode byte, the length byte, and the binary
|
||||
// data.
|
||||
//
|
||||
IAddByte (mQueuedOpcodeByte, 'O', mQueuedLineNum);
|
||||
IAddByte ((UINT8)(mQueuedByteCount + 2), 'L', 0);
|
||||
for (Count = 0; Count < mQueuedByteCount; Count++) {
|
||||
IAddByte (mQueuedBytes[Count], mQueuedKeyBytes[Count], 0);
|
||||
}
|
||||
mQueuedByteCount = 0;
|
||||
mQueuedOpcodeByteValid = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
VfrOpcodeHandler::IAddByte (
|
||||
UINT8 ByteVal,
|
||||
UINT8 KeyByte,
|
||||
UINT32 LineNum
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This internal function is used to add actual IFR bytes to
|
||||
the output stream. Most other functions queue up the bytes
|
||||
in an internal buffer. Once they come here, there's no
|
||||
going back.
|
||||
|
||||
|
||||
Arguments:
|
||||
ByteVal - value to write to output
|
||||
KeyByte - key value tied to the byte -- useful for debug
|
||||
LineNum - line number from source file the byte resulted from
|
||||
|
||||
Returns:
|
||||
0 - if successful
|
||||
1 - failed due to memory allocation failure
|
||||
|
||||
--*/
|
||||
{
|
||||
IFR_BYTE *NewByte;
|
||||
NewByte = (IFR_BYTE *)malloc (sizeof (IFR_BYTE));
|
||||
if (NewByte == NULL) {
|
||||
return 1;
|
||||
}
|
||||
memset ((char *)NewByte, 0, sizeof (IFR_BYTE));
|
||||
NewByte->OpcodeByte = ByteVal;
|
||||
NewByte->KeyByte = KeyByte;
|
||||
NewByte->LineNum = LineNum;
|
||||
//
|
||||
// Add to the list
|
||||
//
|
||||
if (mIfrBytes == NULL) {
|
||||
mIfrBytes = NewByte;
|
||||
} else {
|
||||
mLastIfrByte->Next = NewByte;
|
||||
}
|
||||
mLastIfrByte = NewByte;
|
||||
mBytesWritten++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID
|
||||
WriteStandardFileHeader (
|
||||
FILE *OutFptr
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This function is invoked to emit a standard header to an
|
||||
output text file.
|
||||
|
||||
Arguments:
|
||||
OutFptr - file to write the header to
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
UINT32 TempIndex;
|
||||
for (TempIndex = 0; mSourceFileHeader[TempIndex] != NULL; TempIndex++) {
|
||||
fprintf (OutFptr, "%s\n", mSourceFileHeader[TempIndex]);
|
||||
}
|
||||
//
|
||||
// Write out the VFR compiler version
|
||||
//
|
||||
fprintf (OutFptr, "// VFR compiler version " VFR_COMPILER_VERSION "\n//\n");
|
||||
}
|
227
EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.h
Normal file
227
EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.h
Normal file
@@ -0,0 +1,227 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004, Intel Corporation
|
||||
All rights reserved. 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:
|
||||
|
||||
VfrServices.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Prototypes and defines for routines and classes used by the
|
||||
EFI VFR compiler.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _VFR_SERVICES_H_
|
||||
#define _VFR_SERVICES_H_
|
||||
|
||||
class VfrOpcodeHandler
|
||||
{
|
||||
public:
|
||||
VfrOpcodeHandler (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Constructor for the VFR opcode handling class.
|
||||
|
||||
Arguments:
|
||||
None
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
--*/
|
||||
;
|
||||
~VfrOpcodeHandler (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Destructor for the VFR opcode handler. Free up memory allocated
|
||||
while parsing the VFR script.
|
||||
|
||||
Arguments:
|
||||
None
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
--*/
|
||||
;
|
||||
void
|
||||
WriteIfrBytes (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This function is invoked at the end of parsing. Its purpose
|
||||
is to write out all the IFR bytes that were queued up while
|
||||
parsing.
|
||||
|
||||
Arguments:
|
||||
None
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
--*/
|
||||
;
|
||||
int
|
||||
AddOpcodeByte (
|
||||
UINT8 OpcodeByte,
|
||||
UINT32 LineNum
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This function is invoked by the parser when a new IFR
|
||||
opcode should be emitted.
|
||||
|
||||
Arguments:
|
||||
OpcodeByte - the IFR opcode
|
||||
LineNum - the line number from the source file that resulted
|
||||
in the opcode being emitted.
|
||||
|
||||
Returns:
|
||||
0 always
|
||||
|
||||
--*/
|
||||
;
|
||||
void
|
||||
AddByte (
|
||||
UINT8 ByteVal,
|
||||
UINT8 KeyByte
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This function is invoked by the parser when it determines
|
||||
that more raw IFR bytes should be emitted to the output stream.
|
||||
Here we just queue them up into an output buffer.
|
||||
|
||||
Arguments:
|
||||
ByteVal - the raw byte to emit to the output IFR stream
|
||||
KeyByte - a value that can be used for debug.
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
--*/
|
||||
;
|
||||
void
|
||||
SetVarStoreId (
|
||||
UINT16 VarStoreId
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This function is invoked by the parser when a variable is referenced in the
|
||||
VFR. Save the variable store (and set a flag) so that we can later determine
|
||||
if we need to emit a varstore-select or varstore-select-pair opcode.
|
||||
|
||||
Arguments:
|
||||
VarStoreId - ID of the variable store referenced in the VFR
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
--*/
|
||||
;
|
||||
void
|
||||
SetSecondaryVarStoreId (
|
||||
UINT16 VarStoreId
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This function is invoked by the parser when a secondary variable is
|
||||
referenced in the VFR. Save the variable store (and set a flag) so
|
||||
that we can later determine if we need to emit a varstore-select or
|
||||
varstore-pair opcode.
|
||||
|
||||
Arguments:
|
||||
VarStoreId - ID of the variable store referenced in the VFR
|
||||
|
||||
Returns:
|
||||
None
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
/* */
|
||||
private:
|
||||
int
|
||||
FlushQueue (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This function is invoked to flush the internal IFR buffer.
|
||||
|
||||
Arguments:
|
||||
None
|
||||
|
||||
Returns:
|
||||
0 always
|
||||
|
||||
--*/
|
||||
;
|
||||
int
|
||||
IAddByte (
|
||||
UINT8 ByteVal,
|
||||
UINT8 KeyByte,
|
||||
UINT32 LineNum
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This internal function is used to add actual IFR bytes to
|
||||
the output stream. Most other functions queue up the bytes
|
||||
in an internal buffer. Once they come here, there's no
|
||||
going back.
|
||||
|
||||
|
||||
Arguments:
|
||||
ByteVal - value to write to output
|
||||
KeyByte - key value tied to the byte -- useful for debug
|
||||
LineNum - line number from source file the byte resulted from
|
||||
|
||||
Returns:
|
||||
0 - if successful
|
||||
1 - failed due to memory allocation failure
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
/* */
|
||||
private:
|
||||
IFR_BYTE *mIfrBytes;
|
||||
IFR_BYTE *mLastIfrByte;
|
||||
UINT32 mQueuedByteCount;
|
||||
UINT32 mBytesWritten;
|
||||
UINT32 mQueuedLineNum;
|
||||
UINT8 mQueuedBytes[MAX_QUEUE_COUNT];
|
||||
UINT8 mQueuedKeyBytes[MAX_QUEUE_COUNT];
|
||||
UINT8 mQueuedOpcodeByte;
|
||||
UINT32 mQueuedOpcodeByteValid;
|
||||
UINT16 mPrimaryVarStoreId;
|
||||
UINT8 mPrimaryVarStoreIdSet;
|
||||
UINT16 mSecondaryVarStoreId;
|
||||
UINT8 mSecondaryVarStoreIdSet;
|
||||
UINT16 mDefaultVarStoreId;
|
||||
};
|
||||
|
||||
#endif // #ifndef _VFR_SERVICES_H_
|
172
EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile
Normal file
172
EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile
Normal file
@@ -0,0 +1,172 @@
|
||||
#/*++
|
||||
#
|
||||
# Copyright (c) 2004 - 2007, Intel Corporation
|
||||
# All rights reserved. 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:
|
||||
#
|
||||
# makefile
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# Makefile for building the EFI VFR compiler
|
||||
#
|
||||
#--*/
|
||||
|
||||
|
||||
!IFNDEF EDK_SOURCE
|
||||
!ERROR EDK_SOURCE environmental variable not set
|
||||
!ENDIF
|
||||
|
||||
#
|
||||
# Do this if you want to compile from this directory
|
||||
#
|
||||
!IFNDEF TOOLCHAIN
|
||||
TOOLCHAIN = TOOLCHAIN_MSVC
|
||||
!ENDIF
|
||||
|
||||
!INCLUDE $(BUILD_DIR)\PlatformTools.env
|
||||
|
||||
.SUFFIXES :
|
||||
|
||||
TARGET_NAME = VfrCompile
|
||||
ANTLR_H = $(PCCTS_DIR)\h
|
||||
C_FLAGS_PCCTS = -I. -I$(ANTLR_H) /Zi /Fd$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj /WX /Od /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS)
|
||||
C_FLAGS_PCCTS = $(C_FLAGS_PCCTS)
|
||||
|
||||
LINK_FLAGS_PCCTS =
|
||||
LIBS = "$(EDK_TOOLS_OUTPUT)\Common.lib"
|
||||
|
||||
#
|
||||
# Define the EFI output and source directories.
|
||||
#
|
||||
ETO = $(EDK_TOOLS_OUTPUT)
|
||||
SRC = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)
|
||||
TARGET_EXE = $(ETO)\$(TARGET_NAME).exe
|
||||
|
||||
#
|
||||
# Add deeper lookahead with -ck 3
|
||||
#
|
||||
ANTLR_FLAGS = -CC -e3 -ck 3
|
||||
DLG_FLAGS = -C2 -i -CC
|
||||
|
||||
#
|
||||
# Define paths for include files
|
||||
#
|
||||
INC = -I $(SRC)
|
||||
INC = $(INC) -I $(EDK_SOURCE)\Foundation\Include\Ia32
|
||||
INC = $(INC) -I $(EDK_SOURCE)\Foundation\Efi\Include
|
||||
INC = $(INC) -I $(EDK_SOURCE)\Foundation\Framework\Include
|
||||
INC = $(INC) -I $(EDK_SOURCE)\Foundation\Include\IndustryStandard
|
||||
INC = $(INC) -I $(EDK_SOURCE)\Foundation\ \
|
||||
-I $(EDK_SOURCE)\Foundation\Core\Dxe \
|
||||
-I $(EDK_SOURCE)\Foundation\Efi \
|
||||
-I $(EDK_SOURCE)\Foundation\Framework
|
||||
INC = $(INC) -I $(EDK_TOOLS_SOURCE)\Common
|
||||
INC = $(INC) -I $(EDK_SOURCE)\Foundation\Include
|
||||
|
||||
DLG_FILE = Parser.dlg
|
||||
SCAN_FILE = DLGLexer
|
||||
PARSER_FILE = EfiVfrParser
|
||||
|
||||
#
|
||||
# Create a list of include dependencies
|
||||
#
|
||||
INC_DEPS = $(INC_DEPS) $(SRC)\EfiVfr.h
|
||||
INC_DEPS = $(INC_DEPS) $(EDK_SOURCE)\Foundation\Framework\Include\EfiInternalFormRepresentation.h
|
||||
|
||||
#
|
||||
# This is the grammer file for our project
|
||||
#
|
||||
GRAMMER_FILE = $(SRC)\$(TARGET_NAME).g
|
||||
|
||||
#
|
||||
# If we utilize a separate token file, define it here.
|
||||
#
|
||||
#TOKEN_FILE =
|
||||
|
||||
|
||||
OBJECTS = $(ETO)\$(TARGET_NAME).obj \
|
||||
$(ETO)\$(PARSER_FILE).obj \
|
||||
$(ETO)\AParser.obj \
|
||||
$(ETO)\DLexerBase.obj \
|
||||
$(ETO)\ATokenBuffer.obj \
|
||||
$(ETO)\$(SCAN_FILE).obj \
|
||||
$(ETO)\VfrServices.obj
|
||||
|
||||
#
|
||||
# Per the Language Translation Using PCCTS and C++ Reference Guide, page 109,
|
||||
# these are the outputs of ANTLR and DLG
|
||||
#
|
||||
ANTLR_SPAWN = $(ETO)\$(TARGET_NAME).cpp \
|
||||
$(ETO)\$(PARSER_FILE).cpp \
|
||||
$(ETO)\$(PARSER_FILE).h \
|
||||
$(ETO)\$(DLG_FILE) \
|
||||
$(ETO)\tokens.h
|
||||
|
||||
DLG_SPAWN = $(ETO)\$(SCAN_FILE).cpp \
|
||||
$(ETO)\$(SCAN_FILE).h
|
||||
|
||||
|
||||
#
|
||||
# Default target
|
||||
#
|
||||
all : $(TARGET_EXE)
|
||||
|
||||
#
|
||||
# All antlr-generated files depend on the .g grammer file. Use the -o
|
||||
# option to emit them to the appropriate output directory.
|
||||
#
|
||||
$(ANTLR_SPAWN) : $(GRAMMER_FILE) $(INC_DEPS)
|
||||
$(ANTLR) $(ANTLR_FLAGS) -o $(ETO) $(GRAMMER_FILE)
|
||||
|
||||
$(ETO)\$(TARGET_NAME).obj : $(ETO)\$(TARGET_NAME).cpp $(DLG_SPAWN) $(INC_DEPS)
|
||||
$(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(INC) $(ETO)\$(TARGET_NAME).cpp
|
||||
|
||||
$(ETO)\$(SCAN_FILE).obj : $(ETO)\$(SCAN_FILE).cpp $(DLG_SPAWN) $(INC_DEPS)
|
||||
$(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(INC) $(ETO)\$(SCAN_FILE).cpp
|
||||
|
||||
$(ETO)\$(PARSER_FILE).obj : $(ETO)\$(PARSER_FILE).cpp $(ETO)\$(PARSER_FILE).h $(DLG_SPAWN) $(INC_DEPS)
|
||||
$(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(INC) $(ETO)\$(PARSER_FILE).cpp
|
||||
|
||||
$(DLG_SPAWN) : $(ETO)\$(DLG_FILE) $(INC_DEPS)
|
||||
$(DLG) $(DLG_FLAGS) -o $(ETO) $(ETO)\$(DLG_FILE)
|
||||
|
||||
$(ETO)\AParser.obj : $(ANTLR_H)/AParser.cpp
|
||||
$(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(ANTLR_H)/AParser.cpp
|
||||
|
||||
$(ETO)\ATokenBuffer.obj : $(ANTLR_H)/ATokenBuffer.cpp
|
||||
$(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(ANTLR_H)/ATokenBuffer.cpp
|
||||
|
||||
$(ETO)\DLexerBase.obj : $(ANTLR_H)/DLexerBase.cpp
|
||||
$(CC) -c $(C_FLAGS_PCCTS) /Fo$@ $(ANTLR_H)/DLexerBase.cpp
|
||||
|
||||
$(ETO)\VfrServices.obj : $(SRC)\VfrServices.cpp $(SRC)\VfrServices.h $(INC_DEPS)
|
||||
$(CC) -c $(C_FLAGS_PCCTS) $(INC) /Fo$@ $(SRC)\VfrServices.cpp
|
||||
|
||||
#
|
||||
# Add Binary Build description for this tools.
|
||||
#
|
||||
|
||||
!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))
|
||||
$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe
|
||||
copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y
|
||||
if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \
|
||||
copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y
|
||||
!ELSE
|
||||
$(TARGET_EXE) : $(OBJECTS) $(LIBS)
|
||||
$(LINK) $(MSVS_LINK_LIBPATHS) $(LIBS) /DEBUG /OUT:$(TARGET_EXE) $(LINK_FLAGS_PCCTS) $(OBJECTS) /PDB:$*.pdb
|
||||
if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools
|
||||
if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y
|
||||
if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \
|
||||
copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y
|
||||
!ENDIF
|
||||
|
||||
clean:
|
||||
|
Reference in New Issue
Block a user