1 /*++ 2 3 Copyright (c) 2004, 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 VfrServices.h 15 16 Abstract: 17 18 Prototypes and defines for routines and classes used by the 19 EFI VFR compiler. 20 21 --*/ 22 23 #ifndef _VFR_SERVICES_H_ 24 #define _VFR_SERVICES_H_ 25 26 class VfrOpcodeHandler 27 { 28 public: 29 VfrOpcodeHandler ( 30 VOID 31 ) 32 /*++ 33 34 Routine Description: 35 Constructor for the VFR opcode handling class. 36 37 Arguments: 38 None 39 40 Returns: 41 None 42 43 --*/ 44 ; 45 ~VfrOpcodeHandler ( 46 VOID 47 ) 48 /*++ 49 50 Routine Description: 51 Destructor for the VFR opcode handler. Free up memory allocated 52 while parsing the VFR script. 53 54 Arguments: 55 None 56 57 Returns: 58 None 59 60 --*/ 61 ; 62 void 63 WriteIfrBytes ( 64 VOID 65 ) 66 /*++ 67 68 Routine Description: 69 This function is invoked at the end of parsing. Its purpose 70 is to write out all the IFR bytes that were queued up while 71 parsing. 72 73 Arguments: 74 None 75 76 Returns: 77 None 78 79 --*/ 80 ; 81 int 82 AddOpcodeByte ( 83 UINT8 OpcodeByte, 84 UINT32 LineNum 85 ) 86 /*++ 87 88 Routine Description: 89 This function is invoked by the parser when a new IFR 90 opcode should be emitted. 91 92 Arguments: 93 OpcodeByte - the IFR opcode 94 LineNum - the line number from the source file that resulted 95 in the opcode being emitted. 96 97 Returns: 98 0 always 99 100 --*/ 101 ; 102 void 103 AddByte ( 104 UINT8 ByteVal, 105 UINT8 KeyByte 106 ) 107 /*++ 108 109 Routine Description: 110 This function is invoked by the parser when it determines 111 that more raw IFR bytes should be emitted to the output stream. 112 Here we just queue them up into an output buffer. 113 114 Arguments: 115 ByteVal - the raw byte to emit to the output IFR stream 116 KeyByte - a value that can be used for debug. 117 118 Returns: 119 None 120 121 --*/ 122 ; 123 void 124 SetVarStoreId ( 125 UINT16 VarStoreId 126 ) 127 /*++ 128 129 Routine Description: 130 This function is invoked by the parser when a variable is referenced in the 131 VFR. Save the variable store (and set a flag) so that we can later determine 132 if we need to emit a varstore-select or varstore-select-pair opcode. 133 134 Arguments: 135 VarStoreId - ID of the variable store referenced in the VFR 136 137 Returns: 138 None 139 140 --*/ 141 ; 142 void 143 SetSecondaryVarStoreId ( 144 UINT16 VarStoreId 145 ) 146 /*++ 147 148 Routine Description: 149 This function is invoked by the parser when a secondary variable is 150 referenced in the VFR. Save the variable store (and set a flag) so 151 that we can later determine if we need to emit a varstore-select or 152 varstore-pair opcode. 153 154 Arguments: 155 VarStoreId - ID of the variable store referenced in the VFR 156 157 Returns: 158 None 159 160 --*/ 161 ; 162 163 /* */ 164 private: 165 int 166 FlushQueue ( 167 VOID 168 ) 169 /*++ 170 171 Routine Description: 172 This function is invoked to flush the internal IFR buffer. 173 174 Arguments: 175 None 176 177 Returns: 178 0 always 179 180 --*/ 181 ; 182 int 183 IAddByte ( 184 UINT8 ByteVal, 185 UINT8 KeyByte, 186 UINT32 LineNum 187 ) 188 /*++ 189 190 Routine Description: 191 This internal function is used to add actual IFR bytes to 192 the output stream. Most other functions queue up the bytes 193 in an internal buffer. Once they come here, there's no 194 going back. 195 196 197 Arguments: 198 ByteVal - value to write to output 199 KeyByte - key value tied to the byte -- useful for debug 200 LineNum - line number from source file the byte resulted from 201 202 Returns: 203 0 - if successful 204 1 - failed due to memory allocation failure 205 206 --*/ 207 ; 208 209 /* */ 210 private: 211 IFR_BYTE *mIfrBytes; 212 IFR_BYTE *mLastIfrByte; 213 UINT32 mQueuedByteCount; 214 UINT32 mBytesWritten; 215 UINT32 mQueuedLineNum; 216 UINT8 mQueuedBytes[MAX_QUEUE_COUNT]; 217 UINT8 mQueuedKeyBytes[MAX_QUEUE_COUNT]; 218 UINT8 mQueuedOpcodeByte; 219 UINT32 mQueuedOpcodeByteValid; 220 UINT16 mPrimaryVarStoreId; 221 UINT8 mPrimaryVarStoreIdSet; 222 UINT16 mSecondaryVarStoreId; 223 UINT8 mSecondaryVarStoreIdSet; 224 UINT16 mDefaultVarStoreId; 225 }; 226 227 #endif // #ifndef _VFR_SERVICES_H_ 228