Correct zero value for Guid variable
[efi/basetools/.git] / Source / C / VfrCompile / VfrSyntax.g
1 /*++\r
2 Copyright (c) 2004 - 2009, Intel Corporation\r
3 All rights reserved. This program and the accompanying materials\r
4 are licensed and made available under the terms and conditions of the BSD License\r
5 which accompanies this distribution.  The full text of the license may be found at\r
6 http://opensource.org/licenses/bsd-license.php\r
7 \r
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
10 \r
11 Module Name:\r
12   VfrSyntax.g\r
13 \r
14 Abstract:\r
15 \r
16 --*/\r
17 \r
18 #header<<\r
19 \r
20 #include "EfiVfr.h"\r
21 #include "VfrFormPkg.h"\r
22 #include "VfrError.h"\r
23 #include "VfrUtilityLib.h"\r
24 #include "AToken.h"\r
25 #include "ATokPtr.h"\r
26 >>\r
27 \r
28 <<\r
29 #include "stdio.h"\r
30 #include "PBlackBox.h"\r
31 #include "DLexerBase.h"\r
32 #include "VfrLexer.h"\r
33 #include "AToken.h"\r
34 \r
35 #define GET_LINENO(Obj)       ((Obj)->getLine())\r
36 #define SET_LINE_INFO(Obj, L) {(Obj).SetLineNo((L)->getLine());} while (0)\r
37 #define CRT_END_OP(Obj)       {CIfrEnd EObj; if (Obj != NULL) EObj.SetLineNo ((Obj)->getLine());} while (0)\r
38 \r
39 typedef ANTLRCommonToken ANTLRToken;\r
40 \r
41 class CVfrDLGLexer : public VfrLexer\r
42 {\r
43 public:\r
44   CVfrDLGLexer (DLGFileInput *F) : VfrLexer (F) {};\r
45   INT32 errstd (char *Text)\r
46   {\r
47     printf ("unrecognized input '%s'\n", Text);\r
48   }\r
49 };\r
50 \r
51 UINT8\r
52 VfrParserStart (\r
53   IN FILE *File,\r
54   IN BOOLEAN CompatibleMode\r
55   )\r
56 {\r
57   ParserBlackBox<CVfrDLGLexer, EfiVfrParser, ANTLRToken> VfrParser(File);\r
58   VfrParser.parser()->SetCompatibleMode (CompatibleMode);\r
59   return VfrParser.parser()->vfrProgram();\r
60 }\r
61 >>\r
62 \r
63 //\r
64 // Define a lexical class for parsing quoted strings. Basically\r
65 // starts with a double quote, and ends with a double quote that\r
66 // is not preceeded with a backslash.\r
67 //\r
68 #lexclass QUOTED_STRING\r
69 #token TheString            "~[\"]*\"" << mode (START); >>\r
70 \r
71 //\r
72 // Define a lexclass for skipping over C++ style comments\r
73 //\r
74 #lexclass CPP_COMMENT\r
75 #token "~[\n]*"       << skip (); >>\r
76 #token "\n"           << skip (); mode (START); newline (); >>\r
77 \r
78 //\r
79 // Standard lexclass is START\r
80 //\r
81 #lexclass START\r
82 \r
83 //\r
84 // Find start of C++ style comments\r
85 //\r
86 #token "//"       << skip (); mode (CPP_COMMENT); >>\r
87 \r
88 //\r
89 // Skip whitespace\r
90 //\r
91 #token "[\ \t]"   << skip (); >>\r
92 \r
93 //\r
94 // Skip over newlines, but count them\r
95 //\r
96 #token "\n"       << skip (); newline (); >>\r
97 \r
98 //\r
99 // Skip over 'extern' in any included .H file\r
100 //\r
101 #token "extern"   << skip (); mode (CPP_COMMENT); >>\r
102 \r
103 //\r
104 // Tokens for the different keywords. Syntax is:\r
105 // TokenName("ErrorMessageText")    "TokenString"\r
106 //   where:\r
107 //     TokenName is the token name (must be capitalized) that is used in the rules\r
108 //     ErrorMessageText is the string the compiler emits when it detects a syntax error\r
109 //     TokenString is the actual matching string used in the user script\r
110 //\r
111 #token FormPkgType("formpkgtype")               "formpkgtype"\r
112 #token OpenBrace("{")                           "\{"\r
113 #token CloseBrace("}")                          "\}"\r
114 #token OpenParen("(")                           "\("\r
115 #token CloseParen(")")                          "\)"\r
116 #token OpenBracket("[")                         "\["\r
117 #token CloseBracket("]")                        "\]"\r
118 \r
119 #token LineDefinition                           "#line\ [0-9]+\ \"~[\"]+\"[\ \t]*\n" << gCVfrErrorHandle.ParseFileScopeRecord (begexpr (), line ()); skip (); newline (); >>\r
120 #token DevicePath("devicepath")                 "devicepath"\r
121 #token FormSet("formset")                       "formset"\r
122 #token FormSetId("formsetid")                   "formsetid"\r
123 #token EndFormSet("endformset")                 "endformset"\r
124 #token Title("title")                           "title"\r
125 #token FormId("formid")                         "formid"\r
126 #token OneOf("oneof")                           "oneof"\r
127 #token EndOneOf("endoneof")                     "endoneof"\r
128 #token Prompt("prompt")                         "prompt"\r
129 #token OrderedList("orderedlist")               "orderedlist"\r
130 #token MaxContainers("maxcontainers")           "maxcontainers"\r
131 #token EndList("endlist")                       "endlist"\r
132 #token EndForm("endform")                       "endform"\r
133 #token Form("form")                             "form"\r
134 #token Subtitle("subtitle")                     "subtitle"\r
135 #token Help("help")                             "help"\r
136 #token Text("text")                             "text"\r
137 #token Option("option")                         "option"\r
138 #token FLAGS("flags")                           "flags"\r
139 #token Date("date")                             "date"\r
140 #token EndDate("enddate")                       "enddate"\r
141 #token Year("year")                             "year"\r
142 #token Month("month")                           "month"\r
143 #token Day("day")                               "day"\r
144 #token Time("time")                             "time"\r
145 #token EndTime("endtime")                       "endtime"\r
146 #token Hour("hour")                             "hour"\r
147 #token Minute("minute")                         "minute"\r
148 #token Second("second")                         "second"\r
149 #token GrayOutIf("grayoutif")                   "grayoutif"\r
150 #token Label("label")                           "label"\r
151 #token Timeout("timeout")                       "timeout"\r
152 #token Inventory("inventory")                   "inventory"\r
153 #token NonNvDataMap("_NON_NV_DATA_MAP")         "_NON_NV_DATA_MAP"\r
154 #token Struct("struct")                         "struct"\r
155 #token Boolean("BOOLEAN")                       "BOOLEAN"\r
156 #token Uint64("UINT64")                         "UINT64"\r
157 #token Uint32("UINT32")                         "UINT32"\r
158 #token Uint16("UINT16")                         "UINT16"\r
159 #token Char16("CHAR16")                         "CHAR16"\r
160 #token Uint8("UINT8")                           "UINT8"\r
161 #token Uuid("guid")                             "guid"\r
162 #token CheckBox("checkbox")                     "checkbox"\r
163 #token EndCheckBox("endcheckbox")               "endcheckbox"\r
164 #token Numeric("numeric")                       "numeric"\r
165 #token EndNumeric("endnumeric")                 "endnumeric"\r
166 #token Minimum("minimum")                       "minimum"\r
167 #token Maximum("maximum")                       "maximum"\r
168 #token STEP("step")                             "step"\r
169 #token Default("default")                       "default"\r
170 #token Password("password")                     "password"\r
171 #token EndPassword("endpassword")               "endpassword"\r
172 #token String("string")                         "string"\r
173 #token EndString("endstring")                   "endstring"\r
174 #token MinSize("minsize")                       "minsize"\r
175 #token MaxSize("maxsize")                       "maxsize"\r
176 #token Encoding("encoding")                     "encoding"\r
177 #token SuppressIf("suppressif")                 "suppressif"\r
178 #token DisableIf("disableif")                   "disableif"\r
179 #token Hidden("hidden")                         "hidden"\r
180 #token Goto("goto")                             "goto"\r
181 #token FormSetGuid("formsetguid")               "formsetguid"\r
182 #token InconsistentIf("inconsistentif")         "inconsistentif"\r
183 #token NoSubmitIf("nosubmitif")                 "nosubmitif"\r
184 #token EndIf("endif")                           "endif"\r
185 #token Key("key")                               "key"\r
186 #token DefaultFlag("DEFAULT")                   "DEFAULT"\r
187 #token ManufacturingFlag("MANUFACTURING")       "MANUFACTURING"\r
188 #token InteractiveFlag("INTERACTIVE")           "INTERACTIVE"\r
189 #token NVAccessFlag("NV_ACCESS")                "NV_ACCESS"\r
190 #token ResetRequiredFlag("RESET_REQUIRED")      "RESET_REQUIRED"\r
191 #token LateCheckFlag("LATE_CHECK")              "LATE_CHECK"\r
192 #token ReadOnlyFlag("READ_ONLY")                "READ_ONLY"\r
193 #token OptionOnlyFlag("OPTIONS_ONLY")           "OPTIONS_ONLY"\r
194 #token Class("class")                           "class"\r
195 #token Subclass("subclass")                     "subclass"\r
196 #token ClassGuid("classguid")                   "classguid"\r
197 #token TypeDef("typedef")                       "typedef"\r
198 #token Restore("restore")                       "restore"\r
199 #token Save("save")                             "save"\r
200 #token Defaults("defaults")                     "defaults"\r
201 #token Banner("banner")                         "banner"\r
202 #token Align("align")                           "align"\r
203 #token Left("left")                             "left"\r
204 #token Right("right")                           "right"\r
205 #token Center("center")                         "center"\r
206 #token Line("line")                             "line"\r
207 #token Name("name")                             "name"\r
208 \r
209 #token VarId("varid")                           "varid"\r
210 #token Question("question")                     "question"\r
211 #token QuestionId("questionid")                 "questionid"\r
212 #token Image("image")                           "image"\r
213 #token Locked("locked")                         "locked"\r
214 #token Rule("rule")                             "rule"\r
215 #token EndRule("endrule")                       "endrule"\r
216 #token Value("value")                           "value"\r
217 #token ResetButton("resetbutton")               "resetbutton"\r
218 #token EndResetButton("endresetbutton")         "endresetbutton"\r
219 #token DefaultStore("defaultstore")             "defaultstore"\r
220 #token Attribute("attribute")                   "attribute"\r
221 #token Varstore("varstore")                     "varstore"\r
222 #token Efivarstore("efivarstore")               "efivarstore"\r
223 #token VarSize("varsize")                       "varsize"\r
224 #token NameValueVarStore("namevaluevarstore")   "namevaluevarstore"\r
225 #token Action("action")                         "action"\r
226 #token Config("config")                         "config"\r
227 #token EndAction("endaction")                   "endaction"\r
228 #token Refresh("refresh")                       "refresh"\r
229 #token Interval("interval")                     "interval"\r
230 #token VarstoreDevice("varstoredevice")         "varstoredevice"\r
231 //\r
232 // Define the class and subclass tokens\r
233 //\r
234 #token ClassNonDevice("NONDEVICE")                        "NON_DEVICE"\r
235 #token ClassDiskDevice("DISK_DEVICE")                     "DISK_DEVICE"\r
236 #token ClassVideoDevice("VIDEO_DEVICE")                   "VIDEO_DEVICE"\r
237 #token ClassNetworkDevice("NETWORK_DEVICE")               "NETWORK_DEVICE"\r
238 #token ClassInputDevice("INPUT_DEVICE")                   "INPUT_DEVICE"\r
239 #token ClassOnBoardDevice("ONBOARD_DEVICE")               "ONBOARD_DEVICE"\r
240 #token ClassOtherDevice("OTHER_DEVICE")                   "OTHER_DEVICE"\r
241 \r
242 #token SubclassSetupApplication("SETUP_APPLICATION")      "SETUP_APPLICATION"\r
243 #token SubclassGeneralApplication("GENERAL_APPLICATION")  "GENERAL_APPLICATION"\r
244 #token SubclassFrontPage("FRONT_PAGE")                    "FRONT_PAGE"\r
245 #token SubclassSingleUse("SINGLE_USE")                    "SINGLE_USE"\r
246 \r
247 //\r
248 // This is the overall definition of a VFR form definition script.\r
249 //\r
250 \r
251 vfrProgram > [UINT8 Return] :\r
252   <<\r
253      mParserStatus = 0;\r
254      mConstantOnlyInExpression = FALSE;\r
255   >>\r
256   (\r
257       vfrPragmaPackDefinition\r
258     | vfrDataStructDefinition\r
259   )*\r
260   vfrFormSetDefinition\r
261   << $Return = mParserStatus; >>\r
262   ;\r
263 \r
264 pragmaPackShowDef :\r
265   L:"show"                                          << gCVfrVarDataTypeDB.Pack (L->getLine(), VFR_PACK_SHOW); >>\r
266   ;\r
267 \r
268 pragmaPackStackDef :\r
269   <<\r
270      UINT32 LineNum;\r
271      UINT8  PackAction;\r
272      CHAR8  *Identifier = NULL;\r
273      UINT32 PackNumber  = DEFAULT_PACK_ALIGN;\r
274   >>\r
275   (\r
276       L1:"push"                                     << LineNum = L1->getLine(); PackAction = VFR_PACK_PUSH; >>\r
277     | L2:"pop"                                      << LineNum = L2->getLine(); PackAction = VFR_PACK_POP; >>\r
278   )\r
279   {\r
280     "," ID:StringIdentifier                         << Identifier = ID->getText(); >>\r
281   }\r
282   {\r
283     "," N:Number                                    << PackAction |= VFR_PACK_ASSIGN; PackNumber = _STOU32(N->getText()); >>\r
284   }\r
285                                                     << gCVfrVarDataTypeDB.Pack (LineNum, PackAction, Identifier, PackNumber); >>\r
286   ;\r
287 \r
288 pragmaPackNumber :\r
289   <<\r
290      UINT32 LineNum;\r
291      UINT32 PackNumber = DEFAULT_PACK_ALIGN;\r
292   >>\r
293   N:Number                                          << LineNum = N->getLine(); PackNumber = _STOU32(N->getText()); >>\r
294                                                     << gCVfrVarDataTypeDB.Pack (LineNum, VFR_PACK_ASSIGN, NULL, PackNumber); >>\r
295   ;\r
296 \r
297 vfrPragmaPackDefinition :\r
298   "\#pragma" "pack" "\("\r
299   {\r
300       pragmaPackShowDef\r
301     | pragmaPackStackDef\r
302     | pragmaPackNumber\r
303   }\r
304   "\)"\r
305   ;\r
306 \r
307 vfrDataStructDefinition :\r
308   { TypeDef } Struct                                << gCVfrVarDataTypeDB.DeclareDataTypeBegin (); >>\r
309   { NonNvDataMap }\r
310   {\r
311     N1:StringIdentifier                             << _PCATCH(gCVfrVarDataTypeDB.SetNewTypeName (N1->getText()), N1); >>\r
312   }\r
313   OpenBrace\r
314     vfrDataStructFields\r
315   CloseBrace\r
316   {\r
317     N2:StringIdentifier                             << _PCATCH(gCVfrVarDataTypeDB.SetNewTypeName (N2->getText()), N2); >>\r
318   }\r
319   ";"                                               << gCVfrVarDataTypeDB.DeclareDataTypeEnd (); >>\r
320   ;\r
321 \r
322 vfrDataStructFields :\r
323   (\r
324      dataStructField64     |\r
325      dataStructField32     |\r
326      dataStructField16     |\r
327      dataStructField8      |\r
328      dataStructFieldBool   |\r
329      dataStructFieldString |\r
330      dataStructFieldDate   |\r
331      dataStructFieldTime   |\r
332      dataStructFieldUser\r
333   )*\r
334   ;\r
335 \r
336 dataStructField64 :\r
337   << UINT32 ArrayNum = 0; >>\r
338   "UINT64"\r
339   N:StringIdentifier\r
340   {\r
341     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
342   }\r
343   ";"                                               << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "UINT64", ArrayNum), N); >>\r
344   ;\r
345 \r
346 dataStructField32 :\r
347   << UINT32 ArrayNum = 0; >>\r
348   "UINT32"\r
349   N:StringIdentifier\r
350   {\r
351     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
352   }\r
353   ";"                                               << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "UINT32", ArrayNum), N); >>\r
354   ;\r
355 \r
356 dataStructField16 :\r
357   << UINT32 ArrayNum = 0; >>\r
358   ("UINT16" | "CHAR16")\r
359   N:StringIdentifier\r
360   {\r
361     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
362   }\r
363   ";"                                               << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "UINT16", ArrayNum), N); >>\r
364   ;\r
365 \r
366 dataStructField8 :\r
367   << UINT32 ArrayNum = 0; >>\r
368   "UINT8"\r
369   N:StringIdentifier\r
370   {\r
371     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
372   }\r
373   ";"                                               << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "UINT8", ArrayNum), N); >>\r
374   ;\r
375 \r
376 dataStructFieldBool :\r
377   << UINT32 ArrayNum = 0; >>\r
378   "BOOLEAN"\r
379   N:StringIdentifier\r
380   {\r
381     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
382   }\r
383   ";"                                               << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "BOOLEAN", ArrayNum), N); >>\r
384   ;\r
385 \r
386 dataStructFieldString :\r
387   << UINT32 ArrayNum = 0; >>\r
388   "EFI_STRING_ID"\r
389   N:StringIdentifier\r
390   {\r
391     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
392   }\r
393   ";"                                               << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "EFI_STRING_ID", ArrayNum), N); >>\r
394   ;\r
395 \r
396 dataStructFieldDate :\r
397   << UINT32 ArrayNum = 0; >>\r
398   "EFI_HII_DATE"\r
399   N:StringIdentifier\r
400   {\r
401     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
402   }\r
403   ";"                                               << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "EFI_HII_DATE", ArrayNum), N); >>\r
404   ;\r
405 \r
406 dataStructFieldTime :\r
407   << UINT32 ArrayNum = 0; >>\r
408   "EFI_HII_TIME"\r
409   N:StringIdentifier\r
410   {\r
411     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
412   }\r
413   ";"                                               << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "EFI_HII_TIME", ArrayNum), N); >>\r
414   ;\r
415 \r
416 dataStructFieldUser :\r
417   << UINT32 ArrayNum = 0; >>\r
418   T:StringIdentifier\r
419   N:StringIdentifier\r
420   {\r
421     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
422   }\r
423   ";"                                               << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), T->getText(), ArrayNum), T); >>\r
424   ;\r
425 \r
426 //*****************************************************************************\r
427 //\r
428 // the syntax of GUID definition\r
429 //\r
430 guidSubDefinition [EFI_GUID &Guid] :\r
431   G4:Number "," G5:Number "," G6:Number "," G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number\r
432                                                     <<\r
433                                                        Guid.Data4[0] = _STOU8(G4->getText());\r
434                                                        Guid.Data4[1] = _STOU8(G5->getText());\r
435                                                        Guid.Data4[2] = _STOU8(G6->getText());\r
436                                                        Guid.Data4[3] = _STOU8(G7->getText());\r
437                                                        Guid.Data4[4] = _STOU8(G8->getText());\r
438                                                        Guid.Data4[5] = _STOU8(G9->getText());\r
439                                                        Guid.Data4[6] = _STOU8(G10->getText());\r
440                                                        Guid.Data4[7] = _STOU8(G11->getText());\r
441                                                     >>\r
442   ;\r
443 \r
444 guidDefinition [EFI_GUID &Guid] :\r
445   OpenBrace\r
446     G1:Number "," G2:Number "," G3:Number ","\r
447                                                     <<\r
448                                                        Guid.Data1 = _STOU32 (G1->getText());\r
449                                                        Guid.Data2 = _STOU16 (G2->getText());\r
450                                                        Guid.Data3 = _STOU16 (G3->getText());\r
451                                                     >>\r
452     (\r
453         OpenBrace guidSubDefinition[Guid] CloseBrace\r
454       | guidSubDefinition[Guid]\r
455     )\r
456   CloseBrace\r
457   ;\r
458 \r
459 //*****************************************************************************\r
460 //\r
461 // the syntax of form set definition\r
462 //\r
463 vfrFormSetDefinition :\r
464   <<\r
465      EFI_GUID    Guid;\r
466      EFI_GUID    DefaultClassGuid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID;\r
467      EFI_GUID    ClassGuid1, ClassGuid2, ClassGuid3;\r
468      UINT8       ClassGuidNum = 0;\r
469      CIfrFormSet *FSObj = NULL;\r
470      UINT16      C, SC;\r
471   >>\r
472   L:FormSet\r
473   Uuid "=" guidDefinition[Guid] ","\r
474   Title "=" "STRING_TOKEN" "\(" S1:Number "\)" ","\r
475   Help  "=" "STRING_TOKEN" "\(" S2:Number "\)" ","\r
476   {\r
477     ClassGuid "=" guidDefinition[ClassGuid1]        << ++ClassGuidNum; >>\r
478                   {\r
479                    "\|" guidDefinition[ClassGuid2]  << ++ClassGuidNum; >>\r
480                   }\r
481                   {\r
482                    "\|" guidDefinition[ClassGuid3]  << ++ClassGuidNum; >>\r
483                   }\r
484                   ","\r
485   }\r
486                                                     <<\r
487                                                       switch (ClassGuidNum) {\r
488                                                       case 0:\r
489                                                         FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET));\r
490                                                         FSObj->SetClassGuid(&DefaultClassGuid);\r
491                                                         break;\r
492                                                       case 1:\r
493                                                         FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET));\r
494                                                         FSObj->SetClassGuid(&ClassGuid1);\r
495                                                         break;\r
496                                                       case 2:\r
497                                                         FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + sizeof(EFI_GUID));\r
498                                                         FSObj->SetClassGuid(&ClassGuid1);\r
499                                                         FSObj->SetClassGuid(&ClassGuid2);\r
500                                                         break;\r
501                                                       default:\r
502                                                         FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + 2 * sizeof(EFI_GUID));\r
503                                                         FSObj->SetClassGuid(&ClassGuid1);\r
504                                                         FSObj->SetClassGuid(&ClassGuid2);\r
505                                                         FSObj->SetClassGuid(&ClassGuid3);\r
506                                                         break;\r
507                                                       }\r
508 \r
509                                                       SET_LINE_INFO (*FSObj, L);\r
510                                                       FSObj->SetGuid (&Guid);\r
511                                                       //\r
512                                                       // for framework vfr to store formset guid used by varstore and efivarstore\r
513                                                       //\r
514                                                       if (mCompatibleMode) {\r
515                                                         memcpy (&mFormsetGuid, &Guid, sizeof (EFI_GUID));\r
516                                                       }\r
517                                                       FSObj->SetFormSetTitle (_STOSID(S1->getText()));\r
518                                                       FSObj->SetHelp (_STOSID(S2->getText()));\r
519                                                     >>\r
520   {\r
521     FC:Class "=" classDefinition[C] ","             << {CIfrClass CObj;SET_LINE_INFO (CObj, FC); CObj.SetClass(C);} >>\r
522   }\r
523   {\r
524     FSC:Subclass "=" subclassDefinition[SC] ","     << {CIfrSubClass SCObj; SET_LINE_INFO (SCObj, FSC); SCObj.SetSubClass(SC);} >>\r
525   }\r
526                                                     <<\r
527                                                        _DeclareStandardDefaultStorage (GET_LINENO (L));\r
528                                                     >>\r
529   vfrFormSetList\r
530   E:EndFormSet                                      <<\r
531                                                       if (mCompatibleMode) {\r
532                                                         //\r
533                                                         // declare all undefined varstore and efivarstore\r
534                                                         //\r
535                                                         _DeclareDefaultFrameworkVarStore (GET_LINENO(E));\r
536                                                       }\r
537                                                       CRT_END_OP (E); if (FSObj != NULL) delete FSObj;\r
538                                                     >>\r
539   ";"\r
540   ;\r
541 \r
542 vfrFormSetList :\r
543   (\r
544     vfrFormDefinition             |\r
545     vfrStatementImage             |\r
546     vfrStatementVarStoreLinear    |\r
547     vfrStatementVarStoreEfi       |\r
548     vfrStatementVarStoreNameValue |\r
549     vfrStatementDefaultStore      |\r
550     vfrStatementDisableIfFormSet  |\r
551     vfrStatementSuppressIfFormSet\r
552   )*\r
553   ;\r
554 \r
555 vfrStatementDefaultStore :\r
556   << UINT16  DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD; >>\r
557   D:DefaultStore N:StringIdentifier ","\r
558   Prompt "=" "STRING_TOKEN" "\(" S:Number "\)"\r
559   {\r
560     "," Attribute "=" A:Number                      << DefaultId = _STOU16(A->getText()); >>\r
561   }\r
562                                                     <<\r
563                                                        if (mCVfrDefaultStore.DefaultIdRegistered (DefaultId) == FALSE) {\r
564                                                          CIfrDefaultStore DSObj;\r
565                                                          _PCATCH(mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), N->getText(), _STOSID(S->getText()), DefaultId)), D->getLine();\r
566                                                          DSObj.SetLineNo(D->getLine());\r
567                                                          DSObj.SetDefaultName (_STOSID(S->getText()));\r
568                                                          DSObj.SetDefaultId (DefaultId);\r
569                                                        } else {\r
570                                                          _PCATCH(mCVfrDefaultStore.ReRegisterDefaultStoreById (DefaultId, N->getText(), _STOSID(S->getText()))), D->getLine();\r
571                                                        }\r
572                                                     >>\r
573   ";"\r
574   ;\r
575 \r
576 vfrStatementVarStoreLinear :\r
577   <<\r
578      EFI_GUID        Guid;\r
579      CIfrVarStore    VSObj;\r
580      CHAR8           *TypeName;\r
581      CHAR8           *StoreName;\r
582      UINT32          LineNum;\r
583      EFI_VARSTORE_ID VarStoreId = EFI_VARSTORE_ID_INVALID;\r
584      UINT32          Size;\r
585   >>\r
586   V:Varstore                                        << VSObj.SetLineNo(V->getLine()); >>\r
587   (\r
588       TN:StringIdentifier ","                       << TypeName = TN->getText(); LineNum = TN->getLine(); >>\r
589     | U8:"UINT8" ","                                << TypeName = "UINT8"; LineNum = U8->getLine(); >>\r
590     | U16:"UINT16" ","                              << TypeName = "UINT16"; LineNum = U16->getLine(); >>\r
591     | U32:"UINT32" ","                              << TypeName = "UINT32"; LineNum = U32->getLine(); >>\r
592     | U64:"UINT64" ","                              << TypeName = "UINT64"; LineNum = U64->getLine(); >>\r
593     | D:"EFI_HII_DATE" ","                          << TypeName = "EFI_HII_DATE"; LineNum = D->getLine(); >>\r
594     | T:"EFI_HII_TIME" ","                          << TypeName = "EFI_HII_TIME"; LineNum = T->getLine(); >>\r
595   )\r
596   { Key "=" FID:Number ","                          << // Key is used to assign Varid in Framework VFR but no use in UEFI2.1 VFR\r
597                                                        if (mCompatibleMode) {\r
598                                                          VarStoreId = _STOU16(FID->getText());\r
599                                                        }\r
600                                                     >>\r
601   }\r
602   {\r
603     VarId "=" ID:Number ","                         <<\r
604                                                        _PCATCH(\r
605                                                          (INTN)(VarStoreId = _STOU16(ID->getText())) != 0,\r
606                                                          (INTN)TRUE,\r
607                                                          ID,\r
608                                                          "varid 0 is not allowed."\r
609                                                          );\r
610                                                     >>\r
611   }\r
612   Name "=" SN:StringIdentifier ","\r
613   Uuid "=" guidDefinition[Guid]\r
614                                                     <<\r
615                                                        if (mCompatibleMode) {\r
616                                                          StoreName = TypeName;\r
617                                                        } else {\r
618                                                          StoreName = SN->getText();\r
619                                                        }\r
620                                                        _PCATCH(mCVfrDataStorage.DeclareBufferVarStore (\r
621                                                                                   StoreName,\r
622                                                                                   &Guid,\r
623                                                                                   &gCVfrVarDataTypeDB,\r
624                                                                                   TypeName,\r
625                                                                                   VarStoreId\r
626                                                                                   ), LineNum);\r
627                                                        VSObj.SetGuid (&Guid);\r
628                                                        _PCATCH(mCVfrDataStorage.GetVarStoreId(StoreName, &VarStoreId), SN);\r
629                                                        VSObj.SetVarStoreId (VarStoreId);\r
630                                                        _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);\r
631                                                        VSObj.SetSize ((UINT16) Size);\r
632                                                        VSObj.SetName (SN->getText());\r
633                                                     >>\r
634   ";"\r
635   ;\r
636 \r
637 vfrStatementVarStoreEfi :\r
638   <<\r
639      EFI_GUID        Guid;\r
640      CIfrVarStoreEfi VSEObj;\r
641      EFI_VARSTORE_ID VarStoreId;\r
642      UINT32          Attr = 0;\r
643   >>\r
644   E:Efivarstore                                     << VSEObj.SetLineNo(E->getLine()); >>\r
645   SN:StringIdentifier ","\r
646   Attribute "=" vfrVarStoreEfiAttr[Attr] ( "\|" vfrVarStoreEfiAttr[Attr] )* ","\r
647                                                     << VSEObj.SetAttributes (Attr); >>\r
648   Name "=" "STRING_TOKEN" "\(" VN:Number "\)" ","\r
649   VarSize "=" N:Number ","\r
650   Uuid "=" guidDefinition[Guid]                     << mCVfrDataStorage.DeclareEfiVarStore (SN->getText(), &Guid, _STOSID(VN->getText()), _STOU32(N->getText())); >>\r
651                                                     <<\r
652                                                        VSEObj.SetGuid (&Guid);\r
653                                                        _PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);\r
654                                                        VSEObj.SetVarStoreId (VarStoreId);\r
655                                                     >>\r
656   ";"\r
657   ;\r
658 \r
659 vfrVarStoreEfiAttr [UINT32 & Attr] :\r
660   N:Number                                          << $Attr |= _STOU32(N->getText()); >>\r
661   ;\r
662 \r
663 vfrStatementVarStoreNameValue :\r
664   <<\r
665      EFI_GUID              Guid;\r
666      CIfrVarStoreNameValue VSNVObj;\r
667      EFI_VARSTORE_ID       VarStoreId;\r
668   >>\r
669   L:NameValueVarStore                               << VSNVObj.SetLineNo(L->getLine()); >>\r
670   SN:StringIdentifier ","                           << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreBegin (SN->getText()), SN); >>\r
671   (\r
672     Name "=" "STRING_TOKEN" "\(" N:Number "\)" ","  << _PCATCH(mCVfrDataStorage.NameTableAddItem (_STOSID(N->getText())), SN); >>\r
673   )+\r
674   Uuid "=" guidDefinition[Guid]                     << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreEnd (&Guid), SN); >>\r
675                                                     <<\r
676                                                        VSNVObj.SetGuid (&Guid);\r
677                                                        _PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);\r
678                                                        VSNVObj.SetVarStoreId (VarStoreId);\r
679                                                     >>\r
680   ";"\r
681   ;\r
682 \r
683 //\r
684 // keep classDeinition and validClassNames for compatibility but not generate\r
685 // any IFR object\r
686 //\r
687 classDefinition[UINT16 & Class] :\r
688   << $Class = 0; >>\r
689   validClassNames[$Class] ( "\|" validClassNames[$Class] )*\r
690   ;\r
691 \r
692 validClassNames[UINT16 & Class] :\r
693     ClassNonDevice                                  << $Class |= EFI_NON_DEVICE_CLASS; >>\r
694   | ClassDiskDevice                                 << $Class |= EFI_DISK_DEVICE_CLASS; >>\r
695   | ClassVideoDevice                                << $Class |= EFI_VIDEO_DEVICE_CLASS; >>\r
696   | ClassNetworkDevice                              << $Class |= EFI_NETWORK_DEVICE_CLASS; >>\r
697   | ClassInputDevice                                << $Class |= EFI_INPUT_DEVICE_CLASS; >>\r
698   | ClassOnBoardDevice                              << $Class |= EFI_ON_BOARD_DEVICE_CLASS; >>\r
699   | ClassOtherDevice                                << $Class |= EFI_OTHER_DEVICE_CLASS; >>\r
700   | N:Number                                        << $Class |= _STOU16(N->getText()); >>\r
701   ;\r
702 \r
703 subclassDefinition[UINT16 & SubClass] :\r
704   << $SubClass = 0; >>\r
705     SubclassSetupApplication                        << $SubClass |= EFI_SETUP_APPLICATION_SUBCLASS; >>\r
706   | SubclassGeneralApplication                      << $SubClass |= EFI_GENERAL_APPLICATION_SUBCLASS; >>\r
707   | SubclassFrontPage                               << $SubClass |= EFI_FRONT_PAGE_SUBCLASS; >>\r
708   | SubclassSingleUse                               << $SubClass |= EFI_SINGLE_USE_SUBCLASS; >>\r
709   | N:Number                                        << $SubClass |= _STOU16(N->getText()); >>\r
710   ;\r
711 \r
712 vfrStatementDisableIfFormSet :\r
713   <<\r
714     CIfrDisableIf DIObj;\r
715     mConstantOnlyInExpression = TRUE;\r
716   >>\r
717   D:DisableIf                                       << DIObj.SetLineNo(D->getLine()); >>\r
718   vfrStatementExpression[0] ";"                     << mConstantOnlyInExpression = FALSE; >>\r
719   vfrFormSetList\r
720   E:EndIf                                           << CRT_END_OP (E); >>\r
721   ";"\r
722   ;\r
723 \r
724 vfrStatementSuppressIfFormSet :\r
725   << CIfrSuppressIf SIObj;>>\r
726   L:SuppressIf                                         <<\r
727                                                            if (mCompatibleMode) {\r
728                                                              _PCATCH (VFR_RETURN_UNSUPPORTED, L);\r
729                                                            }\r
730                                                            SIObj.SetLineNo(L->getLine()); \r
731                                                        >>\r
732   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
733   vfrStatementExpression[0] ";"\r
734   vfrFormSetList\r
735   E: EndIf \r
736   ";"                                                  << CRT_END_OP (E); >>\r
737   ;\r
738 \r
739 //*****************************************************************************\r
740 //\r
741 // the syntax of question header and statement header\r
742 //\r
743 vfrStatementHeader[CIfrStatementHeader *SHObj] :\r
744   Prompt "=" "STRING_TOKEN" "\(" S1:Number "\)" "," << $SHObj->SetPrompt (_STOSID(S1->getText())); >>\r
745   Help   "=" "STRING_TOKEN" "\(" S2:Number "\)"     << $SHObj->SetHelp (_STOSID(S2->getText())); >>\r
746   ;\r
747 \r
748 vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_NORMAL]:\r
749   <<\r
750      EFI_VARSTORE_INFO Info;\r
751      EFI_QUESTION_ID   QId       = EFI_QUESTION_ID_INVALID;\r
752      CHAR8             *QName    = NULL;\r
753      CHAR8             *VarIdStr = NULL;\r
754   >>\r
755   {\r
756     Name "=" QN:StringIdentifier ","                <<\r
757                                                        QName = QN->getText();\r
758                                                        _PCATCH(mCVfrQuestionDB.FindQuestion (QName), VFR_RETURN_UNDEFINED, QN, "has already been used please used anther name");\r
759                                                     >>\r
760   }\r
761   { V:VarId "=" vfrStorageVarId[Info, VarIdStr] "," }\r
762   {\r
763     QuestionId "=" ID:Number ","                    <<\r
764                                                        QId = _STOQID(ID->getText());\r
765                                                        _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used please assign another number");\r
766                                                     >>\r
767   }\r
768                                                     <<\r
769                                                        switch (QType) {\r
770                                                        case QUESTION_NORMAL:\r
771                                                          mCVfrQuestionDB.RegisterQuestion (QName, VarIdStr, QId);\r
772                                                          break;\r
773                                                        case QUESTION_DATE:\r
774                                                        mCVfrQuestionDB.RegisterNewDateQuestion (QName, VarIdStr, QId);\r
775                                                        break;\r
776                                                        case QUESTION_TIME:\r
777                                                        mCVfrQuestionDB.RegisterNewTimeQuestion (QName, VarIdStr, QId);\r
778                                                        break;\r
779                                                        default:\r
780                                                        _PCATCH(VFR_RETURN_FATAL_ERROR);\r
781                                                        }\r
782                                                        $QHObj.SetQuestionId (QId);\r
783                                                        $QHObj.SetVarStoreInfo (&Info);\r
784                                                     >>\r
785   vfrStatementHeader[&$QHObj]\r
786                                                     << _SAVE_CURRQEST_VARINFO (Info); >>\r
787                                                     << if (VarIdStr != NULL) delete VarIdStr; >>\r
788   ;\r
789 \r
790 vfrQuestionHeaderWithNoStorage[CIfrQuestionHeader *QHObj] :\r
791   <<\r
792      EFI_QUESTION_ID   QId = EFI_QUESTION_ID_INVALID;\r
793      CHAR8             *QName = NULL;\r
794   >>\r
795   {\r
796     Name "=" QN:StringIdentifier ","                <<\r
797                                                        QName = QN->getText();\r
798                                                        _PCATCH(mCVfrQuestionDB.FindQuestion (QName), VFR_RETURN_UNDEFINED, QN, "has already been used please used anther name");\r
799                                                     >>\r
800   }\r
801   {\r
802     QuestionId "=" ID:Number ","                    <<\r
803                                                        QId = _STOQID(ID->getText());\r
804                                                        _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "redefined quesiont ID");\r
805                                                     >>\r
806   }\r
807                                                     <<\r
808                                                        mCVfrQuestionDB.RegisterQuestion (QName, NULL, QId);\r
809                                                        $QHObj->SetQuestionId (QId);\r
810                                                     >>\r
811   vfrStatementHeader[$QHObj]\r
812   ;\r
813 \r
814 questionheaderFlagsField[UINT8 & Flags] :\r
815     ReadOnlyFlag                                    << $Flags |= 0x01; >>\r
816   | InteractiveFlag                                 << $Flags |= 0x04; >>\r
817   | ResetRequiredFlag                               << $Flags |= 0x10; >>\r
818   | OptionOnlyFlag                                  << $Flags |= 0x80; >>\r
819   | NVAccessFlag\r
820   | LateCheckFlag\r
821   ;\r
822 \r
823 vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr] :\r
824   <<\r
825      UINT32                Idx;\r
826      UINT32                LineNo;\r
827      EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;\r
828      CHAR8                 *VarIdStr    = NULL;\r
829      CHAR8                 *VarStr      = NULL;\r
830      CHAR8                 *SName       = NULL;\r
831      CHAR8                 *TName       = NULL;\r
832      EFI_VFR_RETURN_CODE   VfrReturnCode = VFR_RETURN_SUCCESS;\r
833      EFI_IFR_TYPE_VALUE    Dummy        = gZeroEfiIfrTypeValue;\r
834   >>\r
835   (\r
836     SN1:StringIdentifier                            << SName = SN1->getText(); _STRCAT(&VarIdStr, SN1->getText()); >>\r
837     OpenBracket I1:Number CloseBracket              <<\r
838                                                        Idx = _STOU32(I1->getText());\r
839                                                        _STRCAT(&VarIdStr, "[");\r
840                                                        _STRCAT(&VarIdStr, I1->getText());\r
841                                                        _STRCAT(&VarIdStr, "]");\r
842                                                     >>\r
843                                                     <<\r
844                                                        VfrReturnCode = mCVfrDataStorage.GetVarStoreType (SName, VarStoreType);\r
845                                                        if (mCompatibleMode && VfrReturnCode == VFR_RETURN_UNDEFINED) {\r
846                                                           mCVfrDataStorage.DeclareBufferVarStore (\r
847                                                                              SName,\r
848                                                                              &mFormsetGuid,\r
849                                                                              &gCVfrVarDataTypeDB,\r
850                                                                              SName,\r
851                                                                              EFI_VARSTORE_ID_INVALID,\r
852                                                                              FALSE\r
853                                                                              );\r
854                                                           VfrReturnCode = mCVfrDataStorage.GetVarStoreType (SName, VarStoreType);\r
855                                                        }\r
856                                                        _PCATCH(VfrReturnCode, SN1);\r
857                                                        _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN1);\r
858                                                        _PCATCH(mCVfrDataStorage.GetNameVarStoreInfo (&$Info, Idx), SN1);\r
859                                                     >>\r
860   )\r
861   |\r
862   (\r
863     SN2:StringIdentifier                            << SName = SN2->getText(); _STRCAT(&VarIdStr, SName); >>\r
864                                                     <<\r
865                                                        VfrReturnCode = mCVfrDataStorage.GetVarStoreType (SName, VarStoreType);\r
866                                                        if (mCompatibleMode && VfrReturnCode == VFR_RETURN_UNDEFINED) {\r
867                                                           mCVfrDataStorage.DeclareBufferVarStore (\r
868                                                                              SName,\r
869                                                                              &mFormsetGuid,\r
870                                                                              &gCVfrVarDataTypeDB,\r
871                                                                              SName,\r
872                                                                              EFI_VARSTORE_ID_INVALID,\r
873                                                                              FALSE\r
874                                                                              );\r
875                                                           VfrReturnCode = mCVfrDataStorage.GetVarStoreType (SName, VarStoreType);\r
876                                                        }\r
877                                                        _PCATCH(VfrReturnCode, SN2);\r
878                                                        _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN2);\r
879                                                        if (VarStoreType == EFI_VFR_VARSTORE_BUFFER) {\r
880                                                          _PCATCH(mCVfrDataStorage.GetBufferVarStoreDataTypeName(SName, &TName), SN2);\r
881                                                          _STRCAT(&VarStr, TName);\r
882                                                        }\r
883                                                     >>\r
884 \r
885     (\r
886       "."                                           <<\r
887                                                        _PCATCH(((VarStoreType != EFI_VFR_VARSTORE_BUFFER) ? VFR_RETURN_EFIVARSTORE_USE_ERROR : VFR_RETURN_SUCCESS), SN2);\r
888                                                        _STRCAT(&VarIdStr, "."); _STRCAT(&VarStr, ".");\r
889                                                     >>\r
890       SF:StringIdentifier                           << _STRCAT(&VarIdStr, SF->getText()); _STRCAT(&VarStr, SF->getText()); >>\r
891       {\r
892         OpenBracket I2:Number CloseBracket          <<\r
893                                                        Idx = _STOU32(I2->getText());\r
894                                                        if (mCompatibleMode) Idx --;\r
895                                                        if (Idx > 0) {\r
896                                                          //\r
897                                                          // Idx == 0, [0] can be ignored.\r
898                                                          // Array[0] is same to Array for unify the varid name to cover [0]\r
899                                                          //\r
900                                                          _STRCAT(&VarIdStr, "[");\r
901                                                          _STRCAT(&VarIdStr, I2->getText());\r
902                                                          _STRCAT(&VarIdStr, "]");\r
903                                                        }\r
904                                                        _STRCAT(&VarStr, "[");\r
905                                                        _STRCAT(&VarStr, I2->getText());\r
906                                                        _STRCAT(&VarStr, "]");\r
907                                                     >>\r
908       }\r
909     )*                                              <<\r
910                                                        switch (VarStoreType) {\r
911                                                        case EFI_VFR_VARSTORE_EFI:\r
912                                                          _PCATCH(mCVfrDataStorage.GetEfiVarStoreInfo (&$Info), SN2);\r
913                                                          break;\r
914                                                        case EFI_VFR_VARSTORE_BUFFER:\r
915                                                          _PCATCH(gCVfrVarDataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType, $Info.mVarTotalSize), SN2->getLine(), VarStr);\r
916                                                          _PCATCH((EFI_VFR_RETURN_CODE)gCVfrBufferConfig.Register (\r
917                                                                     SName,\r
918                                                                     NULL),\r
919                                                                  SN2->getLine());\r
920                                                          _PCATCH((EFI_VFR_RETURN_CODE)gCVfrBufferConfig.Write (\r
921                                                                     'a',\r
922                                                                     SName,\r
923                                                                     NULL,\r
924                                                                     $Info.mVarType,\r
925                                                                     $Info.mInfo.mVarOffset,\r
926                                                                     $Info.mVarTotalSize,\r
927                                                                     Dummy),\r
928                                                                  SN2->getLine());\r
929                                                          break;\r
930                                                        case EFI_VFR_VARSTORE_NAME:\r
931                                                        default: break;\r
932                                                        }\r
933 \r
934                                                        QuestVarIdStr = VarIdStr;\r
935                                                        if (VarStr != NULL) {delete VarStr;}\r
936                                                     >>\r
937   )\r
938   ;\r
939 \r
940 vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, CHAR8 *&VarIdStr, UINT32 &LineNo] :\r
941                                                     <<\r
942                                                       UINT32  Idx;\r
943                                                       VarIdStr = NULL; LineNo = 0;\r
944                                                     >>\r
945   (\r
946     SN1:StringIdentifier                            << _STRCAT(&VarIdStr, SN1->getText()); LineNo = SN1->getLine(); >>\r
947     OpenBracket I1:Number CloseBracket              <<\r
948                                                        _STRCAT(&VarIdStr, "[");\r
949                                                        _STRCAT(&VarIdStr, I1->getText());\r
950                                                        _STRCAT(&VarIdStr, "]");\r
951                                                        mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask);\r
952                                                        if (mConstantOnlyInExpression) {\r
953                                                          _PCATCH(VFR_RETURN_CONSTANT_ONLY, LineNo);\r
954                                                        }\r
955                                                     >>\r
956   )\r
957   |\r
958   (\r
959     SN2:StringIdentifier                            << _STRCAT (&VarIdStr, SN2->getText()); LineNo = SN2->getLine(); >>\r
960     (\r
961       "."                                           << \r
962                                                        _STRCAT (&VarIdStr, ".");\r
963                                                        if (mConstantOnlyInExpression) {\r
964                                                          _PCATCH(VFR_RETURN_CONSTANT_ONLY, LineNo);\r
965                                                        }\r
966                                                     >>\r
967       SF:StringIdentifier                           << _STRCAT (&VarIdStr, SF->getText()); >>\r
968       {\r
969         OpenBracket I2:Number CloseBracket          <<\r
970                                                        Idx = _STOU32(I2->getText());\r
971                                                        if (mCompatibleMode) Idx --;\r
972                                                        if (Idx > 0) {\r
973                                                          //\r
974                                                          // Idx == 0, [0] can be ignored.\r
975                                                          // Array[0] is same to Array\r
976                                                          //\r
977                                                          _STRCAT(&VarIdStr, "[");\r
978                                                          _STRCAT(&VarIdStr, I2->getText());\r
979                                                          _STRCAT(&VarIdStr, "]");\r
980                                                        }\r
981                                                     >>\r
982       }\r
983     )*\r
984                                                     << mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask); >>\r
985   )\r
986   ;\r
987 \r
988 vfrConstantValueField[UINT8 Type] > [EFI_IFR_TYPE_VALUE Value] :\r
989     N1:Number                                       <<\r
990                                                        switch ($Type) {\r
991                                                        case EFI_IFR_TYPE_NUM_SIZE_8 :\r
992                                                          $Value.u8     = _STOU8(N1->getText());\r
993                                                        break;\r
994                                                        case EFI_IFR_TYPE_NUM_SIZE_16 :\r
995                                                          $Value.u16    = _STOU16(N1->getText());\r
996                                                        break;\r
997                                                        case EFI_IFR_TYPE_NUM_SIZE_32 :\r
998                                                          $Value.u32    = _STOU32(N1->getText());\r
999                                                        break;\r
1000                                                        case EFI_IFR_TYPE_NUM_SIZE_64 :\r
1001                                                          $Value.u64    = _STOU64(N1->getText());\r
1002                                                        break;\r
1003                                                        case EFI_IFR_TYPE_BOOLEAN :\r
1004                                                          $Value.b      = _STOU8(N1->getText());\r
1005                                                        break;\r
1006                                                        case EFI_IFR_TYPE_STRING :\r
1007                                                          $Value.string = _STOU16(N1->getText());\r
1008                                                        break;\r
1009                                                        case EFI_IFR_TYPE_TIME :\r
1010                                                        case EFI_IFR_TYPE_DATE :\r
1011                                                        default :\r
1012                                                        break;\r
1013                                                        }\r
1014                                                     >>\r
1015   | B1:True                                         << $Value.b      = TRUE; >>\r
1016   | B2:False                                        << $Value.b      = FALSE; >>\r
1017   | O1:One                                          << $Value.u8     = _STOU8(O1->getText()); >>\r
1018   | O2:Ones                                         << $Value.u64    = _STOU64(O2->getText()); >>\r
1019   | Z:Zero                                          << $Value.u8     = _STOU8(Z->getText()); >>\r
1020   | HOUR:Number ":" MINUTE:Number ":" SECOND:Number << $Value.time   = _STOT(HOUR->getText(), MINUTE->getText(), SECOND->getText()); >>\r
1021   | YEAR:Number "/" MONTH:Number "/" DAY:Number     << $Value.date   = _STOD(YEAR->getText(), MONTH->getText(), DAY->getText()); >>\r
1022   | "STRING_TOKEN" "\(" S1:Number "\)"              << $Value.string = _STOSID(S1->getText()); >>\r
1023   ;\r
1024 \r
1025 //*****************************************************************************\r
1026 //\r
1027 // the syntax of form definition\r
1028 //\r
1029 vfrFormDefinition :\r
1030   << CIfrForm FObj; >>\r
1031   F:Form                                            << FObj.SetLineNo(F->getLine()); >>\r
1032   FormId "=" S1:Number ","                          << _PCATCH(FObj.SetFormId (_STOFID(S1->getText())), S1); >>\r
1033   Title "=" "STRING_TOKEN" "\(" S2:Number "\)" ";"  << FObj.SetFormTitle (_STOSID(S2->getText())); >>\r
1034   (\r
1035     vfrStatementImage                        |\r
1036     vfrStatementLocked                       |\r
1037     vfrStatementRules                        |\r
1038     vfrStatementDefault                      |\r
1039     vfrStatementStat                         |\r
1040     vfrStatementQuestions                    |\r
1041     vfrStatementConditional                  |\r
1042     vfrStatementLabel                        |\r
1043     vfrStatementBanner                       |\r
1044     // Just for framework vfr compatibility\r
1045     vfrStatementInvalid\r
1046   )*\r
1047   E:EndForm                                         <<\r
1048                                                       if (mCompatibleMode) {\r
1049                                                         //\r
1050                                                         // Add Label for Framework Vfr\r
1051                                                         //\r
1052                                                         CIfrLabel LObj1;\r
1053                                                         LObj1.SetLineNo(E->getLine());\r
1054                                                         LObj1.SetNumber (0xffff);  //add end label for UEFI, label number hardcode 0xffff\r
1055                                                         CIfrLabel LObj2;\r
1056                                                         LObj2.SetLineNo(E->getLine());\r
1057                                                         LObj2.SetNumber (0x0);     //add dummy label for UEFI, label number hardcode 0x0\r
1058                                                         CIfrLabel LObj3;\r
1059                                                         LObj3.SetLineNo(E->getLine());\r
1060                                                         LObj3.SetNumber (0xffff);  //add end label for UEFI, label number hardcode 0xffff\r
1061                                                         //\r
1062                                                         // Declare undefined Question\r
1063                                                         //\r
1064                                                         if (gCFormPkg.HavePendingUnassigned()) {\r
1065                                                           gCFormPkg.DeclarePendingQuestion (\r
1066                                                                       gCVfrVarDataTypeDB,\r
1067                                                                       mCVfrDataStorage,\r
1068                                                                       mCVfrQuestionDB,\r
1069                                                                       &mFormsetGuid,\r
1070                                                                       E->getLine()\r
1071                                                                     );\r
1072                                                         }\r
1073                                                       }\r
1074                                                       //\r
1075                                                       // mCVfrQuestionDB.PrintAllQuestion();\r
1076                                                       //\r
1077                                                       CRT_END_OP (E);\r
1078                                                     >>\r
1079   ";"\r
1080   ;\r
1081 \r
1082 vfrStatementRules :\r
1083   << CIfrRule RObj; >>\r
1084   R:Rule                                            << RObj.SetLineNo(R->getLine()); >>\r
1085   S1:StringIdentifier ","                           <<\r
1086                                                        mCVfrRulesDB.RegisterRule (S1->getText());\r
1087                                                        RObj.SetRuleId (mCVfrRulesDB.GetRuleId(S1->getText()));\r
1088                                                     >>\r
1089   vfrStatementExpression[0]\r
1090   E:EndRule                                         << CRT_END_OP (E); >>\r
1091   ";"\r
1092   ;\r
1093 \r
1094 vfrStatementDefault :\r
1095   <<\r
1096      BOOLEAN               IsExp         = FALSE;\r
1097      EFI_IFR_TYPE_VALUE    Val           = gZeroEfiIfrTypeValue;\r
1098      CIfrDefault           DObj;\r
1099      EFI_DEFAULT_ID        DefaultId     = EFI_HII_DEFAULT_CLASS_STANDARD;\r
1100      CHAR8                 *VarStoreName = NULL;\r
1101      EFI_VFR_VARSTORE_TYPE VarStoreType  = EFI_VFR_VARSTORE_INVALID;\r
1102   >>\r
1103   D:Default                                         << DObj.SetLineNo(D->getLine()); >>\r
1104   (\r
1105     (\r
1106         vfrStatementValue ","                       << IsExp = TRUE; DObj.SetScope (1); CIfrEnd EndObj1; EndObj1.SetLineNo(D->getLine()); >>\r
1107       | "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] > [Val] ","  << \r
1108                                                         if (gCurrentMinMaxData != NULL && gCurrentMinMaxData->IsNumericOpcode()) {\r
1109                                                           //check default value is valid for Numeric Opcode\r
1110                                                           if (Val.u64 < gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE()) || Val.u64 > gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE())) {\r
1111                                                             _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue.");\r
1112                                                           }\r
1113                                                         }\r
1114                                                         DObj.SetType (_GET_CURRQEST_DATATYPE()); \r
1115                                                         DObj.SetValue(Val);\r
1116                                                     >>\r
1117     )\r
1118     {\r
1119       DefaultStore "=" SN:StringIdentifier ","      << _PCATCH(mCVfrDefaultStore.GetDefaultId (SN->getText(), &DefaultId), SN); DObj.SetDefaultId (DefaultId); >>\r
1120     }\r
1121                                                     <<\r
1122                                                        _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), D->getLine());\r
1123                                                        _PCATCH(mCVfrDataStorage.GetVarStoreType (VarStoreName, VarStoreType), D->getLine());\r
1124                                                        if ((IsExp == FALSE) && (VarStoreType == EFI_VFR_VARSTORE_BUFFER)) {\r
1125                                                          _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (\r
1126                                                                    DefaultId,\r
1127                                                                    _GET_CURRQEST_VARTINFO(),\r
1128                                                                    VarStoreName,\r
1129                                                                    _GET_CURRQEST_DATATYPE (),\r
1130                                                                    Val),\r
1131                                                                    D->getLine()\r
1132                                                                    );\r
1133                                                        }\r
1134                                                     >>\r
1135   )\r
1136   ;\r
1137 \r
1138 vfrStatementStat :\r
1139   vfrStatementSubTitle        |\r
1140   vfrStatementStaticText      |\r
1141   vfrStatementCrossReference\r
1142   ;\r
1143 \r
1144 vfrStatementQuestions :\r
1145   vfrStatementBooleanType     |\r
1146   vfrStatementDate            |\r
1147   vfrStatementNumericType     |\r
1148   vfrStatementStringType      |\r
1149   vfrStatementOrderedList     |\r
1150   vfrStatementTime\r
1151   ;\r
1152 \r
1153 vfrStatementConditional :\r
1154   vfrStatementDisableIfStat   |\r
1155   vfrStatementSuppressIfStat  |    //enhance to be compatible for framework endif\r
1156   vfrStatementGrayOutIfStat   |\r
1157   vfrStatementInconsistentIfStat   //to be compatible for framework\r
1158   ;\r
1159 \r
1160 vfrStatementConditionalNew :\r
1161   vfrStatementDisableIfStat      |\r
1162   vfrStatementSuppressIfStatNew  |\r
1163   vfrStatementGrayOutIfStatNew   |\r
1164   vfrStatementInconsistentIfStat   //to be compatible for framework\r
1165   ;\r
1166 \r
1167 vfrStatementSuppressIfStat :\r
1168   <<mCompatibleMode>>? vfrStatementSuppressIfStatOld\r
1169   | vfrStatementSuppressIfStatNew\r
1170   ;\r
1171 \r
1172 vfrStatementGrayOutIfStat :\r
1173   <<mCompatibleMode>>? vfrStatementGrayOutIfStatOld\r
1174   | vfrStatementGrayOutIfStatNew\r
1175   ;\r
1176 \r
1177 vfrStatementInvalid :\r
1178   (\r
1179     vfrStatementInvalidHidden          |\r
1180     vfrStatementInvalidInventory       |\r
1181     vfrStatementInvalidSaveRestoreDefaults\r
1182   )\r
1183                                                        << _CRT_OP (TRUE); >>\r
1184   ;\r
1185 \r
1186 flagsField :\r
1187   Number | InteractiveFlag | ManufacturingFlag | DefaultFlag |\r
1188   NVAccessFlag | ResetRequiredFlag | LateCheckFlag\r
1189   ;\r
1190 \r
1191 vfrStatementValue :\r
1192   << CIfrValue VObj; >>\r
1193   V:Value                                              << VObj.SetLineNo(V->getLine()); >>\r
1194   "=" vfrStatementExpression[0]                        << {CIfrEnd EndObj; EndObj.SetLineNo(V->getLine());} >>\r
1195   ;\r
1196 \r
1197 vfrStatementSubTitle :\r
1198   << CIfrSubtitle SObj; >>\r
1199   L:Subtitle                                           << SObj.SetLineNo(L->getLine()); >>\r
1200   Text "=" "STRING_TOKEN" "\(" S:Number "\)"           << SObj.SetPrompt (_STOSID(S->getText())); >>\r
1201   {\r
1202     "," FLAGS "=" vfrSubtitleFlags[SObj]\r
1203   }\r
1204   { vfrStatementStatTagList "," }\r
1205   E:";"                                                << CRT_END_OP (E); >>\r
1206   ;\r
1207 \r
1208 vfrSubtitleFlags [CIfrSubtitle & SObj] :\r
1209   << UINT8 LFlags = 0; >>\r
1210   subtitleFlagsField[LFlags] ( "\|" subtitleFlagsField[LFlags] )*\r
1211                                                        << _PCATCH(SObj.SetFlags (LFlags)); >>\r
1212   ;\r
1213 \r
1214 subtitleFlagsField [UINT8 & Flags] :\r
1215     N:Number                                           << $Flags |= _STOU8(N->getText()); >>\r
1216   | "HORIZONTAL"                                       << $Flags |= 0x01; >>\r
1217   ;\r
1218 \r
1219 vfrStatementStaticText :\r
1220   <<\r
1221      UINT8           Flags   = 0;\r
1222      EFI_QUESTION_ID QId     = EFI_QUESTION_ID_INVALID;\r
1223      EFI_STRING_ID   TxtTwo  = EFI_STRING_ID_INVALID;\r
1224    >>\r
1225   T:Text\r
1226   Help "=" "STRING_TOKEN" "\(" S1:Number "\)" ","\r
1227   Text "=" "STRING_TOKEN" "\(" S2:Number "\)"\r
1228   {\r
1229     "," Text "=" "STRING_TOKEN" "\(" S3:Number "\)"    << TxtTwo = _STOSID(S3->getText()); >>\r
1230   }\r
1231   {\r
1232     "," F:FLAGS "=" staticTextFlagsField[Flags] ( "\|" staticTextFlagsField[Flags] )*\r
1233     "," Key "=" KN:Number\r
1234   }\r
1235                                                        <<\r
1236                                                           if (Flags & EFI_IFR_FLAG_CALLBACK) {\r
1237                                                             CIfrAction AObj;\r
1238                                                             mCVfrQuestionDB.RegisterQuestion (NULL, NULL, QId);\r
1239                                                             AObj.SetLineNo (F->getLine());\r
1240                                                             AObj.SetQuestionId (QId);\r
1241                                                             AObj.SetPrompt (_STOSID(S2->getText()));\r
1242                                                             AObj.SetHelp (_STOSID(S1->getText()));\r
1243                                                             _PCATCH(AObj.SetFlags (Flags), F->getLine());\r
1244                                                             AssignQuestionKey (AObj, KN);\r
1245                                                             CRT_END_OP (KN);\r
1246                                                           } else {\r
1247                                                             CIfrText TObj;\r
1248                                                             TObj.SetLineNo (T->getLine());\r
1249                                                             TObj.SetHelp (_STOSID(S1->getText()));\r
1250                                                             TObj.SetPrompt (_STOSID(S2->getText()));\r
1251                                                             TObj.SetTextTwo (TxtTwo);\r
1252                                                           }\r
1253                                                        >>\r
1254   { "," vfrStatementStatTagList }\r
1255   ";"\r
1256   ;\r
1257 \r
1258 staticTextFlagsField[UINT8 & HFlags] :\r
1259     N:Number                                           << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>\r
1260   | questionheaderFlagsField[HFlags]\r
1261   ;\r
1262 \r
1263 vfrStatementCrossReference :\r
1264   vfrStatementGoto            |\r
1265   vfrStatementResetButton\r
1266   ;\r
1267 \r
1268 vfrStatementGoto :\r
1269   <<\r
1270      UINT8               RefType = 1;\r
1271      EFI_STRING_ID       DevPath = EFI_STRING_ID_INVALID;\r
1272      EFI_GUID            FSId = {0,};\r
1273      EFI_FORM_ID         FId;\r
1274      EFI_QUESTION_ID     QId    = EFI_QUESTION_ID_INVALID;\r
1275      UINT32              BitMask;\r
1276      CIfrQuestionHeader  *QHObj = NULL;\r
1277      CIfrRef             *R1Obj = NULL;\r
1278      CIfrRef2            *R2Obj = NULL;\r
1279      CIfrRef3            *R3Obj = NULL;\r
1280      CIfrRef4            *R4Obj = NULL;\r
1281   >>\r
1282   G:Goto\r
1283   (\r
1284     (\r
1285       DevicePath "=" "STRING_TOKEN" "\(" P:Number "\)" ","\r
1286       FormSetGuid "=" guidDefinition[FSId] ","\r
1287       FormId "=" F1:Number ","\r
1288       Question "=" QN1:Number ","\r
1289                                                        <<\r
1290                                                           RefType = 4;\r
1291                                                           DevPath = _STOSID(P->getText());\r
1292                                                           FId = _STOFID(F1->getText());\r
1293                                                           QId = _STOQID(QN1->getText());\r
1294                                                        >>\r
1295     )\r
1296     |\r
1297     (\r
1298       FormSetGuid "=" guidDefinition[FSId] ","\r
1299       FormId "=" F2:Number ","\r
1300       Question "=" QN2:Number ","\r
1301                                                        <<\r
1302                                                           RefType = 3;\r
1303                                                           FId = _STOFID(F2->getText());\r
1304                                                           QId = _STOQID(QN2->getText());\r
1305                                                        >>\r
1306     )\r
1307     |\r
1308     (\r
1309       FormId "=" F3:Number ","                         << RefType = 2; FId = _STOFID(F3->getText()); >>\r
1310       Question "="\r
1311       (\r
1312           QN3:StringIdentifier ","                     << mCVfrQuestionDB.GetQuestionId (QN3->getText (), NULL, QId, BitMask); >>\r
1313         | QN4:Number ","                               << QId = _STOQID(QN4->getText()); >>\r
1314       )\r
1315     )\r
1316     |\r
1317     (\r
1318       F4:Number ","                                    <<\r
1319                                                           RefType = 1;\r
1320                                                           FId = _STOFID(F4->getText());\r
1321                                                        >>\r
1322     )\r
1323   )\r
1324                                                        <<\r
1325                                                           switch (RefType) {\r
1326                                                           case 4:\r
1327                                                             {\r
1328                                                               R4Obj = new CIfrRef4;\r
1329                                                               QHObj = R4Obj;\r
1330                                                               R4Obj->SetLineNo(G->getLine());\r
1331                                                               R4Obj->SetDevicePath (DevPath);\r
1332                                                               R4Obj->SetFormSetId (FSId);\r
1333                                                               R4Obj->SetFormId (FId);\r
1334                                                               R4Obj->SetQuestionId (QId);\r
1335                                                               break;\r
1336                                                             }\r
1337                                                           case 3:\r
1338                                                             {\r
1339                                                               R3Obj = new CIfrRef3;\r
1340                                                               QHObj = R3Obj;\r
1341                                                               R3Obj->SetLineNo(G->getLine());\r
1342                                                               R3Obj->SetFormSetId (FSId);\r
1343                                                               R3Obj->SetFormId (FId);\r
1344                                                               R3Obj->SetQuestionId (QId);\r
1345                                                               break;\r
1346                                                             }\r
1347                                                           case 2:\r
1348                                                             {\r
1349                                                               R2Obj = new CIfrRef2;\r
1350                                                               QHObj = R2Obj;\r
1351                                                               R2Obj->SetLineNo(G->getLine());\r
1352                                                               R2Obj->SetFormId (FId);\r
1353                                                               _PCATCH(R2Obj->SetQuestionId (QId), QN3);\r
1354                                                               break;\r
1355                                                             }\r
1356                                                           case 1:\r
1357                                                             {\r
1358                                                               R1Obj = new CIfrRef;\r
1359                                                               QHObj = R1Obj;\r
1360                                                               R1Obj->SetLineNo(G->getLine());\r
1361                                                               R1Obj->SetFormId (FId);\r
1362                                                               break;\r
1363                                                             }\r
1364                                                           default: break;\r
1365                                                           }\r
1366                                                        >>\r
1367   vfrQuestionHeaderWithNoStorage[QHObj]\r
1368   { "," vfrStatementStatTagList }\r
1369   { "," F:FLAGS  "=" vfrGotoFlags[QHObj, F->getLine()] }\r
1370   {\r
1371     "," Key "=" KN:Number                              << AssignQuestionKey (*QHObj, KN); >>\r
1372   }\r
1373   ";"                                                  << if (R1Obj != NULL) {delete R1Obj;} if (R2Obj != NULL) {delete R2Obj;} if (R3Obj != NULL) {delete R3Obj;} if (R4Obj != NULL) {delete R4Obj;} >>\r
1374   ;\r
1375 \r
1376 vfrGotoFlags [CIfrQuestionHeader *QHObj, UINT32 LineNum] :\r
1377   << UINT8 HFlags = 0; >>\r
1378   gotoFlagsField[HFlags] ( "\|" gotoFlagsField[HFlags] )*\r
1379                                                        << _PCATCH(QHObj->SetFlags (HFlags), LineNum); >>\r
1380   ;\r
1381 \r
1382 gotoFlagsField[UINT8 & HFlags] :\r
1383     N:Number                                           << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>\r
1384   | questionheaderFlagsField[HFlags]\r
1385   ;\r
1386 \r
1387 getStringId :\r
1388   "STRING_TOKEN" "\("\r
1389   IdVal:Number\r
1390   "\)"\r
1391   ;\r
1392 \r
1393 vfrStatementResetButton :\r
1394   <<\r
1395      CIfrResetButton RBObj;\r
1396      UINT16          DefaultId;\r
1397   >>\r
1398   L:ResetButton                                        << RBObj.SetLineNo(L->getLine()); >>\r
1399   DefaultStore\r
1400   "=" N:StringIdentifier ","                           <<\r
1401                                                           _PCATCH(mCVfrDefaultStore.GetDefaultId (N->getText(), &DefaultId), N->getLine());\r
1402                                                           RBObj.SetDefaultId (DefaultId);\r
1403                                                        >>\r
1404   vfrStatementHeader[&RBObj] ","\r
1405   { vfrStatementStatTagList "," }\r
1406   E:EndResetButton                                     << CRT_END_OP (E); >>\r
1407   ";"\r
1408   ;\r
1409 \r
1410 vfrStatementBooleanType :\r
1411   vfrStatementCheckBox |\r
1412   vfrStatementAction\r
1413   ;\r
1414 \r
1415 //*****************************************************\r
1416 // Syntax of checkbox\r
1417 //\r
1418 // Example:\r
1419 //   checkbox\r
1420 //     varid       = MySTestData.mField1,\r
1421 //     prompt      = STRING_TOKEN(STR_CHECK_BOX_PROMPT),\r
1422 //     help        = STRING_TOKEN(STR_CHECK_BOX_HELP),\r
1423 //     flags       = CHECKBOX_DEFAULT | CALLBACK,\r
1424 //     default value = TRUE, defaultstore = MyDefaultStore,\r
1425 //   endcheckbox;\r
1426 //\r
1427 vfrStatementCheckBox :\r
1428   <<\r
1429      CIfrCheckBox       CBObj;\r
1430      EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;\r
1431      CHAR8              *VarStoreName = NULL;\r
1432      UINT32             DataTypeSize;\r
1433   >>\r
1434   L:CheckBox                                           << CBObj.SetLineNo(L->getLine()); >>\r
1435   vfrQuestionHeader[CBObj] ","                         << //check data type\r
1436                                                           _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "CheckBox varid is not the valid data type");\r
1437                                                           if (DataTypeSize != 0 && DataTypeSize != _GET_CURRQEST_VARSIZE()) {\r
1438                                                             _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "CheckBox varid doesn't support array");\r
1439                                                           } else if ((mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId) == EFI_VFR_VARSTORE_BUFFER) &&\r
1440                                                                     (_GET_CURRQEST_VARSIZE() != sizeof (BOOLEAN))) {\r
1441                                                             _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "CheckBox varid only support BOOLEAN data type");\r
1442                                                           }\r
1443                                                        >>\r
1444   {\r
1445     F:FLAGS "=" vfrCheckBoxFlags[CBObj, F->getLine()] ","\r
1446                                                        <<\r
1447                                                           _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), VFR_RETURN_SUCCESS, L, "Failed to retrieve varstore name");\r
1448                                                           Val.b = TRUE;\r
1449                                                           if (CBObj.GetFlags () & 0x01) {\r
1450                                                             _PCATCH(\r
1451                                                               mCVfrDefaultStore.BufferVarStoreAltConfigAdd (\r
1452                                                                                   EFI_HII_DEFAULT_CLASS_STANDARD,\r
1453                                                                                   _GET_CURRQEST_VARTINFO(),\r
1454                                                                                   VarStoreName,\r
1455                                                                                   _GET_CURRQEST_DATATYPE (),\r
1456                                                                                   Val\r
1457                                                                                   ),\r
1458                                                               VFR_RETURN_SUCCESS,\r
1459                                                               L,\r
1460                                                               "No standard default storage found"\r
1461                                                               );\r
1462                                                           }\r
1463                                                           if (CBObj.GetFlags () & 0x02) {\r
1464                                                             _PCATCH(\r
1465                                                               mCVfrDefaultStore.BufferVarStoreAltConfigAdd (\r
1466                                                                                   EFI_HII_DEFAULT_CLASS_MANUFACTURING,\r
1467                                                                                   _GET_CURRQEST_VARTINFO(),\r
1468                                                                                   VarStoreName,\r
1469                                                                                   _GET_CURRQEST_DATATYPE (),\r
1470                                                                                   Val\r
1471                                                                                   ),\r
1472                                                               VFR_RETURN_SUCCESS,\r
1473                                                               L,\r
1474                                                               "No manufacturing default storage found"\r
1475                                                               );\r
1476                                                           }\r
1477                                                         >>\r
1478   }\r
1479   {\r
1480     Key "=" KN:Number  ","                             << AssignQuestionKey (CBObj, KN); >>\r
1481   }\r
1482   vfrStatementQuestionOptionList\r
1483   E:EndCheckBox                                        << CRT_END_OP (E); >>\r
1484   ";"\r
1485   ;\r
1486 \r
1487 vfrCheckBoxFlags [CIfrCheckBox & CBObj, UINT32 LineNum] :\r
1488   <<\r
1489      UINT8 LFlags = 0;\r
1490      UINT8 HFlags = 0;\r
1491   >>\r
1492   checkboxFlagsField[LFlags, HFlags] ( "\|" checkboxFlagsField[LFlags, HFlags] )*\r
1493                                                        << _PCATCH(CBObj.SetFlags (HFlags, LFlags), LineNum); >>\r
1494   ;\r
1495 \r
1496 checkboxFlagsField[UINT8 & LFlags, UINT8 & HFlags] :\r
1497     N:Number                                           <<\r
1498                                                           if (mCompatibleMode) {\r
1499                                                             //\r
1500                                                             // set question flag\r
1501                                                             //\r
1502                                                             $LFlags |= _STOU8(N->getText());\r
1503                                                           } else {\r
1504                                                             _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine());\r
1505                                                           }\r
1506                                                        >>\r
1507   | D:"DEFAULT"                                        <<\r
1508                                                           if (mCompatibleMode) {\r
1509                                                             //\r
1510                                                             // set question Default flag\r
1511                                                             //\r
1512                                                             $LFlags |= 0x01;\r
1513                                                           } else {\r
1514                                                             _PCATCH (VFR_RETURN_UNSUPPORTED, D);\r
1515                                                           }\r
1516                                                        >>\r
1517   | M:"MANUFACTURING"                                  <<\r
1518                                                           if (mCompatibleMode) {\r
1519                                                             //\r
1520                                                             // set question MFG flag\r
1521                                                             //\r
1522                                                             $LFlags |= 0x02;\r
1523                                                           } else {\r
1524                                                             _PCATCH (VFR_RETURN_UNSUPPORTED, M);\r
1525                                                           }\r
1526                                                        >>\r
1527   | "CHECKBOX_DEFAULT"                                 << $LFlags |= 0x01; >>\r
1528   | "CHECKBOX_DEFAULT_MFG"                             << $LFlags |= 0x02; >>\r
1529   | questionheaderFlagsField[HFlags]\r
1530   ;\r
1531 \r
1532 //*****************************************************\r
1533 // Syntax of action\r
1534 //\r
1535 // Example:\r
1536 //   action\r
1537 //     prompt      = STRING_TOKEN(STR_ACTION_PROMPT),\r
1538 //     help        = STRING_TOKEN(STR_ACTION_HELP),\r
1539 //     flags       = CALLBACK,\r
1540 //     config      = STRING_TOKEN(STR_ACTION_CONFIG),\r
1541 //   endaction;\r
1542 //\r
1543 vfrStatementAction :\r
1544   << CIfrAction AObj; >>\r
1545   L:Action                                             << AObj.SetLineNo(L->getLine()); >>\r
1546   vfrQuestionHeaderWithNoStorage[&AObj] ","\r
1547   { F:FLAGS "=" vfrActionFlags[AObj, F->getLine()] "," }\r
1548   Config "=" "STRING_TOKEN" "\(" S:Number "\)" ","     << AObj.SetQuestionConfig (_STOSID(S->getText())); >>\r
1549   vfrStatementQuestionTagList\r
1550   E:EndAction                                          << CRT_END_OP (E); >>\r
1551   ";"\r
1552   ;\r
1553 \r
1554 vfrActionFlags[CIfrAction & AObj, UINT32 LineNum] :\r
1555   << UINT8 HFlags = 0; >>\r
1556   actionFlagsField[HFlags] ( "\|" actionFlagsField[HFlags] )*\r
1557                                                        << _PCATCH(AObj.SetFlags (HFlags), LineNum); >>\r
1558   ;\r
1559 \r
1560 actionFlagsField[UINT8 & HFlags] :\r
1561     N:Number                                           << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>\r
1562   | questionheaderFlagsField[HFlags]\r
1563   ;\r
1564 \r
1565 vfrStatementDate :\r
1566   <<\r
1567      EFI_QUESTION_ID    QId          = EFI_QUESTION_ID_INVALID;\r
1568      CHAR8              *VarIdStr[3] = {NULL, };\r
1569      CIfrDate           DObj;\r
1570      EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;\r
1571   >>\r
1572   L:Date                                               << DObj.SetLineNo(L->getLine()); >>\r
1573   (\r
1574     (\r
1575       vfrQuestionHeader[DObj, QUESTION_DATE] ","\r
1576     { F:FLAGS "=" vfrDateFlags[DObj, F->getLine()] "," }\r
1577       vfrStatementQuestionOptionList\r
1578     )\r
1579     |\r
1580     (\r
1581       Year VarId "=" D1:StringIdentifier "." D1Y:StringIdentifier ","\r
1582                                                        << _STRCAT(&VarIdStr[0], D1->getText()); _STRCAT(&VarIdStr[0], "."); _STRCAT(&VarIdStr[0], D1Y->getText()); >>\r
1583       Prompt "=" "STRING_TOKEN" "\(" YP:Number "\)" ","\r
1584       Help   "=" "STRING_TOKEN" "\(" YH:Number "\)" ","\r
1585       minMaxDateStepDefault[Val.date, 0]\r
1586 \r
1587       Month VarId "=" D2:StringIdentifier "." D2M:StringIdentifier ","\r
1588                                                        << _STRCAT(&VarIdStr[1], D2->getText()); _STRCAT(&VarIdStr[1], "."); _STRCAT(&VarIdStr[1], D2M->getText()); >>\r
1589       Prompt "=" "STRING_TOKEN" "\(" MP:Number "\)" ","\r
1590       Help   "=" "STRING_TOKEN" "\(" MH:Number "\)" ","\r
1591       minMaxDateStepDefault[Val.date, 1]\r
1592 \r
1593       Day VarId "=" D3:StringIdentifier "." D3D:StringIdentifier ","\r
1594                                                        << _STRCAT(&VarIdStr[2], D3->getText()); _STRCAT(&VarIdStr[2], "."); _STRCAT(&VarIdStr[2], D3D->getText()); >>\r
1595       Prompt "=" "STRING_TOKEN" "\(" DP:Number "\)" ","\r
1596       Help   "=" "STRING_TOKEN" "\(" DH:Number "\)" ","\r
1597       minMaxDateStepDefault[Val.date, 2]\r
1598                                                        <<\r
1599                                                           mCVfrQuestionDB.RegisterOldDateQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);\r
1600                                                           DObj.SetQuestionId (QId);\r
1601                                                           DObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_DATE_STORAGE_TIME);\r
1602                                                           DObj.SetPrompt (_STOSID(YP->getText()));\r
1603                                                           DObj.SetHelp (_STOSID(YH->getText()));\r
1604                                                           if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }\r
1605                                                        >>\r
1606                                                        << {CIfrDefault DefaultObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_DATE, Val); DefaultObj.SetLineNo(L->getLine());} >>\r
1607     )\r
1608     ( vfrStatementInconsistentIf )*\r
1609   )\r
1610   E:EndDate                                            << CRT_END_OP (E); >>\r
1611   ";"\r
1612   ;\r
1613 \r
1614 minMaxDateStepDefault[EFI_HII_DATE & D, UINT8 KeyValue] :\r
1615   Minimum   "=" MinN:Number ","\r
1616   Maximum   "=" MaxN:Number ","\r
1617   { "step"    "=" Number "," }\r
1618   {\r
1619     "default" "=" N:Number ","                         <<\r
1620                                                           switch (KeyValue) {\r
1621                                                           case 0: \r
1622                                                             D.Year  = _STOU16(N->getText());\r
1623                                                             if (D.Year < _STOU16 (MinN->getText()) || D.Year > _STOU16 (MaxN->getText())) {\r
1624                                                               _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Year default value must be between Min year and Max year.");\r
1625                                                             }\r
1626                                                             break;\r
1627                                                           case 1: \r
1628                                                             D.Month = _STOU8(N->getText()); \r
1629                                                             if (D.Month < 1 || D.Month > 12) {\r
1630                                                               _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Month default value must be between 1 and 12.");\r
1631                                                             }\r
1632                                                             break;\r
1633                                                           case 2: \r
1634                                                             D.Day = _STOU8(N->getText()); \r
1635                                                             if (D.Day < 1 || D.Day > 31) {\r
1636                                                               _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Day default value must be between 1 and 31.");\r
1637                                                             }\r
1638                                                             break;\r
1639                                                           }\r
1640                                                        >>\r
1641   }\r
1642   ;\r
1643 \r
1644 vfrDateFlags [CIfrDate & DObj, UINT32 LineNum] :\r
1645   << UINT8 LFlags = 0; >>\r
1646   dateFlagsField[LFlags] ( "\|" dateFlagsField[LFlags] )*\r
1647                                                        << _PCATCH(DObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, LFlags), LineNum); >>\r
1648   ;\r
1649 \r
1650 dateFlagsField [UINT8 & Flags] :\r
1651     N:Number                                           << $Flags |= _STOU8(N->getText()); >>\r
1652   | "YEAR_SUPPRESS"                                    << $Flags |= 0x01; >>\r
1653   | "MONTH_SUPPRESS"                                   << $Flags |= 0x02; >>\r
1654   | "DAY_SUPPRESS"                                     << $Flags |= 0x04; >>\r
1655   | "STORAGE_NORMAL"                                   << $Flags |= 0x00; >>\r
1656   | "STORAGE_TIME"                                     << $Flags |= 0x10; >>\r
1657   | "STORAGE_WAKEUP"                                   << $Flags |= 0x20; >>\r
1658   ;\r
1659 \r
1660 vfrStatementNumericType :\r
1661   vfrStatementNumeric   |\r
1662   vfrStatementOneOf\r
1663   ;\r
1664 \r
1665 vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] :\r
1666   <<\r
1667      UINT64 MaxU8 = 0, MinU8 = 0, StepU8 = 0;\r
1668      UINT32 MaxU4 = 0, MinU4 = 0, StepU4 = 0;\r
1669      UINT16 MaxU2 = 0, MinU2 = 0, StepU2 = 0;\r
1670      UINT8  MaxU1 = 0, MinU1 = 0, StepU1 = 0;\r
1671   >>\r
1672   Minimum   "=" I:Number ","\r
1673                                                        <<\r
1674                                                           switch (_GET_CURRQEST_DATATYPE()) {\r
1675                                                           case EFI_IFR_TYPE_NUM_SIZE_64 : MinU8 = _STOU64(I->getText()); break;\r
1676                                                           case EFI_IFR_TYPE_NUM_SIZE_32 : MinU4 = _STOU32(I->getText()); break;\r
1677                                                           case EFI_IFR_TYPE_NUM_SIZE_16 : MinU2 = _STOU16(I->getText()); break;\r
1678                                                           case EFI_IFR_TYPE_NUM_SIZE_8 :  MinU1 = _STOU8(I->getText());  break;\r
1679                                                           }\r
1680                                                        >>\r
1681   Maximum   "=" A:Number ","\r
1682                                                        <<\r
1683                                                           switch (_GET_CURRQEST_DATATYPE()) {\r
1684                                                           case EFI_IFR_TYPE_NUM_SIZE_64 : \r
1685                                                             MaxU8 = _STOU64(A->getText()); \r
1686                                                             if (MaxU8 < MinU8) {\r
1687                                                               _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");\r
1688                                                             }\r
1689                                                             break;\r
1690                                                           case EFI_IFR_TYPE_NUM_SIZE_32 : \r
1691                                                             MaxU4 = _STOU32(A->getText()); \r
1692                                                             if (MaxU4 < MinU4) {\r
1693                                                               _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");\r
1694                                                             }\r
1695                                                             break;\r
1696                                                           case EFI_IFR_TYPE_NUM_SIZE_16 : \r
1697                                                             MaxU2 = _STOU16(A->getText()); \r
1698                                                             if (MaxU2 < MinU2) {\r
1699                                                               _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");\r
1700                                                             }\r
1701                                                             break;\r
1702                                                           case EFI_IFR_TYPE_NUM_SIZE_8 :  \r
1703                                                             MaxU1 = _STOU8(A->getText());  \r
1704                                                             if (MaxU1 < MinU1) {\r
1705                                                               _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");\r
1706                                                             }\r
1707                                                             break;\r
1708                                                           }\r
1709                                                        >>\r
1710   {\r
1711     STEP    "=" S:Number ","\r
1712                                                        <<\r
1713                                                           switch (_GET_CURRQEST_DATATYPE()) {\r
1714                                                           case EFI_IFR_TYPE_NUM_SIZE_64 : StepU8 = _STOU64(S->getText()); break;\r
1715                                                           case EFI_IFR_TYPE_NUM_SIZE_32 : StepU4 = _STOU32(S->getText()); break;\r
1716                                                           case EFI_IFR_TYPE_NUM_SIZE_16 : StepU2 = _STOU16(S->getText()); break;\r
1717                                                           case EFI_IFR_TYPE_NUM_SIZE_8 :  StepU1 = _STOU8(S->getText());  break;\r
1718                                                           }\r
1719                                                        >>\r
1720   }\r
1721                                                        <<\r
1722                                                           switch (_GET_CURRQEST_DATATYPE()) {\r
1723                                                           case EFI_IFR_TYPE_NUM_SIZE_64 : $MMSDObj.SetMinMaxStepData (MinU8, MaxU8, StepU8); break;\r
1724                                                           case EFI_IFR_TYPE_NUM_SIZE_32 : $MMSDObj.SetMinMaxStepData (MinU4, MaxU4, StepU4); break;\r
1725                                                           case EFI_IFR_TYPE_NUM_SIZE_16 : $MMSDObj.SetMinMaxStepData (MinU2, MaxU2, StepU2); break;\r
1726                                                           case EFI_IFR_TYPE_NUM_SIZE_8 :  $MMSDObj.SetMinMaxStepData (MinU1, MaxU1, StepU1);  break;\r
1727                                                           }\r
1728                                                        >>\r
1729   ;\r
1730 \r
1731 vfrStatementNumeric :\r
1732   <<\r
1733      CIfrNumeric NObj;\r
1734      UINT32 DataTypeSize;\r
1735   >>\r
1736   L:Numeric                                            << NObj.SetLineNo(L->getLine()); >>\r
1737   vfrQuestionHeader[NObj] ","                          << // check data type\r
1738                                                           _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "Numeric varid is not the valid data type");\r
1739                                                           if (DataTypeSize != 0 && DataTypeSize != _GET_CURRQEST_VARSIZE()) {\r
1740                                                             _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "Numeric varid doesn't support array");\r
1741                                                           }\r
1742                                                           _PCATCH(NObj.SetFlags (NObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine());\r
1743                                                        >>\r
1744   { F:FLAGS "=" vfrNumericFlags[NObj, F->getLine()] "," }\r
1745   {\r
1746     Key   "=" KN:Number ","                            << AssignQuestionKey (NObj, KN); >>\r
1747   }\r
1748   vfrSetMinMaxStep[NObj]\r
1749   vfrStatementQuestionOptionList\r
1750   E:EndNumeric                                         << CRT_END_OP (E); >>\r
1751   ";"\r
1752   ;\r
1753 \r
1754 vfrNumericFlags [CIfrNumeric & NObj, UINT32 LineNum] :\r
1755   <<\r
1756      UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;\r
1757      UINT8 HFlags = 0;\r
1758      EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;\r
1759   >>\r
1760   numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )*\r
1761                                                        <<\r
1762                                                           //check data type flag\r
1763                                                           VarStoreType = mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId);\r
1764                                                           if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) {\r
1765                                                             if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) {\r
1766                                                               _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type");\r
1767                                                             }\r
1768                                                           } else {\r
1769                                                             // update data type for name/value store\r
1770                                                             UINT32 DataTypeSize;\r
1771                                                             _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;\r
1772                                                             gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize);\r
1773                                                             _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize;\r
1774                                                           }\r
1775                                                           _PCATCH(NObj.SetFlags (HFlags, LFlags), LineNum);\r
1776                                                        >>\r
1777   ;\r
1778 \r
1779 numericFlagsField [UINT8 & HFlags, UINT8 & LFlags] :\r
1780     N:Number                                           << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>\r
1781   | "NUMERIC_SIZE_1"                                   << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_1; >>\r
1782   | "NUMERIC_SIZE_2"                                   << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_2; >>\r
1783   | "NUMERIC_SIZE_4"                                   << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_4; >>\r
1784   | "NUMERIC_SIZE_8"                                   << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_8; >>\r
1785   | "DISPLAY_INT_DEC"                                  << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_INT_DEC; >>\r
1786   | "DISPLAY_UINT_DEC"                                 << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_DEC; >>\r
1787   | "DISPLAY_UINT_HEX"                                 << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_HEX; >>\r
1788   | questionheaderFlagsField[HFlags]\r
1789   ;\r
1790 \r
1791 vfrStatementOneOf :\r
1792   <<\r
1793      CIfrOneOf OObj;\r
1794      UINT32    DataTypeSize;\r
1795   >>\r
1796   L:OneOf                                              << OObj.SetLineNo(L->getLine()); >>\r
1797   vfrQuestionHeader[OObj] ","                          << //check data type\r
1798                                                           _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "OneOf varid is not the valid data type");\r
1799                                                           if (DataTypeSize != 0 && DataTypeSize != _GET_CURRQEST_VARSIZE()) {\r
1800                                                             _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "OneOf varid doesn't support array");\r
1801                                                           }\r
1802                                                           _PCATCH(OObj.SetFlags (OObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine());\r
1803                                                        >>\r
1804   { F:FLAGS "=" vfrOneofFlagsField[OObj, F->getLine()] "," }\r
1805   {\r
1806     vfrSetMinMaxStep[OObj]\r
1807   }\r
1808   vfrStatementQuestionOptionList\r
1809   E:EndOneOf                                           << CRT_END_OP (E); >>\r
1810   ";"\r
1811   ;\r
1812 \r
1813 vfrOneofFlagsField [CIfrOneOf & OObj, UINT32 LineNum] :\r
1814   <<\r
1815      UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;\r
1816      UINT8 HFlags = 0;\r
1817      EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;\r
1818   >>\r
1819   numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )*\r
1820                                                        <<\r
1821                                                           //check data type flag\r
1822                                                           VarStoreType = mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId);\r
1823                                                           if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) {\r
1824                                                             if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) {\r
1825                                                               _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type");\r
1826                                                             }\r
1827                                                           } else {\r
1828                                                             // update data type for Name/Value store\r
1829                                                             UINT32 DataTypeSize;\r
1830                                                             _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;\r
1831                                                             gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize);\r
1832                                                             _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize;\r
1833                                                           }\r
1834                                                           _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum);\r
1835                                                        >>\r
1836   ;\r
1837 \r
1838 vfrStatementStringType :\r
1839   vfrStatementString    |\r
1840   vfrStatementPassword\r
1841   ;\r
1842 \r
1843 vfrStatementString :\r
1844   <<\r
1845      CIfrString SObj;\r
1846   >>\r
1847   L:String                                             << SObj.SetLineNo(L->getLine()); >>\r
1848   vfrQuestionHeader[SObj] ","\r
1849   { F:FLAGS "=" vfrStringFlagsField[SObj, F->getLine()] "," }\r
1850   {\r
1851     Key "=" KN:Number ","                              << AssignQuestionKey (SObj, KN); >>\r
1852   }\r
1853   MinSize "=" MIN:Number ","                           << SObj.SetMinSize (_STOU8(MIN->getText())); >>\r
1854   MaxSize "=" MAX:Number ","                           << SObj.SetMaxSize (_STOU8(MAX->getText())); >>\r
1855   vfrStatementQuestionOptionList\r
1856   E:EndString                                          << CRT_END_OP (E); >>\r
1857   ";"\r
1858   ;\r
1859 \r
1860 vfrStringFlagsField [CIfrString & SObj, UINT32 LineNum] :\r
1861   <<\r
1862      UINT8 LFlags = 0;\r
1863      UINT8 HFlags = 0;\r
1864   >>\r
1865   stringFlagsField[HFlags, LFlags] ( "\|" stringFlagsField[HFlags, LFlags] )*\r
1866                                                        << _PCATCH(SObj.SetFlags (HFlags, LFlags), LineNum); >>\r
1867   ;\r
1868 \r
1869 stringFlagsField [UINT8 & HFlags, UINT8 & LFlags] :\r
1870     N:Number                                           << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>\r
1871   | "MULTI_LINE"                                       << $LFlags = 0x01; >>\r
1872   | questionheaderFlagsField[HFlags]\r
1873   ;\r
1874 \r
1875 vfrStatementPassword :\r
1876   <<\r
1877      CIfrPassword PObj;\r
1878   >>\r
1879   L:Password                                           << PObj.SetLineNo(L->getLine()); >>\r
1880   vfrQuestionHeader[PObj] ","\r
1881   { F:FLAGS "=" vfrPasswordFlagsField[PObj, F->getLine()] "," }\r
1882   {\r
1883     Key "=" KN:Number ","                              << AssignQuestionKey (PObj, KN); >>\r
1884   }\r
1885   MinSize "=" MIN:Number ","                           << PObj.SetMinSize (_STOU16(MIN->getText())); >>\r
1886   MaxSize "=" MAX:Number ","                           << PObj.SetMaxSize (_STOU16(MAX->getText())); >>\r
1887   { Encoding "=" Number "," }\r
1888   vfrStatementQuestionOptionList\r
1889   E:EndPassword                                        << CRT_END_OP (E); >>\r
1890   ";"\r
1891   ;\r
1892 \r
1893 vfrPasswordFlagsField [CIfrPassword & PObj, UINT32 LineNum] :\r
1894   << UINT8 HFlags = 0; >>\r
1895   passwordFlagsField[HFlags] ( "\|" passwordFlagsField[HFlags] )*\r
1896                                                        << _PCATCH(PObj.SetFlags(HFlags), LineNum); >>\r
1897   ;\r
1898 \r
1899 passwordFlagsField [UINT8 & HFlags] :\r
1900     N:Number                                           << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>\r
1901   | questionheaderFlagsField[HFlags]\r
1902   ;\r
1903 \r
1904 vfrStatementOrderedList :\r
1905   <<\r
1906      CIfrOrderedList OLObj;\r
1907   >>\r
1908   L:OrderedList                                        << OLObj.SetLineNo(L->getLine()); >>\r
1909   vfrQuestionHeader[OLObj] ","\r
1910                                                        << OLObj.SetMaxContainers ((UINT8) _GET_CURRQEST_ARRAY_SIZE()); >>\r
1911   {\r
1912     MaxContainers "=" M:Number ","                     << OLObj.SetMaxContainers (_STOU8(M->getText())); >>\r
1913   }\r
1914   { F:FLAGS "=" vfrOrderedListFlags[OLObj, F->getLine()] }\r
1915   vfrStatementQuestionOptionList\r
1916   E:EndList                                            << CRT_END_OP (E); >>\r
1917   ";"\r
1918   ;\r
1919 \r
1920 vfrOrderedListFlags [CIfrOrderedList & OLObj, UINT32 LineNum] :\r
1921   <<\r
1922      UINT8 HFlags = 0;\r
1923      UINT8 LFlags = 0;\r
1924   >>\r
1925   orderedlistFlagsField[HFlags, LFlags] ( "\|" orderedlistFlagsField[HFlags, LFlags] )*\r
1926                                                        << _PCATCH(OLObj.SetFlags (HFlags, LFlags), LineNum); >>\r
1927   ;\r
1928 \r
1929 orderedlistFlagsField [UINT8 & HFlags, UINT8 & LFlags] :\r
1930     N:Number                                           << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>\r
1931   | "UNIQUE"                                           << $LFlags |= 0x01; >>\r
1932   | "NOEMPTY"                                          << $LFlags |= 0x02; >>\r
1933   | questionheaderFlagsField[HFlags]\r
1934   ;\r
1935 \r
1936 vfrStatementTime :\r
1937   <<\r
1938      EFI_QUESTION_ID    QId          = EFI_QUESTION_ID_INVALID;\r
1939      CHAR8              *VarIdStr[3] = {NULL, };\r
1940      CIfrTime           TObj;\r
1941      EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;\r
1942   >>\r
1943   L:Time                                               << TObj.SetLineNo(L->getLine()); >>\r
1944   (\r
1945     (\r
1946       vfrQuestionHeader[TObj, QUESTION_TIME] ","\r
1947     { F:FLAGS "=" vfrTimeFlags[TObj, F->getLine()] "," }\r
1948       vfrStatementDefault\r
1949     )\r
1950     |\r
1951     (\r
1952       Hour VarId "=" T1:StringIdentifier "." T1H:StringIdentifier ","\r
1953                                                        << _STRCAT(&VarIdStr[0], T1->getText()); _STRCAT(&VarIdStr[0], "."); _STRCAT(&VarIdStr[0], T1H->getText()); >>\r
1954       Prompt "=" "STRING_TOKEN" "\(" HP:Number "\)" ","\r
1955       Help   "=" "STRING_TOKEN" "\(" HH:Number "\)" ","\r
1956       minMaxTimeStepDefault[Val.time, 0]\r
1957 \r
1958       Minute VarId "=" T2:StringIdentifier "." T2M:StringIdentifier ","\r
1959                                                        << _STRCAT(&VarIdStr[1], T2->getText()); _STRCAT(&VarIdStr[1], "."); _STRCAT(&VarIdStr[1], T2M->getText()); >>\r
1960       Prompt "=" "STRING_TOKEN" "\(" MP:Number "\)" ","\r
1961       Help   "=" "STRING_TOKEN" "\(" MH:Number "\)" ","\r
1962       minMaxTimeStepDefault[Val.time, 1]\r
1963 \r
1964       Second VarId "=" T3:StringIdentifier "." T3S:StringIdentifier ","\r
1965                                                        << _STRCAT(&VarIdStr[2], T3->getText()); _STRCAT(&VarIdStr[2], "."); _STRCAT(&VarIdStr[2], T3S->getText()); >>\r
1966       Prompt "=" "STRING_TOKEN" "\(" SP:Number "\)" ","\r
1967       Help   "=" "STRING_TOKEN" "\(" SH:Number "\)" ","\r
1968       minMaxTimeStepDefault[Val.time, 2]\r
1969                                                        <<\r
1970                                                           mCVfrQuestionDB.RegisterOldTimeQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);\r
1971                                                           TObj.SetQuestionId (QId);\r
1972                                                           TObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_TIME_STORAGE_TIME);\r
1973                                                           TObj.SetPrompt (_STOSID(HP->getText()));\r
1974                                                           TObj.SetHelp (_STOSID(HH->getText()));\r
1975                                                           if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }\r
1976                                                        >>\r
1977                                                        << {CIfrDefault DefaultObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_TIME, Val); DefaultObj.SetLineNo(L->getLine());} >>\r
1978     )\r
1979     ( vfrStatementInconsistentIf )*\r
1980   )\r
1981   E:EndTime                                            << CRT_END_OP (E); >>\r
1982   ";"\r
1983   ;\r
1984 \r
1985 minMaxTimeStepDefault[EFI_HII_TIME & T, UINT8 KeyValue] :\r
1986   Minimum   "=" Number ","\r
1987   Maximum   "=" Number ","\r
1988   { "step"    "=" Number "," }\r
1989   {\r
1990     "default" "=" N:Number ","                         <<\r
1991                                                           switch (KeyValue) {\r
1992                                                           case 0: \r
1993                                                             T.Hour   = _STOU8(N->getText()); \r
1994                                                             if (T.Hour > 23) {\r
1995                                                               _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Hour default value must be between 0 and 23.");\r
1996                                                             }\r
1997                                                             break;\r
1998                                                           case 1: \r
1999                                                             T.Minute = _STOU8(N->getText()); \r
2000                                                             if (T.Minute > 59) {\r
2001                                                               _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Minute default value must be between 0 and 59.");\r
2002                                                             }\r
2003                                                             break;\r
2004                                                           case 2: \r
2005                                                             T.Second = _STOU8(N->getText());\r
2006                                                             if (T.Second > 59) {\r
2007                                                               _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Second default value must be between 0 and 59.");\r
2008                                                             }\r
2009                                                             break;\r
2010                                                           }\r
2011                                                        >>\r
2012   }\r
2013   ;\r
2014 \r
2015 vfrTimeFlags [CIfrTime & TObj, UINT32 LineNum] :\r
2016   << UINT8 LFlags = 0; >>\r
2017   timeFlagsField[LFlags] ( "\|" timeFlagsField[LFlags] )*\r
2018                                                        << _PCATCH(TObj.SetFlags(EFI_IFR_QUESTION_FLAG_DEFAULT, LFlags), LineNum); >>\r
2019   ;\r
2020 \r
2021 timeFlagsField [UINT8 & Flags] :\r
2022     N:Number                                           << $Flags |= _STOU8(N->getText()); >>\r
2023   | "HOUR_SUPPRESS"                                    << $Flags |= 0x01; >>\r
2024   | "MINUTE_SUPPRESS"                                  << $Flags |= 0x02; >>\r
2025   | "SECOND_SUPPRESS"                                  << $Flags |= 0x04; >>\r
2026   | "STORAGE_NORMAL"                                   << $Flags |= 0x00; >>\r
2027   | "STORAGE_TIME"                                     << $Flags |= 0x10; >>\r
2028   | "STORAGE_WAKEUP"                                   << $Flags |= 0x20; >>\r
2029   ;\r
2030 \r
2031 vfrStatementQuestionTag :\r
2032   vfrStatementStatTag ","       |\r
2033   vfrStatementInconsistentIf    |\r
2034   vfrStatementNoSubmitIf        |\r
2035   vfrStatementDisableIfQuest    |\r
2036   vfrStatementRefresh           |\r
2037   vfrStatementVarstoreDevice\r
2038   ;\r
2039 \r
2040 vfrStatementQuestionTagList :\r
2041   ( vfrStatementQuestionTag )*\r
2042   ;\r
2043 \r
2044 vfrStatementQuestionOptionTag :\r
2045   vfrStatementSuppressIfQuest   |\r
2046   vfrStatementGrayOutIfQuest    |\r
2047   vfrStatementValue             |\r
2048   vfrStatementDefault           |\r
2049   vfrStatementOptions\r
2050   ;\r
2051 \r
2052 vfrStatementQuestionOptionList :\r
2053   (\r
2054     vfrStatementQuestionTag     |\r
2055     vfrStatementQuestionOptionTag\r
2056   )*\r
2057   ;\r
2058 \r
2059 vfrStatementStatList :\r
2060   vfrStatementStat                        |\r
2061   vfrStatementQuestions                   |\r
2062   vfrStatementConditionalNew              |\r
2063   vfrStatementLabel                       |\r
2064   // Just for framework vfr compatibility\r
2065   vfrStatementInvalid\r
2066   ;\r
2067 \r
2068 vfrStatementStatListOld :\r
2069   vfrStatementStat                        |\r
2070   vfrStatementQuestions                   |\r
2071   vfrStatementLabel                       |\r
2072   // Just for framework vfr compatibility\r
2073   vfrStatementInvalid\r
2074   ;\r
2075 \r
2076 vfrStatementDisableIfStat :\r
2077   << \r
2078     CIfrDisableIf DIObj; \r
2079   >>\r
2080   L:DisableIf                                          << DIObj.SetLineNo(L->getLine()); >>\r
2081   vfrStatementExpression[0] ";" \r
2082   ( vfrStatementStatList )*\r
2083   E:EndIf                                              << CRT_END_OP (E); >>\r
2084   ";"\r
2085   ;\r
2086 \r
2087 vfrStatementInconsistentIfStat :\r
2088   << CIfrInconsistentIf IIObj; >>\r
2089   L:InconsistentIf                                     <<\r
2090                                                           if (!mCompatibleMode) {\r
2091                                                             _PCATCH (VFR_RETURN_UNSUPPORTED, L);\r
2092                                                           }\r
2093                                                           IIObj.SetLineNo(L->getLine());\r
2094                                                        >>\r
2095   Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" ","     << IIObj.SetError (_STOSID(S->getText())); >>\r
2096   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
2097   vfrStatementExpression[0]\r
2098   E:EndIf                                              << CRT_END_OP (E); >>\r
2099   ";"\r
2100   ;\r
2101 \r
2102 //\r
2103 // Compatible for framework vfr file\r
2104 //\r
2105 vfrStatementgrayoutIfSuppressIf:\r
2106   << CIfrSuppressIf SIObj; >>\r
2107   L:SuppressIf                                         << SIObj.SetLineNo(L->getLine()); >>\r
2108   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
2109   vfrStatementExpression[0]\r
2110   ";"\r
2111   ;\r
2112 \r
2113 vfrStatementsuppressIfGrayOutIf:\r
2114   << CIfrGrayOutIf GOIObj; >>\r
2115   L:GrayOutIf                                          << GOIObj.SetLineNo(L->getLine()); >>\r
2116   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
2117   vfrStatementExpression[0]\r
2118   ";"\r
2119   ;\r
2120 \r
2121 vfrStatementSuppressIfStatNew :\r
2122   << CIfrSuppressIf SIObj;>>\r
2123   L:SuppressIf                                         << SIObj.SetLineNo(L->getLine()); >>\r
2124   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
2125   vfrStatementExpression[0]\r
2126   ";"\r
2127   ( vfrStatementStatList )*\r
2128   E: EndIf ";"                                       << CRT_END_OP (E); >>\r
2129   ;\r
2130 \r
2131 vfrStatementGrayOutIfStatNew :\r
2132   << CIfrGrayOutIf GOIObj;>>\r
2133   L:GrayOutIf                                          << GOIObj.SetLineNo(L->getLine()); >>\r
2134   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
2135   vfrStatementExpression[0]\r
2136   ";"\r
2137   ( vfrStatementStatList )*\r
2138   E: EndIf ";"                                       << CRT_END_OP (E); >>\r
2139   ;\r
2140 \r
2141 vfrStatementSuppressIfStatOld :\r
2142   <<\r
2143     CIfrSuppressIf SIObj;\r
2144     BOOLEAN        GrayOutExist = FALSE;\r
2145   >>\r
2146   L:SuppressIf                                       << SIObj.SetLineNo(L->getLine()); >>\r
2147   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
2148   vfrStatementExpression[0]\r
2149   ";"\r
2150   {\r
2151     vfrStatementsuppressIfGrayOutIf\r
2152                                                      << GrayOutExist = TRUE; >>\r
2153   }\r
2154   ( vfrStatementStatListOld )*\r
2155   E: EndIf ";"                                       << if (GrayOutExist) CRT_END_OP (E); CRT_END_OP (E);>>\r
2156   ;\r
2157 \r
2158 vfrStatementGrayOutIfStatOld :\r
2159   <<\r
2160     CIfrGrayOutIf  GOIObj;\r
2161     BOOLEAN        SuppressExist = FALSE;\r
2162   >>\r
2163   L:GrayOutIf                                          << GOIObj.SetLineNo(L->getLine()); >>\r
2164   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
2165   vfrStatementExpression[0]\r
2166   ";"\r
2167   {\r
2168     vfrStatementgrayoutIfSuppressIf\r
2169                                                        << SuppressExist = TRUE; >>\r
2170   }\r
2171   ( vfrStatementStatListOld )*\r
2172   E: EndIf ";"                                         << if (SuppressExist) CRT_END_OP (E); CRT_END_OP (E); >>\r
2173   ;\r
2174 \r
2175 vfrImageTag :\r
2176   << CIfrImage IObj; >>\r
2177   L:Image "=" "IMAGE_TOKEN" "\(" S1:Number "\)"        << IObj.SetImageId (_STOSID(S1->getText())); IObj.SetLineNo(L->getLine()); >>\r
2178   ;\r
2179 \r
2180 vfrLockedTag :\r
2181   << CIfrLocked LObj; >>\r
2182   L:Locked                                             << LObj.SetLineNo(L->getLine()); >>\r
2183   ;\r
2184 \r
2185 vfrStatementStatTag :\r
2186   vfrImageTag  |\r
2187   vfrLockedTag\r
2188   ;\r
2189 \r
2190 vfrStatementStatTagList :\r
2191   vfrStatementStatTag ( "," vfrStatementStatTag )*\r
2192   ;\r
2193 \r
2194 vfrStatementImage :\r
2195   vfrImageTag\r
2196   ";"\r
2197   ;\r
2198 \r
2199 vfrStatementLocked :\r
2200   vfrLockedTag\r
2201   ";"\r
2202   ;\r
2203 \r
2204 vfrStatementInconsistentIf :\r
2205   << CIfrInconsistentIf IIObj; >>\r
2206   L:InconsistentIf                                     << IIObj.SetLineNo(L->getLine()); >>\r
2207   Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" ","     << IIObj.SetError (_STOSID(S->getText())); >>\r
2208   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
2209   vfrStatementExpression[0]\r
2210   E:EndIf                                              << CRT_END_OP (E); >>\r
2211   ;\r
2212 \r
2213 vfrStatementNoSubmitIf :\r
2214   << CIfrNoSubmitIf NSIObj; >>\r
2215   L:NoSubmitIf                                         << NSIObj.SetLineNo(L->getLine()); >>\r
2216   Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" ","     << NSIObj.SetError (_STOSID(S->getText())); >>\r
2217   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
2218   vfrStatementExpression[0]\r
2219   E:EndIf                                              << CRT_END_OP (E); >>\r
2220   ;\r
2221 \r
2222 vfrStatementDisableIfQuest :\r
2223   << \r
2224     CIfrDisableIf DIObj; \r
2225   >>\r
2226   L:DisableIf                                          << DIObj.SetLineNo(L->getLine()); >>\r
2227   vfrStatementExpression[0] ";"\r
2228   vfrStatementQuestionOptionList\r
2229   E:EndIf                                              << CRT_END_OP (E); >>\r
2230   ;\r
2231 \r
2232 vfrStatementRefresh :\r
2233   << CIfrRefresh RObj; >>\r
2234   L:Refresh                                            << RObj.SetLineNo(L->getLine()); >>\r
2235   Interval "=" I:Number                                << RObj.SetRefreshInterval (_STOU8(I->getText())); >>\r
2236   ;\r
2237 \r
2238 vfrStatementVarstoreDevice :\r
2239   << CIfrVarStoreDevice VDObj; >>\r
2240   L:VarstoreDevice                                     << VDObj.SetLineNo(L->getLine()); >>\r
2241   "=" "STRING_TOKEN" "\(" S:Number "\)" ","            << VDObj.SetDevicePath (_STOSID(S->getText())); >>\r
2242   ;\r
2243 \r
2244 vfrStatementSuppressIfQuest :\r
2245   << CIfrSuppressIf SIObj; >>\r
2246   L:SuppressIf                                         << SIObj.SetLineNo(L->getLine()); >>\r
2247   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
2248   vfrStatementExpression[0] ";"\r
2249   vfrStatementQuestionOptionList\r
2250   E:EndIf                                              << CRT_END_OP (E); >>\r
2251   ;\r
2252 \r
2253 vfrStatementGrayOutIfQuest :\r
2254   << CIfrGrayOutIf GOIObj; >>\r
2255   L:GrayOutIf                                          << GOIObj.SetLineNo(L->getLine()); >>\r
2256   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
2257   vfrStatementExpression[0] ";"\r
2258   vfrStatementQuestionOptionList\r
2259   E:EndIf                                              << CRT_END_OP (E); >>\r
2260   ;\r
2261 \r
2262 vfrStatementOptions :\r
2263   vfrStatementOneOfOption\r
2264   ;\r
2265 \r
2266 vfrStatementOneOfOption :\r
2267   <<\r
2268      EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;\r
2269      CIfrOneOfOption    OOOObj;\r
2270      CHAR8              *VarStoreName = NULL;\r
2271   >>\r
2272   L:Option                                             << OOOObj.SetLineNo(L->getLine()); >>\r
2273   Text  "=" "STRING_TOKEN" "\(" S:Number "\)" ","      << OOOObj.SetOption (_STOSID(S->getText())); >>\r
2274   Value "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] >[Val] ","    \r
2275                                                        << \r
2276                                                           if (gCurrentMinMaxData != NULL) {\r
2277                                                             //set min/max value for oneof opcode\r
2278                                                             UINT64 Step = gCurrentMinMaxData->GetStepData(_GET_CURRQEST_DATATYPE());\r
2279                                                             switch (_GET_CURRQEST_DATATYPE()) {\r
2280                                                             case EFI_IFR_TYPE_NUM_SIZE_64:\r
2281                                                               gCurrentMinMaxData->SetMinMaxStepData(Val.u64, Val.u64, Step);\r
2282                                                               break;\r
2283                                                             case EFI_IFR_TYPE_NUM_SIZE_32:\r
2284                                                               gCurrentMinMaxData->SetMinMaxStepData(Val.u32, Val.u32, (UINT32) Step);\r
2285                                                               break;\r
2286                                                             case EFI_IFR_TYPE_NUM_SIZE_16:\r
2287                                                               gCurrentMinMaxData->SetMinMaxStepData(Val.u16, Val.u16, (UINT16) Step);\r
2288                                                               break;\r
2289                                                             case EFI_IFR_TYPE_NUM_SIZE_8:\r
2290                                                               gCurrentMinMaxData->SetMinMaxStepData(Val.u8, Val.u8, (UINT8) Step);\r
2291                                                               break;\r
2292                                                             default:\r
2293                                                               break;\r
2294                                                             }\r
2295                                                           }\r
2296                                                           OOOObj.SetType (_GET_CURRQEST_DATATYPE()); \r
2297                                                           OOOObj.SetValue (Val); \r
2298                                                        >>\r
2299   F:FLAGS "=" vfrOneOfOptionFlags[OOOObj, F->getLine()]\r
2300                                                        <<\r
2301                                                           _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), L->getLine());\r
2302                                                           if (OOOObj.GetFlags () & 0x10) {\r
2303                                                             _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (\r
2304                                                                       EFI_HII_DEFAULT_CLASS_STANDARD,\r
2305                                                                        _GET_CURRQEST_VARTINFO(),\r
2306                                                                       VarStoreName,\r
2307                                                                       _GET_CURRQEST_DATATYPE (),\r
2308                                                                       Val\r
2309                                                                       ), L->getLine());\r
2310                                                           }\r
2311                                                           if (OOOObj.GetFlags () & 0x20) {\r
2312                                                             _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (\r
2313                                                                       EFI_HII_DEFAULT_CLASS_MANUFACTURING,\r
2314                                                                        _GET_CURRQEST_VARTINFO(),\r
2315                                                                       VarStoreName,\r
2316                                                                       _GET_CURRQEST_DATATYPE (),\r
2317                                                                       Val\r
2318                                                                       ), L->getLine());\r
2319                                                           }\r
2320                                                        >>\r
2321   {\r
2322     "," Key "=" KN:Number                              <<\r
2323                                                          if (!mCompatibleMode) {\r
2324                                                            _PCATCH (VFR_RETURN_UNSUPPORTED, KN);\r
2325                                                          }\r
2326                                                          //\r
2327                                                          // Guid Option Key\r
2328                                                          //\r
2329                                                          CIfrOptionKey IfrOptionKey (\r
2330                                                                          gCurrentQuestion->QUESTION_ID(),\r
2331                                                                          Val,\r
2332                                                                          _STOQID(KN->getText())\r
2333                                                                          );\r
2334                                                          SET_LINE_INFO (IfrOptionKey, KN);\r
2335                                                        >>\r
2336   }\r
2337   (\r
2338     T:"," vfrImageTag                                  << OOOObj.SetScope (1); CRT_END_OP (T); >>\r
2339   )*\r
2340   ";"\r
2341   ;\r
2342 \r
2343 vfrOneOfOptionFlags [CIfrOneOfOption & OOOObj, UINT32 LineNum] :\r
2344   <<\r
2345      UINT8 LFlags = _GET_CURRQEST_DATATYPE();\r
2346      UINT8 HFlags = 0;\r
2347   >>\r
2348   oneofoptionFlagsField[HFlags, LFlags] ( "\|" oneofoptionFlagsField[HFlags, LFlags] )*\r
2349                                                        << _PCATCH(gCurrentQuestion->SetFlags(HFlags), LineNum); >>\r
2350                                                        << _PCATCH(OOOObj.SetFlags(LFlags), LineNum); >>\r
2351   ;\r
2352 \r
2353 oneofoptionFlagsField [UINT8 & HFlags, UINT8 & LFlags] :\r
2354     N:Number                                           << $LFlags |= _STOU8(N->getText()); >>\r
2355   | "OPTION_DEFAULT"                                   << $LFlags |= 0x10; >>\r
2356   | "OPTION_DEFAULT_MFG"                               << $LFlags |= 0x20; >>\r
2357   | InteractiveFlag                                    << $HFlags |= 0x04; >>\r
2358   | NVAccessFlag                                       << $HFlags |= 0x08; >>\r
2359   | ResetRequiredFlag                                  << $HFlags |= 0x10; >>\r
2360   | LateCheckFlag                                      << $HFlags |= 0x20; >>\r
2361   | ManufacturingFlag                                  << $LFlags |= 0x20; >>\r
2362   | DefaultFlag                                        << $LFlags |= 0x10; >>\r
2363   ;\r
2364 \r
2365 vfrStatementLabel :\r
2366   L:Label\r
2367   N:Number                                             <<\r
2368                                                           if (mCompatibleMode) {\r
2369                                                             //\r
2370                                                             // Add end Label for Framework Vfr\r
2371                                                             //\r
2372                                                             CIfrLabel LObj1;\r
2373                                                             LObj1.SetLineNo(L->getLine());\r
2374                                                             LObj1.SetNumber (0xffff);  //add end label for UEFI, label number hardcode 0xffff\r
2375                                                           }\r
2376 \r
2377                                                           {\r
2378                                                             CIfrLabel LObj2;\r
2379                                                             LObj2.SetLineNo(L->getLine());\r
2380                                                             LObj2.SetNumber (_STOU16(N->getText()));\r
2381                                                           }\r
2382                                                        >>\r
2383   ";"\r
2384   ;\r
2385 \r
2386 vfrStatementBanner :\r
2387   << CIfrBanner BObj; >>\r
2388   B:Banner { "," }                                     << BObj.SetLineNo(B->getLine()); >>\r
2389   Title "=" "STRING_TOKEN" "\(" S:Number "\)" ","      << BObj.SetTitle (_STOSID(S->getText())); >>\r
2390   (\r
2391     (\r
2392       Line L:Number ","                                << BObj.SetLine (_STOU16(L->getText())); >>\r
2393       Align\r
2394       (\r
2395           Left                                         << BObj.SetAlign (0); >>\r
2396         | Center                                       << BObj.SetAlign (1); >>\r
2397         | Right                                        << BObj.SetAlign (2); >>\r
2398       ) ";"\r
2399     )\r
2400     |\r
2401     (\r
2402       Timeout "=" T:Number ";"                         << {CIfrTimeout TObj(_STOU16(T->getText()));} >>\r
2403     )\r
2404   )\r
2405   ;\r
2406 \r
2407 //******************************************************************************\r
2408 //\r
2409 // keep some syntax for compatibility but not generate any IFR object\r
2410 //\r
2411 vfrStatementInvalidHidden :\r
2412   L:Hidden               <<\r
2413                             if (!mCompatibleMode) {\r
2414                               _PCATCH (VFR_RETURN_UNSUPPORTED, L);\r
2415                             }\r
2416                          >>\r
2417   Value "=" Number ","\r
2418   Key "=" Number ";"\r
2419   ;\r
2420 \r
2421 vfrStatementInvalidInconsistentIf :\r
2422   InconsistentIf\r
2423   Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" ","\r
2424   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
2425   vfrStatementExpression[0]\r
2426   EndIf\r
2427   ";"\r
2428   ;\r
2429 \r
2430 vfrStatementInvalidInventory :\r
2431   L:Inventory                                      <<\r
2432                                                       if (!mCompatibleMode) {\r
2433                                                         _PCATCH (VFR_RETURN_UNSUPPORTED, L);\r
2434                                                       }\r
2435                                                    >>\r
2436   Help "=" "STRING_TOKEN" "\(" Number "\)" ","\r
2437   Text "=" "STRING_TOKEN" "\(" Number "\)" ","\r
2438   {\r
2439     Text  "=" "STRING_TOKEN" "\(" Number "\)"\r
2440   }\r
2441   ";"\r
2442   ;\r
2443 \r
2444 vfrStatementInvalidSaveRestoreDefaults :\r
2445   (\r
2446    L:Save                                          <<\r
2447                                                       if (!mCompatibleMode) {\r
2448                                                         _PCATCH (VFR_RETURN_UNSUPPORTED, L);\r
2449                                                       }\r
2450                                                    >>\r
2451   |\r
2452    K:Restore                                       <<\r
2453                                                       if (!mCompatibleMode) {\r
2454                                                         _PCATCH (VFR_RETURN_UNSUPPORTED, K);\r
2455                                                       }\r
2456                                                    >>\r
2457   )\r
2458   Defaults ","\r
2459   FormId "=" Number  ","\r
2460   Prompt "=" "STRING_TOKEN" "\(" Number "\)" ","\r
2461   Help   "=" "STRING_TOKEN" "\(" Number "\)"\r
2462   { "," FLAGS "=" flagsField ( "\|" flagsField )* }\r
2463   { "," Key   "=" Number }\r
2464   ";"\r
2465   ;\r
2466 \r
2467 //******************************************************************************\r
2468 //\r
2469 // The syntax of expression\r
2470 //\r
2471 #token Dup("dup")                               "dup"\r
2472 #token VarEqVal("vareqval")                     "vareqval"\r
2473 #token Var("var")                               "var"\r
2474 #token IdEqVal("ideqval")                       "ideqval"\r
2475 #token IdEqId("ideqid")                         "ideqid"\r
2476 #token IdEqValList("ideqvallist")               "ideqvallist"\r
2477 #token QuestionRef("questionref")               "questionref"\r
2478 #token RuleRef("ruleref")                       "ruleref"\r
2479 #token StringRef("stringref")                   "stringref"\r
2480 #token PushThis("pushthis")                     "pushthis"\r
2481 #token Security("security")                     "security"\r
2482 #token True("TRUE")                             "TRUE"\r
2483 #token False("FALSE")                           "FALSE"\r
2484 #token One("ONE")                               "ONE"\r
2485 #token Ones("ONES")                             "ONES"\r
2486 #token Zero("ZERO")                             "ZERO"\r
2487 #token Undefined("UNDEFINED")                   "UNDEFINED"\r
2488 #token Version("VERSION")                       "VERSION"\r
2489 #token Length("length")                         "length"\r
2490 #token AND("AND")                               "AND"\r
2491 #token OR("OR")                                 "OR"\r
2492 #token NOT("NOT")                               "NOT"\r
2493 #token BitWiseNot("~")                          "\~"\r
2494 #token BoolVal("boolval")                       "boolval"\r
2495 #token StringVal("stringval")                   "stringval"\r
2496 #token UnIntVal("unintval")                     "unintval"\r
2497 #token ToUpper("toupper")                       "toupper"\r
2498 #token ToLower("tolower")                       "tolower"\r
2499 #token Match("match")                           "match"\r
2500 #token Catenate("catenate")                     "catenate"\r
2501 #token QuestionRefVal("questionrefval")         "questionrefval"\r
2502 #token StringRefVal("stringrefval")             "stringrefval"\r
2503 \r
2504 //\r
2505 // Root expression extension function called by other function.\r
2506 //\r
2507 vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :\r
2508   << if ($RootLevel == 0) {_CLEAR_SAVED_OPHDR ();} >>\r
2509   andTerm[$RootLevel, $ExpOpCount]\r
2510   (\r
2511     L:OR andTerm[$RootLevel, $ExpOpCou