Sync BaseTool trunk (version r2601) into EDKII BaseTools.
[mirror_edk2.git] / BaseTools / Source / C / VfrCompile / VfrSyntax.g
1 /*++
2 Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
3 This program and the accompanying materials
4 are licensed and made available under the terms and conditions of the BSD License
5 which accompanies this distribution. The full text of the license may be found at
6 http://opensource.org/licenses/bsd-license.php
7
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
10
11 Module Name:
12 VfrSyntax.g
13
14 Abstract:
15
16 --*/
17
18 #header<<
19
20 #include "EfiVfr.h"
21 #include "VfrFormPkg.h"
22 #include "VfrError.h"
23 #include "VfrUtilityLib.h"
24 #include "AToken.h"
25 #include "ATokPtr.h"
26 >>
27
28 <<
29 #include "stdio.h"
30 #include "PBlackBox.h"
31 #include "DLexerBase.h"
32 #include "VfrLexer.h"
33 #include "AToken.h"
34
35 #define GET_LINENO(Obj) ((Obj)->getLine())
36 #define SET_LINE_INFO(Obj, L) {(Obj).SetLineNo((L)->getLine());} while (0)
37 #define CRT_END_OP(Obj) {CIfrEnd EObj; if (Obj != NULL) EObj.SetLineNo ((Obj)->getLine());} while (0)
38
39 typedef ANTLRCommonToken ANTLRToken;
40
41 class CVfrDLGLexer : public VfrLexer
42 {
43 public:
44 CVfrDLGLexer (DLGFileInput *F) : VfrLexer (F) {};
45 INT32 errstd (char *Text)
46 {
47 printf ("unrecognized input '%s'\n", Text);
48 }
49 };
50
51 UINT8
52 VfrParserStart (
53 IN FILE *File,
54 IN INPUT_INFO_TO_SYNTAX *InputInfo
55 )
56 {
57 ParserBlackBox<CVfrDLGLexer, EfiVfrParser, ANTLRToken> VfrParser(File);
58 VfrParser.parser()->SetCompatibleMode (InputInfo->CompatibleMode);
59 VfrParser.parser()->SetOverrideClassGuid (InputInfo->OverrideClassGuid);
60 return VfrParser.parser()->vfrProgram();
61 }
62 >>
63
64 //
65 // Define a lexical class for parsing quoted strings. Basically
66 // starts with a double quote, and ends with a double quote that
67 // is not preceeded with a backslash.
68 //
69 #lexclass QUOTED_STRING
70 #token TheString "~[\"]*\"" << mode (START); >>
71
72 //
73 // Define a lexclass for skipping over C++ style comments
74 //
75 #lexclass CPP_COMMENT
76 #token "~[\n]*" << skip (); >>
77 #token "\n" << skip (); mode (START); newline (); >>
78
79 //
80 // Standard lexclass is START
81 //
82 #lexclass START
83
84 //
85 // Find start of C++ style comments
86 //
87 #token "//" << skip (); mode (CPP_COMMENT); >>
88
89 //
90 // Skip whitespace
91 //
92 #token "[\ \t]" << skip (); >>
93
94 //
95 // Skip over newlines, but count them
96 //
97 #token "\n" << skip (); newline (); >>
98
99 //
100 // Skip over 'extern' in any included .H file
101 //
102 #token "extern" << skip (); mode (CPP_COMMENT); >>
103
104 //
105 // Tokens for the different keywords. Syntax is:
106 // TokenName("ErrorMessageText") "TokenString"
107 // where:
108 // TokenName is the token name (must be capitalized) that is used in the rules
109 // ErrorMessageText is the string the compiler emits when it detects a syntax error
110 // TokenString is the actual matching string used in the user script
111 //
112 #token FormPkgType("formpkgtype") "formpkgtype"
113 #token OpenBrace("{") "\{"
114 #token CloseBrace("}") "\}"
115 #token OpenParen("(") "\("
116 #token CloseParen(")") "\)"
117 #token OpenBracket("[") "\["
118 #token CloseBracket("]") "\]"
119
120 #token LineDefinition "#line\ [0-9]+\ \"~[\"]+\"[\ \t]*\n" << gCVfrErrorHandle.ParseFileScopeRecord (begexpr (), line ()); skip (); newline (); >>
121 #token DevicePath("devicepath") "devicepath"
122 #token FormSet("formset") "formset"
123 #token FormSetId("formsetid") "formsetid"
124 #token EndFormSet("endformset") "endformset"
125 #token Title("title") "title"
126 #token FormId("formid") "formid"
127 #token OneOf("oneof") "oneof"
128 #token EndOneOf("endoneof") "endoneof"
129 #token Prompt("prompt") "prompt"
130 #token OrderedList("orderedlist") "orderedlist"
131 #token MaxContainers("maxcontainers") "maxcontainers"
132 #token EndList("endlist") "endlist"
133 #token EndForm("endform") "endform"
134 #token Form("form") "form"
135 #token FormMap("formmap") "formmap"
136 #token MapTitle("maptitle") "maptitle"
137 #token MapGuid("mapguid") "mapguid"
138 #token Subtitle("subtitle") "subtitle"
139 #token Help("help") "help"
140 #token Text("text") "text"
141 #token Option("option") "option"
142 #token FLAGS("flags") "flags"
143 #token Date("date") "date"
144 #token EndDate("enddate") "enddate"
145 #token Year("year") "year"
146 #token Month("month") "month"
147 #token Day("day") "day"
148 #token Time("time") "time"
149 #token EndTime("endtime") "endtime"
150 #token Hour("hour") "hour"
151 #token Minute("minute") "minute"
152 #token Second("second") "second"
153 #token GrayOutIf("grayoutif") "grayoutif"
154 #token Label("label") "label"
155 #token Timeout("timeout") "timeout"
156 #token Inventory("inventory") "inventory"
157 #token NonNvDataMap("_NON_NV_DATA_MAP") "_NON_NV_DATA_MAP"
158 #token Struct("struct") "struct"
159 #token Boolean("BOOLEAN") "BOOLEAN"
160 #token Uint64("UINT64") "UINT64"
161 #token Uint32("UINT32") "UINT32"
162 #token Uint16("UINT16") "UINT16"
163 #token Char16("CHAR16") "CHAR16"
164 #token Uint8("UINT8") "UINT8"
165 #token Uuid("guid") "guid"
166 #token CheckBox("checkbox") "checkbox"
167 #token EndCheckBox("endcheckbox") "endcheckbox"
168 #token Numeric("numeric") "numeric"
169 #token EndNumeric("endnumeric") "endnumeric"
170 #token Minimum("minimum") "minimum"
171 #token Maximum("maximum") "maximum"
172 #token STEP("step") "step"
173 #token Default("default") "default"
174 #token Password("password") "password"
175 #token EndPassword("endpassword") "endpassword"
176 #token String("string") "string"
177 #token EndString("endstring") "endstring"
178 #token MinSize("minsize") "minsize"
179 #token MaxSize("maxsize") "maxsize"
180 #token Encoding("encoding") "encoding"
181 #token SuppressIf("suppressif") "suppressif"
182 #token DisableIf("disableif") "disableif"
183 #token Hidden("hidden") "hidden"
184 #token Goto("goto") "goto"
185 #token FormSetGuid("formsetguid") "formsetguid"
186 #token InconsistentIf("inconsistentif") "inconsistentif"
187 #token WarningIf("warningif") "warningif"
188 #token NoSubmitIf("nosubmitif") "nosubmitif"
189 #token EndIf("endif") "endif"
190 #token Key("key") "key"
191 #token DefaultFlag("DEFAULT") "DEFAULT"
192 #token ManufacturingFlag("MANUFACTURING") "MANUFACTURING"
193 #token InteractiveFlag("INTERACTIVE") "INTERACTIVE"
194 #token NVAccessFlag("NV_ACCESS") "NV_ACCESS"
195 #token ResetRequiredFlag("RESET_REQUIRED") "RESET_REQUIRED"
196 #token LateCheckFlag("LATE_CHECK") "LATE_CHECK"
197 #token ReadOnlyFlag("READ_ONLY") "READ_ONLY"
198 #token OptionOnlyFlag("OPTIONS_ONLY") "OPTIONS_ONLY"
199 #token Class("class") "class"
200 #token Subclass("subclass") "subclass"
201 #token ClassGuid("classguid") "classguid"
202 #token TypeDef("typedef") "typedef"
203 #token Restore("restore") "restore"
204 #token Save("save") "save"
205 #token Defaults("defaults") "defaults"
206 #token Banner("banner") "banner"
207 #token Align("align") "align"
208 #token Left("left") "left"
209 #token Right("right") "right"
210 #token Center("center") "center"
211 #token Line("line") "line"
212 #token Name("name") "name"
213
214 #token VarId("varid") "varid"
215 #token Question("question") "question"
216 #token QuestionId("questionid") "questionid"
217 #token Image("image") "image"
218 #token Locked("locked") "locked"
219 #token Rule("rule") "rule"
220 #token EndRule("endrule") "endrule"
221 #token Value("value") "value"
222 #token Read("read") "read"
223 #token Write("write") "write"
224 #token ResetButton("resetbutton") "resetbutton"
225 #token EndResetButton("endresetbutton") "endresetbutton"
226 #token DefaultStore("defaultstore") "defaultstore"
227 #token Attribute("attribute") "attribute"
228 #token Varstore("varstore") "varstore"
229 #token Efivarstore("efivarstore") "efivarstore"
230 #token VarSize("varsize") "varsize"
231 #token NameValueVarStore("namevaluevarstore") "namevaluevarstore"
232 #token Action("action") "action"
233 #token Config("config") "config"
234 #token EndAction("endaction") "endaction"
235 #token Refresh("refresh") "refresh"
236 #token Interval("interval") "interval"
237 #token VarstoreDevice("varstoredevice") "varstoredevice"
238 #token GuidOp("guidop") "guidop"
239 #token EndGuidOp("endguidop") "endguidop"
240 #token DataType("datatype") "datatype"
241 #token Data("data") "data"
242 #token Modal("modal") "modal"
243
244 //
245 // Define the class and subclass tokens
246 //
247 #token ClassNonDevice("NONDEVICE") "NON_DEVICE"
248 #token ClassDiskDevice("DISK_DEVICE") "DISK_DEVICE"
249 #token ClassVideoDevice("VIDEO_DEVICE") "VIDEO_DEVICE"
250 #token ClassNetworkDevice("NETWORK_DEVICE") "NETWORK_DEVICE"
251 #token ClassInputDevice("INPUT_DEVICE") "INPUT_DEVICE"
252 #token ClassOnBoardDevice("ONBOARD_DEVICE") "ONBOARD_DEVICE"
253 #token ClassOtherDevice("OTHER_DEVICE") "OTHER_DEVICE"
254
255 #token SubclassSetupApplication("SETUP_APPLICATION") "SETUP_APPLICATION"
256 #token SubclassGeneralApplication("GENERAL_APPLICATION") "GENERAL_APPLICATION"
257 #token SubclassFrontPage("FRONT_PAGE") "FRONT_PAGE"
258 #token SubclassSingleUse("SINGLE_USE") "SINGLE_USE"
259
260 //
261 // This is the overall definition of a VFR form definition script.
262 //
263
264 vfrProgram > [UINT8 Return] :
265 <<
266 mParserStatus = 0;
267 mCIfrOpHdrIndex = 0;
268 mConstantOnlyInExpression = FALSE;
269 >>
270 (
271 vfrPragmaPackDefinition
272 | vfrDataStructDefinition
273 )*
274 vfrFormSetDefinition
275 << $Return = mParserStatus; >>
276 ;
277
278 pragmaPackShowDef :
279 L:"show" << gCVfrVarDataTypeDB.Pack (L->getLine(), VFR_PACK_SHOW); >>
280 ;
281
282 pragmaPackStackDef :
283 <<
284 UINT32 LineNum;
285 UINT8 PackAction;
286 CHAR8 *Identifier = NULL;
287 UINT32 PackNumber = DEFAULT_PACK_ALIGN;
288 >>
289 (
290 L1:"push" << LineNum = L1->getLine(); PackAction = VFR_PACK_PUSH; >>
291 | L2:"pop" << LineNum = L2->getLine(); PackAction = VFR_PACK_POP; >>
292 )
293 {
294 "," ID:StringIdentifier << Identifier = ID->getText(); >>
295 }
296 {
297 "," N:Number << PackAction |= VFR_PACK_ASSIGN; PackNumber = _STOU32(N->getText()); >>
298 }
299 << gCVfrVarDataTypeDB.Pack (LineNum, PackAction, Identifier, PackNumber); >>
300 ;
301
302 pragmaPackNumber :
303 <<
304 UINT32 LineNum;
305 UINT32 PackNumber = DEFAULT_PACK_ALIGN;
306 >>
307 N:Number << LineNum = N->getLine(); PackNumber = _STOU32(N->getText()); >>
308 << gCVfrVarDataTypeDB.Pack (LineNum, VFR_PACK_ASSIGN, NULL, PackNumber); >>
309 ;
310
311 vfrPragmaPackDefinition :
312 "\#pragma" "pack" "\("
313 {
314 pragmaPackShowDef
315 | pragmaPackStackDef
316 | pragmaPackNumber
317 }
318 "\)"
319 ;
320
321 vfrDataStructDefinition :
322 { TypeDef } Struct << gCVfrVarDataTypeDB.DeclareDataTypeBegin (); >>
323 { NonNvDataMap }
324 {
325 N1:StringIdentifier << _PCATCH(gCVfrVarDataTypeDB.SetNewTypeName (N1->getText()), N1); >>
326 }
327 OpenBrace
328 vfrDataStructFields
329 CloseBrace
330 {
331 N2:StringIdentifier << _PCATCH(gCVfrVarDataTypeDB.SetNewTypeName (N2->getText()), N2); >>
332 }
333 ";" << gCVfrVarDataTypeDB.DeclareDataTypeEnd (); >>
334 ;
335
336 vfrDataStructFields :
337 (
338 dataStructField64 |
339 dataStructField32 |
340 dataStructField16 |
341 dataStructField8 |
342 dataStructFieldBool |
343 dataStructFieldString |
344 dataStructFieldDate |
345 dataStructFieldTime |
346 dataStructFieldRef |
347 dataStructFieldUser
348 )*
349 ;
350
351 dataStructField64 :
352 << UINT32 ArrayNum = 0; >>
353 D:"UINT64"
354 N:StringIdentifier
355 {
356 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
357 }
358 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
359 ;
360
361 dataStructField32 :
362 << UINT32 ArrayNum = 0; >>
363 D:"UINT32"
364 N:StringIdentifier
365 {
366 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
367 }
368 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
369 ;
370
371 dataStructField16 :
372 <<
373 UINT32 ArrayNum = 0;
374 >>
375 ("UINT16" | "CHAR16")
376 N:StringIdentifier
377 {
378 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
379 }
380 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), (CHAR8 *) "UINT16", ArrayNum), N); >>
381 ;
382
383 dataStructField8 :
384 << UINT32 ArrayNum = 0; >>
385 D:"UINT8"
386 N:StringIdentifier
387 {
388 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
389 }
390 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
391 ;
392
393 dataStructFieldBool :
394 << UINT32 ArrayNum = 0; >>
395 D:"BOOLEAN"
396 N:StringIdentifier
397 {
398 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
399 }
400 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
401 ;
402
403 dataStructFieldString :
404 << UINT32 ArrayNum = 0; >>
405 D:"EFI_STRING_ID"
406 N:StringIdentifier
407 {
408 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
409 }
410 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
411 ;
412
413 dataStructFieldDate :
414 << UINT32 ArrayNum = 0; >>
415 D:"EFI_HII_DATE"
416 N:StringIdentifier
417 {
418 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
419 }
420 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
421 ;
422
423 dataStructFieldTime :
424 << UINT32 ArrayNum = 0; >>
425 D:"EFI_HII_TIME"
426 N:StringIdentifier
427 {
428 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
429 }
430 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
431 ;
432
433 dataStructFieldRef :
434 << UINT32 ArrayNum = 0; >>
435 D:"EFI_HII_REF"
436 N:StringIdentifier
437 {
438 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
439 }
440 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
441 ;
442
443 dataStructFieldUser :
444 << UINT32 ArrayNum = 0; >>
445 T:StringIdentifier
446 N:StringIdentifier
447 {
448 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
449 }
450 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), T->getText(), ArrayNum), T); >>
451 ;
452
453 //*****************************************************************************
454 //
455 // the syntax of GUID definition
456 //
457 guidSubDefinition [EFI_GUID &Guid] :
458 G4:Number "," G5:Number "," G6:Number "," G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
459 <<
460 Guid.Data4[0] = _STOU8(G4->getText());
461 Guid.Data4[1] = _STOU8(G5->getText());
462 Guid.Data4[2] = _STOU8(G6->getText());
463 Guid.Data4[3] = _STOU8(G7->getText());
464 Guid.Data4[4] = _STOU8(G8->getText());
465 Guid.Data4[5] = _STOU8(G9->getText());
466 Guid.Data4[6] = _STOU8(G10->getText());
467 Guid.Data4[7] = _STOU8(G11->getText());
468 >>
469 ;
470
471 guidDefinition [EFI_GUID &Guid] :
472 OpenBrace
473 G1:Number "," G2:Number "," G3:Number ","
474 <<
475 Guid.Data1 = _STOU32 (G1->getText());
476 Guid.Data2 = _STOU16 (G2->getText());
477 Guid.Data3 = _STOU16 (G3->getText());
478 >>
479 (
480 OpenBrace guidSubDefinition[Guid] CloseBrace
481 | guidSubDefinition[Guid]
482 )
483 CloseBrace
484 ;
485
486 //*****************************************************************************
487 //
488 // the syntax of form set definition
489 //
490 vfrFormSetDefinition :
491 <<
492 EFI_GUID Guid;
493 EFI_GUID DefaultClassGuid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID;
494 EFI_GUID ClassGuid1, ClassGuid2, ClassGuid3;
495 UINT8 ClassGuidNum = 0;
496 CIfrFormSet *FSObj = NULL;
497 UINT16 C, SC;
498 CHAR8* InsertOpcodeAddr = NULL;
499 >>
500 L:FormSet
501 Uuid "=" guidDefinition[Guid] ","
502 Title "=" "STRING_TOKEN" "\(" S1:Number "\)" ","
503 Help "=" "STRING_TOKEN" "\(" S2:Number "\)" ","
504 {
505 ClassGuid "=" guidDefinition[ClassGuid1] << ++ClassGuidNum; >>
506 {
507 "\|" guidDefinition[ClassGuid2] << ++ClassGuidNum; >>
508 }
509 {
510 "\|" guidDefinition[ClassGuid3] << ++ClassGuidNum; >>
511 }
512 ","
513 }
514 <<
515 if (mOverrideClassGuid != NULL && ClassGuidNum >= 3) {
516 _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "Already has 3 class guids, can't add extra class guid!");
517 }
518 switch (ClassGuidNum) {
519 case 0:
520 if (mOverrideClassGuid != NULL) {
521 ClassGuidNum = 2;
522 } else {
523 ClassGuidNum = 1;
524 }
525 FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));
526 FSObj->SetClassGuid(&DefaultClassGuid);
527 if (mOverrideClassGuid != NULL) {
528 FSObj->SetClassGuid(mOverrideClassGuid);
529 }
530 break;
531 case 1:
532 if (mOverrideClassGuid != NULL) {
533 ClassGuidNum ++;
534 }
535 FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));
536 FSObj->SetClassGuid(&ClassGuid1);
537 if (mOverrideClassGuid != NULL) {
538 FSObj->SetClassGuid(mOverrideClassGuid);
539 }
540 break;
541 case 2:
542 if (mOverrideClassGuid != NULL) {
543 ClassGuidNum ++;
544 }
545 FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));
546 FSObj->SetClassGuid(&ClassGuid1);
547 FSObj->SetClassGuid(&ClassGuid2);
548 if (mOverrideClassGuid != NULL) {
549 FSObj->SetClassGuid(mOverrideClassGuid);
550 }
551 break;
552 case 3:
553 FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));
554 FSObj->SetClassGuid(&ClassGuid1);
555 FSObj->SetClassGuid(&ClassGuid2);
556 FSObj->SetClassGuid(&ClassGuid3);
557 break;
558 default:
559 break;
560 }
561
562 SET_LINE_INFO (*FSObj, L);
563 FSObj->SetGuid (&Guid);
564 //
565 // for framework vfr to store formset guid used by varstore and efivarstore
566 //
567 if (mCompatibleMode) {
568 memcpy (&mFormsetGuid, &Guid, sizeof (EFI_GUID));
569 }
570 FSObj->SetFormSetTitle (_STOSID(S1->getText()));
571 FSObj->SetHelp (_STOSID(S2->getText()));
572 >>
573 {
574 FC:Class "=" classDefinition[C] "," << {CIfrClass CObj;SET_LINE_INFO (CObj, FC); CObj.SetClass(C);} >>
575 }
576 {
577 FSC:Subclass "=" subclassDefinition[SC] "," << {CIfrSubClass SCObj; SET_LINE_INFO (SCObj, FSC); SCObj.SetSubClass(SC);} >>
578 }
579 <<
580 _DeclareStandardDefaultStorage (GET_LINENO (L));
581 >>
582 vfrFormSetList
583 E:EndFormSet <<
584 if (mCompatibleMode) {
585 //
586 // declare all undefined varstore and efivarstore
587 //
588 _DeclareDefaultFrameworkVarStore (GET_LINENO(E));
589 }
590
591 //
592 // Declare undefined Question so that they can be used in expression.
593 //
594 if (gCFormPkg.HavePendingUnassigned()) {
595 mParserStatus += gCFormPkg.DeclarePendingQuestion (
596 gCVfrVarDataTypeDB,
597 mCVfrDataStorage,
598 mCVfrQuestionDB,
599 &mFormsetGuid,
600 E->getLine(),
601 &InsertOpcodeAddr
602 );
603 gNeedAdjustOpcode = TRUE;
604 }
605
606 CRT_END_OP (E);
607
608 //
609 // Adjust the pending question position.
610 // Move the position from current to before the end of the last form in the form set.
611 //
612 if (gNeedAdjustOpcode) {
613 gCFormPkg.AdjustDynamicInsertOpcode (
614 mLastFormEndAddr,
615 InsertOpcodeAddr
616 );
617 }
618
619 if (FSObj != NULL) {
620 delete FSObj;
621 }
622 >>
623 ";"
624 ;
625
626 vfrFormSetList :
627 (
628 vfrFormDefinition |
629 vfrFormMapDefinition |
630 vfrStatementImage |
631 vfrStatementVarStoreLinear |
632 vfrStatementVarStoreEfi |
633 vfrStatementVarStoreNameValue |
634 vfrStatementDefaultStore |
635 vfrStatementDisableIfFormSet |
636 vfrStatementSuppressIfFormSet |
637 vfrStatementExtension
638 )*
639 ;
640
641 vfrStatementExtension:
642 <<
643 EFI_GUID Guid;
644 CIfrGuid *GuidObj = NULL;
645 CHAR8 *TypeName = NULL;
646 UINT32 TypeSize = 0;
647 UINT8 *DataBuff = NULL;
648 UINT32 Size = 0;
649 UINT8 Idx = 0;
650 UINT32 LineNum;
651 BOOLEAN IsStruct = FALSE;
652 UINT32 ArrayNum = 0;
653 >>
654 L:GuidOp
655 Uuid "=" guidDefinition[Guid]
656 {"," DataType "="
657 (
658 U64:"UINT64" {OpenBracket AN1:Number CloseBracket <<ArrayNum = _STOU32(AN1->getText());>>}
659 << TypeName = U64->getText(); LineNum = U64->getLine(); >>
660 | U32:"UINT32" {OpenBracket AN2:Number CloseBracket <<ArrayNum = _STOU32(AN2->getText());>>}
661 << TypeName = U32->getText(); LineNum = U32->getLine(); >>
662 | U16:"UINT16" {OpenBracket AN3:Number CloseBracket <<ArrayNum = _STOU32(AN3->getText());>>}
663 << TypeName = U16->getText(); LineNum = U16->getLine(); >>
664 | U8:"UINT8" {OpenBracket AN4:Number CloseBracket <<ArrayNum = _STOU32(AN4->getText());>>}
665 << TypeName = U8->getText(); LineNum = U8->getLine(); >>
666 | BL:"BOOLEAN" {OpenBracket AN5:Number CloseBracket <<ArrayNum = _STOU32(AN5->getText());>>}
667 << TypeName = BL->getText(); LineNum = BL->getLine(); >>
668 | SI:"EFI_STRING_ID" {OpenBracket AN6:Number CloseBracket <<ArrayNum = _STOU32(AN6->getText());>>}
669 << TypeName = SI->getText(); LineNum = SI->getLine(); >>
670 | D:"EFI_HII_DATE" {OpenBracket AN7:Number CloseBracket <<ArrayNum = _STOU32(AN7->getText());>>}
671 << TypeName = D->getText(); LineNum = D->getLine(); IsStruct = TRUE;>>
672 | T:"EFI_HII_TIME" {OpenBracket AN8:Number CloseBracket <<ArrayNum = _STOU32(AN8->getText());>>}
673 << TypeName = T->getText(); LineNum = T->getLine(); IsStruct = TRUE;>>
674 | R:"EFI_HII_REF" {OpenBracket AN9:Number CloseBracket <<ArrayNum = _STOU32(AN9->getText());>>}
675 << TypeName = R->getText(); LineNum = R->getLine(); IsStruct = TRUE;>>
676 | TN:StringIdentifier {OpenBracket AN10:Number CloseBracket <<ArrayNum = _STOU32(AN10->getText());>>}
677 << TypeName = TN->getText(); LineNum = TN->getLine(); IsStruct = TRUE;>>
678 )
679 <<
680 _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &TypeSize), LineNum);
681 if (ArrayNum > 0) {
682 Size = TypeSize*ArrayNum;
683 } else {
684 Size = TypeSize;
685 }
686 if (Size > (128 - sizeof (EFI_IFR_GUID))) return;
687 DataBuff = (UINT8 *)malloc(Size);
688 for (Idx = 0; Idx < Size; Idx++) {
689 DataBuff[Idx] = 0;
690 }
691 >>
692 vfrExtensionData [DataBuff, Size, TypeName, TypeSize, IsStruct, ArrayNum]
693 }
694 <<
695 {
696 GuidObj = new CIfrGuid(Size);
697 if (GuidObj != NULL) {
698 GuidObj->SetLineNo(L->getLine());
699 GuidObj->SetGuid (&Guid);
700 }
701 }
702 if (TypeName != NULL) {
703 GuidObj->SetData(DataBuff, Size);
704 }
705 >>
706 {","
707 (
708 vfrStatementExtension
709 )*
710 E:EndGuidOp << GuidObj->SetScope(1); CRT_END_OP (E); >>
711 }
712 <<
713 if (GuidObj != NULL) delete GuidObj;
714 if (DataBuff != NULL) free(DataBuff);
715 >>
716 ";"
717 ;
718
719 vfrExtensionData[UINT8 *DataBuff, UINT32 Size, CHAR8 *TypeName, UINT32 TypeSize, BOOLEAN IsStruct, UINT32 ArrayNum]:
720 <<
721 CHAR8 *TFName = NULL;
722 UINT32 ArrayIdx = 0;
723 UINT16 FieldOffset;
724 UINT8 FieldType;
725 UINT32 FieldSize;
726 UINT64 Data_U64 = 0;
727 UINT32 Data_U32 = 0;
728 UINT16 Data_U16 = 0;
729 UINT8 Data_U8 = 0;
730 BOOLEAN Data_BL = 0;
731 EFI_STRING_ID Data_SID = 0;
732 BOOLEAN IsArray = FALSE;
733 UINT8 *ByteOffset = NULL;
734 >>
735 (
736 ("," "data" {OpenBracket IDX1:Number CloseBracket <<IsArray = TRUE;>>}
737 <<
738 ArrayIdx = 0;
739 if (IsArray == TRUE) {
740 ArrayIdx = _STOU8(IDX1->getText());
741 if (ArrayIdx >= ArrayNum) return;
742 IsArray = FALSE;
743 }
744 ByteOffset = DataBuff + (ArrayIdx * TypeSize);
745 if (IsStruct == TRUE) {
746 _STRCAT(&TFName, TypeName);
747 }
748 >>
749 ("." FN:StringIdentifier
750 <<
751 if (IsStruct == TRUE) {
752 _STRCAT(&TFName, ".");
753 _STRCAT(&TFName, FN->getText());
754 }
755 >>
756 {
757 OpenBracket IDX2:Number CloseBracket
758 <<
759 if (IsStruct == TRUE) {
760 _STRCAT(&TFName, "[");
761 _STRCAT(&TFName, IDX2->getText());
762 _STRCAT(&TFName, "]");
763 }
764 >>
765 }
766 )*
767 "=" RD:Number
768 <<
769 if (IsStruct == FALSE) {
770 if (strcmp ("UINT64", TypeName) == 0) {
771 Data_U64 = _STOU64(RD->getText());
772 memcpy (ByteOffset, &Data_U64, TypeSize);
773 }else if (strcmp ("UINT32", TypeName) == 0) {
774 Data_U32 = _STOU32(RD->getText());
775 memcpy (ByteOffset, &Data_U32, TypeSize);
776 }else if (strcmp ("UINT16", TypeName) == 0) {
777 Data_U16 = _STOU16(RD->getText());
778 memcpy (ByteOffset, &Data_U16, TypeSize);
779 }else if (strcmp ("UINT8", TypeName) == 0) {
780 Data_U8 = _STOU8(RD->getText());
781 memcpy (ByteOffset, &Data_U8, TypeSize);
782 }else if (strcmp ("BOOLEAN", TypeName)== 0) {
783 Data_BL = _STOU8(RD->getText());
784 memcpy (ByteOffset, &Data_BL, TypeSize);
785 }else if (strcmp ("EFI_STRING_ID", TypeName) == 0) {
786 Data_SID = _STOSID(RD->getText());
787 memcpy (ByteOffset, &Data_SID, TypeSize);
788 }
789 } else {
790 gCVfrVarDataTypeDB.GetDataFieldInfo(TFName, FieldOffset, FieldType, FieldSize);
791 switch (FieldType) {
792 case EFI_IFR_TYPE_NUM_SIZE_8:
793 Data_U8 = _STOU8(RD->getText());
794 memcpy (ByteOffset + FieldOffset, &Data_U8, FieldSize);
795 break;
796 case EFI_IFR_TYPE_NUM_SIZE_16:
797 Data_U16 = _STOU16(RD->getText());
798 memcpy (ByteOffset + FieldOffset, &Data_U16, FieldSize);
799 break;
800 case EFI_IFR_TYPE_NUM_SIZE_32:
801 Data_U32 = _STOU32(RD->getText());
802 memcpy (ByteOffset + FieldOffset, &Data_U32, FieldSize);
803 break;
804 case EFI_IFR_TYPE_NUM_SIZE_64:
805 Data_U64 = _STOU64(RD->getText());
806 memcpy (ByteOffset + FieldOffset, &Data_U64, FieldSize);
807 break;
808 case EFI_IFR_TYPE_BOOLEAN:
809 Data_BL = _STOU8(RD->getText());
810 memcpy (ByteOffset + FieldOffset, &Data_BL, FieldSize);
811 break;
812 case EFI_IFR_TYPE_STRING:
813 Data_SID = _STOSID(RD->getText());
814 memcpy (ByteOffset + FieldOffset, &Data_SID, FieldSize);
815 break;
816 default:
817 break;
818 }
819 }
820 if (TFName != NULL) { delete TFName; TFName = NULL; }
821 >>
822 )*
823 )
824 ;
825
826
827 vfrStatementDefaultStore :
828 << UINT16 DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD; >>
829 D:DefaultStore N:StringIdentifier ","
830 Prompt "=" "STRING_TOKEN" "\(" S:Number "\)"
831 {
832 "," Attribute "=" A:Number << DefaultId = _STOU16(A->getText()); >>
833 }
834 <<
835 if (mCVfrDefaultStore.DefaultIdRegistered (DefaultId) == FALSE) {
836 CIfrDefaultStore DSObj;
837 _PCATCH(mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), N->getText(), _STOSID(S->getText()), DefaultId)), D->getLine();
838 DSObj.SetLineNo(D->getLine());
839 DSObj.SetDefaultName (_STOSID(S->getText()));
840 DSObj.SetDefaultId (DefaultId);
841 } else {
842 _PCATCH(mCVfrDefaultStore.ReRegisterDefaultStoreById (DefaultId, N->getText(), _STOSID(S->getText()))), D->getLine();
843 }
844 >>
845 ";"
846 ;
847
848 vfrStatementVarStoreLinear :
849 <<
850 EFI_GUID Guid;
851 CIfrVarStore VSObj;
852 CHAR8 *TypeName;
853 CHAR8 *StoreName;
854 UINT32 LineNum;
855 EFI_VARSTORE_ID VarStoreId = EFI_VARSTORE_ID_INVALID;
856 UINT32 Size;
857 >>
858 V:Varstore << VSObj.SetLineNo(V->getLine()); >>
859 (
860 TN:StringIdentifier "," << TypeName = TN->getText(); LineNum = TN->getLine(); >>
861 | U8:"UINT8" "," << TypeName = U8->getText(); LineNum = U8->getLine(); >>
862 | U16:"UINT16" "," << TypeName = U16->getText(); LineNum = U16->getLine(); >>
863 | C16:"CHAR16" "," << TypeName = (CHAR8 *) "UINT16"; LineNum = C16->getLine(); >>
864 | U32:"UINT32" "," << TypeName = U32->getText(); LineNum = U32->getLine(); >>
865 | U64:"UINT64" "," << TypeName = U64->getText(); LineNum = U64->getLine(); >>
866 | D:"EFI_HII_DATE" "," << TypeName = D->getText(); LineNum = D->getLine(); >>
867 | T:"EFI_HII_TIME" "," << TypeName = T->getText(); LineNum = T->getLine(); >>
868 | R:"EFI_HII_REF" "," << TypeName = R->getText(); LineNum = R->getLine(); >>
869 )
870 { Key "=" FID:Number "," << // Key is used to assign Varid in Framework VFR but no use in UEFI2.1 VFR
871 if (mCompatibleMode) {
872 VarStoreId = _STOU16(FID->getText());
873 }
874 >>
875 }
876 {
877 VarId "=" ID:Number "," <<
878 _PCATCH(
879 (INTN)(VarStoreId = _STOU16(ID->getText())) != 0,
880 (INTN)TRUE,
881 ID,
882 "varid 0 is not allowed."
883 );
884 >>
885 }
886 Name "=" SN:StringIdentifier ","
887 Uuid "=" guidDefinition[Guid]
888 <<
889 if (mCompatibleMode) {
890 StoreName = TypeName;
891 } else {
892 StoreName = SN->getText();
893 }
894 _PCATCH(mCVfrDataStorage.DeclareBufferVarStore (
895 StoreName,
896 &Guid,
897 &gCVfrVarDataTypeDB,
898 TypeName,
899 VarStoreId
900 ), LineNum);
901 VSObj.SetGuid (&Guid);
902 _PCATCH(mCVfrDataStorage.GetVarStoreId(StoreName, &VarStoreId, &Guid), SN);
903 VSObj.SetVarStoreId (VarStoreId);
904 _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);
905 VSObj.SetSize ((UINT16) Size);
906 VSObj.SetName (SN->getText());
907 >>
908 ";"
909 ;
910
911 vfrStatementVarStoreEfi :
912 <<
913 BOOLEAN IsUEFI23EfiVarstore = TRUE;
914 EFI_GUID Guid;
915 CIfrVarStoreEfi VSEObj;
916 EFI_VARSTORE_ID VarStoreId = EFI_VARSTORE_ID_INVALID;
917 UINT32 Attr = 0;
918 UINT32 Size;
919 CHAR8 *TypeName;
920 UINT32 LineNum;
921 CHAR8 *StoreName = NULL;
922 >>
923 E:Efivarstore << VSEObj.SetLineNo(E->getLine()); >>
924 (
925 TN:StringIdentifier "," << TypeName = TN->getText(); LineNum = TN->getLine(); >>
926 | U8:"UINT8" "," << TypeName = U8->getText(); LineNum = U8->getLine(); >>
927 | U16:"UINT16" "," << TypeName = U16->getText(); LineNum = U16->getLine(); >>
928 | C16:"CHAR16" "," << TypeName = (CHAR8 *) "UINT16"; LineNum = C16->getLine(); >>
929 | U32:"UINT32" "," << TypeName = U32->getText(); LineNum = U32->getLine(); >>
930 | U64:"UINT64" "," << TypeName = U64->getText(); LineNum = U64->getLine(); >>
931 | D:"EFI_HII_DATE" "," << TypeName = D->getText(); LineNum = D->getLine(); >>
932 | T:"EFI_HII_TIME" "," << TypeName = T->getText(); LineNum = T->getLine(); >>
933 | R:"EFI_HII_REF" "," << TypeName = R->getText(); LineNum = R->getLine(); >>
934 )
935 {
936 VarId "=" ID:Number "," <<
937 _PCATCH(
938 (INTN)(VarStoreId = _STOU16(ID->getText())) != 0,
939 (INTN)TRUE,
940 ID,
941 "varid 0 is not allowed."
942 );
943 >>
944 }
945 Attribute "=" vfrVarStoreEfiAttr[Attr] ( "\|" vfrVarStoreEfiAttr[Attr] )* ","
946 << VSEObj.SetAttributes (Attr); >>
947
948 (
949 Name "=" SN:StringIdentifier "," << StoreName = SN->getText(); >>
950 |
951 Name "=" "STRING_TOKEN" "\(" VN:Number "\)" ","
952 VarSize "=" N:Number "," <<
953 IsUEFI23EfiVarstore = FALSE;
954 StoreName = gCVfrStringDB.GetVarStoreNameFormStringId(_STOSID(VN->getText()));
955 if (StoreName == NULL) {
956 _PCATCH (VFR_RETURN_UNSUPPORTED, VN->getLine(), "Can't get varstore name for this StringId!");
957 }
958 Size = _STOU32(N->getText());
959 switch (Size) {
960 case 1:
961 TypeName = (CHAR8 *) "UINT8";
962 break;
963 case 2:
964 TypeName = (CHAR8 *) "UINT16";
965 break;
966 case 4:
967 TypeName = (CHAR8 *) "UINT32";
968 break;
969 case 8:
970 TypeName = (CHAR8 *) "UINT64";
971 break;
972 default:
973 _PCATCH (VFR_RETURN_UNSUPPORTED, N);
974 break;
975 }
976 >>
977 )
978
979 Uuid "=" guidDefinition[Guid] <<
980 if (IsUEFI23EfiVarstore) {
981 _PCATCH(mCVfrDataStorage.DeclareBufferVarStore (
982 StoreName,
983 &Guid,
984 &gCVfrVarDataTypeDB,
985 TypeName,
986 VarStoreId
987 ), LineNum);
988 _PCATCH(mCVfrDataStorage.GetVarStoreId(StoreName, &VarStoreId, &Guid), SN);
989 _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);
990 } else {
991 _PCATCH(mCVfrDataStorage.DeclareBufferVarStore (
992 TN->getText(),
993 &Guid,
994 &gCVfrVarDataTypeDB,
995 TypeName,
996 VarStoreId
997 ), LineNum);
998 _PCATCH(mCVfrDataStorage.GetVarStoreId(TN->getText(), &VarStoreId, &Guid), VN);
999 _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), N->getLine());
1000 }
1001 VSEObj.SetGuid (&Guid);
1002 VSEObj.SetVarStoreId (VarStoreId);
1003
1004 VSEObj.SetSize ((UINT16) Size);
1005 VSEObj.SetName (StoreName);
1006 if (IsUEFI23EfiVarstore == FALSE && StoreName != NULL) {
1007 delete StoreName;
1008 }
1009 >>
1010 ";"
1011 ;
1012
1013 vfrVarStoreEfiAttr [UINT32 & Attr] :
1014 N:Number << $Attr |= _STOU32(N->getText()); >>
1015 ;
1016
1017 vfrStatementVarStoreNameValue :
1018 <<
1019 EFI_GUID Guid;
1020 CIfrVarStoreNameValue VSNVObj;
1021 EFI_VARSTORE_ID VarStoreId;
1022 >>
1023 L:NameValueVarStore << VSNVObj.SetLineNo(L->getLine()); >>
1024 SN:StringIdentifier "," << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreBegin (SN->getText()), SN); >>
1025 (
1026 Name "=" "STRING_TOKEN" "\(" N:Number "\)" "," << _PCATCH(mCVfrDataStorage.NameTableAddItem (_STOSID(N->getText())), SN); >>
1027 )+
1028 Uuid "=" guidDefinition[Guid] << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreEnd (&Guid), SN); >>
1029 <<
1030 VSNVObj.SetGuid (&Guid);
1031 _PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId, &Guid), SN);
1032 VSNVObj.SetVarStoreId (VarStoreId);
1033 >>
1034 ";"
1035 ;
1036
1037 //
1038 // keep classDeinition and validClassNames for compatibility but not generate
1039 // any IFR object
1040 //
1041 classDefinition[UINT16 & Class] :
1042 << $Class = 0; >>
1043 validClassNames[$Class] ( "\|" validClassNames[$Class] )*
1044 ;
1045
1046 validClassNames[UINT16 & Class] :
1047 ClassNonDevice << $Class |= EFI_NON_DEVICE_CLASS; >>
1048 | ClassDiskDevice << $Class |= EFI_DISK_DEVICE_CLASS; >>
1049 | ClassVideoDevice << $Class |= EFI_VIDEO_DEVICE_CLASS; >>
1050 | ClassNetworkDevice << $Class |= EFI_NETWORK_DEVICE_CLASS; >>
1051 | ClassInputDevice << $Class |= EFI_INPUT_DEVICE_CLASS; >>
1052 | ClassOnBoardDevice << $Class |= EFI_ON_BOARD_DEVICE_CLASS; >>
1053 | ClassOtherDevice << $Class |= EFI_OTHER_DEVICE_CLASS; >>
1054 | N:Number << $Class |= _STOU16(N->getText()); >>
1055 ;
1056
1057 subclassDefinition[UINT16 & SubClass] :
1058 << $SubClass = 0; >>
1059 SubclassSetupApplication << $SubClass |= EFI_SETUP_APPLICATION_SUBCLASS; >>
1060 | SubclassGeneralApplication << $SubClass |= EFI_GENERAL_APPLICATION_SUBCLASS; >>
1061 | SubclassFrontPage << $SubClass |= EFI_FRONT_PAGE_SUBCLASS; >>
1062 | SubclassSingleUse << $SubClass |= EFI_SINGLE_USE_SUBCLASS; >>
1063 | N:Number << $SubClass |= _STOU16(N->getText()); >>
1064 ;
1065
1066 vfrStatementDisableIfFormSet :
1067 <<
1068 CIfrDisableIf DIObj;
1069 mConstantOnlyInExpression = TRUE;
1070 >>
1071 D:DisableIf << DIObj.SetLineNo(D->getLine()); >>
1072 vfrStatementExpression[0] ";" << mConstantOnlyInExpression = FALSE; >>
1073 vfrFormSetList
1074 E:EndIf << CRT_END_OP (E); >>
1075 ";"
1076 ;
1077
1078 vfrStatementSuppressIfFormSet :
1079 << CIfrSuppressIf SIObj;>>
1080 L:SuppressIf <<
1081 if (mCompatibleMode) {
1082 _PCATCH (VFR_RETURN_UNSUPPORTED, L);
1083 }
1084 SIObj.SetLineNo(L->getLine());
1085 >>
1086 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
1087 vfrStatementExpression[0] ";"
1088 vfrFormSetList
1089 E: EndIf
1090 ";" << CRT_END_OP (E); >>
1091 ;
1092
1093 //*****************************************************************************
1094 //
1095 // the syntax of question header and statement header
1096 //
1097 vfrStatementHeader[CIfrStatementHeader *SHObj] :
1098 Prompt "=" "STRING_TOKEN" "\(" S1:Number "\)" "," << $SHObj->SetPrompt (_STOSID(S1->getText())); >>
1099 Help "=" "STRING_TOKEN" "\(" S2:Number "\)" << $SHObj->SetHelp (_STOSID(S2->getText())); >>
1100 ;
1101
1102 vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_NORMAL]:
1103 <<
1104 EFI_VARSTORE_INFO Info;
1105 Info.mVarType = EFI_IFR_TYPE_OTHER;
1106 Info.mVarTotalSize = 0;
1107 Info.mInfo.mVarOffset = EFI_VAROFFSET_INVALID;
1108 Info.mVarStoreId = EFI_VARSTORE_ID_INVALID;
1109 EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
1110 CHAR8 *QName = NULL;
1111 CHAR8 *VarIdStr = NULL;
1112 mUsedDefaultCount = 0;
1113 >>
1114 {
1115 Name "=" QN:StringIdentifier "," <<
1116 QName = QN->getText();
1117 _PCATCH(mCVfrQuestionDB.FindQuestion (QName), VFR_RETURN_UNDEFINED, QN, "has already been used please used anther name");
1118 >>
1119 }
1120 { V:VarId "=" vfrStorageVarId[Info, VarIdStr] "," }
1121 {
1122 QuestionId "=" ID:Number "," <<
1123 QId = _STOQID(ID->getText());
1124 _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used please assign another number");
1125 >>
1126 }
1127 <<
1128 switch (QType) {
1129 case QUESTION_NORMAL:
1130 mCVfrQuestionDB.RegisterQuestion (QName, VarIdStr, QId);
1131 break;
1132 case QUESTION_DATE:
1133 mCVfrQuestionDB.RegisterNewDateQuestion (QName, VarIdStr, QId);
1134 break;
1135 case QUESTION_TIME:
1136 mCVfrQuestionDB.RegisterNewTimeQuestion (QName, VarIdStr, QId);
1137 break;
1138 case QUESTION_REF:
1139 //
1140 // VarIdStr != NULL stand for question with storagae.
1141 //
1142 if (VarIdStr != NULL) {
1143 mCVfrQuestionDB.RegisterRefQuestion (QName, VarIdStr, QId);
1144 } else {
1145 mCVfrQuestionDB.RegisterQuestion (QName, NULL, QId);
1146 }
1147 break;
1148 default:
1149 _PCATCH(VFR_RETURN_FATAL_ERROR);
1150 }
1151 $QHObj.SetQuestionId (QId);
1152 if (VarIdStr != NULL) {
1153 $QHObj.SetVarStoreInfo (&Info);
1154 }
1155 >>
1156 vfrStatementHeader[&$QHObj]
1157 <<
1158 if (VarIdStr != NULL) {
1159 delete VarIdStr;
1160 }
1161 _SAVE_CURRQEST_VARINFO (Info);
1162 >>
1163 ;
1164
1165 questionheaderFlagsField[UINT8 & Flags] :
1166 ReadOnlyFlag << $Flags |= 0x01; >>
1167 | InteractiveFlag << $Flags |= 0x04; >>
1168 | ResetRequiredFlag << $Flags |= 0x10; >>
1169 | OptionOnlyFlag << $Flags |= 0x80; >>
1170 | NVAccessFlag
1171 | LateCheckFlag
1172 ;
1173
1174 vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr, BOOLEAN CheckFlag = TRUE] :
1175 <<
1176 UINT32 Idx;
1177 UINT32 LineNo;
1178 EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
1179 CHAR8 *VarIdStr = NULL;
1180 CHAR8 *VarStr = NULL;
1181 CHAR8 *SName = NULL;
1182 CHAR8 *TName = NULL;
1183 EFI_VFR_RETURN_CODE VfrReturnCode = VFR_RETURN_SUCCESS;
1184 EFI_IFR_TYPE_VALUE Dummy = gZeroEfiIfrTypeValue;
1185 EFI_GUID *VarGuid = NULL;
1186 >>
1187 (
1188 SN1:StringIdentifier << SName = SN1->getText(); _STRCAT(&VarIdStr, SN1->getText()); >>
1189 OpenBracket I1:Number CloseBracket <<
1190 Idx = _STOU32(I1->getText());
1191 _STRCAT(&VarIdStr, "[");
1192 _STRCAT(&VarIdStr, I1->getText());
1193 _STRCAT(&VarIdStr, "]");
1194 >>
1195 <<
1196 VfrReturnCode = mCVfrDataStorage.GetVarStoreId(SName, &$Info.mVarStoreId);
1197 if (mCompatibleMode && VfrReturnCode == VFR_RETURN_UNDEFINED) {
1198 mCVfrDataStorage.DeclareBufferVarStore (
1199 SName,
1200 &mFormsetGuid,
1201 &gCVfrVarDataTypeDB,
1202 SName,
1203 EFI_VARSTORE_ID_INVALID,
1204 FALSE
1205 );
1206 VfrReturnCode = mCVfrDataStorage.GetVarStoreId(SName, &$Info.mVarStoreId, &mFormsetGuid);
1207 }
1208 if (CheckFlag || VfrReturnCode == VFR_RETURN_SUCCESS) {
1209 _PCATCH(VfrReturnCode, SN1);
1210 _PCATCH(mCVfrDataStorage.GetNameVarStoreInfo (&$Info, Idx), SN1);
1211 }
1212
1213 QuestVarIdStr = VarIdStr;
1214 >>
1215 )
1216 |
1217 (
1218 SN2:StringIdentifier << SName = SN2->getText(); _STRCAT(&VarIdStr, SName); >>
1219 <<
1220 VfrReturnCode = mCVfrDataStorage.GetVarStoreId(SName, &$Info.mVarStoreId);
1221 if (mCompatibleMode && VfrReturnCode == VFR_RETURN_UNDEFINED) {
1222 mCVfrDataStorage.DeclareBufferVarStore (
1223 SName,
1224 &mFormsetGuid,
1225 &gCVfrVarDataTypeDB,
1226 SName,
1227 EFI_VARSTORE_ID_INVALID,
1228 FALSE
1229 );
1230 VfrReturnCode = mCVfrDataStorage.GetVarStoreId(SName, &$Info.mVarStoreId, &mFormsetGuid);
1231 }
1232 if (CheckFlag || VfrReturnCode == VFR_RETURN_SUCCESS) {
1233 _PCATCH(VfrReturnCode, SN2);
1234 VarStoreType = mCVfrDataStorage.GetVarStoreType ($Info.mVarStoreId);
1235 if (VarStoreType == EFI_VFR_VARSTORE_BUFFER) {
1236 _PCATCH(mCVfrDataStorage.GetBufferVarStoreDataTypeName(Info.mVarStoreId, &TName), SN2);
1237 _STRCAT(&VarStr, TName);
1238 }
1239 }
1240 >>
1241
1242 (
1243 "." <<
1244 if (CheckFlag || VfrReturnCode == VFR_RETURN_SUCCESS) {
1245 _PCATCH(((VarStoreType != EFI_VFR_VARSTORE_BUFFER) ? VFR_RETURN_EFIVARSTORE_USE_ERROR : VFR_RETURN_SUCCESS), SN2);
1246 }
1247 _STRCAT(&VarIdStr, "."); _STRCAT(&VarStr, ".");
1248 >>
1249 SF:StringIdentifier << _STRCAT(&VarIdStr, SF->getText()); _STRCAT(&VarStr, SF->getText()); >>
1250 {
1251 OpenBracket I2:Number CloseBracket <<
1252 Idx = _STOU32(I2->getText());
1253 if (mCompatibleMode) Idx --;
1254 if (Idx > 0) {
1255 //
1256 // Idx == 0, [0] can be ignored.
1257 // Array[0] is same to Array for unify the varid name to cover [0]
1258 //
1259 _STRCAT(&VarIdStr, "[");
1260 _STRCAT(&VarIdStr, I2->getText());
1261 _STRCAT(&VarIdStr, "]");
1262 }
1263 _STRCAT(&VarStr, "[");
1264 _STRCAT(&VarStr, I2->getText());
1265 _STRCAT(&VarStr, "]");
1266 >>
1267 }
1268 )* <<
1269 switch (VarStoreType) {
1270 case EFI_VFR_VARSTORE_EFI:
1271 _PCATCH(mCVfrDataStorage.GetEfiVarStoreInfo (&$Info), SN2);
1272 break;
1273 case EFI_VFR_VARSTORE_BUFFER:
1274 _PCATCH(gCVfrVarDataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType, $Info.mVarTotalSize), SN2->getLine(), VarStr);
1275 VarGuid = mCVfrDataStorage.GetVarStoreGuid($Info.mVarStoreId);
1276 _PCATCH((EFI_VFR_RETURN_CODE)gCVfrBufferConfig.Register (
1277 SName,
1278 VarGuid,
1279 NULL),
1280 SN2->getLine());
1281 _PCATCH((EFI_VFR_RETURN_CODE)gCVfrBufferConfig.Write (
1282 'a',
1283 SName,
1284 VarGuid,
1285 NULL,
1286 $Info.mVarType,
1287 $Info.mInfo.mVarOffset,
1288 $Info.mVarTotalSize,
1289 Dummy),
1290 SN2->getLine());
1291 break;
1292 case EFI_VFR_VARSTORE_NAME:
1293 default: break;
1294 }
1295
1296 QuestVarIdStr = VarIdStr;
1297 if (VarStr != NULL) {delete VarStr;}
1298 >>
1299 )
1300 ;
1301
1302 vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, CHAR8 *&VarIdStr, UINT32 &LineNo] :
1303 <<
1304 UINT32 Idx;
1305 VarIdStr = NULL; LineNo = 0;
1306 >>
1307 (
1308 SN1:StringIdentifier << _STRCAT(&VarIdStr, SN1->getText()); LineNo = SN1->getLine(); >>
1309 OpenBracket I1:Number CloseBracket <<
1310 _STRCAT(&VarIdStr, "[");
1311 _STRCAT(&VarIdStr, I1->getText());
1312 _STRCAT(&VarIdStr, "]");
1313 mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask);
1314 if (mConstantOnlyInExpression) {
1315 _PCATCH(VFR_RETURN_CONSTANT_ONLY, LineNo);
1316 }
1317 >>
1318 )
1319 |
1320 (
1321 SN2:StringIdentifier << _STRCAT (&VarIdStr, SN2->getText()); LineNo = SN2->getLine(); >>
1322 (
1323 "." <<
1324 _STRCAT (&VarIdStr, ".");
1325 if (mConstantOnlyInExpression) {
1326 _PCATCH(VFR_RETURN_CONSTANT_ONLY, LineNo);
1327 }
1328 >>
1329 SF:StringIdentifier << _STRCAT (&VarIdStr, SF->getText()); >>
1330 {
1331 OpenBracket I2:Number CloseBracket <<
1332 Idx = _STOU32(I2->getText());
1333 if (mCompatibleMode) Idx --;
1334 if (Idx > 0) {
1335 //
1336 // Idx == 0, [0] can be ignored.
1337 // Array[0] is same to Array
1338 //
1339 _STRCAT(&VarIdStr, "[");
1340 _STRCAT(&VarIdStr, I2->getText());
1341 _STRCAT(&VarIdStr, "]");
1342 }
1343 >>
1344 }
1345 )*
1346 << mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask); >>
1347 )
1348 ;
1349
1350 vfrConstantValueField[UINT8 Type] > [EFI_IFR_TYPE_VALUE Value] :
1351 <<
1352 EFI_GUID Guid;
1353 >>
1354 N1:Number <<
1355 switch ($Type) {
1356 case EFI_IFR_TYPE_NUM_SIZE_8 :
1357 $Value.u8 = _STOU8(N1->getText());
1358 break;
1359 case EFI_IFR_TYPE_NUM_SIZE_16 :
1360 $Value.u16 = _STOU16(N1->getText());
1361 break;
1362 case EFI_IFR_TYPE_NUM_SIZE_32 :
1363 $Value.u32 = _STOU32(N1->getText());
1364 break;
1365 case EFI_IFR_TYPE_NUM_SIZE_64 :
1366 $Value.u64 = _STOU64(N1->getText());
1367 break;
1368 case EFI_IFR_TYPE_BOOLEAN :
1369 $Value.b = _STOU8(N1->getText());
1370 break;
1371 case EFI_IFR_TYPE_STRING :
1372 $Value.string = _STOU16(N1->getText());
1373 break;
1374 case EFI_IFR_TYPE_TIME :
1375 case EFI_IFR_TYPE_DATE :
1376 case EFI_IFR_TYPE_REF :
1377 default :
1378 break;
1379 }
1380 >>
1381 | B1:True << $Value.b = TRUE; >>
1382 | B2:False << $Value.b = FALSE; >>
1383 | O1:One << $Value.u8 = _STOU8(O1->getText()); >>
1384 | O2:Ones << $Value.u64 = _STOU64(O2->getText()); >>
1385 | Z:Zero << $Value.u8 = _STOU8(Z->getText()); >>
1386 | HOUR:Number ":" MINUTE:Number ":" SECOND:Number << $Value.time = _STOT(HOUR->getText(), MINUTE->getText(), SECOND->getText()); >>
1387 | YEAR:Number "/" MONTH:Number "/" DAY:Number << $Value.date = _STOD(YEAR->getText(), MONTH->getText(), DAY->getText()); >>
1388 | QI:Number";" FI:Number";" guidDefinition[Guid] ";" "STRING_TOKEN" "\(" DP:Number "\)"
1389 << $Value.ref = _STOR(QI->getText(), FI->getText(), &Guid, DP->getText()); >>
1390 | "STRING_TOKEN" "\(" S1:Number "\)" << $Value.string = _STOSID(S1->getText()); >>
1391 ;
1392
1393 //*****************************************************************************
1394 //
1395 // the syntax of form definition
1396 //
1397 vfrFormDefinition :
1398 << CIfrForm FObj; >>
1399 F:Form << FObj.SetLineNo(F->getLine()); >>
1400 FormId "=" S1:Number "," << _PCATCH(FObj.SetFormId (_STOFID(S1->getText())), S1); >>
1401 Title "=" "STRING_TOKEN" "\(" S2:Number "\)" ";" << FObj.SetFormTitle (_STOSID(S2->getText())); >>
1402 (
1403 vfrStatementImage |
1404 vfrStatementLocked |
1405 vfrStatementRules |
1406 vfrStatementDefault |
1407 vfrStatementStat |
1408 vfrStatementQuestions |
1409 vfrStatementConditional |
1410 vfrStatementLabel |
1411 vfrStatementBanner |
1412 // Just for framework vfr compatibility
1413 vfrStatementInvalid |
1414 vfrStatementExtension |
1415 vfrStatementModal
1416 )*
1417 E:EndForm <<
1418 if (mCompatibleMode) {
1419 //
1420 // Add Label for Framework Vfr
1421 //
1422 CIfrLabel LObj1;
1423 LObj1.SetLineNo(E->getLine());
1424 LObj1.SetNumber (0xffff); //add end label for UEFI, label number hardcode 0xffff
1425 CIfrLabel LObj2;
1426 LObj2.SetLineNo(E->getLine());
1427 LObj2.SetNumber (0x0); //add dummy label for UEFI, label number hardcode 0x0
1428 CIfrLabel LObj3;
1429 LObj3.SetLineNo(E->getLine());
1430 LObj3.SetNumber (0xffff); //add end label for UEFI, label number hardcode 0xffff
1431 }
1432
1433 {CIfrEnd EObj; EObj.SetLineNo (E->getLine()); mLastFormEndAddr = EObj.GetObjBinAddr (); gAdjustOpcodeOffset = EObj.GetObjBinOffset ();}
1434 >>
1435 ";"
1436 ;
1437
1438 vfrFormMapDefinition :
1439 <<
1440 CIfrFormMap *FMapObj = NULL;
1441 UINT32 FormMapMethodNumber = 0;
1442 EFI_GUID Guid;
1443 >>
1444 F:FormMap << FMapObj = new CIfrFormMap(); FMapObj->SetLineNo(F->getLine()); >>
1445 FormId "=" S1:Number "," << _PCATCH(FMapObj->SetFormId (_STOFID(S1->getText())), S1); >>
1446 (
1447 MapTitle "=" "STRING_TOKEN" "\(" S2:Number "\)" ";"
1448 MapGuid "=" guidDefinition[Guid] ";" << FMapObj->SetFormMapMethod (_STOFID(S2->getText()), &Guid); FormMapMethodNumber ++; >>
1449 )* << if (FormMapMethodNumber == 0) {_PCATCH (VFR_RETURN_INVALID_PARAMETER, F->getLine(), "No MapMethod is set for FormMap!");} delete FMapObj;>>
1450 (
1451 vfrStatementImage |
1452 vfrStatementLocked |
1453 vfrStatementRules |
1454 vfrStatementDefault |
1455 vfrStatementStat |
1456 vfrStatementQuestions |
1457 vfrStatementConditional |
1458 vfrStatementLabel |
1459 vfrStatementBanner |
1460 vfrStatementExtension |
1461 vfrStatementModal
1462 )*
1463 E:EndForm << CRT_END_OP (E); >>
1464 ";"
1465 ;
1466
1467 vfrStatementRules :
1468 << CIfrRule RObj; >>
1469 R:Rule << RObj.SetLineNo(R->getLine()); >>
1470 S1:StringIdentifier "," <<
1471 mCVfrRulesDB.RegisterRule (S1->getText());
1472 RObj.SetRuleId (mCVfrRulesDB.GetRuleId(S1->getText()));
1473 >>
1474 vfrStatementExpression[0]
1475 E:EndRule << CRT_END_OP (E); >>
1476 ";"
1477 ;
1478
1479 vfrStatementDefault :
1480 <<
1481 BOOLEAN IsExp = FALSE;
1482 EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;
1483 CIfrDefault *DObj = NULL;
1484 CIfrDefault2 *DObj2 = NULL;
1485 EFI_DEFAULT_ID DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
1486 CHAR8 *VarStoreName = NULL;
1487 EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
1488 UINT32 Size = 0;
1489 EFI_GUID *VarGuid = NULL;
1490 >>
1491 D:Default
1492 (
1493 (
1494 "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] > [Val] ","
1495 <<
1496 if (gCurrentMinMaxData != NULL && gCurrentMinMaxData->IsNumericOpcode()) {
1497 //check default value is valid for Numeric Opcode
1498 if (Val.u64 < gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE()) || Val.u64 > gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE())) {
1499 _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue.");
1500 }
1501 }
1502 if (_GET_CURRQEST_DATATYPE() == EFI_IFR_TYPE_OTHER) {
1503 _PCATCH (VFR_RETURN_FATAL_ERROR, D->getLine(), "Default data type error.");
1504 Size = sizeof (EFI_IFR_TYPE_VALUE);
1505 } else {
1506 _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &Size), D->getLine());
1507 }
1508 Size += OFFSET_OF (EFI_IFR_DEFAULT, Value);
1509 DObj = new CIfrDefault ((UINT8)Size);
1510 DObj->SetLineNo(D->getLine());
1511 DObj->SetType (_GET_CURRQEST_DATATYPE());
1512 DObj->SetValue(Val);
1513 >>
1514 | << IsExp = TRUE; DObj2 = new CIfrDefault2; DObj2->SetLineNo(D->getLine()); DObj2->SetScope (1); >>
1515 vfrStatementValue "," << CIfrEnd EndObj1; EndObj1.SetLineNo(D->getLine()); >>
1516 )
1517 {
1518 DefaultStore "=" SN:StringIdentifier "," <<
1519 _PCATCH(mCVfrDefaultStore.GetDefaultId (SN->getText(), &DefaultId), SN);
1520 if (DObj != NULL) {
1521 DObj->SetDefaultId (DefaultId);
1522 }
1523
1524 if (DObj2 != NULL) {
1525 DObj2->SetDefaultId (DefaultId);
1526 }
1527 >>
1528 }
1529 <<
1530 CheckDuplicateDefaultValue (DefaultId, D);
1531 if (_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) {
1532 _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), D->getLine());
1533 VarGuid = mCVfrDataStorage.GetVarStoreGuid(_GET_CURRQEST_VARTINFO().mVarStoreId);
1534 VarStoreType = mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId);
1535 if ((IsExp == FALSE) && (VarStoreType == EFI_VFR_VARSTORE_BUFFER)) {
1536 _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
1537 DefaultId,
1538 _GET_CURRQEST_VARTINFO(),
1539 VarStoreName,
1540 VarGuid,
1541 _GET_CURRQEST_DATATYPE (),
1542 Val),
1543 D->getLine()
1544 );
1545 }
1546 }
1547 if (DObj != NULL) {delete DObj;}
1548 if (DObj2 != NULL) {delete DObj2;}
1549 >>
1550 )
1551 ;
1552
1553 vfrStatementStat :
1554 vfrStatementSubTitle |
1555 vfrStatementStaticText |
1556 vfrStatementCrossReference
1557 ;
1558
1559 vfrStatementQuestions :
1560 vfrStatementBooleanType |
1561 vfrStatementDate |
1562 vfrStatementNumericType |
1563 vfrStatementStringType |
1564 vfrStatementOrderedList |
1565 vfrStatementTime
1566 ;
1567
1568 vfrStatementConditional :
1569 vfrStatementDisableIfStat |
1570 vfrStatementSuppressIfStat | //enhance to be compatible for framework endif
1571 vfrStatementGrayOutIfStat |
1572 vfrStatementInconsistentIfStat //to be compatible for framework
1573 ;
1574
1575 vfrStatementConditionalNew :
1576 vfrStatementDisableIfStat |
1577 vfrStatementSuppressIfStatNew |
1578 vfrStatementGrayOutIfStatNew |
1579 vfrStatementInconsistentIfStat //to be compatible for framework
1580 ;
1581
1582 vfrStatementSuppressIfStat :
1583 <<mCompatibleMode>>? vfrStatementSuppressIfStatOld
1584 | vfrStatementSuppressIfStatNew
1585 ;
1586
1587 vfrStatementGrayOutIfStat :
1588 <<mCompatibleMode>>? vfrStatementGrayOutIfStatOld
1589 | vfrStatementGrayOutIfStatNew
1590 ;
1591
1592 vfrStatementInvalid :
1593 (
1594 vfrStatementInvalidHidden |
1595 vfrStatementInvalidInventory |
1596 vfrStatementInvalidSaveRestoreDefaults
1597 )
1598 << _CRT_OP (TRUE); >>
1599 ;
1600
1601 flagsField :
1602 Number | InteractiveFlag | ManufacturingFlag | DefaultFlag |
1603 NVAccessFlag | ResetRequiredFlag | LateCheckFlag
1604 ;
1605
1606 vfrStatementValue :
1607 << CIfrValue VObj; >>
1608 V:Value << VObj.SetLineNo(V->getLine()); >>
1609 "=" vfrStatementExpression[0] << {CIfrEnd EndObj; EndObj.SetLineNo(V->getLine());} >>
1610 ;
1611
1612 vfrStatementRead :
1613 << CIfrRead RObj; >>
1614 R:Read << RObj.SetLineNo(R->getLine()); >>
1615 vfrStatementExpression[0] ";"
1616 ;
1617
1618 vfrStatementWrite :
1619 << CIfrWrite WObj; >>
1620 W:Write << WObj.SetLineNo(W->getLine()); >>
1621 vfrStatementExpression[0] ";"
1622 ;
1623
1624 vfrStatementSubTitle :
1625 << CIfrSubtitle SObj; >>
1626 L:Subtitle << SObj.SetLineNo(L->getLine()); >>
1627 Text "=" "STRING_TOKEN" "\(" S:Number "\)" << SObj.SetPrompt (_STOSID(S->getText())); >>
1628 {
1629 "," FLAGS "=" vfrSubtitleFlags[SObj]
1630 }
1631 { vfrStatementStatTagList "," }
1632 E:";" << CRT_END_OP (E); >>
1633 ;
1634
1635 vfrSubtitleFlags [CIfrSubtitle & SObj] :
1636 << UINT8 LFlags = 0; >>
1637 subtitleFlagsField[LFlags] ( "\|" subtitleFlagsField[LFlags] )*
1638 << _PCATCH(SObj.SetFlags (LFlags)); >>
1639 ;
1640
1641 subtitleFlagsField [UINT8 & Flags] :
1642 N:Number << $Flags |= _STOU8(N->getText()); >>
1643 | "HORIZONTAL" << $Flags |= 0x01; >>
1644 ;
1645
1646 vfrStatementStaticText :
1647 <<
1648 UINT8 Flags = 0;
1649 EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
1650 EFI_STRING_ID TxtTwo = EFI_STRING_ID_INVALID;
1651 >>
1652 T:Text
1653 Help "=" "STRING_TOKEN" "\(" S1:Number "\)" ","
1654 Text "=" "STRING_TOKEN" "\(" S2:Number "\)"
1655 {
1656 "," Text "=" "STRING_TOKEN" "\(" S3:Number "\)" << TxtTwo = _STOSID(S3->getText()); >>
1657 }
1658 {
1659 "," F:FLAGS "=" staticTextFlagsField[Flags] ( "\|" staticTextFlagsField[Flags] )*
1660 "," Key "=" KN:Number
1661 }
1662 <<
1663 if (Flags & EFI_IFR_FLAG_CALLBACK) {
1664 CIfrAction AObj;
1665 mCVfrQuestionDB.RegisterQuestion (NULL, NULL, QId);
1666 AObj.SetLineNo (F->getLine());
1667 AObj.SetQuestionId (QId);
1668 AObj.SetPrompt (_STOSID(S2->getText()));
1669 AObj.SetHelp (_STOSID(S1->getText()));
1670 _PCATCH(AObj.SetFlags (Flags), F->getLine());
1671 AssignQuestionKey (AObj, KN);
1672 CRT_END_OP (KN);
1673 } else {
1674 CIfrText TObj;
1675 TObj.SetLineNo (T->getLine());
1676 TObj.SetHelp (_STOSID(S1->getText()));
1677 TObj.SetPrompt (_STOSID(S2->getText()));
1678 TObj.SetTextTwo (TxtTwo);
1679 }
1680 >>
1681 { "," vfrStatementStatTagList }
1682 ";"
1683 ;
1684
1685 staticTextFlagsField[UINT8 & HFlags] :
1686 N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
1687 | questionheaderFlagsField[HFlags]
1688 ;
1689
1690 vfrStatementCrossReference :
1691 vfrStatementGoto |
1692 vfrStatementResetButton
1693 ;
1694
1695 vfrStatementGoto :
1696 <<
1697 UINT8 RefType = 5;
1698 EFI_STRING_ID DevPath = EFI_STRING_ID_INVALID;
1699 EFI_GUID FSId = {0,};
1700 EFI_FORM_ID FId;
1701 EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
1702 UINT32 BitMask;
1703 CIfrQuestionHeader *QHObj = NULL;
1704 CIfrOpHeader *OHObj = NULL;
1705 CIfrRef *R1Obj = NULL;
1706 CIfrRef2 *R2Obj = NULL;
1707 CIfrRef3 *R3Obj = NULL;
1708 CIfrRef4 *R4Obj = NULL;
1709 CIfrRef5 *R5Obj = NULL;
1710 >>
1711 G:Goto
1712 {
1713 (
1714 DevicePath "=" "STRING_TOKEN" "\(" P:Number "\)" ","
1715 FormSetGuid "=" guidDefinition[FSId] ","
1716 FormId "=" F1:Number ","
1717 Question "=" QN1:Number ","
1718 <<
1719 RefType = 4;
1720 DevPath = _STOSID(P->getText());
1721 FId = _STOFID(F1->getText());
1722 QId = _STOQID(QN1->getText());
1723 >>
1724 )
1725 |
1726 (
1727 FormSetGuid "=" guidDefinition[FSId] ","
1728 FormId "=" F2:Number ","
1729 Question "=" QN2:Number ","
1730 <<
1731 RefType = 3;
1732 FId = _STOFID(F2->getText());
1733 QId = _STOQID(QN2->getText());
1734 >>
1735 )
1736 |
1737 (
1738 FormId "=" F3:Number "," << RefType = 2; FId = _STOFID(F3->getText()); >>
1739 Question "="
1740 (
1741 QN3:StringIdentifier "," <<
1742 mCVfrQuestionDB.GetQuestionId (QN3->getText (), NULL, QId, BitMask);
1743 if (QId == EFI_QUESTION_ID_INVALID) {
1744 _PCATCH(VFR_RETURN_UNDEFINED, QN3);
1745 }
1746 >>
1747 | QN4:Number "," << QId = _STOQID(QN4->getText()); >>
1748 )
1749 )
1750 |
1751 (
1752 F4:Number "," <<
1753 RefType = 1;
1754 FId = _STOFID(F4->getText());
1755 >>
1756 )
1757 }
1758 <<
1759 switch (RefType) {
1760 case 5:
1761 {
1762 R5Obj = new CIfrRef5;
1763 QHObj = R5Obj;
1764 OHObj = R5Obj;
1765 R5Obj->SetLineNo(G->getLine());
1766 break;
1767 }
1768 case 4:
1769 {
1770 R4Obj = new CIfrRef4;
1771 QHObj = R4Obj;
1772 OHObj = R4Obj;
1773 R4Obj->SetLineNo(G->getLine());
1774 R4Obj->SetDevicePath (DevPath);
1775 R4Obj->SetFormSetId (FSId);
1776 R4Obj->SetFormId (FId);
1777 R4Obj->SetQuestionId (QId);
1778 break;
1779 }
1780 case 3:
1781 {
1782 R3Obj = new CIfrRef3;
1783 QHObj = R3Obj;
1784 OHObj = R3Obj;
1785 R3Obj->SetLineNo(G->getLine());
1786 R3Obj->SetFormSetId (FSId);
1787 R3Obj->SetFormId (FId);
1788 R3Obj->SetQuestionId (QId);
1789 break;
1790 }
1791 case 2:
1792 {
1793 R2Obj = new CIfrRef2;
1794 QHObj = R2Obj;
1795 OHObj = R2Obj;
1796 R2Obj->SetLineNo(G->getLine());
1797 R2Obj->SetFormId (FId);
1798 R2Obj->SetQuestionId (QId);
1799 break;
1800 }
1801 case 1:
1802 {
1803 R1Obj = new CIfrRef;
1804 QHObj = R1Obj;
1805 OHObj = R1Obj;
1806 R1Obj->SetLineNo(G->getLine());
1807 R1Obj->SetFormId (FId);
1808 break;
1809 }
1810 default: break;
1811 }
1812 >>
1813 vfrQuestionHeader[*QHObj, QUESTION_REF] <<
1814 if (_GET_CURRQEST_DATATYPE() == EFI_IFR_TYPE_OTHER) {
1815 _GET_CURRQEST_VARTINFO().mVarType = EFI_IFR_TYPE_REF;
1816 }
1817 >>
1818 { "," F:FLAGS "=" vfrGotoFlags[QHObj, F->getLine()] }
1819 {
1820 "," Key "=" KN:Number << AssignQuestionKey (*QHObj, KN); >>
1821 }
1822 {
1823 E:","
1824 vfrStatementQuestionOptionList << OHObj->SetScope(1); CRT_END_OP (E);>>
1825 }
1826 ";" << if (R1Obj != NULL) {delete R1Obj;} if (R2Obj != NULL) {delete R2Obj;} if (R3Obj != NULL) {delete R3Obj;} if (R4Obj != NULL) {delete R4Obj;} if (R5Obj != NULL) {delete R5Obj;}>>
1827 ;
1828
1829 vfrGotoFlags [CIfrQuestionHeader *QHObj, UINT32 LineNum] :
1830 << UINT8 HFlags = 0; >>
1831 gotoFlagsField[HFlags] ( "\|" gotoFlagsField[HFlags] )*
1832 << _PCATCH(QHObj->SetFlags (HFlags), LineNum); >>
1833 ;
1834
1835 gotoFlagsField[UINT8 & HFlags] :
1836 N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
1837 | questionheaderFlagsField[HFlags]
1838 ;
1839
1840 getStringId :
1841 "STRING_TOKEN" "\("
1842 IdVal:Number
1843 "\)"
1844 ;
1845
1846 vfrStatementResetButton :
1847 <<
1848 CIfrResetButton RBObj;
1849 UINT16 DefaultId;
1850 >>
1851 L:ResetButton << RBObj.SetLineNo(L->getLine()); >>
1852 DefaultStore
1853 "=" N:StringIdentifier "," <<
1854 _PCATCH(mCVfrDefaultStore.GetDefaultId (N->getText(), &DefaultId), N->getLine());
1855 RBObj.SetDefaultId (DefaultId);
1856 >>
1857 vfrStatementHeader[&RBObj] ","
1858 { vfrStatementStatTagList "," }
1859 E:EndResetButton << CRT_END_OP (E); >>
1860 ";"
1861 ;
1862
1863 vfrStatementBooleanType :
1864 vfrStatementCheckBox |
1865 vfrStatementAction
1866 ;
1867
1868 //*****************************************************
1869 // Syntax of checkbox
1870 //
1871 // Example:
1872 // checkbox
1873 // varid = MySTestData.mField1,
1874 // prompt = STRING_TOKEN(STR_CHECK_BOX_PROMPT),
1875 // help = STRING_TOKEN(STR_CHECK_BOX_HELP),
1876 // flags = CHECKBOX_DEFAULT | CALLBACK,
1877 // default value = TRUE, defaultstore = MyDefaultStore,
1878 // endcheckbox;
1879 //
1880 vfrStatementCheckBox :
1881 <<
1882 CIfrCheckBox CBObj;
1883 EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;
1884 CHAR8 *VarStoreName = NULL;
1885 UINT32 DataTypeSize;
1886 EFI_GUID *VarStoreGuid = NULL;
1887 >>
1888 L:CheckBox << CBObj.SetLineNo(L->getLine()); >>
1889 vfrQuestionHeader[CBObj] "," << //check data type
1890 if (_GET_CURRQEST_DATATYPE() == EFI_IFR_TYPE_OTHER) {
1891 _GET_CURRQEST_VARTINFO().mVarType = EFI_IFR_TYPE_BOOLEAN;
1892 }
1893 if (_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) {
1894 _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "CheckBox varid is not the valid data type");
1895 if (DataTypeSize != 0 && DataTypeSize != _GET_CURRQEST_VARSIZE()) {
1896 _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "CheckBox varid doesn't support array");
1897 } else if ((mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId) == EFI_VFR_VARSTORE_BUFFER) &&
1898 (_GET_CURRQEST_VARSIZE() != sizeof (BOOLEAN))) {
1899 _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "CheckBox varid only support BOOLEAN data type");
1900 }
1901 }
1902 >>
1903 {
1904 F:FLAGS "=" vfrCheckBoxFlags[CBObj, F->getLine()] ","
1905 <<
1906 if (_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) {
1907 _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), VFR_RETURN_SUCCESS, L, "Failed to retrieve varstore name");
1908 VarStoreGuid = mCVfrDataStorage.GetVarStoreGuid(_GET_CURRQEST_VARTINFO().mVarStoreId);
1909 Val.b = TRUE;
1910 if (CBObj.GetFlags () & 0x01) {
1911 CheckDuplicateDefaultValue (EFI_HII_DEFAULT_CLASS_STANDARD, F);
1912 _PCATCH(
1913 mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
1914 EFI_HII_DEFAULT_CLASS_STANDARD,
1915 _GET_CURRQEST_VARTINFO(),
1916 VarStoreName,
1917 VarStoreGuid,
1918 _GET_CURRQEST_DATATYPE (),
1919 Val
1920 ),
1921 VFR_RETURN_SUCCESS,
1922 L,
1923 "No standard default storage found"
1924 );
1925 }
1926 if (CBObj.GetFlags () & 0x02) {
1927 CheckDuplicateDefaultValue (EFI_HII_DEFAULT_CLASS_MANUFACTURING, F);
1928 _PCATCH(
1929 mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
1930 EFI_HII_DEFAULT_CLASS_MANUFACTURING,
1931 _GET_CURRQEST_VARTINFO(),
1932 VarStoreName,
1933 VarStoreGuid,
1934 _GET_CURRQEST_DATATYPE (),
1935 Val
1936 ),
1937 VFR_RETURN_SUCCESS,
1938 L,
1939 "No manufacturing default storage found"
1940 );
1941 }
1942 }
1943 >>
1944 }
1945 {
1946 Key "=" KN:Number "," << AssignQuestionKey (CBObj, KN); >>
1947 }
1948 vfrStatementQuestionOptionList
1949 E:EndCheckBox << CRT_END_OP (E); >>
1950 ";"
1951 ;
1952
1953 vfrCheckBoxFlags [CIfrCheckBox & CBObj, UINT32 LineNum] :
1954 <<
1955 UINT8 LFlags = 0;
1956 UINT8 HFlags = 0;
1957 >>
1958 checkboxFlagsField[LFlags, HFlags] ( "\|" checkboxFlagsField[LFlags, HFlags] )*
1959 << _PCATCH(CBObj.SetFlags (HFlags, LFlags), LineNum); >>
1960 ;
1961
1962 checkboxFlagsField[UINT8 & LFlags, UINT8 & HFlags] :
1963 N:Number <<
1964 if (mCompatibleMode) {
1965 //
1966 // set question flag
1967 //
1968 $LFlags |= _STOU8(N->getText());
1969 } else {
1970 _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine());
1971 }
1972 >>
1973 | D:"DEFAULT" <<
1974 if (mCompatibleMode) {
1975 //
1976 // set question Default flag
1977 //
1978 $LFlags |= 0x01;
1979 } else {
1980 _PCATCH (VFR_RETURN_UNSUPPORTED, D);
1981 }
1982 >>
1983 | M:"MANUFACTURING" <<
1984 if (mCompatibleMode) {
1985 //
1986 // set question MFG flag
1987 //
1988 $LFlags |= 0x02;
1989 } else {
1990 _PCATCH (VFR_RETURN_UNSUPPORTED, M);
1991 }
1992 >>
1993 | "CHECKBOX_DEFAULT" << $LFlags |= 0x01; >>
1994 | "CHECKBOX_DEFAULT_MFG" << $LFlags |= 0x02; >>
1995 | questionheaderFlagsField[HFlags]
1996 ;
1997
1998 //*****************************************************
1999 // Syntax of action
2000 //
2001 // Example:
2002 // action
2003 // prompt = STRING_TOKEN(STR_ACTION_PROMPT),
2004 // help = STRING_TOKEN(STR_ACTION_HELP),
2005 // flags = CALLBACK,
2006 // config = STRING_TOKEN(STR_ACTION_CONFIG),
2007 // endaction;
2008 //
2009 vfrStatementAction :
2010 << CIfrAction AObj; >>
2011 L:Action << AObj.SetLineNo(L->getLine()); >>
2012 vfrQuestionHeader[AObj] ","
2013 { F:FLAGS "=" vfrActionFlags[AObj, F->getLine()] "," }
2014 Config "=" "STRING_TOKEN" "\(" S:Number "\)" "," << AObj.SetQuestionConfig (_STOSID(S->getText())); >>
2015 vfrStatementQuestionTagList
2016 E:EndAction << CRT_END_OP (E); >>
2017 ";"
2018 ;
2019
2020 vfrActionFlags[CIfrAction & AObj, UINT32 LineNum] :
2021 << UINT8 HFlags = 0; >>
2022 actionFlagsField[HFlags] ( "\|" actionFlagsField[HFlags] )*
2023 << _PCATCH(AObj.SetFlags (HFlags), LineNum); >>
2024 ;
2025
2026 actionFlagsField[UINT8 & HFlags] :
2027 N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
2028 | questionheaderFlagsField[HFlags]
2029 ;
2030
2031 vfrStatementDate :
2032 <<
2033 EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
2034 CHAR8 *VarIdStr[3] = {NULL, };
2035 CIfrDate DObj;
2036 EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;
2037 UINT8 Size = OFFSET_OF (EFI_IFR_DEFAULT, Value) + sizeof (EFI_HII_DATE);
2038 >>
2039 L:Date << DObj.SetLineNo(L->getLine()); >>
2040 (
2041 (
2042 vfrQuestionHeader[DObj, QUESTION_DATE] "," <<
2043 if (_GET_CURRQEST_DATATYPE() == EFI_IFR_TYPE_OTHER) {
2044 _GET_CURRQEST_VARTINFO().mVarType = EFI_IFR_TYPE_DATE;
2045 }
2046 >>
2047 { F:FLAGS "=" vfrDateFlags[DObj, F->getLine()] "," }
2048 vfrStatementQuestionOptionList
2049 )
2050 |
2051 (
2052 Year VarId "=" D1:StringIdentifier "." D1Y:StringIdentifier ","
2053 << _STRCAT(&VarIdStr[0], D1->getText()); _STRCAT(&VarIdStr[0], "."); _STRCAT(&VarIdStr[0], D1Y->getText()); >>
2054 Prompt "=" "STRING_TOKEN" "\(" YP:Number "\)" ","
2055 Help "=" "STRING_TOKEN" "\(" YH:Number "\)" ","
2056 minMaxDateStepDefault[Val.date, 0]
2057
2058 Month VarId "=" D2:StringIdentifier "." D2M:StringIdentifier ","
2059 << _STRCAT(&VarIdStr[1], D2->getText()); _STRCAT(&VarIdStr[1], "."); _STRCAT(&VarIdStr[1], D2M->getText()); >>
2060 Prompt "=" "STRING_TOKEN" "\(" MP:Number "\)" ","
2061 Help "=" "STRING_TOKEN" "\(" MH:Number "\)" ","
2062 minMaxDateStepDefault[Val.date, 1]
2063
2064 Day VarId "=" D3:StringIdentifier "." D3D:StringIdentifier ","
2065 << _STRCAT(&VarIdStr[2], D3->getText()); _STRCAT(&VarIdStr[2], "."); _STRCAT(&VarIdStr[2], D3D->getText()); >>
2066 Prompt "=" "STRING_TOKEN" "\(" DP:Number "\)" ","
2067 Help "=" "STRING_TOKEN" "\(" DH:Number "\)" ","
2068 minMaxDateStepDefault[Val.date, 2]
2069 { G:FLAGS "=" vfrDateFlags[DObj, G->getLine()] "," }
2070 <<
2071 mCVfrQuestionDB.RegisterOldDateQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);
2072 DObj.SetQuestionId (QId);
2073 DObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_DATE_STORAGE_TIME);
2074 DObj.SetPrompt (_STOSID(YP->getText()));
2075 DObj.SetHelp (_STOSID(YH->getText()));
2076 if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }
2077 >>
2078 << {CIfrDefault DefaultObj(Size, EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_DATE, Val); DefaultObj.SetLineNo(L->getLine());} >>
2079 )
2080 ( vfrStatementInconsistentIf )*
2081 )
2082 E:EndDate << CRT_END_OP (E); >>
2083 ";"
2084 ;
2085
2086 minMaxDateStepDefault[EFI_HII_DATE & D, UINT8 KeyValue] :
2087 Minimum "=" MinN:Number ","
2088 Maximum "=" MaxN:Number ","
2089 { "step" "=" Number "," }
2090 {
2091 "default" "=" N:Number "," <<
2092 switch (KeyValue) {
2093 case 0:
2094 D.Year = _STOU16(N->getText());
2095 if (D.Year < _STOU16 (MinN->getText()) || D.Year > _STOU16 (MaxN->getText())) {
2096 _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Year default value must be between Min year and Max year.");
2097 }
2098 break;
2099 case 1:
2100 D.Month = _STOU8(N->getText());
2101 if (D.Month < 1 || D.Month > 12) {
2102 _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Month default value must be between 1 and 12.");
2103 }
2104 break;
2105 case 2:
2106 D.Day = _STOU8(N->getText());
2107 if (D.Day < 1 || D.Day > 31) {
2108 _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Day default value must be between 1 and 31.");
2109 }
2110 break;
2111 }
2112 >>
2113 }
2114 ;
2115
2116 vfrDateFlags [CIfrDate & DObj, UINT32 LineNum] :
2117 << UINT8 LFlags = 0; >>
2118 dateFlagsField[LFlags] ( "\|" dateFlagsField[LFlags] )*
2119 << _PCATCH(DObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, LFlags), LineNum); >>
2120 ;
2121
2122 dateFlagsField [UINT8 & Flags] :
2123 N:Number << $Flags |= _STOU8(N->getText()); >>
2124 | "YEAR_SUPPRESS" << $Flags |= 0x01; >>
2125 | "MONTH_SUPPRESS" << $Flags |= 0x02; >>
2126 | "DAY_SUPPRESS" << $Flags |= 0x04; >>
2127 | "STORAGE_NORMAL" << $Flags |= 0x00; >>
2128 | "STORAGE_TIME" << $Flags |= 0x10; >>
2129 | "STORAGE_WAKEUP" << $Flags |= 0x20; >>
2130 ;
2131
2132 vfrStatementNumericType :
2133 vfrStatementNumeric |
2134 vfrStatementOneOf
2135 ;
2136
2137 vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] :
2138 <<
2139 UINT64 MaxU8 = 0, MinU8 = 0, StepU8 = 0;
2140 UINT32 MaxU4 = 0, MinU4 = 0, StepU4 = 0;
2141 UINT16 MaxU2 = 0, MinU2 = 0, StepU2 = 0;
2142 UINT8 MaxU1 = 0, MinU1 = 0, StepU1 = 0;
2143 >>
2144 Minimum "=" I:Number ","
2145 <<
2146 switch (_GET_CURRQEST_DATATYPE()) {
2147 case EFI_IFR_TYPE_NUM_SIZE_64 : MinU8 = _STOU64(I->getText()); break;
2148 case EFI_IFR_TYPE_NUM_SIZE_32 : MinU4 = _STOU32(I->getText()); break;
2149 case EFI_IFR_TYPE_NUM_SIZE_16 : MinU2 = _STOU16(I->getText()); break;
2150 case EFI_IFR_TYPE_NUM_SIZE_8 : MinU1 = _STOU8(I->getText()); break;
2151 }
2152 >>
2153 Maximum "=" A:Number ","
2154 <<
2155 switch (_GET_CURRQEST_DATATYPE()) {
2156 case EFI_IFR_TYPE_NUM_SIZE_64 :
2157 MaxU8 = _STOU64(A->getText());
2158 if (MaxU8 < MinU8) {
2159 _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
2160 }
2161 break;
2162 case EFI_IFR_TYPE_NUM_SIZE_32 :
2163 MaxU4 = _STOU32(A->getText());
2164 if (MaxU4 < MinU4) {
2165 _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
2166 }
2167 break;
2168 case EFI_IFR_TYPE_NUM_SIZE_16 :
2169 MaxU2 = _STOU16(A->getText());
2170 if (MaxU2 < MinU2) {
2171 _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
2172 }
2173 break;
2174 case EFI_IFR_TYPE_NUM_SIZE_8 :
2175 MaxU1 = _STOU8(A->getText());
2176 if (MaxU1 < MinU1) {
2177 _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
2178 }
2179 break;
2180 }
2181 >>
2182 {
2183 STEP "=" S:Number ","
2184 <<
2185 switch (_GET_CURRQEST_DATATYPE()) {
2186 case EFI_IFR_TYPE_NUM_SIZE_64 : StepU8 = _STOU64(S->getText()); break;
2187 case EFI_IFR_TYPE_NUM_SIZE_32 : StepU4 = _STOU32(S->getText()); break;
2188 case EFI_IFR_TYPE_NUM_SIZE_16 : StepU2 = _STOU16(S->getText()); break;
2189 case EFI_IFR_TYPE_NUM_SIZE_8 : StepU1 = _STOU8(S->getText()); break;
2190 }
2191 >>
2192 }
2193 <<
2194 switch (_GET_CURRQEST_DATATYPE()) {
2195 case EFI_IFR_TYPE_NUM_SIZE_64 : $MMSDObj.SetMinMaxStepData (MinU8, MaxU8, StepU8); break;
2196 case EFI_IFR_TYPE_NUM_SIZE_32 : $MMSDObj.SetMinMaxStepData (MinU4, MaxU4, StepU4); break;
2197 case EFI_IFR_TYPE_NUM_SIZE_16 : $MMSDObj.SetMinMaxStepData (MinU2, MaxU2, StepU2); break;
2198 case EFI_IFR_TYPE_NUM_SIZE_8 : $MMSDObj.SetMinMaxStepData (MinU1, MaxU1, StepU1); break;
2199 }
2200 >>
2201 ;
2202
2203 vfrStatementNumeric :
2204 <<
2205 CIfrNumeric NObj;
2206 UINT32 DataTypeSize;
2207 BOOLEAN IsSupported = TRUE;
2208 UINT8 ShrinkSize = 0;
2209 >>
2210 L:Numeric << NObj.SetLineNo(L->getLine()); >>
2211 vfrQuestionHeader[NObj] "," << // check data type
2212 if (_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) {
2213 _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "Numeric varid is not the valid data type");
2214 if (DataTypeSize != 0 && DataTypeSize != _GET_CURRQEST_VARSIZE()) {
2215 _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "Numeric varid doesn't support array");
2216 }
2217 _PCATCH(NObj.SetFlags (NObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine());
2218 }
2219 >>
2220 { F:FLAGS "=" vfrNumericFlags[NObj, F->getLine()] "," }
2221 {
2222 Key "=" KN:Number "," << AssignQuestionKey (NObj, KN); >>
2223 }
2224 vfrSetMinMaxStep[NObj] <<
2225 switch (_GET_CURRQEST_DATATYPE()) {
2226 //
2227 // Base on the type to know the actual used size,shrink the buffer
2228 // size allocate before.
2229 //
2230 case EFI_IFR_TYPE_NUM_SIZE_8: ShrinkSize = 21;break;
2231 case EFI_IFR_TYPE_NUM_SIZE_16:ShrinkSize = 18;break;
2232 case EFI_IFR_TYPE_NUM_SIZE_32:ShrinkSize = 12;break;
2233 case EFI_IFR_TYPE_NUM_SIZE_64:break;
2234 default:
2235 IsSupported = FALSE;
2236 break;
2237 }
2238 NObj.ShrinkBinSize (ShrinkSize);
2239 if (!IsSupported) {
2240 _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "Numeric question only support UINT8, UINT16, UINT32 and UINT64 data type.");
2241 }
2242 >>
2243 vfrStatementQuestionOptionList
2244 E:EndNumeric <<
2245 CRT_END_OP (E);
2246 >>
2247 ";"
2248 ;
2249
2250 vfrNumericFlags [CIfrNumeric & NObj, UINT32 LineNum] :
2251 <<
2252 UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;
2253 UINT8 HFlags = 0;
2254 EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
2255 BOOLEAN IsSetType = FALSE;
2256 >>
2257 numericFlagsField[HFlags, LFlags, IsSetType] ( "\|" numericFlagsField[HFlags, LFlags, IsSetType] )*
2258 <<
2259 //check data type flag
2260 if (_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) {
2261 VarStoreType = mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId);
2262 if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) {
2263 if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) {
2264 _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type");
2265 }
2266 } else {
2267 // update data type for name/value store
2268 UINT32 DataTypeSize;
2269 _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;
2270 gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize);
2271 _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize;
2272 }
2273 } else if (IsSetType){
2274 _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;
2275 }
2276 _PCATCH(NObj.SetFlags (HFlags, LFlags), LineNum);
2277 >>
2278 ;
2279
2280 numericFlagsField [UINT8 & HFlags, UINT8 & LFlags, BOOLEAN & IsSetType] :
2281 N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
2282 | "NUMERIC_SIZE_1" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_1; IsSetType = TRUE;>>
2283 | "NUMERIC_SIZE_2" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_2; IsSetType = TRUE;>>
2284 | "NUMERIC_SIZE_4" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_4; IsSetType = TRUE;>>
2285 | "NUMERIC_SIZE_8" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_8; IsSetType = TRUE;>>
2286 | "DISPLAY_INT_DEC" << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_INT_DEC; >>
2287 | "DISPLAY_UINT_DEC" << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_DEC; >>
2288 | "DISPLAY_UINT_HEX" << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_HEX; >>
2289 | questionheaderFlagsField[HFlags]
2290 ;
2291
2292 vfrStatementOneOf :
2293 <<
2294 CIfrOneOf OObj;
2295 UINT32 DataTypeSize;
2296 BOOLEAN IsSupported = TRUE;
2297 UINT8 ShrinkSize = 0;
2298 >>
2299 L:OneOf << OObj.SetLineNo(L->getLine()); >>
2300 vfrQuestionHeader[OObj] "," << //check data type
2301 if (_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) {
2302 _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "OneOf varid is not the valid data type");
2303 if (DataTypeSize != 0 && DataTypeSize != _GET_CURRQEST_VARSIZE()) {
2304 _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "OneOf varid doesn't support array");
2305 }
2306 _PCATCH(OObj.SetFlags (OObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine());
2307 }
2308 >>
2309 { F:FLAGS "=" vfrOneofFlagsField[OObj, F->getLine()] "," }
2310 {
2311 vfrSetMinMaxStep[OObj]
2312 }
2313 <<
2314 switch (_GET_CURRQEST_DATATYPE()) {
2315 //
2316 // Base on the type to know the actual used size,shrink the buffer
2317 // size allocate before.
2318 //
2319 case EFI_IFR_TYPE_NUM_SIZE_8: ShrinkSize = 21;break;
2320 case EFI_IFR_TYPE_NUM_SIZE_16:ShrinkSize = 18;break;
2321 case EFI_IFR_TYPE_NUM_SIZE_32:ShrinkSize = 12;break;
2322 case EFI_IFR_TYPE_NUM_SIZE_64:break;
2323 default:
2324 IsSupported = FALSE;
2325 break;
2326 }
2327 OObj.ShrinkBinSize (ShrinkSize);
2328 if (!IsSupported) {
2329 _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "OneOf question only support UINT8, UINT16, UINT32 and UINT64 data type.");
2330 }
2331 >>
2332 vfrStatementQuestionOptionList
2333 E:EndOneOf <<
2334 CRT_END_OP (E);
2335 >>
2336 ";"
2337 ;
2338
2339 vfrOneofFlagsField [CIfrOneOf & OObj, UINT32 LineNum] :
2340 <<
2341 UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;
2342 UINT8 HFlags = 0;
2343 EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
2344 BOOLEAN IsSetType = FALSE;
2345 >>
2346 numericFlagsField[HFlags, LFlags, IsSetType] ( "\|" numericFlagsField[HFlags, LFlags, IsSetType] )*
2347 <<
2348 //check data type flag
2349 if (_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) {
2350 VarStoreType = mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId);
2351 if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) {
2352 if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) {
2353 _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type");
2354 }
2355 } else {
2356 // update data type for Name/Value store
2357 UINT32 DataTypeSize;
2358 _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;
2359 gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize);
2360 _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize;
2361 }
2362 } else if (IsSetType){
2363 _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;
2364 }
2365 _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum);
2366 >>
2367 ;
2368
2369 vfrStatementStringType :
2370 vfrStatementString |
2371 vfrStatementPassword
2372 ;
2373
2374 vfrStatementString :
2375 <<
2376 CIfrString SObj;
2377 UINT32 VarArraySize;
2378 UINT8 StringMinSize;
2379 UINT8 StringMaxSize;
2380 >>
2381 L:String << SObj.SetLineNo(L->getLine()); >>
2382 vfrQuestionHeader[SObj] ","
2383 { F:FLAGS "=" vfrStringFlagsField[SObj, F->getLine()] "," }
2384 {
2385 Key "=" KN:Number "," << AssignQuestionKey (SObj, KN); >>
2386 }
2387 MinSize "=" MIN:Number "," <<
2388 VarArraySize = _GET_CURRQEST_ARRAY_SIZE();
2389 StringMinSize = _STOU8(MIN->getText());
2390 if (_STOU64(MIN->getText()) > StringMinSize) {
2391 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MIN->getLine(), "String MinSize takes only one byte, which can't be larger than 0xFF.");
2392 } else if (VarArraySize != 0 && StringMinSize > VarArraySize) {
2393 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MIN->getLine(), "String MinSize can't be larger than the max number of elements in string array.");
2394 }
2395 SObj.SetMinSize (StringMinSize);
2396 >>
2397 MaxSize "=" MAX:Number "," <<
2398 StringMaxSize = _STOU8(MAX->getText());
2399 if (_STOU64(MAX->getText()) > StringMaxSize) {
2400 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "String MaxSize takes only one byte, which can't be larger than 0xFF.");
2401 } else if (VarArraySize != 0 && StringMaxSize > VarArraySize) {
2402 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "String MaxSize can't be larger than the max number of elements in string array.");
2403 } else if (StringMaxSize < StringMinSize) {
2404 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "String MaxSize can't be less than String MinSize.");
2405 }
2406 SObj.SetMaxSize (StringMaxSize);
2407 >>
2408 vfrStatementQuestionOptionList
2409 E:EndString << CRT_END_OP (E); >>
2410 ";"
2411 ;
2412
2413 vfrStringFlagsField [CIfrString & SObj, UINT32 LineNum] :
2414 <<
2415 UINT8 LFlags = 0;
2416 UINT8 HFlags = 0;
2417 >>
2418 stringFlagsField[HFlags, LFlags] ( "\|" stringFlagsField[HFlags, LFlags] )*
2419 << _PCATCH(SObj.SetFlags (HFlags, LFlags), LineNum); >>
2420 ;
2421
2422 stringFlagsField [UINT8 & HFlags, UINT8 & LFlags] :
2423 N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
2424 | "MULTI_LINE" << $LFlags = 0x01; >>
2425 | questionheaderFlagsField[HFlags]
2426 ;
2427
2428 vfrStatementPassword :
2429 <<
2430 CIfrPassword PObj;
2431 UINT32 VarArraySize;
2432 UINT16 PasswordMinSize;
2433 UINT16 PasswordMaxSize;
2434 >>
2435 L:Password << PObj.SetLineNo(L->getLine()); >>
2436 vfrQuestionHeader[PObj] ","
2437 { F:FLAGS "=" vfrPasswordFlagsField[PObj, F->getLine()] "," }
2438 {
2439 Key "=" KN:Number "," << AssignQuestionKey (PObj, KN); >>
2440 }
2441 MinSize "=" MIN:Number "," <<
2442 VarArraySize = _GET_CURRQEST_ARRAY_SIZE();
2443 PasswordMinSize = _STOU16(MIN->getText());
2444 if (_STOU64(MIN->getText()) > PasswordMinSize) {
2445 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MIN->getLine(), "Password MinSize takes only two byte, which can't be larger than 0xFFFF.");
2446 } else if (VarArraySize != 0 && PasswordMinSize > VarArraySize) {
2447 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MIN->getLine(), "Password MinSize can't be larger than the max number of elements in password array.");
2448 }
2449 PObj.SetMinSize (PasswordMinSize);
2450 >>
2451 MaxSize "=" MAX:Number "," <<
2452 PasswordMaxSize = _STOU16(MAX->getText());
2453 if (_STOU64(MAX->getText()) > PasswordMaxSize) {
2454 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "Password MaxSize takes only two byte, which can't be larger than 0xFFFF.");
2455 } else if (VarArraySize != 0 && PasswordMaxSize > VarArraySize) {
2456 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "Password MaxSize can't be larger than the max number of elements in password array.");
2457 } else if (PasswordMaxSize < PasswordMinSize) {
2458 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "Password MaxSize can't be less than Password MinSize.");
2459 }
2460 PObj.SetMaxSize (PasswordMaxSize);
2461 >>
2462 { Encoding "=" Number "," }
2463 vfrStatementQuestionOptionList
2464 E:EndPassword << CRT_END_OP (E); >>
2465 ";"
2466 ;
2467
2468 vfrPasswordFlagsField [CIfrPassword & PObj, UINT32 LineNum] :
2469 << UINT8 HFlags = 0; >>
2470 passwordFlagsField[HFlags] ( "\|" passwordFlagsField[HFlags] )*
2471 << _PCATCH(PObj.SetFlags(HFlags), LineNum); >>
2472 ;
2473
2474 passwordFlagsField [UINT8 & HFlags] :
2475 N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
2476 | questionheaderFlagsField[HFlags]
2477 ;
2478
2479 vfrStatementOrderedList :
2480 <<
2481 CIfrOrderedList OLObj;
2482 UINT32 VarArraySize;
2483 >>
2484 L:OrderedList << OLObj.SetLineNo(L->getLine()); >>
2485 vfrQuestionHeader[OLObj] ","
2486 <<
2487 VarArraySize = _GET_CURRQEST_ARRAY_SIZE();
2488 OLObj.SetMaxContainers ((UINT8) (VarArraySize > 0xFF ? 0xFF : VarArraySize));
2489 >>
2490 {
2491 MaxContainers "=" M:Number "," <<
2492 if (_STOU64(M->getText()) > _STOU8(M->getText())) {
2493 _PCATCH (VFR_RETURN_INVALID_PARAMETER, M->getLine(), "OrderedList MaxContainers takes only one byte, which can't be larger than 0xFF.");
2494 } else if (VarArraySize != 0 && _STOU8(M->getText()) > VarArraySize) {
2495 _PCATCH (VFR_RETURN_INVALID_PARAMETER, M->getLine(), "OrderedList MaxContainers can't be larger than the max number of elements in array.");
2496 }
2497 OLObj.SetMaxContainers (_STOU8(M->getText()));
2498 >>
2499 }
2500 { F:FLAGS "=" vfrOrderedListFlags[OLObj, F->getLine()] }
2501 vfrStatementQuestionOptionList
2502 E:EndList << CRT_END_OP (E); >>
2503 ";"
2504 ;
2505
2506 vfrOrderedListFlags [CIfrOrderedList & OLObj, UINT32 LineNum] :
2507 <<
2508 UINT8 HFlags = 0;
2509 UINT8 LFlags = 0;
2510 >>
2511 orderedlistFlagsField[HFlags, LFlags] ( "\|" orderedlistFlagsField[HFlags, LFlags] )*
2512 << _PCATCH(OLObj.SetFlags (HFlags, LFlags), LineNum); >>
2513 ;
2514
2515 orderedlistFlagsField [UINT8 & HFlags, UINT8 & LFlags] :
2516 N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
2517 | "UNIQUE" << $LFlags |= 0x01; >>
2518 | "NOEMPTY" << $LFlags |= 0x02; >>
2519 | questionheaderFlagsField[HFlags]
2520 ;
2521
2522 vfrStatementTime :
2523 <<
2524 EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
2525 CHAR8 *VarIdStr[3] = {NULL, };
2526 CIfrTime TObj;
2527 EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;
2528 UINT8 Size = OFFSET_OF (EFI_IFR_DEFAULT, Value) + sizeof (EFI_HII_TIME);
2529 >>
2530 L:Time << TObj.SetLineNo(L->getLine()); >>
2531 (
2532 (
2533 vfrQuestionHeader[TObj, QUESTION_TIME] "," <<
2534 if (_GET_CURRQEST_DATATYPE() == EFI_IFR_TYPE_OTHER) {
2535 _GET_CURRQEST_VARTINFO().mVarType = EFI_IFR_TYPE_TIME;
2536 }
2537 >>
2538 { F:FLAGS "=" vfrTimeFlags[TObj, F->getLine()] "," }
2539 vfrStatementQuestionOptionList
2540 )
2541 |
2542 (
2543 Hour VarId "=" T1:StringIdentifier "." T1H:StringIdentifier ","
2544 << _STRCAT(&VarIdStr[0], T1->getText()); _STRCAT(&VarIdStr[0], "."); _STRCAT(&VarIdStr[0], T1H->getText()); >>
2545 Prompt "=" "STRING_TOKEN" "\(" HP:Number "\)" ","
2546 Help "=" "STRING_TOKEN" "\(" HH:Number "\)" ","
2547 minMaxTimeStepDefault[Val.time, 0]
2548
2549 Minute VarId "=" T2:StringIdentifier "." T2M:StringIdentifier ","
2550 << _STRCAT(&VarIdStr[1], T2->getText()); _STRCAT(&VarIdStr[1], "."); _STRCAT(&VarIdStr[1], T2M->getText()); >>
2551 Prompt "=" "STRING_TOKEN" "\(" MP:Number "\)" ","
2552 Help "=" "STRING_TOKEN" "\(" MH:Number "\)" ","
2553 minMaxTimeStepDefault[Val.time, 1]
2554
2555 Second VarId "=" T3:StringIdentifier "." T3S:StringIdentifier ","
2556 << _STRCAT(&VarIdStr[2], T3->getText()); _STRCAT(&VarIdStr[2], "."); _STRCAT(&VarIdStr[2], T3S->getText()); >>
2557 Prompt "=" "STRING_TOKEN" "\(" SP:Number "\)" ","
2558 Help "=" "STRING_TOKEN" "\(" SH:Number "\)" ","
2559 minMaxTimeStepDefault[Val.time, 2]
2560 { G:FLAGS "=" vfrTimeFlags[TObj, G->getLine()] "," }
2561 <<
2562 mCVfrQuestionDB.RegisterOldTimeQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);
2563 TObj.SetQuestionId (QId);
2564 TObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_TIME_STORAGE_TIME);
2565 TObj.SetPrompt (_STOSID(HP->getText()));
2566 TObj.SetHelp (_STOSID(HH->getText()));
2567 if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }
2568 >>
2569 << {CIfrDefault DefaultObj(Size, EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_TIME, Val); DefaultObj.SetLineNo(L->getLine());} >>
2570 )
2571 ( vfrStatementInconsistentIf )*
2572 )
2573 E:EndTime << CRT_END_OP (E); >>
2574 ";"
2575 ;
2576
2577 minMaxTimeStepDefault[EFI_HII_TIME & T, UINT8 KeyValue] :
2578 Minimum "=" Number ","
2579 Maximum "=" Number ","
2580 { "step" "=" Number "," }
2581 {
2582 "default" "=" N:Number "," <<
2583 switch (KeyValue) {
2584 case 0:
2585 T.Hour = _STOU8(N->getText());
2586 if (T.Hour > 23) {
2587 _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Hour default value must be between 0 and 23.");
2588 }
2589 break;
2590 case 1:
2591 T.Minute = _STOU8(N->getText());
2592 if (T.Minute > 59) {
2593 _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Minute default value must be between 0 and 59.");
2594 }
2595 break;
2596 case 2:
2597 T.Second = _STOU8(N->getText());
2598 if (T.Second > 59) {
2599 _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Second default value must be between 0 and 59.");
2600 }
2601 break;
2602 }
2603 >>
2604 }
2605 ;
2606
2607 vfrTimeFlags [CIfrTime & TObj, UINT32 LineNum] :
2608 << UINT8 LFlags = 0; >>
2609 timeFlagsField[LFlags] ( "\|" timeFlagsField[LFlags] )*
2610 << _PCATCH(TObj.SetFlags(EFI_IFR_QUESTION_FLAG_DEFAULT, LFlags), LineNum); >>
2611 ;
2612
2613 timeFlagsField [UINT8 & Flags] :
2614 N:Number << $Flags |= _STOU8(N->getText()); >>
2615 | "HOUR_SUPPRESS" << $Flags |= 0x01; >>
2616 | "MINUTE_SUPPRESS" << $Flags |= 0x02; >>
2617 | "SECOND_SUPPRESS" << $Flags |= 0x04; >>
2618 | "STORAGE_NORMAL" << $Flags |= 0x00; >>
2619 | "STORAGE_TIME" << $Flags |= 0x10; >>
2620 | "STORAGE_WAKEUP" << $Flags |= 0x20; >>
2621 ;
2622
2623 vfrStatementQuestionTag :
2624 vfrStatementStatTag "," |
2625 vfrStatementInconsistentIf |
2626 vfrStatementNoSubmitIf |
2627 vfrStatementDisableIfQuest |
2628 vfrStatementRefresh |
2629 vfrStatementVarstoreDevice |
2630 vfrStatementExtension |
2631 vfrStatementRefreshEvent |
2632 vfrStatementWarningIf
2633 ;
2634
2635 vfrStatementQuestionTagList :
2636 ( vfrStatementQuestionTag )*
2637 ;
2638
2639 vfrStatementQuestionOptionTag :
2640 vfrStatementSuppressIfQuest |
2641 vfrStatementGrayOutIfQuest |
2642 vfrStatementValue |
2643 vfrStatementDefault |
2644 vfrStatementRead |
2645 vfrStatementWrite |
2646 vfrStatementOptions
2647 ;
2648
2649 vfrStatementQuestionOptionList :
2650 (
2651 vfrStatementQuestionTag |
2652 vfrStatementQuestionOptionTag
2653 )*
2654 ;
2655
2656 vfrStatementStatList :
2657 vfrStatementStat |
2658 vfrStatementQuestions |
2659 vfrStatementConditionalNew |
2660 vfrStatementLabel |
2661 vfrStatementExtension |
2662 // Just for framework vfr compatibility
2663 vfrStatementInvalid
2664 ;
2665
2666 vfrStatementStatListOld :
2667 vfrStatementStat |
2668 vfrStatementQuestions |
2669 vfrStatementLabel |
2670 // Just for framework vfr compatibility
2671 vfrStatementInvalid
2672 ;
2673
2674 vfrStatementDisableIfStat :
2675 <<
2676 CIfrDisableIf DIObj;
2677 >>
2678 L:DisableIf << DIObj.SetLineNo(L->getLine()); >>
2679 vfrStatementExpression[0] ";"
2680 ( vfrStatementStatList )*
2681 E:EndIf << CRT_END_OP (E); >>
2682 ";"
2683 ;
2684
2685 vfrStatementInconsistentIfStat :
2686 << CIfrInconsistentIf IIObj; >>
2687 L:InconsistentIf <<
2688 if (!mCompatibleMode) {
2689 _PCATCH (VFR_RETURN_UNSUPPORTED, L);
2690 }
2691 IIObj.SetLineNo(L->getLine());
2692 >>
2693 Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" "," << IIObj.SetError (_STOSID(S->getText())); >>
2694 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2695 vfrStatementExpression[0]
2696 E:EndIf << CRT_END_OP (E); >>
2697 ";"
2698 ;
2699
2700 //
2701 // Compatible for framework vfr file
2702 //
2703 vfrStatementgrayoutIfSuppressIf:
2704 << CIfrSuppressIf SIObj; >>
2705 L:SuppressIf << SIObj.SetLineNo(L->getLine()); >>
2706 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2707 vfrStatementExpression[0]
2708 ";"
2709 ;
2710
2711 vfrStatementsuppressIfGrayOutIf:
2712 << CIfrGrayOutIf GOIObj; >>
2713 L:GrayOutIf << GOIObj.SetLineNo(L->getLine()); >>
2714 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2715 vfrStatementExpression[0]
2716 ";"
2717 ;
2718
2719 vfrStatementSuppressIfStatNew :
2720 << CIfrSuppressIf SIObj;>>
2721 L:SuppressIf << SIObj.SetLineNo(L->getLine()); >>
2722 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2723 vfrStatementExpression[0]
2724 ";"
2725 ( vfrStatementStatList )*
2726 E: EndIf ";" << CRT_END_OP (E); >>
2727 ;
2728
2729 vfrStatementGrayOutIfStatNew :
2730 << CIfrGrayOutIf GOIObj;>>
2731 L:GrayOutIf << GOIObj.SetLineNo(L->getLine()); >>
2732 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2733 vfrStatementExpression[0]
2734 ";"
2735 ( vfrStatementStatList )*
2736 E: EndIf ";" << CRT_END_OP (E); >>
2737 ;
2738
2739 vfrStatementSuppressIfStatOld :
2740 <<
2741 CIfrSuppressIf SIObj;
2742 BOOLEAN GrayOutExist = FALSE;
2743 >>
2744 L:SuppressIf << SIObj.SetLineNo(L->getLine()); >>
2745 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2746 vfrStatementExpression[0]
2747 ";"
2748 {
2749 vfrStatementsuppressIfGrayOutIf
2750 << GrayOutExist = TRUE; >>
2751 }
2752 ( vfrStatementStatListOld )*
2753 E: EndIf ";" << if (GrayOutExist) CRT_END_OP (E); CRT_END_OP (E);>>
2754 ;
2755
2756 vfrStatementGrayOutIfStatOld :
2757 <<
2758 CIfrGrayOutIf GOIObj;
2759 BOOLEAN SuppressExist = FALSE;
2760 >>
2761 L:GrayOutIf << GOIObj.SetLineNo(L->getLine()); >>
2762 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2763 vfrStatementExpression[0]
2764 ";"
2765 {
2766 vfrStatementgrayoutIfSuppressIf
2767 << SuppressExist = TRUE; >>
2768 }
2769 ( vfrStatementStatListOld )*
2770 E: EndIf ";" << if (SuppressExist) CRT_END_OP (E); CRT_END_OP (E); >>
2771 ;
2772
2773 vfrImageTag :
2774 << CIfrImage IObj; >>
2775 L:Image "=" "IMAGE_TOKEN" "\(" S1:Number "\)" << IObj.SetImageId (_STOSID(S1->getText())); IObj.SetLineNo(L->getLine()); >>
2776 ;
2777
2778 vfrLockedTag :
2779 << CIfrLocked LObj; >>
2780 L:Locked << LObj.SetLineNo(L->getLine()); >>
2781 ;
2782
2783 vfrModalTag :
2784 << CIfrModal MObj; >>
2785 L:Modal << MObj.SetLineNo(L->getLine()); >>
2786 ;
2787
2788 vfrStatementStatTag :
2789 vfrImageTag |
2790 vfrLockedTag
2791 ;
2792
2793 vfrStatementStatTagList :
2794 vfrStatementStatTag ( "," vfrStatementStatTag )*
2795 ;
2796
2797 vfrStatementImage :
2798 vfrImageTag
2799 ";"
2800 ;
2801
2802 vfrStatementModal :
2803 vfrModalTag
2804 ";"
2805 ;
2806
2807 vfrStatementLocked :
2808 vfrLockedTag
2809 ";"
2810 ;
2811
2812 vfrStatementInconsistentIf :
2813 << CIfrInconsistentIf IIObj; >>
2814 L:InconsistentIf << IIObj.SetLineNo(L->getLine()); >>
2815 Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" "," << IIObj.SetError (_STOSID(S->getText())); >>
2816 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2817 vfrStatementExpression[0]
2818 E:EndIf << CRT_END_OP (E); >>
2819 ;
2820
2821 vfrStatementNoSubmitIf :
2822 << CIfrNoSubmitIf NSIObj; >>
2823 L:NoSubmitIf << NSIObj.SetLineNo(L->getLine()); >>
2824 Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" "," << NSIObj.SetError (_STOSID(S->getText())); >>
2825 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2826 vfrStatementExpression[0]
2827 E:EndIf << CRT_END_OP (E); >>
2828 ;
2829
2830 vfrStatementWarningIf :
2831 << CIfrWarningIf WIObj; >>
2832 L:WarningIf << WIObj.SetLineNo(L->getLine()); >>
2833 Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" "," << WIObj.SetWarning (_STOSID(S->getText())); >>
2834 {Timeout "=" T:Number "," << WIObj.SetTimeOut (_STOU8(T->getText())); >>}
2835 vfrStatementExpression[0]
2836 E:EndIf << CRT_END_OP (E); >>
2837 ;
2838
2839 vfrStatementDisableIfQuest :
2840 <<
2841 CIfrDisableIf DIObj;
2842 >>
2843 L:DisableIf << DIObj.SetLineNo(L->getLine()); >>
2844 vfrStatementExpression[0] ";"
2845 vfrStatementQuestionOptionList
2846 E:EndIf << CRT_END_OP (E); >>
2847 ;
2848
2849 vfrStatementRefresh :
2850 << CIfrRefresh RObj; >>
2851 L:Refresh << RObj.SetLineNo(L->getLine()); >>
2852 Interval "=" I:Number << RObj.SetRefreshInterval (_STOU8(I->getText())); >>
2853 ;
2854
2855 vfrStatementRefreshEvent :
2856 <<
2857 CIfrRefreshId RiObj;
2858 EFI_GUID Guid;
2859 >>
2860 L:RefreshGuid << RiObj.SetLineNo(L->getLine()); >>
2861 "=" guidDefinition[Guid] "," << RiObj.SetRefreshEventGroutId (&Guid); >>
2862 ;
2863
2864 vfrStatementVarstoreDevice :
2865 << CIfrVarStoreDevice VDObj; >>
2866 L:VarstoreDevice << VDObj.SetLineNo(L->getLine()); >>
2867 "=" "STRING_TOKEN" "\(" S:Number "\)" "," << VDObj.SetDevicePath (_STOSID(S->getText())); >>
2868 ;
2869
2870 vfrStatementSuppressIfQuest :
2871 << CIfrSuppressIf SIObj; >>
2872 L:SuppressIf << SIObj.SetLineNo(L->getLine()); >>
2873 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2874 vfrStatementExpression[0] ";"
2875 vfrStatementQuestionOptionList
2876 E:EndIf << CRT_END_OP (E); >>
2877 ;
2878
2879 vfrStatementGrayOutIfQuest :
2880 << CIfrGrayOutIf GOIObj; >>
2881 L:GrayOutIf << GOIObj.SetLineNo(L->getLine()); >>
2882 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2883 vfrStatementExpression[0] ";"
2884 vfrStatementQuestionOptionList
2885 E:EndIf << CRT_END_OP (E); >>
2886 ;
2887
2888 vfrStatementOptions :
2889 vfrStatementOneOfOption
2890 ;
2891
2892 vfrStatementOneOfOption :
2893 <<
2894 EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;
2895 CHAR8 *VarStoreName = NULL;
2896 UINT32 Size = 0;
2897 BOOLEAN TypeError = FALSE;
2898 EFI_VFR_RETURN_CODE ReturnCode = VFR_RETURN_SUCCESS;
2899 EFI_GUID *VarStoreGuid = NULL;
2900
2901 if (_GET_CURRQEST_DATATYPE() == EFI_IFR_TYPE_OTHER) {
2902 TypeError = TRUE;
2903 Size = sizeof (EFI_IFR_TYPE_VALUE);
2904 } else {
2905 ReturnCode = gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &Size);
2906 }
2907
2908 Size += OFFSET_OF (EFI_IFR_ONE_OF_OPTION, Value);
2909 CIfrOneOfOption OOOObj ((UINT8)Size);
2910 >>
2911 L:Option <<
2912 OOOObj.SetLineNo(L->getLine());
2913 if (TypeError) {
2914 _PCATCH (VFR_RETURN_FATAL_ERROR, L->getLine(), "Get data type error.");
2915 }
2916 if (ReturnCode != VFR_RETURN_SUCCESS) {
2917 _PCATCH (ReturnCode, L->getLine());
2918 }
2919 >>
2920 Text "=" "STRING_TOKEN" "\(" S:Number "\)" "," << OOOObj.SetOption (_STOSID(S->getText())); >>
2921 Value "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] >[Val] ","
2922 <<
2923 if (gCurrentMinMaxData != NULL) {
2924 //set min/max value for oneof opcode
2925 UINT64 Step = gCurrentMinMaxData->GetStepData(_GET_CURRQEST_DATATYPE());
2926 switch (_GET_CURRQEST_DATATYPE()) {
2927 case EFI_IFR_TYPE_NUM_SIZE_64:
2928 gCurrentMinMaxData->SetMinMaxStepData(Val.u64, Val.u64, Step);
2929 break;
2930 case EFI_IFR_TYPE_NUM_SIZE_32:
2931 gCurrentMinMaxData->SetMinMaxStepData(Val.u32, Val.u32, (UINT32) Step);
2932 break;
2933 case EFI_IFR_TYPE_NUM_SIZE_16:
2934 gCurrentMinMaxData->SetMinMaxStepData(Val.u16, Val.u16, (UINT16) Step);
2935 break;
2936 case EFI_IFR_TYPE_NUM_SIZE_8:
2937 gCurrentMinMaxData->SetMinMaxStepData(Val.u8, Val.u8, (UINT8) Step);
2938 break;
2939 default:
2940 break;
2941 }
2942 }
2943 OOOObj.SetType (_GET_CURRQEST_DATATYPE());
2944 OOOObj.SetValue (Val);
2945 >>
2946 F:FLAGS "=" vfrOneOfOptionFlags[OOOObj, F->getLine()]
2947 <<
2948 if (_GET_CURRQEST_VARTINFO().mVarStoreId != EFI_VARSTORE_ID_INVALID) {
2949 _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), L->getLine());
2950 VarStoreGuid = mCVfrDataStorage.GetVarStoreGuid(_GET_CURRQEST_VARTINFO().mVarStoreId);
2951 if (OOOObj.GetFlags () & 0x10) {
2952 CheckDuplicateDefaultValue (EFI_HII_DEFAULT_CLASS_STANDARD, F);
2953 _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
2954 EFI_HII_DEFAULT_CLASS_STANDARD,
2955 _GET_CURRQEST_VARTINFO(),
2956 VarStoreName,
2957 VarStoreGuid,
2958 _GET_CURRQEST_DATATYPE (),
2959 Val
2960 ), L->getLine());
2961 }
2962 if (OOOObj.GetFlags () & 0x20) {
2963 CheckDuplicateDefaultValue (EFI_HII_DEFAULT_CLASS_MANUFACTURING, F);
2964 _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
2965 EFI_HII_DEFAULT_CLASS_MANUFACTURING,
2966 _GET_CURRQEST_VARTINFO(),
2967 VarStoreName,
2968 VarStoreGuid,
2969 _GET_CURRQEST_DATATYPE (),
2970 Val
2971 ), L->getLine());
2972 }
2973 }
2974 >>
2975 {
2976 "," Key "=" KN:Number <<
2977 if (!mCompatibleMode) {
2978 _PCATCH (VFR_RETURN_UNSUPPORTED, KN);
2979 }
2980 //
2981 // Guid Option Key
2982 //
2983 CIfrOptionKey IfrOptionKey (
2984 gCurrentQuestion->QUESTION_ID(),
2985 Val,
2986 _STOQID(KN->getText())
2987 );
2988 SET_LINE_INFO (IfrOptionKey, KN);
2989 >>
2990 }
2991 (
2992 T:"," vfrImageTag << OOOObj.SetScope (1); CRT_END_OP (T); >>
2993 )*
2994 ";"
2995 ;
2996
2997 vfrOneOfOptionFlags [CIfrOneOfOption & OOOObj, UINT32 LineNum] :
2998 <<
2999 UINT8 LFlags = _GET_CURRQEST_DATATYPE();
3000 UINT8 HFlags = 0;
3001 >>
3002 oneofoptionFlagsField[HFlags, LFlags] ( "\|" oneofoptionFlagsField[HFlags, LFlags] )*
3003 << _PCATCH(gCurrentQuestion->SetFlags(HFlags), LineNum); >>
3004 << _PCATCH(OOOObj.SetFlags(LFlags), LineNum); >>
3005 ;
3006
3007 oneofoptionFlagsField [UINT8 & HFlags, UINT8 & LFlags] :
3008 N:Number << $LFlags |= _STOU8(N->getText()); >>
3009 | "OPTION_DEFAULT" << $LFlags |= 0x10; >>
3010 | "OPTION_DEFAULT_MFG" << $LFlags |= 0x20; >>
3011 | InteractiveFlag << $HFlags |= 0x04; >>
3012 | NVAccessFlag << $HFlags |= 0x08; >>
3013 | ResetRequiredFlag << $HFlags |= 0x10; >>
3014 | LateCheckFlag << $HFlags |= 0x20; >>
3015 | ManufacturingFlag << $LFlags |= 0x20; >>
3016 | DefaultFlag << $LFlags |= 0x10; >>
3017 ;
3018
3019 vfrStatementLabel :
3020 L:Label
3021 N:Number <<
3022 if (mCompatibleMode) {
3023 //
3024 // Add end Label for Framework Vfr
3025 //
3026 CIfrLabel LObj1;
3027 LObj1.SetLineNo(L->getLine());
3028 LObj1.SetNumber (0xffff); //add end label for UEFI, label number hardcode 0xffff
3029 }
3030
3031 {
3032 CIfrLabel LObj2;
3033 LObj2.SetLineNo(L->getLine());
3034 LObj2.SetNumber (_STOU16(N->getText()));
3035 }
3036 >>
3037 ";"
3038 ;
3039
3040 vfrStatementBanner :
3041 << CIfrBanner BObj; >>
3042 B:Banner { "," } << BObj.SetLineNo(B->getLine()); >>
3043 Title "=" "STRING_TOKEN" "\(" S:Number "\)" "," << BObj.SetTitle (_STOSID(S->getText())); >>
3044 (
3045 (
3046 Line L:Number "," << BObj.SetLine (_STOU16(L->getText())); >>
3047 Align
3048 (
3049 Left << BObj.SetAlign (0); >>
3050 | Center << BObj.SetAlign (1); >>
3051 | Right << BObj.SetAlign (2); >>
3052 ) ";"
3053 )
3054 |
3055 (
3056 Timeout "=" T:Number ";" << {CIfrTimeout TObj(_STOU16(T->getText()));} >>
3057 )
3058 )
3059 ;
3060
3061 //******************************************************************************
3062 //
3063 // keep some syntax for compatibility but not generate any IFR object
3064 //
3065 vfrStatementInvalidHidden :
3066 L:Hidden <<
3067 if (!mCompatibleMode) {
3068 _PCATCH (VFR_RETURN_UNSUPPORTED, L);
3069 }
3070 >>
3071 Value "=" Number ","
3072 Key "=" Number ";"
3073 ;
3074
3075 vfrStatementInvalidInconsistentIf :
3076 InconsistentIf
3077 Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" ","
3078 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
3079 vfrStatementExpression[0]
3080 EndIf
3081 ";"
3082 ;
3083
3084 vfrStatementInvalidInventory :
3085 L:Inventory <<
3086 if (!mCompatibleMode) {
3087 _PCATCH (VFR_RETURN_UNSUPPORTED, L);
3088 }
3089 >>
3090 Help "=" "STRING_TOKEN" "\(" Number "\)" ","
3091 Text "=" "STRING_TOKEN" "\(" Number "\)" ","
3092 {
3093 Text "=" "STRING_TOKEN" "\(" Number "\)"
3094 }
3095 ";"
3096 ;
3097
3098 vfrStatementInvalidSaveRestoreDefaults :
3099 (
3100 L:Save <<
3101 if (!mCompatibleMode) {
3102 _PCATCH (VFR_RETURN_UNSUPPORTED, L);
3103 }
3104 >>
3105 |
3106 K:Restore <<
3107 if (!mCompatibleMode) {
3108 _PCATCH (VFR_RETURN_UNSUPPORTED, K);
3109 }
3110 >>
3111 )
3112 Defaults ","
3113 FormId "=" Number ","
3114 Prompt "=" "STRING_TOKEN" "\(" Number "\)" ","
3115 Help "=" "STRING_TOKEN" "\(" Number "\)"
3116 { "," FLAGS "=" flagsField ( "\|" flagsField )* }
3117 { "," Key "=" Number }
3118 ";"
3119 ;
3120
3121 //******************************************************************************
3122 //
3123 // The syntax of expression
3124 //
3125 #token Dup("dup") "dup"
3126 #token VarEqVal("vareqval") "vareqval"
3127 #token Var("var") "var"
3128 #token IdEqVal("ideqval") "ideqval"
3129 #token IdEqId("ideqid") "ideqid"
3130 #token IdEqValList("ideqvallist") "ideqvallist"
3131 #token QuestionRef("questionref") "questionref"
3132 #token RuleRef("ruleref") "ruleref"
3133 #token StringRef("stringref") "stringref"
3134 #token PushThis("pushthis") "pushthis"
3135 #token Security("security") "security"
3136 #token Get("get") "get"
3137 #token True("TRUE") "TRUE"
3138 #token False("FALSE") "FALSE"
3139 #token One("ONE") "ONE"
3140 #token Ones("ONES") "ONES"
3141 #token Zero("ZERO") "ZERO"
3142 #token Undefined("UNDEFINED") "UNDEFINED"
3143 #token Version("VERSION") "VERSION"
3144 #token Length("length") "length"
3145 #token AND("AND") "AND"
3146 #token OR("OR") "OR"
3147 #token NOT("NOT") "NOT"
3148 #token Set("set") "set"
3149 #token BitWiseNot("~") "\~"
3150 #token BoolVal("boolval") "boolval"
3151 #token StringVal("stringval") "stringval"
3152 #token UnIntVal("unintval") "unintval"
3153 #token ToUpper("toupper") "toupper"
3154 #token ToLower("tolower") "tolower"
3155 #token Match("match") "match"
3156 #token Catenate("catenate") "catenate"
3157 #token QuestionRefVal("questionrefval") "questionrefval"
3158 #token StringRefVal("stringrefval") "stringrefval"
3159 #token Map("map") "map"
3160 #token RefreshGuid("refreshguid") "refreshguid"
3161
3162 //
3163 // Root expression extension function called by other function.
3164 //
3165 vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :
3166 << if ($RootLevel == 0) {mCIfrOpHdrIndex ++; if (mCIfrOpHdrIndex >= MAX_IFR_EXPRESSION_DEPTH) _PCATCH (VFR_RETURN_INVALID_PARAMETER, 0, "The depth of expression exceeds the max supported level 8!"); _CLEAR_SAVED_OPHDR ();} >>
3167 andTerm[$RootLevel, $ExpOpCount]
3168 (
3169 L:OR andTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrOr OObj(L->getLine()); >>
3170 )*
3171 <<
3172 //
3173 // Extend OpCode Scope only for the root expression.
3174 //
3175 if ($ExpOpCount > 1 && $RootLevel == 0) {
3176 if (_SET_SAVED_OPHDR_SCOPE()) {
3177 CIfrEnd EObj;
3178 if (mCIfrOpHdrLineNo[mCIfrOpHdrIndex] != 0) {
3179 EObj.SetLineNo (mCIfrOpHdrLineNo[mCIfrOpHdrIndex]);
3180 }
3181 }
3182 }
3183
3184 if ($RootLevel == 0) {
3185 mCIfrOpHdrIndex --;
3186 }
3187 >>
3188 ;
3189
3190 //
3191 // Add new sub function for the sub expression extension to remember the ExpOpCount
3192 // This funciton is only called by sub expression.
3193 //
3194 vfrStatementExpressionSub [UINT32 RootLevel, UINT32 & ExpOpCount] :
3195 andTerm[$RootLevel, $ExpOpCount]
3196 (
3197 L:OR andTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrOr OObj(L->getLine()); >>
3198 )*
3199 ;
3200
3201 andTerm[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3202 bitwiseorTerm[$RootLevel, $ExpOpCount]
3203 (
3204 L:AND bitwiseorTerm [$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrAnd AObj(L->getLine()); >>
3205 )*
3206 ;
3207
3208 bitwiseorTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3209 bitwiseandTerm[$RootLevel, $ExpOpCount]
3210 (
3211 L:"\|" bitwiseandTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrBitWiseOr BWOObj(L->getLine()); >>
3212 )*
3213 ;
3214
3215 bitwiseandTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3216 equalTerm[$RootLevel, $ExpOpCount]
3217 (
3218 L:"&" equalTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrBitWiseAnd BWAObj(L->getLine()); >>
3219 )*
3220 ;
3221
3222 equalTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3223 compareTerm[$RootLevel, $ExpOpCount]
3224 (
3225 (
3226 L1:"==" compareTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrEqual EObj(L1->getLine()); >>
3227 )
3228 |
3229 (
3230 L2:"!=" compareTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrNotEqual NEObj(L2->getLine()); >>
3231 )
3232 )*
3233 ;
3234
3235 compareTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3236 shiftTerm[$RootLevel, $ExpOpCount]
3237 (
3238 (
3239 L1:"<" shiftTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrLessThan LTObj(L1->getLine()); >>
3240 )
3241 |
3242 (
3243 L2:"<=" shiftTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrLessEqual LEObj(L2->getLine()); >>
3244 )
3245 |
3246 (
3247 L3:">" shiftTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrGreaterThan GTObj(L3->getLine()); >>
3248 )
3249 |
3250 (
3251 L4:">=" shiftTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrGreaterEqual GEObj(L4->getLine()); >>
3252 )
3253 )*
3254 ;
3255
3256 shiftTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3257 addMinusTerm[$RootLevel, $ExpOpCount]
3258 (
3259 (
3260 L1:"\<<" addMinusTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrShiftLeft SLObj(L1->getLine()); >>
3261 )
3262 |
3263 (
3264 L2:"\>>" addMinusTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrShiftRight SRObj(L2->getLine()); >>
3265 )
3266 )*
3267 ;
3268
3269 addMinusTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3270 multdivmodTerm[$RootLevel, $ExpOpCount]
3271 (
3272 (
3273 L1:"\+" multdivmodTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrAdd AObj(L1->getLine()); >>
3274 )
3275 |
3276 (
3277 L2:"\-" multdivmodTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrSubtract SObj(L2->getLine()); >>
3278 )
3279 )*
3280 ;
3281
3282 multdivmodTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3283 castTerm[$RootLevel, $ExpOpCount]
3284 (
3285 (
3286 L1:"\*" castTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrMultiply MObj(L1->getLine()); >>
3287 )
3288 |
3289 (
3290 L2:"/" castTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrDivide DObj(L2->getLine()); >>
3291 )
3292 |
3293 (
3294 L3:"%" castTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrModulo MObj(L3->getLine()); >>
3295 )
3296 )*
3297 ;
3298
3299 castTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3300 << UINT8 CastType = 0xFF; >>
3301 (
3302 L:"\("
3303 (
3304 Boolean << CastType = 0; >>
3305 | Uint64 << CastType = 1; >>
3306 | Uint32 << CastType = 1; >>
3307 | Uint16 << CastType = 1; >>
3308 | Uint8 << CastType = 1; >>
3309 )
3310 "\)"
3311 )*
3312 atomTerm[$RootLevel, $ExpOpCount]
3313 <<
3314 switch (CastType) {
3315 case 0: { CIfrToBoolean TBObj(L->getLine()); $ExpOpCount++; } break;
3316 case 1: { CIfrToUint TUObj(L->getLine()); $ExpOpCount++; } break;
3317 }
3318 >>
3319 ;
3320
3321 atomTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3322 vfrExpressionCatenate[$RootLevel, $ExpOpCount]
3323 | vfrExpressionMatch[$RootLevel, $ExpOpCount]
3324 | vfrExpressionParen[$RootLevel, $ExpOpCount]
3325 | vfrExpressionBuildInFunction[$RootLevel, $ExpOpCount]
3326 | vfrExpressionConstant[$RootLevel, $ExpOpCount]
3327 | vfrExpressionUnaryOp[$RootLevel, $ExpOpCount]
3328 | vfrExpressionTernaryOp[$RootLevel, $ExpOpCount]
3329 | vfrExpressionMap[$RootLevel, $ExpOpCount]
3330 | (
3331 L:NOT
3332 atomTerm[$RootLevel, $ExpOpCount] << { CIfrNot NObj(L->getLine()); $ExpOpCount++; } >>
3333 )
3334 ;
3335
3336 vfrExpressionCatenate [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3337 L:Catenate
3338 "\("
3339 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3340 ","
3341 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3342 "\)" << { CIfrCatenate CObj(L->getLine()); $ExpOpCount++; } >>
3343 ;
3344
3345 vfrExpressionMatch [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3346 L:Match
3347 "\("
3348 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3349 ","
3350 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3351 "\)" << { CIfrMatch MObj(L->getLine()); $ExpOpCount++; } >>
3352 ;
3353
3354 vfrExpressionParen [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3355 "\("
3356 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3357 "\)"
3358 ;
3359
3360 vfrExpressionBuildInFunction [UINT32 & RootLevel, UINT32 & ExpOpCount] :
3361 dupExp[$RootLevel, $ExpOpCount]
3362 | vareqvalExp[$RootLevel, $ExpOpCount] //Compatible for Framework vareqval
3363 | ideqvalExp[$RootLevel, $ExpOpCount]
3364 | ideqidExp[$RootLevel, $ExpOpCount]
3365 | ideqvallistExp[$RootLevel, $ExpOpCount]
3366 | questionref1Exp[$RootLevel, $ExpOpCount]
3367 | rulerefExp[$RootLevel, $ExpOpCount]
3368 | stringref1Exp[$RootLevel, $ExpOpCount]
3369 | pushthisExp[$RootLevel, $ExpOpCount]
3370 | securityExp[$RootLevel, $ExpOpCount]
3371 | getExp[$RootLevel, $ExpOpCount]
3372 ;
3373
3374 dupExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :
3375 L:Dup << { CIfrDup DObj(L->getLine()); _SAVE_OPHDR_COND(DObj, ($ExpOpCount == 0), L->getLine()); $ExpOpCount++; } >>
3376 ;
3377
3378 vareqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :
3379 <<
3380 EFI_QUESTION_ID QId;
3381 UINT32 Mask;
3382 UINT16 ConstVal;
3383 CHAR8 *VarIdStr;
3384 UINT32 LineNo;
3385 EFI_VFR_RETURN_CODE VfrReturnCode = VFR_RETURN_SUCCESS;
3386 EFI_VARSTORE_ID VarStoreId = EFI_VARSTORE_ID_INVALID;
3387 >>
3388 L:VarEqVal <<
3389 if (!mCompatibleMode) {
3390 _PCATCH (VFR_RETURN_UNSUPPORTED, L);
3391 }
3392 >>
3393 VK:Var
3394 OpenParen
3395 VN:Number <<
3396 VarIdStr = NULL; _STRCAT(&VarIdStr, VK->getText()); _STRCAT(&VarIdStr, VN->getText());
3397 VfrReturnCode = mCVfrDataStorage.GetVarStoreId (VarIdStr, &VarStoreId);
3398 if (VfrReturnCode == VFR_RETURN_UNDEFINED) {
3399 _PCATCH (mCVfrDataStorage.DeclareEfiVarStore (
3400 VarIdStr,
3401 &mFormsetGuid,
3402 _STOSID(VN->getText()),
3403 0x2, //default type is UINT16
3404 FALSE
3405 ), VN);
3406 } else {
3407 _PCATCH (VfrReturnCode, VN);
3408 }
3409 mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, QId, Mask);
3410 LineNo = GET_LINENO(VN);
3411 >>
3412 CloseParen
3413 (
3414 (
3415 "=="
3416 V1:Number << ConstVal = _STOU16(V1->getText()); >>
3417 <<
3418 if (Mask == 0) {
3419 CIfrEqIdVal EIVObj (L->getLine());
3420 _SAVE_OPHDR_COND (EIVObj, ($ExpOpCount == 0), L->getLine());
3421 EIVObj.SetQuestionId (QId, VarIdStr, LineNo);
3422 EIVObj.SetValue (ConstVal);
3423 $ExpOpCount++;
3424 } else {
3425 IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, EQUAL);
3426 }
3427 >>
3428 )
3429 |
3430 (
3431 "<="
3432 V2:Number << ConstVal = _STOU16(V2->getText()); >>
3433 << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, LESS_EQUAL); >>
3434 )
3435 |
3436 (
3437 "<"
3438 V3:Number << ConstVal = _STOU16(V3->getText()); >>
3439 << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, LESS_THAN); >>
3440 )
3441 |
3442 (
3443 ">="
3444 V4:Number << ConstVal = _STOU16(V4->getText()); >>
3445 << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_EQUAL); >>
3446 )
3447 |
3448 (
3449 ">"
3450 V5:Number << ConstVal = _STOU16(V5->getText()); >>
3451 << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_THAN); >>
3452 )
3453 )
3454 ;
3455
3456 ideqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :
3457 <<
3458 EFI_QUESTION_ID QId;
3459 UINT32 Mask;
3460 UINT16 ConstVal;
3461 CHAR8 *VarIdStr;
3462 UINT32 LineNo;
3463 >>
3464 L:IdEqVal
3465 vfrQuestionDataFieldName[QId, Mask, VarIdStr, LineNo]
3466 (
3467 (
3468 "=="
3469 V1:Number << ConstVal = _STOU16(V1->getText()); >>
3470 <<
3471 if (Mask == 0) {
3472 CIfrEqIdVal EIVObj (L->getLine());
3473 _SAVE_OPHDR_COND (EIVObj, ($ExpOpCount == 0), L->getLine());
3474 EIVObj.SetQuestionId (QId, VarIdStr, LineNo);
3475 EIVObj.SetValue (ConstVal);
3476 $ExpOpCount++;
3477 } else {
3478 IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, EQUAL);
3479 }
3480 >>
3481 )
3482 |
3483 (
3484 "<="
3485 V2:Number << ConstVal = _STOU16(V2->getText()); >>
3486 << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, LESS_EQUAL); >>
3487 )
3488 |
3489 (
3490 "<"
3491 V3:Number << ConstVal = _STOU16(V3->getText()); >>
3492 << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, LESS_THAN); >>
3493 )
3494 |
3495 (
3496 ">="
3497 V4:Number << ConstVal = _STOU16(V4->getText()); >>
3498 << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_EQUAL); >>
3499 )
3500 |
3501 (
3502 ">"
3503 V5:Number << ConstVal = _STOU16(V5->getText()); >>
3504 << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_THAN); >>
3505 )
3506 )
3507 ;
3508
3509 ideqidExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3510 <<
3511 EFI_QUESTION_ID QId[2];
3512 UINT32 Mask[2];
3513 CHAR8 *VarIdStr[2];
3514 UINT32 LineNo[2];
3515 >>
3516 L:IdEqId
3517 vfrQuestionDataFieldName[QId[0], Mask[0], VarIdStr[0], LineNo[0]]
3518 (
3519 (
3520 "=="
3521 vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]
3522 <<
3523 if (Mask[0] & Mask[1]) {
3524 IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], EQUAL);
3525 } else {
3526 CIfrEqIdId EIIObj(L->getLine());
3527 _SAVE_OPHDR_COND (EIIObj, ($ExpOpCount == 0), L->getLine());
3528 EIIObj.SetQuestionId1 (QId[0], VarIdStr[0], LineNo[0]);
3529 EIIObj.SetQuestionId2 (QId[1], VarIdStr[1], LineNo[1]);
3530 $ExpOpCount++;
3531 }
3532 >>
3533 )
3534 |
3535 (
3536 "<="
3537 vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]
3538 << IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], LESS_EQUAL); >>
3539 )
3540 |
3541 (
3542 "<"
3543 vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]
3544 << IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], LESS_THAN); >>
3545 )
3546 |
3547 (
3548 ">="
3549 vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]
3550 << IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], GREATER_EQUAL); >>
3551 )
3552 |
3553 (
3554 ">"
3555 vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]
3556 << IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], GREATER_THAN); >>
3557 )
3558 )
3559 ;
3560
3561 ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3562 <<
3563 UINT16 ListLen = 0;
3564 EFI_QUESTION_ID QId;
3565 UINT32 Mask;
3566 UINT16 ValueList[EFI_IFR_MAX_LENGTH] = {0,};
3567 CHAR8 *VarIdStr;
3568 UINT32 LineNo;
3569 >>
3570 L:IdEqValList
3571 vfrQuestionDataFieldName[QId, Mask, VarIdStr, LineNo]
3572 "=="
3573 (
3574 V:Number << ValueList[ListLen] = _STOU16(V->getText()); ListLen++; >>
3575 )+
3576 <<
3577 if (Mask != 0) {
3578 IdEqListDoSpecial ($ExpOpCount, LineNo, QId, VarIdStr, Mask, ListLen, ValueList);
3579 } else {
3580 UINT16 Index;
3581 CIfrEqIdList EILObj(L->getLine());
3582 if (QId != EFI_QUESTION_ID_INVALID) {
3583 EILObj.SetQuestionId (QId, VarIdStr, LineNo);
3584 }
3585 EILObj.SetListLength (ListLen);
3586 for