summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h
blob: d6862119db3a78a363c11de59b8e85a996dbce50 (plain)
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
/*++

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_