1 /*++ 2 3 Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR> 4 This program and the accompanying materials 5 are licensed and made available under the terms and conditions of the BSD License 6 which accompanies this distribution. The full text of the license may be found at 7 http://opensource.org/licenses/bsd-license.php 8 9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 11 12 Module Name: 13 14 EfiVfr.h 15 16 Abstract: 17 18 Defines and prototypes for the EFI internal forms representation 19 setup protocol and drivers 20 21 --*/ 22 23 #ifndef _EFI_VFR_H_ 24 #define _EFI_VFR_H_ 25 26 #include "Tiano.h" 27 #include "EfiInternalFormRepresentation.h" 28 #include <string.h> 29 30 // 31 // This number should be incremented with each change to the VFR compiler. 32 // We write the version to the output list file for debug purposes. 33 // 34 #define UTILITY_VERSION "v1.9" 35 #define UTILITY_NAME "VfrCompile" 36 37 // 38 // Maximum file path for filenames 39 // 40 #define MAX_PATH 255 41 #define MAX_QUEUE_COUNT 255 42 #define MAX_LINE_LEN 1024 43 44 // 45 // We parse C-style structure definitions which can then be referenced 46 // in VFR statements. 47 // We need to define an internal structure that can be used to 48 // track the fields in a structure definition, and another structure 49 // to keep track of the structure name and subfields. 50 // 51 typedef struct _STRUCT_FIELD_DEFINITION { 52 struct _STRUCT_FIELD_DEFINITION *Next; 53 int DataSize; 54 int Offset; // from the start of the structure 55 int ArrayLength; 56 char IsArray; 57 char *Name; 58 } STRUCT_FIELD_DEFINITION; 59 60 typedef struct _STRUCT_DEFINITION { 61 struct _STRUCT_DEFINITION *Next; 62 int Size; 63 int LineNum; // line number where the structure was defined 64 int IsNonNV; // if this is the non-NV data structure definition 65 int Referenced; // if it's referenced anywhere in the VFR 66 int VarStoreIdValid; // found a 'varstore' statement for it in the VFR 67 unsigned short VarStoreId; // key from a varstore IFR statement 68 int VarStoreLineNum; // line number where VARSTORE was defined 69 char *Name; 70 STRUCT_FIELD_DEFINITION *Field; 71 STRUCT_FIELD_DEFINITION *LastField; 72 } STRUCT_DEFINITION; 73 74 // 75 // For the IdEqValList variable list of UINT16's, keep track of them using 76 // a linked list until we know how many there are. 77 // We also use a linked list of these to keep track of labels used in 78 // the VFR script so we can catch duplicates. 79 // We'll also use it to keep track of defined varstore id's so we can 80 // detect duplicate definitions. 81 // 82 typedef struct _UINT16_LIST { 83 struct _UINT16_LIST *Next; 84 UINT16 Value; 85 UINT32 LineNum; 86 } UINT16_LIST; 87 88 typedef struct _GOTO_REFERENCE { 89 struct _GOTO_REFERENCE *Next; 90 UINT32 RefLineNum; // line number of source file where referenced 91 UINT16 Value; 92 } GOTO_REFERENCE; 93 94 typedef struct _FORM_ID_VALUE { 95 struct _FORM_ID_VALUE *Next; 96 UINT32 LineNum; 97 UINT16 Value; 98 } FORM_ID_VALUE; 99 100 // 101 // We keep track in the parser of all "#line 4 "x.y"" strings so we 102 // can cross-reference the line numbers in the preprocessor output .i file 103 // to the original input files. 104 // 105 typedef struct _PARSER_LINE_DEFINITION { 106 struct _PARSER_LINE_DEFINITION *Next; 107 UINT32 HashLineNum; // from the #line stmt 108 UINT32 TokenLineNum; // line number in the .i file 109 INT8 *FileName; // from the #line stmt 110 } PARSER_LINE_DEFINITION; 111 112 extern PARSER_LINE_DEFINITION *gLineDefinition; 113 extern PARSER_LINE_DEFINITION *gLastLineDefinition; 114 115 extern 116 char * 117 ConvertLineNumber ( 118 UINT32 *LineNum 119 ) 120 /*++ 121 122 Routine Description: 123 Given the line number in the preprocessor-output file, use the line number 124 information we've saved to determine the source file name and line number 125 where the code originally came from. This is required for error reporting. 126 127 Arguments: 128 LineNum - the line number in the preprocessor-output file. 129 130 Returns: 131 Returns a pointer to the source file name. Also returns the line number 132 in the provided LineNum argument 133 134 --*/ 135 ; 136 137 typedef struct _IFR_BYTE { 138 struct _IFR_BYTE *Next; 139 UINT32 LineNum; 140 UINT8 OpcodeByte; 141 UINT8 KeyByte; 142 } IFR_BYTE; 143 144 typedef struct { 145 INT8 VfrFileName[MAX_PATH]; 146 INT8 VfrListFileName[MAX_PATH]; 147 INT8 CreateListFile; 148 INT8 CreateIfrBinFile; 149 INT8 IfrOutputFileName[MAX_PATH]; 150 INT8 OutputDirectory[MAX_PATH]; 151 INT8 PreprocessorOutputFileName[MAX_PATH]; 152 INT8 VfrBaseFileName[MAX_PATH]; // name of input VFR file with no path or extension 153 INT8 *IncludePaths; 154 INT8 *CPreprocessorOptions; 155 } OPTIONS; 156 157 extern OPTIONS gOptions; 158 159 VOID 160 WriteStandardFileHeader ( 161 FILE *OutFptr 162 ) 163 /*++ 164 165 Routine Description: 166 This function is invoked to emit a standard header to an 167 output text file. 168 169 Arguments: 170 OutFptr - file to write the header to 171 172 Returns: 173 None 174 175 --*/ 176 ; 177 178 #endif // #ifndef _EFI_VFR_H_ 179