]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/VfrCompile/VfrSyntax.g
Sync BaseTools Branch (version r2271) to EDKII main trunk.
[mirror_edk2.git] / BaseTools / Source / C / VfrCompile / VfrSyntax.g
1 /*++
2 Copyright (c) 2004 - 2011, 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 NoSubmitIf("nosubmitif") "nosubmitif"
188 #token EndIf("endif") "endif"
189 #token Key("key") "key"
190 #token DefaultFlag("DEFAULT") "DEFAULT"
191 #token ManufacturingFlag("MANUFACTURING") "MANUFACTURING"
192 #token InteractiveFlag("INTERACTIVE") "INTERACTIVE"
193 #token NVAccessFlag("NV_ACCESS") "NV_ACCESS"
194 #token ResetRequiredFlag("RESET_REQUIRED") "RESET_REQUIRED"
195 #token LateCheckFlag("LATE_CHECK") "LATE_CHECK"
196 #token ReadOnlyFlag("READ_ONLY") "READ_ONLY"
197 #token OptionOnlyFlag("OPTIONS_ONLY") "OPTIONS_ONLY"
198 #token Class("class") "class"
199 #token Subclass("subclass") "subclass"
200 #token ClassGuid("classguid") "classguid"
201 #token TypeDef("typedef") "typedef"
202 #token Restore("restore") "restore"
203 #token Save("save") "save"
204 #token Defaults("defaults") "defaults"
205 #token Banner("banner") "banner"
206 #token Align("align") "align"
207 #token Left("left") "left"
208 #token Right("right") "right"
209 #token Center("center") "center"
210 #token Line("line") "line"
211 #token Name("name") "name"
212
213 #token VarId("varid") "varid"
214 #token Question("question") "question"
215 #token QuestionId("questionid") "questionid"
216 #token Image("image") "image"
217 #token Locked("locked") "locked"
218 #token Rule("rule") "rule"
219 #token EndRule("endrule") "endrule"
220 #token Value("value") "value"
221 #token Read("read") "read"
222 #token Write("write") "write"
223 #token ResetButton("resetbutton") "resetbutton"
224 #token EndResetButton("endresetbutton") "endresetbutton"
225 #token DefaultStore("defaultstore") "defaultstore"
226 #token Attribute("attribute") "attribute"
227 #token Varstore("varstore") "varstore"
228 #token Efivarstore("efivarstore") "efivarstore"
229 #token VarSize("varsize") "varsize"
230 #token NameValueVarStore("namevaluevarstore") "namevaluevarstore"
231 #token Action("action") "action"
232 #token Config("config") "config"
233 #token EndAction("endaction") "endaction"
234 #token Refresh("refresh") "refresh"
235 #token Interval("interval") "interval"
236 #token VarstoreDevice("varstoredevice") "varstoredevice"
237 #token GuidOp("guidop") "guidop"
238 #token EndGuidOp("endguidop") "endguidop"
239 #token DataType("datatype") "datatype"
240 #token Data("data") "data"
241 #token Modal("modal") "modal"
242
243 //
244 // Define the class and subclass tokens
245 //
246 #token ClassNonDevice("NONDEVICE") "NON_DEVICE"
247 #token ClassDiskDevice("DISK_DEVICE") "DISK_DEVICE"
248 #token ClassVideoDevice("VIDEO_DEVICE") "VIDEO_DEVICE"
249 #token ClassNetworkDevice("NETWORK_DEVICE") "NETWORK_DEVICE"
250 #token ClassInputDevice("INPUT_DEVICE") "INPUT_DEVICE"
251 #token ClassOnBoardDevice("ONBOARD_DEVICE") "ONBOARD_DEVICE"
252 #token ClassOtherDevice("OTHER_DEVICE") "OTHER_DEVICE"
253
254 #token SubclassSetupApplication("SETUP_APPLICATION") "SETUP_APPLICATION"
255 #token SubclassGeneralApplication("GENERAL_APPLICATION") "GENERAL_APPLICATION"
256 #token SubclassFrontPage("FRONT_PAGE") "FRONT_PAGE"
257 #token SubclassSingleUse("SINGLE_USE") "SINGLE_USE"
258
259 //
260 // This is the overall definition of a VFR form definition script.
261 //
262
263 vfrProgram > [UINT8 Return] :
264 <<
265 mParserStatus = 0;
266 mCIfrOpHdrIndex = 0;
267 mConstantOnlyInExpression = FALSE;
268 >>
269 (
270 vfrPragmaPackDefinition
271 | vfrDataStructDefinition
272 )*
273 vfrFormSetDefinition
274 << $Return = mParserStatus; >>
275 ;
276
277 pragmaPackShowDef :
278 L:"show" << gCVfrVarDataTypeDB.Pack (L->getLine(), VFR_PACK_SHOW); >>
279 ;
280
281 pragmaPackStackDef :
282 <<
283 UINT32 LineNum;
284 UINT8 PackAction;
285 CHAR8 *Identifier = NULL;
286 UINT32 PackNumber = DEFAULT_PACK_ALIGN;
287 >>
288 (
289 L1:"push" << LineNum = L1->getLine(); PackAction = VFR_PACK_PUSH; >>
290 | L2:"pop" << LineNum = L2->getLine(); PackAction = VFR_PACK_POP; >>
291 )
292 {
293 "," ID:StringIdentifier << Identifier = ID->getText(); >>
294 }
295 {
296 "," N:Number << PackAction |= VFR_PACK_ASSIGN; PackNumber = _STOU32(N->getText()); >>
297 }
298 << gCVfrVarDataTypeDB.Pack (LineNum, PackAction, Identifier, PackNumber); >>
299 ;
300
301 pragmaPackNumber :
302 <<
303 UINT32 LineNum;
304 UINT32 PackNumber = DEFAULT_PACK_ALIGN;
305 >>
306 N:Number << LineNum = N->getLine(); PackNumber = _STOU32(N->getText()); >>
307 << gCVfrVarDataTypeDB.Pack (LineNum, VFR_PACK_ASSIGN, NULL, PackNumber); >>
308 ;
309
310 vfrPragmaPackDefinition :
311 "\#pragma" "pack" "\("
312 {
313 pragmaPackShowDef
314 | pragmaPackStackDef
315 | pragmaPackNumber
316 }
317 "\)"
318 ;
319
320 vfrDataStructDefinition :
321 { TypeDef } Struct << gCVfrVarDataTypeDB.DeclareDataTypeBegin (); >>
322 { NonNvDataMap }
323 {
324 N1:StringIdentifier << _PCATCH(gCVfrVarDataTypeDB.SetNewTypeName (N1->getText()), N1); >>
325 }
326 OpenBrace
327 vfrDataStructFields
328 CloseBrace
329 {
330 N2:StringIdentifier << _PCATCH(gCVfrVarDataTypeDB.SetNewTypeName (N2->getText()), N2); >>
331 }
332 ";" << gCVfrVarDataTypeDB.DeclareDataTypeEnd (); >>
333 ;
334
335 vfrDataStructFields :
336 (
337 dataStructField64 |
338 dataStructField32 |
339 dataStructField16 |
340 dataStructField8 |
341 dataStructFieldBool |
342 dataStructFieldString |
343 dataStructFieldDate |
344 dataStructFieldTime |
345 dataStructFieldRef |
346 dataStructFieldUser
347 )*
348 ;
349
350 dataStructField64 :
351 << UINT32 ArrayNum = 0; >>
352 D:"UINT64"
353 N:StringIdentifier
354 {
355 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
356 }
357 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
358 ;
359
360 dataStructField32 :
361 << UINT32 ArrayNum = 0; >>
362 D:"UINT32"
363 N:StringIdentifier
364 {
365 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
366 }
367 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
368 ;
369
370 dataStructField16 :
371 <<
372 UINT32 ArrayNum = 0;
373 >>
374 ("UINT16" | "CHAR16")
375 N:StringIdentifier
376 {
377 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
378 }
379 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), (CHAR8 *) "UINT16", ArrayNum), N); >>
380 ;
381
382 dataStructField8 :
383 << UINT32 ArrayNum = 0; >>
384 D:"UINT8"
385 N:StringIdentifier
386 {
387 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
388 }
389 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
390 ;
391
392 dataStructFieldBool :
393 << UINT32 ArrayNum = 0; >>
394 D:"BOOLEAN"
395 N:StringIdentifier
396 {
397 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
398 }
399 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
400 ;
401
402 dataStructFieldString :
403 << UINT32 ArrayNum = 0; >>
404 D:"EFI_STRING_ID"
405 N:StringIdentifier
406 {
407 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
408 }
409 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
410 ;
411
412 dataStructFieldDate :
413 << UINT32 ArrayNum = 0; >>
414 D:"EFI_HII_DATE"
415 N:StringIdentifier
416 {
417 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
418 }
419 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
420 ;
421
422 dataStructFieldTime :
423 << UINT32 ArrayNum = 0; >>
424 D:"EFI_HII_TIME"
425 N:StringIdentifier
426 {
427 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
428 }
429 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
430 ;
431
432 dataStructFieldRef :
433 << UINT32 ArrayNum = 0; >>
434 D:"EFI_HII_REF"
435 N:StringIdentifier
436 {
437 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
438 }
439 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
440 ;
441
442 dataStructFieldUser :
443 << UINT32 ArrayNum = 0; >>
444 T:StringIdentifier
445 N:StringIdentifier
446 {
447 OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
448 }
449 ";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), T->getText(), ArrayNum), T); >>
450 ;
451
452 //*****************************************************************************
453 //
454 // the syntax of GUID definition
455 //
456 guidSubDefinition [EFI_GUID &Guid] :
457 G4:Number "," G5:Number "," G6:Number "," G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
458 <<
459 Guid.Data4[0] = _STOU8(G4->getText());
460 Guid.Data4[1] = _STOU8(G5->getText());
461 Guid.Data4[2] = _STOU8(G6->getText());
462 Guid.Data4[3] = _STOU8(G7->getText());
463 Guid.Data4[4] = _STOU8(G8->getText());
464 Guid.Data4[5] = _STOU8(G9->getText());
465 Guid.Data4[6] = _STOU8(G10->getText());
466 Guid.Data4[7] = _STOU8(G11->getText());
467 >>
468 ;
469
470 guidDefinition [EFI_GUID &Guid] :
471 OpenBrace
472 G1:Number "," G2:Number "," G3:Number ","
473 <<
474 Guid.Data1 = _STOU32 (G1->getText());
475 Guid.Data2 = _STOU16 (G2->getText());
476 Guid.Data3 = _STOU16 (G3->getText());
477 >>
478 (
479 OpenBrace guidSubDefinition[Guid] CloseBrace
480 | guidSubDefinition[Guid]
481 )
482 CloseBrace
483 ;
484
485 //*****************************************************************************
486 //
487 // the syntax of form set definition
488 //
489 vfrFormSetDefinition :
490 <<
491 EFI_GUID Guid;
492 EFI_GUID DefaultClassGuid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID;
493 EFI_GUID ClassGuid1, ClassGuid2, ClassGuid3;
494 UINT8 ClassGuidNum = 0;
495 CIfrFormSet *FSObj = NULL;
496 UINT16 C, SC;
497 >>
498 L:FormSet
499 Uuid "=" guidDefinition[Guid] ","
500 Title "=" "STRING_TOKEN" "\(" S1:Number "\)" ","
501 Help "=" "STRING_TOKEN" "\(" S2:Number "\)" ","
502 {
503 ClassGuid "=" guidDefinition[ClassGuid1] << ++ClassGuidNum; >>
504 {
505 "\|" guidDefinition[ClassGuid2] << ++ClassGuidNum; >>
506 }
507 {
508 "\|" guidDefinition[ClassGuid3] << ++ClassGuidNum; >>
509 }
510 ","
511 }
512 <<
513 if (mOverrideClassGuid != NULL && ClassGuidNum >= 3) {
514 _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "Already has 3 class guids, can't add extra class guid!");
515 }
516 switch (ClassGuidNum) {
517 case 0:
518 if (mOverrideClassGuid != NULL) {
519 ClassGuidNum = 2;
520 } else {
521 ClassGuidNum = 1;
522 }
523 FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));
524 FSObj->SetClassGuid(&DefaultClassGuid);
525 if (mOverrideClassGuid != NULL) {
526 FSObj->SetClassGuid(mOverrideClassGuid);
527 }
528 break;
529 case 1:
530 if (mOverrideClassGuid != NULL) {
531 ClassGuidNum ++;
532 }
533 FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));
534 FSObj->SetClassGuid(&ClassGuid1);
535 if (mOverrideClassGuid != NULL) {
536 FSObj->SetClassGuid(mOverrideClassGuid);
537 }
538 break;
539 case 2:
540 if (mOverrideClassGuid != NULL) {
541 ClassGuidNum ++;
542 }
543 FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));
544 FSObj->SetClassGuid(&ClassGuid1);
545 FSObj->SetClassGuid(&ClassGuid2);
546 if (mOverrideClassGuid != NULL) {
547 FSObj->SetClassGuid(mOverrideClassGuid);
548 }
549 break;
550 case 3:
551 FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));
552 FSObj->SetClassGuid(&ClassGuid1);
553 FSObj->SetClassGuid(&ClassGuid2);
554 FSObj->SetClassGuid(&ClassGuid3);
555 break;
556 default:
557 break;
558 }
559
560 SET_LINE_INFO (*FSObj, L);
561 FSObj->SetGuid (&Guid);
562 //
563 // for framework vfr to store formset guid used by varstore and efivarstore
564 //
565 if (mCompatibleMode) {
566 memcpy (&mFormsetGuid, &Guid, sizeof (EFI_GUID));
567 }
568 FSObj->SetFormSetTitle (_STOSID(S1->getText()));
569 FSObj->SetHelp (_STOSID(S2->getText()));
570 >>
571 {
572 FC:Class "=" classDefinition[C] "," << {CIfrClass CObj;SET_LINE_INFO (CObj, FC); CObj.SetClass(C);} >>
573 }
574 {
575 FSC:Subclass "=" subclassDefinition[SC] "," << {CIfrSubClass SCObj; SET_LINE_INFO (SCObj, FSC); SCObj.SetSubClass(SC);} >>
576 }
577 <<
578 _DeclareStandardDefaultStorage (GET_LINENO (L));
579 >>
580 vfrFormSetList
581 E:EndFormSet <<
582 if (mCompatibleMode) {
583 //
584 // declare all undefined varstore and efivarstore
585 //
586 _DeclareDefaultFrameworkVarStore (GET_LINENO(E));
587 }
588 CRT_END_OP (E); if (FSObj != NULL) delete FSObj;
589 >>
590 ";"
591 ;
592
593 vfrFormSetList :
594 (
595 vfrFormDefinition |
596 vfrFormMapDefinition |
597 vfrStatementImage |
598 vfrStatementVarStoreLinear |
599 vfrStatementVarStoreEfi |
600 vfrStatementVarStoreNameValue |
601 vfrStatementDefaultStore |
602 vfrStatementDisableIfFormSet |
603 vfrStatementSuppressIfFormSet |
604 vfrStatementExtension
605 )*
606 ;
607
608 vfrStatementExtension:
609 <<
610 EFI_GUID Guid;
611 CIfrGuid *GuidObj = NULL;
612 CHAR8 *TypeName = NULL;
613 UINT32 TypeSize = 0;
614 UINT8 *DataBuff = NULL;
615 UINT32 Size = 0;
616 UINT8 Idx = 0;
617 UINT32 LineNum;
618 BOOLEAN IsStruct = FALSE;
619 UINT32 ArrayNum = 0;
620 >>
621 L:GuidOp
622 Uuid "=" guidDefinition[Guid]
623 {"," DataType "="
624 (
625 U64:"UINT64" {OpenBracket AN1:Number CloseBracket <<ArrayNum = _STOU32(AN1->getText());>>}
626 << TypeName = U64->getText(); LineNum = U64->getLine(); >>
627 | U32:"UINT32" {OpenBracket AN2:Number CloseBracket <<ArrayNum = _STOU32(AN2->getText());>>}
628 << TypeName = U32->getText(); LineNum = U32->getLine(); >>
629 | U16:"UINT16" {OpenBracket AN3:Number CloseBracket <<ArrayNum = _STOU32(AN3->getText());>>}
630 << TypeName = U16->getText(); LineNum = U16->getLine(); >>
631 | U8:"UINT8" {OpenBracket AN4:Number CloseBracket <<ArrayNum = _STOU32(AN4->getText());>>}
632 << TypeName = U8->getText(); LineNum = U8->getLine(); >>
633 | BL:"BOOLEAN" {OpenBracket AN5:Number CloseBracket <<ArrayNum = _STOU32(AN5->getText());>>}
634 << TypeName = BL->getText(); LineNum = BL->getLine(); >>
635 | SI:"EFI_STRING_ID" {OpenBracket AN6:Number CloseBracket <<ArrayNum = _STOU32(AN6->getText());>>}
636 << TypeName = SI->getText(); LineNum = SI->getLine(); >>
637 | D:"EFI_HII_DATE" {OpenBracket AN7:Number CloseBracket <<ArrayNum = _STOU32(AN7->getText());>>}
638 << TypeName = D->getText(); LineNum = D->getLine(); IsStruct = TRUE;>>
639 | T:"EFI_HII_TIME" {OpenBracket AN8:Number CloseBracket <<ArrayNum = _STOU32(AN8->getText());>>}
640 << TypeName = T->getText(); LineNum = T->getLine(); IsStruct = TRUE;>>
641 | R:"EFI_HII_REF" {OpenBracket AN9:Number CloseBracket <<ArrayNum = _STOU32(AN9->getText());>>}
642 << TypeName = R->getText(); LineNum = R->getLine(); IsStruct = TRUE;>>
643 | TN:StringIdentifier {OpenBracket AN10:Number CloseBracket <<ArrayNum = _STOU32(AN10->getText());>>}
644 << TypeName = TN->getText(); LineNum = TN->getLine(); IsStruct = TRUE;>>
645 )
646 <<
647 _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &TypeSize), LineNum);
648 if (ArrayNum > 0) {
649 Size = TypeSize*ArrayNum;
650 } else {
651 Size = TypeSize;
652 }
653 if (Size > (128 - sizeof (EFI_IFR_GUID))) return;
654 DataBuff = (UINT8 *)malloc(Size);
655 for (Idx = 0; Idx < Size; Idx++) {
656 DataBuff[Idx] = 0;
657 }
658 >>
659 vfrExtensionData [DataBuff, Size, TypeName, TypeSize, IsStruct, ArrayNum]
660 }
661 <<
662 {
663 GuidObj = new CIfrGuid(Size);
664 if (GuidObj != NULL) {
665 GuidObj->SetLineNo(L->getLine());
666 GuidObj->SetGuid (&Guid);
667 }
668 }
669 if (TypeName != NULL) {
670 GuidObj->SetData(DataBuff, Size);
671 }
672 >>
673 {","
674 (
675 vfrStatementExtension
676 )*
677 E:EndGuidOp << GuidObj->SetScope(1); CRT_END_OP (E); >>
678 }
679 <<
680 if (GuidObj != NULL) delete GuidObj;
681 if (DataBuff != NULL) free(DataBuff);
682 >>
683 ";"
684 ;
685
686 vfrExtensionData[UINT8 *DataBuff, UINT32 Size, CHAR8 *TypeName, UINT32 TypeSize, BOOLEAN IsStruct, UINT32 ArrayNum]:
687 <<
688 CHAR8 *TFName = NULL;
689 UINT32 ArrayIdx = 0;
690 UINT16 FieldOffset;
691 UINT8 FieldType;
692 UINT32 FieldSize;
693 UINT64 Data_U64 = 0;
694 UINT32 Data_U32 = 0;
695 UINT16 Data_U16 = 0;
696 UINT8 Data_U8 = 0;
697 BOOLEAN Data_BL = 0;
698 EFI_STRING_ID Data_SID = 0;
699 BOOLEAN IsArray = FALSE;
700 UINT8 *ByteOffset = NULL;
701 >>
702 (
703 ("," "data" {OpenBracket IDX1:Number CloseBracket <<IsArray = TRUE;>>}
704 <<
705 ArrayIdx = 0;
706 if (IsArray == TRUE) {
707 ArrayIdx = _STOU8(IDX1->getText());
708 if (ArrayIdx >= ArrayNum) return;
709 IsArray = FALSE;
710 }
711 ByteOffset = DataBuff + (ArrayIdx * TypeSize);
712 if (IsStruct == TRUE) {
713 _STRCAT(&TFName, TypeName);
714 }
715 >>
716 ("." FN:StringIdentifier
717 <<
718 if (IsStruct == TRUE) {
719 _STRCAT(&TFName, ".");
720 _STRCAT(&TFName, FN->getText());
721 }
722 >>
723 {
724 OpenBracket IDX2:Number CloseBracket
725 <<
726 if (IsStruct == TRUE) {
727 _STRCAT(&TFName, "[");
728 _STRCAT(&TFName, IDX2->getText());
729 _STRCAT(&TFName, "]");
730 }
731 >>
732 }
733 )*
734 "=" RD:Number
735 <<
736 if (IsStruct == FALSE) {
737 if (strcmp ("UINT64", TypeName) == 0) {
738 Data_U64 = _STOU64(RD->getText());
739 memcpy (ByteOffset, &Data_U64, TypeSize);
740 }else if (strcmp ("UINT32", TypeName) == 0) {
741 Data_U32 = _STOU32(RD->getText());
742 memcpy (ByteOffset, &Data_U32, TypeSize);
743 }else if (strcmp ("UINT16", TypeName) == 0) {
744 Data_U16 = _STOU16(RD->getText());
745 memcpy (ByteOffset, &Data_U16, TypeSize);
746 }else if (strcmp ("UINT8", TypeName) == 0) {
747 Data_U8 = _STOU8(RD->getText());
748 memcpy (ByteOffset, &Data_U8, TypeSize);
749 }else if (strcmp ("BOOLEAN", TypeName)== 0) {
750 Data_BL = _STOU8(RD->getText());
751 memcpy (ByteOffset, &Data_BL, TypeSize);
752 }else if (strcmp ("EFI_STRING_ID", TypeName) == 0) {
753 Data_SID = _STOSID(RD->getText());
754 memcpy (ByteOffset, &Data_SID, TypeSize);
755 }
756 } else {
757 gCVfrVarDataTypeDB.GetDataFieldInfo(TFName, FieldOffset, FieldType, FieldSize);
758 switch (FieldType) {
759 case EFI_IFR_TYPE_NUM_SIZE_8:
760 Data_U8 = _STOU8(RD->getText());
761 memcpy (ByteOffset + FieldOffset, &Data_U8, FieldSize);
762 break;
763 case EFI_IFR_TYPE_NUM_SIZE_16:
764 Data_U16 = _STOU16(RD->getText());
765 memcpy (ByteOffset + FieldOffset, &Data_U16, FieldSize);
766 break;
767 case EFI_IFR_TYPE_NUM_SIZE_32:
768 Data_U32 = _STOU32(RD->getText());
769 memcpy (ByteOffset + FieldOffset, &Data_U32, FieldSize);
770 break;
771 case EFI_IFR_TYPE_NUM_SIZE_64:
772 Data_U64 = _STOU64(RD->getText());
773 memcpy (ByteOffset + FieldOffset, &Data_U64, FieldSize);
774 break;
775 case EFI_IFR_TYPE_BOOLEAN:
776 Data_BL = _STOU8(RD->getText());
777 memcpy (ByteOffset + FieldOffset, &Data_BL, FieldSize);
778 break;
779 case EFI_IFR_TYPE_STRING:
780 Data_SID = _STOSID(RD->getText());
781 memcpy (ByteOffset + FieldOffset, &Data_SID, FieldSize);
782 break;
783 default:
784 break;
785 }
786 }
787 if (TFName != NULL) { delete TFName; TFName = NULL; }
788 >>
789 )*
790 )
791 ;
792
793
794 vfrStatementDefaultStore :
795 << UINT16 DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD; >>
796 D:DefaultStore N:StringIdentifier ","
797 Prompt "=" "STRING_TOKEN" "\(" S:Number "\)"
798 {
799 "," Attribute "=" A:Number << DefaultId = _STOU16(A->getText()); >>
800 }
801 <<
802 if (mCVfrDefaultStore.DefaultIdRegistered (DefaultId) == FALSE) {
803 CIfrDefaultStore DSObj;
804 _PCATCH(mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), N->getText(), _STOSID(S->getText()), DefaultId)), D->getLine();
805 DSObj.SetLineNo(D->getLine());
806 DSObj.SetDefaultName (_STOSID(S->getText()));
807 DSObj.SetDefaultId (DefaultId);
808 } else {
809 _PCATCH(mCVfrDefaultStore.ReRegisterDefaultStoreById (DefaultId, N->getText(), _STOSID(S->getText()))), D->getLine();
810 }
811 >>
812 ";"
813 ;
814
815 vfrStatementVarStoreLinear :
816 <<
817 EFI_GUID Guid;
818 CIfrVarStore VSObj;
819 CHAR8 *TypeName;
820 CHAR8 *StoreName;
821 UINT32 LineNum;
822 EFI_VARSTORE_ID VarStoreId = EFI_VARSTORE_ID_INVALID;
823 UINT32 Size;
824 >>
825 V:Varstore << VSObj.SetLineNo(V->getLine()); >>
826 (
827 TN:StringIdentifier "," << TypeName = TN->getText(); LineNum = TN->getLine(); >>
828 | U8:"UINT8" "," << TypeName = U8->getText(); LineNum = U8->getLine(); >>
829 | U16:"UINT16" "," << TypeName = U16->getText(); LineNum = U16->getLine(); >>
830 | C16:"CHAR16" "," << TypeName = (CHAR8 *) "UINT16"; LineNum = C16->getLine(); >>
831 | U32:"UINT32" "," << TypeName = U32->getText(); LineNum = U32->getLine(); >>
832 | U64:"UINT64" "," << TypeName = U64->getText(); LineNum = U64->getLine(); >>
833 | D:"EFI_HII_DATE" "," << TypeName = D->getText(); LineNum = D->getLine(); >>
834 | T:"EFI_HII_TIME" "," << TypeName = T->getText(); LineNum = T->getLine(); >>
835 | R:"EFI_HII_REF" "," << TypeName = R->getText(); LineNum = R->getLine(); >>
836 )
837 { Key "=" FID:Number "," << // Key is used to assign Varid in Framework VFR but no use in UEFI2.1 VFR
838 if (mCompatibleMode) {
839 VarStoreId = _STOU16(FID->getText());
840 }
841 >>
842 }
843 {
844 VarId "=" ID:Number "," <<
845 _PCATCH(
846 (INTN)(VarStoreId = _STOU16(ID->getText())) != 0,
847 (INTN)TRUE,
848 ID,
849 "varid 0 is not allowed."
850 );
851 >>
852 }
853 Name "=" SN:StringIdentifier ","
854 Uuid "=" guidDefinition[Guid]
855 <<
856 if (mCompatibleMode) {
857 StoreName = TypeName;
858 } else {
859 StoreName = SN->getText();
860 }
861 _PCATCH(mCVfrDataStorage.DeclareBufferVarStore (
862 StoreName,
863 &Guid,
864 &gCVfrVarDataTypeDB,
865 TypeName,
866 VarStoreId
867 ), LineNum);
868 VSObj.SetGuid (&Guid);
869 _PCATCH(mCVfrDataStorage.GetVarStoreId(StoreName, &VarStoreId), SN);
870 VSObj.SetVarStoreId (VarStoreId);
871 _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);
872 VSObj.SetSize ((UINT16) Size);
873 VSObj.SetName (SN->getText());
874 >>
875 ";"
876 ;
877
878 vfrStatementVarStoreEfi :
879 <<
880 BOOLEAN IsUEFI23EfiVarstore = TRUE;
881 EFI_GUID Guid;
882 CIfrVarStoreEfi VSEObj;
883 EFI_VARSTORE_ID VarStoreId = EFI_VARSTORE_ID_INVALID;
884 UINT32 Attr = 0;
885 UINT32 Size;
886 CHAR8 *TypeName;
887 UINT32 LineNum;
888 CHAR8 *StoreName = NULL;
889 >>
890 E:Efivarstore << VSEObj.SetLineNo(E->getLine()); >>
891 (
892 TN:StringIdentifier "," << TypeName = TN->getText(); LineNum = TN->getLine(); >>
893 | U8:"UINT8" "," << TypeName = U8->getText(); LineNum = U8->getLine(); >>
894 | U16:"UINT16" "," << TypeName = U16->getText(); LineNum = U16->getLine(); >>
895 | C16:"CHAR16" "," << TypeName = (CHAR8 *) "UINT16"; LineNum = C16->getLine(); >>
896 | U32:"UINT32" "," << TypeName = U32->getText(); LineNum = U32->getLine(); >>
897 | U64:"UINT64" "," << TypeName = U64->getText(); LineNum = U64->getLine(); >>
898 | D:"EFI_HII_DATE" "," << TypeName = D->getText(); LineNum = D->getLine(); >>
899 | T:"EFI_HII_TIME" "," << TypeName = T->getText(); LineNum = T->getLine(); >>
900 | R:"EFI_HII_REF" "," << TypeName = R->getText(); LineNum = R->getLine(); >>
901 )
902 {
903 VarId "=" ID:Number "," <<
904 _PCATCH(
905 (INTN)(VarStoreId = _STOU16(ID->getText())) != 0,
906 (INTN)TRUE,
907 ID,
908 "varid 0 is not allowed."
909 );
910 >>
911 }
912 Attribute "=" vfrVarStoreEfiAttr[Attr] ( "\|" vfrVarStoreEfiAttr[Attr] )* ","
913 << VSEObj.SetAttributes (Attr); >>
914
915 (
916 Name "=" SN:StringIdentifier "," << StoreName = SN->getText(); >>
917 |
918 Name "=" "STRING_TOKEN" "\(" VN:Number "\)" ","
919 VarSize "=" N:Number "," <<
920 IsUEFI23EfiVarstore = FALSE;
921 StoreName = gCVfrStringDB.GetVarStoreNameFormStringId(_STOSID(VN->getText()));
922 if (StoreName == NULL) {
923 _PCATCH (VFR_RETURN_UNSUPPORTED, VN->getLine(), "Can't get varstore name for this StringId!");
924 }
925 Size = _STOU32(N->getText());
926 switch (Size) {
927 case 1:
928 TypeName = (CHAR8 *) "UINT8";
929 break;
930 case 2:
931 TypeName = (CHAR8 *) "UINT16";
932 break;
933 case 4:
934 TypeName = (CHAR8 *) "UINT32";
935 break;
936 case 8:
937 TypeName = (CHAR8 *) "UINT64";
938 break;
939 default:
940 _PCATCH (VFR_RETURN_UNSUPPORTED, N);
941 break;
942 }
943 >>
944 )
945
946 Uuid "=" guidDefinition[Guid] <<
947 if (IsUEFI23EfiVarstore) {
948 _PCATCH(mCVfrDataStorage.DeclareBufferVarStore (
949 StoreName,
950 &Guid,
951 &gCVfrVarDataTypeDB,
952 TypeName,
953 VarStoreId
954 ), LineNum);
955 _PCATCH(mCVfrDataStorage.GetVarStoreId(StoreName, &VarStoreId), SN);
956 _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);
957 } else {
958 _PCATCH(mCVfrDataStorage.DeclareBufferVarStore (
959 TN->getText(),
960 &Guid,
961 &gCVfrVarDataTypeDB,
962 TypeName,
963 VarStoreId
964 ), LineNum);
965 _PCATCH(mCVfrDataStorage.GetVarStoreId(TN->getText(), &VarStoreId), VN);
966 _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), N->getLine());
967 }
968 VSEObj.SetGuid (&Guid);
969 VSEObj.SetVarStoreId (VarStoreId);
970
971 VSEObj.SetSize ((UINT16) Size);
972 VSEObj.SetName (StoreName);
973 if (IsUEFI23EfiVarstore == FALSE && StoreName != NULL) {
974 delete StoreName;
975 }
976 >>
977 ";"
978 ;
979
980 vfrVarStoreEfiAttr [UINT32 & Attr] :
981 N:Number << $Attr |= _STOU32(N->getText()); >>
982 ;
983
984 vfrStatementVarStoreNameValue :
985 <<
986 EFI_GUID Guid;
987 CIfrVarStoreNameValue VSNVObj;
988 EFI_VARSTORE_ID VarStoreId;
989 >>
990 L:NameValueVarStore << VSNVObj.SetLineNo(L->getLine()); >>
991 SN:StringIdentifier "," << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreBegin (SN->getText()), SN); >>
992 (
993 Name "=" "STRING_TOKEN" "\(" N:Number "\)" "," << _PCATCH(mCVfrDataStorage.NameTableAddItem (_STOSID(N->getText())), SN); >>
994 )+
995 Uuid "=" guidDefinition[Guid] << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreEnd (&Guid), SN); >>
996 <<
997 VSNVObj.SetGuid (&Guid);
998 _PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);
999 VSNVObj.SetVarStoreId (VarStoreId);
1000 >>
1001 ";"
1002 ;
1003
1004 //
1005 // keep classDeinition and validClassNames for compatibility but not generate
1006 // any IFR object
1007 //
1008 classDefinition[UINT16 & Class] :
1009 << $Class = 0; >>
1010 validClassNames[$Class] ( "\|" validClassNames[$Class] )*
1011 ;
1012
1013 validClassNames[UINT16 & Class] :
1014 ClassNonDevice << $Class |= EFI_NON_DEVICE_CLASS; >>
1015 | ClassDiskDevice << $Class |= EFI_DISK_DEVICE_CLASS; >>
1016 | ClassVideoDevice << $Class |= EFI_VIDEO_DEVICE_CLASS; >>
1017 | ClassNetworkDevice << $Class |= EFI_NETWORK_DEVICE_CLASS; >>
1018 | ClassInputDevice << $Class |= EFI_INPUT_DEVICE_CLASS; >>
1019 | ClassOnBoardDevice << $Class |= EFI_ON_BOARD_DEVICE_CLASS; >>
1020 | ClassOtherDevice << $Class |= EFI_OTHER_DEVICE_CLASS; >>
1021 | N:Number << $Class |= _STOU16(N->getText()); >>
1022 ;
1023
1024 subclassDefinition[UINT16 & SubClass] :
1025 << $SubClass = 0; >>
1026 SubclassSetupApplication << $SubClass |= EFI_SETUP_APPLICATION_SUBCLASS; >>
1027 | SubclassGeneralApplication << $SubClass |= EFI_GENERAL_APPLICATION_SUBCLASS; >>
1028 | SubclassFrontPage << $SubClass |= EFI_FRONT_PAGE_SUBCLASS; >>
1029 | SubclassSingleUse << $SubClass |= EFI_SINGLE_USE_SUBCLASS; >>
1030 | N:Number << $SubClass |= _STOU16(N->getText()); >>
1031 ;
1032
1033 vfrStatementDisableIfFormSet :
1034 <<
1035 CIfrDisableIf DIObj;
1036 mConstantOnlyInExpression = TRUE;
1037 >>
1038 D:DisableIf << DIObj.SetLineNo(D->getLine()); >>
1039 vfrStatementExpression[0] ";" << mConstantOnlyInExpression = FALSE; >>
1040 vfrFormSetList
1041 E:EndIf << CRT_END_OP (E); >>
1042 ";"
1043 ;
1044
1045 vfrStatementSuppressIfFormSet :
1046 << CIfrSuppressIf SIObj;>>
1047 L:SuppressIf <<
1048 if (mCompatibleMode) {
1049 _PCATCH (VFR_RETURN_UNSUPPORTED, L);
1050 }
1051 SIObj.SetLineNo(L->getLine());
1052 >>
1053 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
1054 vfrStatementExpression[0] ";"
1055 vfrFormSetList
1056 E: EndIf
1057 ";" << CRT_END_OP (E); >>
1058 ;
1059
1060 //*****************************************************************************
1061 //
1062 // the syntax of question header and statement header
1063 //
1064 vfrStatementHeader[CIfrStatementHeader *SHObj] :
1065 Prompt "=" "STRING_TOKEN" "\(" S1:Number "\)" "," << $SHObj->SetPrompt (_STOSID(S1->getText())); >>
1066 Help "=" "STRING_TOKEN" "\(" S2:Number "\)" << $SHObj->SetHelp (_STOSID(S2->getText())); >>
1067 ;
1068
1069 vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_NORMAL]:
1070 <<
1071 EFI_VARSTORE_INFO Info;
1072 EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
1073 CHAR8 *QName = NULL;
1074 CHAR8 *VarIdStr = NULL;
1075 >>
1076 {
1077 Name "=" QN:StringIdentifier "," <<
1078 QName = QN->getText();
1079 _PCATCH(mCVfrQuestionDB.FindQuestion (QName), VFR_RETURN_UNDEFINED, QN, "has already been used please used anther name");
1080 >>
1081 }
1082 { V:VarId "=" vfrStorageVarId[Info, VarIdStr] "," }
1083 {
1084 QuestionId "=" ID:Number "," <<
1085 QId = _STOQID(ID->getText());
1086 _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used please assign another number");
1087 >>
1088 }
1089 <<
1090 switch (QType) {
1091 case QUESTION_NORMAL:
1092 mCVfrQuestionDB.RegisterQuestion (QName, VarIdStr, QId);
1093 break;
1094 case QUESTION_DATE:
1095 mCVfrQuestionDB.RegisterNewDateQuestion (QName, VarIdStr, QId);
1096 break;
1097 case QUESTION_TIME:
1098 mCVfrQuestionDB.RegisterNewTimeQuestion (QName, VarIdStr, QId);
1099 break;
1100 case QUESTION_REF:
1101 //
1102 // VarIdStr != NULL stand for question with storagae.
1103 //
1104 if (VarIdStr != NULL) {
1105 mCVfrQuestionDB.RegisterRefQuestion (QName, VarIdStr, QId);
1106 } else {
1107 mCVfrQuestionDB.RegisterQuestion (QName, NULL, QId);
1108 }
1109 break;
1110 default:
1111 _PCATCH(VFR_RETURN_FATAL_ERROR);
1112 }
1113 $QHObj.SetQuestionId (QId);
1114 if (VarIdStr != NULL) {
1115 $QHObj.SetVarStoreInfo (&Info);
1116 }
1117 >>
1118 vfrStatementHeader[&$QHObj]
1119 <<
1120 if (VarIdStr != NULL) {
1121 delete VarIdStr;
1122 _SAVE_CURRQEST_VARINFO (Info);
1123 }
1124 >>
1125 ;
1126
1127 questionheaderFlagsField[UINT8 & Flags] :
1128 ReadOnlyFlag << $Flags |= 0x01; >>
1129 | InteractiveFlag << $Flags |= 0x04; >>
1130 | ResetRequiredFlag << $Flags |= 0x10; >>
1131 | OptionOnlyFlag << $Flags |= 0x80; >>
1132 | NVAccessFlag
1133 | LateCheckFlag
1134 ;
1135
1136 vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr, BOOLEAN CheckFlag = TRUE] :
1137 <<
1138 UINT32 Idx;
1139 UINT32 LineNo;
1140 EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
1141 CHAR8 *VarIdStr = NULL;
1142 CHAR8 *VarStr = NULL;
1143 CHAR8 *SName = NULL;
1144 CHAR8 *TName = NULL;
1145 EFI_VFR_RETURN_CODE VfrReturnCode = VFR_RETURN_SUCCESS;
1146 EFI_IFR_TYPE_VALUE Dummy = gZeroEfiIfrTypeValue;
1147 >>
1148 (
1149 SN1:StringIdentifier << SName = SN1->getText(); _STRCAT(&VarIdStr, SN1->getText()); >>
1150 OpenBracket I1:Number CloseBracket <<
1151 Idx = _STOU32(I1->getText());
1152 _STRCAT(&VarIdStr, "[");
1153 _STRCAT(&VarIdStr, I1->getText());
1154 _STRCAT(&VarIdStr, "]");
1155 >>
1156 <<
1157 VfrReturnCode = mCVfrDataStorage.GetVarStoreType (SName, VarStoreType);
1158 if (mCompatibleMode && VfrReturnCode == VFR_RETURN_UNDEFINED) {
1159 mCVfrDataStorage.DeclareBufferVarStore (
1160 SName,
1161 &mFormsetGuid,
1162 &gCVfrVarDataTypeDB,
1163 SName,
1164 EFI_VARSTORE_ID_INVALID,
1165 FALSE
1166 );
1167 VfrReturnCode = mCVfrDataStorage.GetVarStoreType (SName, VarStoreType);
1168 }
1169 if (CheckFlag || VfrReturnCode == VFR_RETURN_SUCCESS) {
1170 _PCATCH(VfrReturnCode, SN1);
1171 _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN1);
1172 _PCATCH(mCVfrDataStorage.GetNameVarStoreInfo (&$Info, Idx), SN1);
1173 }
1174
1175 QuestVarIdStr = VarIdStr;
1176 >>
1177 )
1178 |
1179 (
1180 SN2:StringIdentifier << SName = SN2->getText(); _STRCAT(&VarIdStr, SName); >>
1181 <<
1182 VfrReturnCode = mCVfrDataStorage.GetVarStoreType (SName, VarStoreType);
1183 if (mCompatibleMode && VfrReturnCode == VFR_RETURN_UNDEFINED) {
1184 mCVfrDataStorage.DeclareBufferVarStore (
1185 SName,
1186 &mFormsetGuid,
1187 &gCVfrVarDataTypeDB,
1188 SName,
1189 EFI_VARSTORE_ID_INVALID,
1190 FALSE
1191 );
1192 VfrReturnCode = mCVfrDataStorage.GetVarStoreType (SName, VarStoreType);
1193 }
1194 if (CheckFlag || VfrReturnCode == VFR_RETURN_SUCCESS) {
1195 _PCATCH(VfrReturnCode, SN2);
1196 _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN2);
1197 if (VarStoreType == EFI_VFR_VARSTORE_BUFFER) {
1198 _PCATCH(mCVfrDataStorage.GetBufferVarStoreDataTypeName(SName, &TName), SN2);
1199 _STRCAT(&VarStr, TName);
1200 }
1201 }
1202 >>
1203
1204 (
1205 "." <<
1206 if (CheckFlag || VfrReturnCode == VFR_RETURN_SUCCESS) {
1207 _PCATCH(((VarStoreType != EFI_VFR_VARSTORE_BUFFER) ? VFR_RETURN_EFIVARSTORE_USE_ERROR : VFR_RETURN_SUCCESS), SN2);
1208 }
1209 _STRCAT(&VarIdStr, "."); _STRCAT(&VarStr, ".");
1210 >>
1211 SF:StringIdentifier << _STRCAT(&VarIdStr, SF->getText()); _STRCAT(&VarStr, SF->getText()); >>
1212 {
1213 OpenBracket I2:Number CloseBracket <<
1214 Idx = _STOU32(I2->getText());
1215 if (mCompatibleMode) Idx --;
1216 if (Idx > 0) {
1217 //
1218 // Idx == 0, [0] can be ignored.
1219 // Array[0] is same to Array for unify the varid name to cover [0]
1220 //
1221 _STRCAT(&VarIdStr, "[");
1222 _STRCAT(&VarIdStr, I2->getText());
1223 _STRCAT(&VarIdStr, "]");
1224 }
1225 _STRCAT(&VarStr, "[");
1226 _STRCAT(&VarStr, I2->getText());
1227 _STRCAT(&VarStr, "]");
1228 >>
1229 }
1230 )* <<
1231 switch (VarStoreType) {
1232 case EFI_VFR_VARSTORE_EFI:
1233 _PCATCH(mCVfrDataStorage.GetEfiVarStoreInfo (&$Info), SN2);
1234 break;
1235 case EFI_VFR_VARSTORE_BUFFER:
1236 _PCATCH(gCVfrVarDataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType, $Info.mVarTotalSize), SN2->getLine(), VarStr);
1237 _PCATCH((EFI_VFR_RETURN_CODE)gCVfrBufferConfig.Register (
1238 SName,
1239 NULL),
1240 SN2->getLine());
1241 _PCATCH((EFI_VFR_RETURN_CODE)gCVfrBufferConfig.Write (
1242 'a',
1243 SName,
1244 NULL,
1245 $Info.mVarType,
1246 $Info.mInfo.mVarOffset,
1247 $Info.mVarTotalSize,
1248 Dummy),
1249 SN2->getLine());
1250 break;
1251 case EFI_VFR_VARSTORE_NAME:
1252 default: break;
1253 }
1254
1255 QuestVarIdStr = VarIdStr;
1256 if (VarStr != NULL) {delete VarStr;}
1257 >>
1258 )
1259 ;
1260
1261 vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, CHAR8 *&VarIdStr, UINT32 &LineNo] :
1262 <<
1263 UINT32 Idx;
1264 VarIdStr = NULL; LineNo = 0;
1265 >>
1266 (
1267 SN1:StringIdentifier << _STRCAT(&VarIdStr, SN1->getText()); LineNo = SN1->getLine(); >>
1268 OpenBracket I1:Number CloseBracket <<
1269 _STRCAT(&VarIdStr, "[");
1270 _STRCAT(&VarIdStr, I1->getText());
1271 _STRCAT(&VarIdStr, "]");
1272 mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask);
1273 if (mConstantOnlyInExpression) {
1274 _PCATCH(VFR_RETURN_CONSTANT_ONLY, LineNo);
1275 }
1276 >>
1277 )
1278 |
1279 (
1280 SN2:StringIdentifier << _STRCAT (&VarIdStr, SN2->getText()); LineNo = SN2->getLine(); >>
1281 (
1282 "." <<
1283 _STRCAT (&VarIdStr, ".");
1284 if (mConstantOnlyInExpression) {
1285 _PCATCH(VFR_RETURN_CONSTANT_ONLY, LineNo);
1286 }
1287 >>
1288 SF:StringIdentifier << _STRCAT (&VarIdStr, SF->getText()); >>
1289 {
1290 OpenBracket I2:Number CloseBracket <<
1291 Idx = _STOU32(I2->getText());
1292 if (mCompatibleMode) Idx --;
1293 if (Idx > 0) {
1294 //
1295 // Idx == 0, [0] can be ignored.
1296 // Array[0] is same to Array
1297 //
1298 _STRCAT(&VarIdStr, "[");
1299 _STRCAT(&VarIdStr, I2->getText());
1300 _STRCAT(&VarIdStr, "]");
1301 }
1302 >>
1303 }
1304 )*
1305 << mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask); >>
1306 )
1307 ;
1308
1309 vfrConstantValueField[UINT8 Type] > [EFI_IFR_TYPE_VALUE Value] :
1310 <<
1311 EFI_GUID Guid;
1312 >>
1313 N1:Number <<
1314 switch ($Type) {
1315 case EFI_IFR_TYPE_NUM_SIZE_8 :
1316 $Value.u8 = _STOU8(N1->getText());
1317 break;
1318 case EFI_IFR_TYPE_NUM_SIZE_16 :
1319 $Value.u16 = _STOU16(N1->getText());
1320 break;
1321 case EFI_IFR_TYPE_NUM_SIZE_32 :
1322 $Value.u32 = _STOU32(N1->getText());
1323 break;
1324 case EFI_IFR_TYPE_NUM_SIZE_64 :
1325 $Value.u64 = _STOU64(N1->getText());
1326 break;
1327 case EFI_IFR_TYPE_BOOLEAN :
1328 $Value.b = _STOU8(N1->getText());
1329 break;
1330 case EFI_IFR_TYPE_STRING :
1331 $Value.string = _STOU16(N1->getText());
1332 break;
1333 case EFI_IFR_TYPE_TIME :
1334 case EFI_IFR_TYPE_DATE :
1335 case EFI_IFR_TYPE_REF :
1336 default :
1337 break;
1338 }
1339 >>
1340 | B1:True << $Value.b = TRUE; >>
1341 | B2:False << $Value.b = FALSE; >>
1342 | O1:One << $Value.u8 = _STOU8(O1->getText()); >>
1343 | O2:Ones << $Value.u64 = _STOU64(O2->getText()); >>
1344 | Z:Zero << $Value.u8 = _STOU8(Z->getText()); >>
1345 | HOUR:Number ":" MINUTE:Number ":" SECOND:Number << $Value.time = _STOT(HOUR->getText(), MINUTE->getText(), SECOND->getText()); >>
1346 | YEAR:Number "/" MONTH:Number "/" DAY:Number << $Value.date = _STOD(YEAR->getText(), MONTH->getText(), DAY->getText()); >>
1347 | QI:Number";" FI:Number";" guidDefinition[Guid] ";" "STRING_TOKEN" "\(" DP:Number "\)"
1348 << $Value.ref = _STOR(QI->getText(), FI->getText(), &Guid, DP->getText()); >>
1349 | "STRING_TOKEN" "\(" S1:Number "\)" << $Value.string = _STOSID(S1->getText()); >>
1350 ;
1351
1352 //*****************************************************************************
1353 //
1354 // the syntax of form definition
1355 //
1356 vfrFormDefinition :
1357 << CIfrForm FObj; >>
1358 F:Form << FObj.SetLineNo(F->getLine()); >>
1359 FormId "=" S1:Number "," << _PCATCH(FObj.SetFormId (_STOFID(S1->getText())), S1); >>
1360 Title "=" "STRING_TOKEN" "\(" S2:Number "\)" ";" << FObj.SetFormTitle (_STOSID(S2->getText())); >>
1361 (
1362 vfrStatementImage |
1363 vfrStatementLocked |
1364 vfrStatementRules |
1365 vfrStatementDefault |
1366 vfrStatementStat |
1367 vfrStatementQuestions |
1368 vfrStatementConditional |
1369 vfrStatementLabel |
1370 vfrStatementBanner |
1371 // Just for framework vfr compatibility
1372 vfrStatementInvalid |
1373 vfrStatementExtension |
1374 vfrStatementModal
1375 )*
1376 E:EndForm <<
1377 if (mCompatibleMode) {
1378 //
1379 // Add Label for Framework Vfr
1380 //
1381 CIfrLabel LObj1;
1382 LObj1.SetLineNo(E->getLine());
1383 LObj1.SetNumber (0xffff); //add end label for UEFI, label number hardcode 0xffff
1384 CIfrLabel LObj2;
1385 LObj2.SetLineNo(E->getLine());
1386 LObj2.SetNumber (0x0); //add dummy label for UEFI, label number hardcode 0x0
1387 CIfrLabel LObj3;
1388 LObj3.SetLineNo(E->getLine());
1389 LObj3.SetNumber (0xffff); //add end label for UEFI, label number hardcode 0xffff
1390 //
1391 // Declare undefined Question
1392 //
1393 if (gCFormPkg.HavePendingUnassigned()) {
1394 gCFormPkg.DeclarePendingQuestion (
1395 gCVfrVarDataTypeDB,
1396 mCVfrDataStorage,
1397 mCVfrQuestionDB,
1398 &mFormsetGuid,
1399 E->getLine()
1400 );
1401 }
1402 }
1403 //
1404 // mCVfrQuestionDB.PrintAllQuestion();
1405 //
1406 CRT_END_OP (E);
1407 >>
1408 ";"
1409 ;
1410
1411 vfrFormMapDefinition :
1412 <<
1413 CIfrFormMap *FMapObj = NULL;
1414 UINT32 FormMapMethodNumber = 0;
1415 EFI_GUID Guid;
1416 >>
1417 F:FormMap << FMapObj = new CIfrFormMap(); FMapObj->SetLineNo(F->getLine()); >>
1418 FormId "=" S1:Number "," << _PCATCH(FMapObj->SetFormId (_STOFID(S1->getText())), S1); >>
1419 (
1420 MapTitle "=" "STRING_TOKEN" "\(" S2:Number "\)" ";"
1421 MapGuid "=" guidDefinition[Guid] ";" << FMapObj->SetFormMapMethod (_STOFID(S2->getText()), &Guid); FormMapMethodNumber ++; >>
1422 )* << if (FormMapMethodNumber == 0) {_PCATCH (VFR_RETURN_INVALID_PARAMETER, F->getLine(), "No MapMethod is set for FormMap!");} delete FMapObj;>>
1423 (
1424 vfrStatementImage |
1425 vfrStatementLocked |
1426 vfrStatementRules |
1427 vfrStatementDefault |
1428 vfrStatementStat |
1429 vfrStatementQuestions |
1430 vfrStatementConditional |
1431 vfrStatementLabel |
1432 vfrStatementBanner |
1433 vfrStatementExtension |
1434 vfrStatementModal
1435 )*
1436 E:EndForm << CRT_END_OP (E); >>
1437 ";"
1438 ;
1439
1440 vfrStatementRules :
1441 << CIfrRule RObj; >>
1442 R:Rule << RObj.SetLineNo(R->getLine()); >>
1443 S1:StringIdentifier "," <<
1444 mCVfrRulesDB.RegisterRule (S1->getText());
1445 RObj.SetRuleId (mCVfrRulesDB.GetRuleId(S1->getText()));
1446 >>
1447 vfrStatementExpression[0]
1448 E:EndRule << CRT_END_OP (E); >>
1449 ";"
1450 ;
1451
1452 vfrStatementDefault :
1453 <<
1454 BOOLEAN IsExp = FALSE;
1455 EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;
1456 CIfrDefault DObj;
1457 EFI_DEFAULT_ID DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
1458 CHAR8 *VarStoreName = NULL;
1459 EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
1460 >>
1461 D:Default << DObj.SetLineNo(D->getLine()); >>
1462 (
1463 (
1464 vfrStatementValue "," << IsExp = TRUE; DObj.SetScope (1); CIfrEnd EndObj1; EndObj1.SetLineNo(D->getLine()); >>
1465 | "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] > [Val] "," <<
1466 if (gCurrentMinMaxData != NULL && gCurrentMinMaxData->IsNumericOpcode()) {
1467 //check default value is valid for Numeric Opcode
1468 if (Val.u64 < gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE()) || Val.u64 > gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE())) {
1469 _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue.");
1470 }
1471 }
1472 DObj.SetType (_GET_CURRQEST_DATATYPE());
1473 DObj.SetValue(Val);
1474 >>
1475 )
1476 {
1477 DefaultStore "=" SN:StringIdentifier "," << _PCATCH(mCVfrDefaultStore.GetDefaultId (SN->getText(), &DefaultId), SN); DObj.SetDefaultId (DefaultId); >>
1478 }
1479 <<
1480 _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), D->getLine());
1481 _PCATCH(mCVfrDataStorage.GetVarStoreType (VarStoreName, VarStoreType), D->getLine());
1482 if ((IsExp == FALSE) && (VarStoreType == EFI_VFR_VARSTORE_BUFFER)) {
1483 _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
1484 DefaultId,
1485 _GET_CURRQEST_VARTINFO(),
1486 VarStoreName,
1487 _GET_CURRQEST_DATATYPE (),
1488 Val),
1489 D->getLine()
1490 );
1491 }
1492 >>
1493 )
1494 ;
1495
1496 vfrStatementStat :
1497 vfrStatementSubTitle |
1498 vfrStatementStaticText |
1499 vfrStatementCrossReference
1500 ;
1501
1502 vfrStatementQuestions :
1503 vfrStatementBooleanType |
1504 vfrStatementDate |
1505 vfrStatementNumericType |
1506 vfrStatementStringType |
1507 vfrStatementOrderedList |
1508 vfrStatementTime
1509 ;
1510
1511 vfrStatementConditional :
1512 vfrStatementDisableIfStat |
1513 vfrStatementSuppressIfStat | //enhance to be compatible for framework endif
1514 vfrStatementGrayOutIfStat |
1515 vfrStatementInconsistentIfStat //to be compatible for framework
1516 ;
1517
1518 vfrStatementConditionalNew :
1519 vfrStatementDisableIfStat |
1520 vfrStatementSuppressIfStatNew |
1521 vfrStatementGrayOutIfStatNew |
1522 vfrStatementInconsistentIfStat //to be compatible for framework
1523 ;
1524
1525 vfrStatementSuppressIfStat :
1526 <<mCompatibleMode>>? vfrStatementSuppressIfStatOld
1527 | vfrStatementSuppressIfStatNew
1528 ;
1529
1530 vfrStatementGrayOutIfStat :
1531 <<mCompatibleMode>>? vfrStatementGrayOutIfStatOld
1532 | vfrStatementGrayOutIfStatNew
1533 ;
1534
1535 vfrStatementInvalid :
1536 (
1537 vfrStatementInvalidHidden |
1538 vfrStatementInvalidInventory |
1539 vfrStatementInvalidSaveRestoreDefaults
1540 )
1541 << _CRT_OP (TRUE); >>
1542 ;
1543
1544 flagsField :
1545 Number | InteractiveFlag | ManufacturingFlag | DefaultFlag |
1546 NVAccessFlag | ResetRequiredFlag | LateCheckFlag
1547 ;
1548
1549 vfrStatementValue :
1550 << CIfrValue VObj; >>
1551 V:Value << VObj.SetLineNo(V->getLine()); >>
1552 "=" vfrStatementExpression[0] << {CIfrEnd EndObj; EndObj.SetLineNo(V->getLine());} >>
1553 ;
1554
1555 vfrStatementRead :
1556 << CIfrRead RObj; >>
1557 R:Read << RObj.SetLineNo(R->getLine()); >>
1558 vfrStatementExpression[0] ";"
1559 ;
1560
1561 vfrStatementWrite :
1562 << CIfrWrite WObj; >>
1563 W:Write << WObj.SetLineNo(W->getLine()); >>
1564 vfrStatementExpression[0] ";"
1565 ;
1566
1567 vfrStatementSubTitle :
1568 << CIfrSubtitle SObj; >>
1569 L:Subtitle << SObj.SetLineNo(L->getLine()); >>
1570 Text "=" "STRING_TOKEN" "\(" S:Number "\)" << SObj.SetPrompt (_STOSID(S->getText())); >>
1571 {
1572 "," FLAGS "=" vfrSubtitleFlags[SObj]
1573 }
1574 { vfrStatementStatTagList "," }
1575 E:";" << CRT_END_OP (E); >>
1576 ;
1577
1578 vfrSubtitleFlags [CIfrSubtitle & SObj] :
1579 << UINT8 LFlags = 0; >>
1580 subtitleFlagsField[LFlags] ( "\|" subtitleFlagsField[LFlags] )*
1581 << _PCATCH(SObj.SetFlags (LFlags)); >>
1582 ;
1583
1584 subtitleFlagsField [UINT8 & Flags] :
1585 N:Number << $Flags |= _STOU8(N->getText()); >>
1586 | "HORIZONTAL" << $Flags |= 0x01; >>
1587 ;
1588
1589 vfrStatementStaticText :
1590 <<
1591 UINT8 Flags = 0;
1592 EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
1593 EFI_STRING_ID TxtTwo = EFI_STRING_ID_INVALID;
1594 >>
1595 T:Text
1596 Help "=" "STRING_TOKEN" "\(" S1:Number "\)" ","
1597 Text "=" "STRING_TOKEN" "\(" S2:Number "\)"
1598 {
1599 "," Text "=" "STRING_TOKEN" "\(" S3:Number "\)" << TxtTwo = _STOSID(S3->getText()); >>
1600 }
1601 {
1602 "," F:FLAGS "=" staticTextFlagsField[Flags] ( "\|" staticTextFlagsField[Flags] )*
1603 "," Key "=" KN:Number
1604 }
1605 <<
1606 if (Flags & EFI_IFR_FLAG_CALLBACK) {
1607 CIfrAction AObj;
1608 mCVfrQuestionDB.RegisterQuestion (NULL, NULL, QId);
1609 AObj.SetLineNo (F->getLine());
1610 AObj.SetQuestionId (QId);
1611 AObj.SetPrompt (_STOSID(S2->getText()));
1612 AObj.SetHelp (_STOSID(S1->getText()));
1613 _PCATCH(AObj.SetFlags (Flags), F->getLine());
1614 AssignQuestionKey (AObj, KN);
1615 CRT_END_OP (KN);
1616 } else {
1617 CIfrText TObj;
1618 TObj.SetLineNo (T->getLine());
1619 TObj.SetHelp (_STOSID(S1->getText()));
1620 TObj.SetPrompt (_STOSID(S2->getText()));
1621 TObj.SetTextTwo (TxtTwo);
1622 }
1623 >>
1624 { "," vfrStatementStatTagList }
1625 ";"
1626 ;
1627
1628 staticTextFlagsField[UINT8 & HFlags] :
1629 N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
1630 | questionheaderFlagsField[HFlags]
1631 ;
1632
1633 vfrStatementCrossReference :
1634 vfrStatementGoto |
1635 vfrStatementResetButton
1636 ;
1637
1638 vfrStatementGoto :
1639 <<
1640 UINT8 RefType = 5;
1641 EFI_STRING_ID DevPath = EFI_STRING_ID_INVALID;
1642 EFI_GUID FSId = {0,};
1643 EFI_FORM_ID FId;
1644 EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
1645 UINT32 BitMask;
1646 CIfrQuestionHeader *QHObj = NULL;
1647 CIfrRef *R1Obj = NULL;
1648 CIfrRef2 *R2Obj = NULL;
1649 CIfrRef3 *R3Obj = NULL;
1650 CIfrRef4 *R4Obj = NULL;
1651 CIfrRef5 *R5Obj = NULL;
1652 >>
1653 G:Goto
1654 {
1655 (
1656 DevicePath "=" "STRING_TOKEN" "\(" P:Number "\)" ","
1657 FormSetGuid "=" guidDefinition[FSId] ","
1658 FormId "=" F1:Number ","
1659 Question "=" QN1:Number ","
1660 <<
1661 RefType = 4;
1662 DevPath = _STOSID(P->getText());
1663 FId = _STOFID(F1->getText());
1664 QId = _STOQID(QN1->getText());
1665 >>
1666 )
1667 |
1668 (
1669 FormSetGuid "=" guidDefinition[FSId] ","
1670 FormId "=" F2:Number ","
1671 Question "=" QN2:Number ","
1672 <<
1673 RefType = 3;
1674 FId = _STOFID(F2->getText());
1675 QId = _STOQID(QN2->getText());
1676 >>
1677 )
1678 |
1679 (
1680 FormId "=" F3:Number "," << RefType = 2; FId = _STOFID(F3->getText()); >>
1681 Question "="
1682 (
1683 QN3:StringIdentifier "," << mCVfrQuestionDB.GetQuestionId (QN3->getText (), NULL, QId, BitMask); >>
1684 | QN4:Number "," << QId = _STOQID(QN4->getText()); >>
1685 )
1686 )
1687 |
1688 (
1689 F4:Number "," <<
1690 RefType = 1;
1691 FId = _STOFID(F4->getText());
1692 >>
1693 )
1694 }
1695 <<
1696 switch (RefType) {
1697 case 5:
1698 {
1699 R5Obj = new CIfrRef5;
1700 QHObj = R5Obj;
1701 R5Obj->SetLineNo(G->getLine());
1702 break;
1703 }
1704 case 4:
1705 {
1706 R4Obj = new CIfrRef4;
1707 QHObj = R4Obj;
1708 R4Obj->SetLineNo(G->getLine());
1709 R4Obj->SetDevicePath (DevPath);
1710 R4Obj->SetFormSetId (FSId);
1711 R4Obj->SetFormId (FId);
1712 R4Obj->SetQuestionId (QId);
1713 break;
1714 }
1715 case 3:
1716 {
1717 R3Obj = new CIfrRef3;
1718 QHObj = R3Obj;
1719 R3Obj->SetLineNo(G->getLine());
1720 R3Obj->SetFormSetId (FSId);
1721 R3Obj->SetFormId (FId);
1722 R3Obj->SetQuestionId (QId);
1723 break;
1724 }
1725 case 2:
1726 {
1727 R2Obj = new CIfrRef2;
1728 QHObj = R2Obj;
1729 R2Obj->SetLineNo(G->getLine());
1730 R2Obj->SetFormId (FId);
1731 _PCATCH(R2Obj->SetQuestionId (QId), QN3);
1732 break;
1733 }
1734 case 1:
1735 {
1736 R1Obj = new CIfrRef;
1737 QHObj = R1Obj;
1738 R1Obj->SetLineNo(G->getLine());
1739 R1Obj->SetFormId (FId);
1740 break;
1741 }
1742 default: break;
1743 }
1744 >>
1745 vfrQuestionHeader[*QHObj, QUESTION_REF]
1746 { "," vfrStatementStatTagList }
1747 { "," F:FLAGS "=" vfrGotoFlags[QHObj, F->getLine()] }
1748 {
1749 "," Key "=" KN:Number << AssignQuestionKey (*QHObj, KN); >>
1750 }
1751 ";" << 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;}>>
1752 ;
1753
1754 vfrGotoFlags [CIfrQuestionHeader *QHObj, UINT32 LineNum] :
1755 << UINT8 HFlags = 0; >>
1756 gotoFlagsField[HFlags] ( "\|" gotoFlagsField[HFlags] )*
1757 << _PCATCH(QHObj->SetFlags (HFlags), LineNum); >>
1758 ;
1759
1760 gotoFlagsField[UINT8 & HFlags] :
1761 N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
1762 | questionheaderFlagsField[HFlags]
1763 ;
1764
1765 getStringId :
1766 "STRING_TOKEN" "\("
1767 IdVal:Number
1768 "\)"
1769 ;
1770
1771 vfrStatementResetButton :
1772 <<
1773 CIfrResetButton RBObj;
1774 UINT16 DefaultId;
1775 >>
1776 L:ResetButton << RBObj.SetLineNo(L->getLine()); >>
1777 DefaultStore
1778 "=" N:StringIdentifier "," <<
1779 _PCATCH(mCVfrDefaultStore.GetDefaultId (N->getText(), &DefaultId), N->getLine());
1780 RBObj.SetDefaultId (DefaultId);
1781 >>
1782 vfrStatementHeader[&RBObj] ","
1783 { vfrStatementStatTagList "," }
1784 E:EndResetButton << CRT_END_OP (E); >>
1785 ";"
1786 ;
1787
1788 vfrStatementBooleanType :
1789 vfrStatementCheckBox |
1790 vfrStatementAction
1791 ;
1792
1793 //*****************************************************
1794 // Syntax of checkbox
1795 //
1796 // Example:
1797 // checkbox
1798 // varid = MySTestData.mField1,
1799 // prompt = STRING_TOKEN(STR_CHECK_BOX_PROMPT),
1800 // help = STRING_TOKEN(STR_CHECK_BOX_HELP),
1801 // flags = CHECKBOX_DEFAULT | CALLBACK,
1802 // default value = TRUE, defaultstore = MyDefaultStore,
1803 // endcheckbox;
1804 //
1805 vfrStatementCheckBox :
1806 <<
1807 CIfrCheckBox CBObj;
1808 EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;
1809 CHAR8 *VarStoreName = NULL;
1810 UINT32 DataTypeSize;
1811 >>
1812 L:CheckBox << CBObj.SetLineNo(L->getLine()); >>
1813 vfrQuestionHeader[CBObj] "," << //check data type
1814 _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "CheckBox varid is not the valid data type");
1815 if (DataTypeSize != 0 && DataTypeSize != _GET_CURRQEST_VARSIZE()) {
1816 _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "CheckBox varid doesn't support array");
1817 } else if ((mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId) == EFI_VFR_VARSTORE_BUFFER) &&
1818 (_GET_CURRQEST_VARSIZE() != sizeof (BOOLEAN))) {
1819 _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "CheckBox varid only support BOOLEAN data type");
1820 }
1821 >>
1822 {
1823 F:FLAGS "=" vfrCheckBoxFlags[CBObj, F->getLine()] ","
1824 <<
1825 _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), VFR_RETURN_SUCCESS, L, "Failed to retrieve varstore name");
1826 Val.b = TRUE;
1827 if (CBObj.GetFlags () & 0x01) {
1828 _PCATCH(
1829 mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
1830 EFI_HII_DEFAULT_CLASS_STANDARD,
1831 _GET_CURRQEST_VARTINFO(),
1832 VarStoreName,
1833 _GET_CURRQEST_DATATYPE (),
1834 Val
1835 ),
1836 VFR_RETURN_SUCCESS,
1837 L,
1838 "No standard default storage found"
1839 );
1840 }
1841 if (CBObj.GetFlags () & 0x02) {
1842 _PCATCH(
1843 mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
1844 EFI_HII_DEFAULT_CLASS_MANUFACTURING,
1845 _GET_CURRQEST_VARTINFO(),
1846 VarStoreName,
1847 _GET_CURRQEST_DATATYPE (),
1848 Val
1849 ),
1850 VFR_RETURN_SUCCESS,
1851 L,
1852 "No manufacturing default storage found"
1853 );
1854 }
1855 >>
1856 }
1857 {
1858 Key "=" KN:Number "," << AssignQuestionKey (CBObj, KN); >>
1859 }
1860 vfrStatementQuestionOptionList
1861 E:EndCheckBox << CRT_END_OP (E); >>
1862 ";"
1863 ;
1864
1865 vfrCheckBoxFlags [CIfrCheckBox & CBObj, UINT32 LineNum] :
1866 <<
1867 UINT8 LFlags = 0;
1868 UINT8 HFlags = 0;
1869 >>
1870 checkboxFlagsField[LFlags, HFlags] ( "\|" checkboxFlagsField[LFlags, HFlags] )*
1871 << _PCATCH(CBObj.SetFlags (HFlags, LFlags), LineNum); >>
1872 ;
1873
1874 checkboxFlagsField[UINT8 & LFlags, UINT8 & HFlags] :
1875 N:Number <<
1876 if (mCompatibleMode) {
1877 //
1878 // set question flag
1879 //
1880 $LFlags |= _STOU8(N->getText());
1881 } else {
1882 _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine());
1883 }
1884 >>
1885 | D:"DEFAULT" <<
1886 if (mCompatibleMode) {
1887 //
1888 // set question Default flag
1889 //
1890 $LFlags |= 0x01;
1891 } else {
1892 _PCATCH (VFR_RETURN_UNSUPPORTED, D);
1893 }
1894 >>
1895 | M:"MANUFACTURING" <<
1896 if (mCompatibleMode) {
1897 //
1898 // set question MFG flag
1899 //
1900 $LFlags |= 0x02;
1901 } else {
1902 _PCATCH (VFR_RETURN_UNSUPPORTED, M);
1903 }
1904 >>
1905 | "CHECKBOX_DEFAULT" << $LFlags |= 0x01; >>
1906 | "CHECKBOX_DEFAULT_MFG" << $LFlags |= 0x02; >>
1907 | questionheaderFlagsField[HFlags]
1908 ;
1909
1910 //*****************************************************
1911 // Syntax of action
1912 //
1913 // Example:
1914 // action
1915 // prompt = STRING_TOKEN(STR_ACTION_PROMPT),
1916 // help = STRING_TOKEN(STR_ACTION_HELP),
1917 // flags = CALLBACK,
1918 // config = STRING_TOKEN(STR_ACTION_CONFIG),
1919 // endaction;
1920 //
1921 vfrStatementAction :
1922 << CIfrAction AObj; >>
1923 L:Action << AObj.SetLineNo(L->getLine()); >>
1924 vfrQuestionHeader[AObj] ","
1925 { F:FLAGS "=" vfrActionFlags[AObj, F->getLine()] "," }
1926 Config "=" "STRING_TOKEN" "\(" S:Number "\)" "," << AObj.SetQuestionConfig (_STOSID(S->getText())); >>
1927 vfrStatementQuestionTagList
1928 E:EndAction << CRT_END_OP (E); >>
1929 ";"
1930 ;
1931
1932 vfrActionFlags[CIfrAction & AObj, UINT32 LineNum] :
1933 << UINT8 HFlags = 0; >>
1934 actionFlagsField[HFlags] ( "\|" actionFlagsField[HFlags] )*
1935 << _PCATCH(AObj.SetFlags (HFlags), LineNum); >>
1936 ;
1937
1938 actionFlagsField[UINT8 & HFlags] :
1939 N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
1940 | questionheaderFlagsField[HFlags]
1941 ;
1942
1943 vfrStatementDate :
1944 <<
1945 EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
1946 CHAR8 *VarIdStr[3] = {NULL, };
1947 CIfrDate DObj;
1948 EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;
1949 >>
1950 L:Date << DObj.SetLineNo(L->getLine()); >>
1951 (
1952 (
1953 vfrQuestionHeader[DObj, QUESTION_DATE] ","
1954 { F:FLAGS "=" vfrDateFlags[DObj, F->getLine()] "," }
1955 vfrStatementQuestionOptionList
1956 )
1957 |
1958 (
1959 Year VarId "=" D1:StringIdentifier "." D1Y:StringIdentifier ","
1960 << _STRCAT(&VarIdStr[0], D1->getText()); _STRCAT(&VarIdStr[0], "."); _STRCAT(&VarIdStr[0], D1Y->getText()); >>
1961 Prompt "=" "STRING_TOKEN" "\(" YP:Number "\)" ","
1962 Help "=" "STRING_TOKEN" "\(" YH:Number "\)" ","
1963 minMaxDateStepDefault[Val.date, 0]
1964
1965 Month VarId "=" D2:StringIdentifier "." D2M:StringIdentifier ","
1966 << _STRCAT(&VarIdStr[1], D2->getText()); _STRCAT(&VarIdStr[1], "."); _STRCAT(&VarIdStr[1], D2M->getText()); >>
1967 Prompt "=" "STRING_TOKEN" "\(" MP:Number "\)" ","
1968 Help "=" "STRING_TOKEN" "\(" MH:Number "\)" ","
1969 minMaxDateStepDefault[Val.date, 1]
1970
1971 Day VarId "=" D3:StringIdentifier "." D3D:StringIdentifier ","
1972 << _STRCAT(&VarIdStr[2], D3->getText()); _STRCAT(&VarIdStr[2], "."); _STRCAT(&VarIdStr[2], D3D->getText()); >>
1973 Prompt "=" "STRING_TOKEN" "\(" DP:Number "\)" ","
1974 Help "=" "STRING_TOKEN" "\(" DH:Number "\)" ","
1975 minMaxDateStepDefault[Val.date, 2]
1976 <<
1977 mCVfrQuestionDB.RegisterOldDateQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);
1978 DObj.SetQuestionId (QId);
1979 DObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_DATE_STORAGE_TIME);
1980 DObj.SetPrompt (_STOSID(YP->getText()));
1981 DObj.SetHelp (_STOSID(YH->getText()));
1982 if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }
1983 >>
1984 << {CIfrDefault DefaultObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_DATE, Val); DefaultObj.SetLineNo(L->getLine());} >>
1985 )
1986 ( vfrStatementInconsistentIf )*
1987 )
1988 E:EndDate << CRT_END_OP (E); >>
1989 ";"
1990 ;
1991
1992 minMaxDateStepDefault[EFI_HII_DATE & D, UINT8 KeyValue] :
1993 Minimum "=" MinN:Number ","
1994 Maximum "=" MaxN:Number ","
1995 { "step" "=" Number "," }
1996 {
1997 "default" "=" N:Number "," <<
1998 switch (KeyValue) {
1999 case 0:
2000 D.Year = _STOU16(N->getText());
2001 if (D.Year < _STOU16 (MinN->getText()) || D.Year > _STOU16 (MaxN->getText())) {
2002 _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Year default value must be between Min year and Max year.");
2003 }
2004 break;
2005 case 1:
2006 D.Month = _STOU8(N->getText());
2007 if (D.Month < 1 || D.Month > 12) {
2008 _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Month default value must be between 1 and 12.");
2009 }
2010 break;
2011 case 2:
2012 D.Day = _STOU8(N->getText());
2013 if (D.Day < 1 || D.Day > 31) {
2014 _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Day default value must be between 1 and 31.");
2015 }
2016 break;
2017 }
2018 >>
2019 }
2020 ;
2021
2022 vfrDateFlags [CIfrDate & DObj, UINT32 LineNum] :
2023 << UINT8 LFlags = 0; >>
2024 dateFlagsField[LFlags] ( "\|" dateFlagsField[LFlags] )*
2025 << _PCATCH(DObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, LFlags), LineNum); >>
2026 ;
2027
2028 dateFlagsField [UINT8 & Flags] :
2029 N:Number << $Flags |= _STOU8(N->getText()); >>
2030 | "YEAR_SUPPRESS" << $Flags |= 0x01; >>
2031 | "MONTH_SUPPRESS" << $Flags |= 0x02; >>
2032 | "DAY_SUPPRESS" << $Flags |= 0x04; >>
2033 | "STORAGE_NORMAL" << $Flags |= 0x00; >>
2034 | "STORAGE_TIME" << $Flags |= 0x10; >>
2035 | "STORAGE_WAKEUP" << $Flags |= 0x20; >>
2036 ;
2037
2038 vfrStatementNumericType :
2039 vfrStatementNumeric |
2040 vfrStatementOneOf
2041 ;
2042
2043 vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] :
2044 <<
2045 UINT64 MaxU8 = 0, MinU8 = 0, StepU8 = 0;
2046 UINT32 MaxU4 = 0, MinU4 = 0, StepU4 = 0;
2047 UINT16 MaxU2 = 0, MinU2 = 0, StepU2 = 0;
2048 UINT8 MaxU1 = 0, MinU1 = 0, StepU1 = 0;
2049 >>
2050 Minimum "=" I:Number ","
2051 <<
2052 switch (_GET_CURRQEST_DATATYPE()) {
2053 case EFI_IFR_TYPE_NUM_SIZE_64 : MinU8 = _STOU64(I->getText()); break;
2054 case EFI_IFR_TYPE_NUM_SIZE_32 : MinU4 = _STOU32(I->getText()); break;
2055 case EFI_IFR_TYPE_NUM_SIZE_16 : MinU2 = _STOU16(I->getText()); break;
2056 case EFI_IFR_TYPE_NUM_SIZE_8 : MinU1 = _STOU8(I->getText()); break;
2057 }
2058 >>
2059 Maximum "=" A:Number ","
2060 <<
2061 switch (_GET_CURRQEST_DATATYPE()) {
2062 case EFI_IFR_TYPE_NUM_SIZE_64 :
2063 MaxU8 = _STOU64(A->getText());
2064 if (MaxU8 < MinU8) {
2065 _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
2066 }
2067 break;
2068 case EFI_IFR_TYPE_NUM_SIZE_32 :
2069 MaxU4 = _STOU32(A->getText());
2070 if (MaxU4 < MinU4) {
2071 _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
2072 }
2073 break;
2074 case EFI_IFR_TYPE_NUM_SIZE_16 :
2075 MaxU2 = _STOU16(A->getText());
2076 if (MaxU2 < MinU2) {
2077 _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
2078 }
2079 break;
2080 case EFI_IFR_TYPE_NUM_SIZE_8 :
2081 MaxU1 = _STOU8(A->getText());
2082 if (MaxU1 < MinU1) {
2083 _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum");
2084 }
2085 break;
2086 }
2087 >>
2088 {
2089 STEP "=" S:Number ","
2090 <<
2091 switch (_GET_CURRQEST_DATATYPE()) {
2092 case EFI_IFR_TYPE_NUM_SIZE_64 : StepU8 = _STOU64(S->getText()); break;
2093 case EFI_IFR_TYPE_NUM_SIZE_32 : StepU4 = _STOU32(S->getText()); break;
2094 case EFI_IFR_TYPE_NUM_SIZE_16 : StepU2 = _STOU16(S->getText()); break;
2095 case EFI_IFR_TYPE_NUM_SIZE_8 : StepU1 = _STOU8(S->getText()); break;
2096 }
2097 >>
2098 }
2099 <<
2100 switch (_GET_CURRQEST_DATATYPE()) {
2101 case EFI_IFR_TYPE_NUM_SIZE_64 : $MMSDObj.SetMinMaxStepData (MinU8, MaxU8, StepU8); break;
2102 case EFI_IFR_TYPE_NUM_SIZE_32 : $MMSDObj.SetMinMaxStepData (MinU4, MaxU4, StepU4); break;
2103 case EFI_IFR_TYPE_NUM_SIZE_16 : $MMSDObj.SetMinMaxStepData (MinU2, MaxU2, StepU2); break;
2104 case EFI_IFR_TYPE_NUM_SIZE_8 : $MMSDObj.SetMinMaxStepData (MinU1, MaxU1, StepU1); break;
2105 }
2106 >>
2107 ;
2108
2109 vfrStatementNumeric :
2110 <<
2111 CIfrNumeric NObj;
2112 UINT32 DataTypeSize;
2113 >>
2114 L:Numeric << NObj.SetLineNo(L->getLine()); >>
2115 vfrQuestionHeader[NObj] "," << // check data type
2116 _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "Numeric varid is not the valid data type");
2117 if (DataTypeSize != 0 && DataTypeSize != _GET_CURRQEST_VARSIZE()) {
2118 _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "Numeric varid doesn't support array");
2119 }
2120 _PCATCH(NObj.SetFlags (NObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine());
2121 >>
2122 { F:FLAGS "=" vfrNumericFlags[NObj, F->getLine()] "," }
2123 {
2124 Key "=" KN:Number "," << AssignQuestionKey (NObj, KN); >>
2125 }
2126 vfrSetMinMaxStep[NObj]
2127 vfrStatementQuestionOptionList
2128 E:EndNumeric << CRT_END_OP (E); >>
2129 ";"
2130 ;
2131
2132 vfrNumericFlags [CIfrNumeric & NObj, UINT32 LineNum] :
2133 <<
2134 UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;
2135 UINT8 HFlags = 0;
2136 EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
2137 >>
2138 numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )*
2139 <<
2140 //check data type flag
2141 VarStoreType = mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId);
2142 if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) {
2143 if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) {
2144 _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type");
2145 }
2146 } else {
2147 // update data type for name/value store
2148 UINT32 DataTypeSize;
2149 _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;
2150 gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize);
2151 _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize;
2152 }
2153 _PCATCH(NObj.SetFlags (HFlags, LFlags), LineNum);
2154 >>
2155 ;
2156
2157 numericFlagsField [UINT8 & HFlags, UINT8 & LFlags] :
2158 N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
2159 | "NUMERIC_SIZE_1" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_1; >>
2160 | "NUMERIC_SIZE_2" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_2; >>
2161 | "NUMERIC_SIZE_4" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_4; >>
2162 | "NUMERIC_SIZE_8" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_8; >>
2163 | "DISPLAY_INT_DEC" << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_INT_DEC; >>
2164 | "DISPLAY_UINT_DEC" << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_DEC; >>
2165 | "DISPLAY_UINT_HEX" << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_HEX; >>
2166 | questionheaderFlagsField[HFlags]
2167 ;
2168
2169 vfrStatementOneOf :
2170 <<
2171 CIfrOneOf OObj;
2172 UINT32 DataTypeSize;
2173 >>
2174 L:OneOf << OObj.SetLineNo(L->getLine()); >>
2175 vfrQuestionHeader[OObj] "," << //check data type
2176 _PCATCH (gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize), L->getLine(), "OneOf varid is not the valid data type");
2177 if (DataTypeSize != 0 && DataTypeSize != _GET_CURRQEST_VARSIZE()) {
2178 _PCATCH (VFR_RETURN_INVALID_PARAMETER, L->getLine(), "OneOf varid doesn't support array");
2179 }
2180 _PCATCH(OObj.SetFlags (OObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine());
2181 >>
2182 { F:FLAGS "=" vfrOneofFlagsField[OObj, F->getLine()] "," }
2183 {
2184 vfrSetMinMaxStep[OObj]
2185 }
2186 vfrStatementQuestionOptionList
2187 E:EndOneOf << CRT_END_OP (E); >>
2188 ";"
2189 ;
2190
2191 vfrOneofFlagsField [CIfrOneOf & OObj, UINT32 LineNum] :
2192 <<
2193 UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;
2194 UINT8 HFlags = 0;
2195 EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
2196 >>
2197 numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )*
2198 <<
2199 //check data type flag
2200 VarStoreType = mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId);
2201 if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) {
2202 if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) {
2203 _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type");
2204 }
2205 } else {
2206 // update data type for Name/Value store
2207 UINT32 DataTypeSize;
2208 _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;
2209 gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize);
2210 _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize;
2211 }
2212 _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum);
2213 >>
2214 ;
2215
2216 vfrStatementStringType :
2217 vfrStatementString |
2218 vfrStatementPassword
2219 ;
2220
2221 vfrStatementString :
2222 <<
2223 CIfrString SObj;
2224 UINT32 VarArraySize;
2225 UINT8 StringMinSize;
2226 UINT8 StringMaxSize;
2227 >>
2228 L:String << SObj.SetLineNo(L->getLine()); >>
2229 vfrQuestionHeader[SObj] ","
2230 { F:FLAGS "=" vfrStringFlagsField[SObj, F->getLine()] "," }
2231 {
2232 Key "=" KN:Number "," << AssignQuestionKey (SObj, KN); >>
2233 }
2234 MinSize "=" MIN:Number "," <<
2235 VarArraySize = _GET_CURRQEST_ARRAY_SIZE();
2236 StringMinSize = _STOU8(MIN->getText());
2237 if (_STOU64(MIN->getText()) > StringMinSize) {
2238 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MIN->getLine(), "String MinSize takes only one byte, which can't be larger than 0xFF.");
2239 } else if (VarArraySize != 0 && StringMinSize > VarArraySize) {
2240 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MIN->getLine(), "String MinSize can't be larger than the max number of elements in string array.");
2241 }
2242 SObj.SetMinSize (StringMinSize);
2243 >>
2244 MaxSize "=" MAX:Number "," <<
2245 StringMaxSize = _STOU8(MAX->getText());
2246 if (_STOU64(MAX->getText()) > StringMaxSize) {
2247 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "String MaxSize takes only one byte, which can't be larger than 0xFF.");
2248 } else if (VarArraySize != 0 && StringMaxSize > VarArraySize) {
2249 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "String MaxSize can't be larger than the max number of elements in string array.");
2250 } else if (StringMaxSize < StringMinSize) {
2251 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "String MaxSize can't be less than String MinSize.");
2252 }
2253 SObj.SetMaxSize (StringMaxSize);
2254 >>
2255 vfrStatementQuestionOptionList
2256 E:EndString << CRT_END_OP (E); >>
2257 ";"
2258 ;
2259
2260 vfrStringFlagsField [CIfrString & SObj, UINT32 LineNum] :
2261 <<
2262 UINT8 LFlags = 0;
2263 UINT8 HFlags = 0;
2264 >>
2265 stringFlagsField[HFlags, LFlags] ( "\|" stringFlagsField[HFlags, LFlags] )*
2266 << _PCATCH(SObj.SetFlags (HFlags, LFlags), LineNum); >>
2267 ;
2268
2269 stringFlagsField [UINT8 & HFlags, UINT8 & LFlags] :
2270 N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
2271 | "MULTI_LINE" << $LFlags = 0x01; >>
2272 | questionheaderFlagsField[HFlags]
2273 ;
2274
2275 vfrStatementPassword :
2276 <<
2277 CIfrPassword PObj;
2278 UINT32 VarArraySize;
2279 UINT16 PasswordMinSize;
2280 UINT16 PasswordMaxSize;
2281 >>
2282 L:Password << PObj.SetLineNo(L->getLine()); >>
2283 vfrQuestionHeader[PObj] ","
2284 { F:FLAGS "=" vfrPasswordFlagsField[PObj, F->getLine()] "," }
2285 {
2286 Key "=" KN:Number "," << AssignQuestionKey (PObj, KN); >>
2287 }
2288 MinSize "=" MIN:Number "," <<
2289 VarArraySize = _GET_CURRQEST_ARRAY_SIZE();
2290 PasswordMinSize = _STOU16(MIN->getText());
2291 if (_STOU64(MIN->getText()) > PasswordMinSize) {
2292 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MIN->getLine(), "Password MinSize takes only two byte, which can't be larger than 0xFFFF.");
2293 } else if (VarArraySize != 0 && PasswordMinSize > VarArraySize) {
2294 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MIN->getLine(), "Password MinSize can't be larger than the max number of elements in password array.");
2295 }
2296 PObj.SetMinSize (PasswordMinSize);
2297 >>
2298 MaxSize "=" MAX:Number "," <<
2299 PasswordMaxSize = _STOU16(MAX->getText());
2300 if (_STOU64(MAX->getText()) > PasswordMaxSize) {
2301 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "Password MaxSize takes only two byte, which can't be larger than 0xFFFF.");
2302 } else if (VarArraySize != 0 && PasswordMaxSize > VarArraySize) {
2303 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "Password MaxSize can't be larger than the max number of elements in password array.");
2304 } else if (PasswordMaxSize < PasswordMinSize) {
2305 _PCATCH (VFR_RETURN_INVALID_PARAMETER, MAX->getLine(), "Password MaxSize can't be less than Password MinSize.");
2306 }
2307 PObj.SetMaxSize (PasswordMaxSize);
2308 >>
2309 { Encoding "=" Number "," }
2310 vfrStatementQuestionOptionList
2311 E:EndPassword << CRT_END_OP (E); >>
2312 ";"
2313 ;
2314
2315 vfrPasswordFlagsField [CIfrPassword & PObj, UINT32 LineNum] :
2316 << UINT8 HFlags = 0; >>
2317 passwordFlagsField[HFlags] ( "\|" passwordFlagsField[HFlags] )*
2318 << _PCATCH(PObj.SetFlags(HFlags), LineNum); >>
2319 ;
2320
2321 passwordFlagsField [UINT8 & HFlags] :
2322 N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
2323 | questionheaderFlagsField[HFlags]
2324 ;
2325
2326 vfrStatementOrderedList :
2327 <<
2328 CIfrOrderedList OLObj;
2329 UINT32 VarArraySize;
2330 >>
2331 L:OrderedList << OLObj.SetLineNo(L->getLine()); >>
2332 vfrQuestionHeader[OLObj] ","
2333 <<
2334 VarArraySize = _GET_CURRQEST_ARRAY_SIZE();
2335 OLObj.SetMaxContainers ((UINT8) (VarArraySize > 0xFF ? 0xFF : VarArraySize));
2336 >>
2337 {
2338 MaxContainers "=" M:Number "," <<
2339 if (_STOU64(M->getText()) > _STOU8(M->getText())) {
2340 _PCATCH (VFR_RETURN_INVALID_PARAMETER, M->getLine(), "OrderedList MaxContainers takes only one byte, which can't be larger than 0xFF.");
2341 } else if (VarArraySize != 0 && _STOU8(M->getText()) > VarArraySize) {
2342 _PCATCH (VFR_RETURN_INVALID_PARAMETER, M->getLine(), "OrderedList MaxContainers can't be larger than the max number of elements in array.");
2343 }
2344 OLObj.SetMaxContainers (_STOU8(M->getText()));
2345 >>
2346 }
2347 { F:FLAGS "=" vfrOrderedListFlags[OLObj, F->getLine()] }
2348 vfrStatementQuestionOptionList
2349 E:EndList << CRT_END_OP (E); >>
2350 ";"
2351 ;
2352
2353 vfrOrderedListFlags [CIfrOrderedList & OLObj, UINT32 LineNum] :
2354 <<
2355 UINT8 HFlags = 0;
2356 UINT8 LFlags = 0;
2357 >>
2358 orderedlistFlagsField[HFlags, LFlags] ( "\|" orderedlistFlagsField[HFlags, LFlags] )*
2359 << _PCATCH(OLObj.SetFlags (HFlags, LFlags), LineNum); >>
2360 ;
2361
2362 orderedlistFlagsField [UINT8 & HFlags, UINT8 & LFlags] :
2363 N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
2364 | "UNIQUE" << $LFlags |= 0x01; >>
2365 | "NOEMPTY" << $LFlags |= 0x02; >>
2366 | questionheaderFlagsField[HFlags]
2367 ;
2368
2369 vfrStatementTime :
2370 <<
2371 EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
2372 CHAR8 *VarIdStr[3] = {NULL, };
2373 CIfrTime TObj;
2374 EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;
2375 >>
2376 L:Time << TObj.SetLineNo(L->getLine()); >>
2377 (
2378 (
2379 vfrQuestionHeader[TObj, QUESTION_TIME] ","
2380 { F:FLAGS "=" vfrTimeFlags[TObj, F->getLine()] "," }
2381 vfrStatementQuestionOptionList
2382 )
2383 |
2384 (
2385 Hour VarId "=" T1:StringIdentifier "." T1H:StringIdentifier ","
2386 << _STRCAT(&VarIdStr[0], T1->getText()); _STRCAT(&VarIdStr[0], "."); _STRCAT(&VarIdStr[0], T1H->getText()); >>
2387 Prompt "=" "STRING_TOKEN" "\(" HP:Number "\)" ","
2388 Help "=" "STRING_TOKEN" "\(" HH:Number "\)" ","
2389 minMaxTimeStepDefault[Val.time, 0]
2390
2391 Minute VarId "=" T2:StringIdentifier "." T2M:StringIdentifier ","
2392 << _STRCAT(&VarIdStr[1], T2->getText()); _STRCAT(&VarIdStr[1], "."); _STRCAT(&VarIdStr[1], T2M->getText()); >>
2393 Prompt "=" "STRING_TOKEN" "\(" MP:Number "\)" ","
2394 Help "=" "STRING_TOKEN" "\(" MH:Number "\)" ","
2395 minMaxTimeStepDefault[Val.time, 1]
2396
2397 Second VarId "=" T3:StringIdentifier "." T3S:StringIdentifier ","
2398 << _STRCAT(&VarIdStr[2], T3->getText()); _STRCAT(&VarIdStr[2], "."); _STRCAT(&VarIdStr[2], T3S->getText()); >>
2399 Prompt "=" "STRING_TOKEN" "\(" SP:Number "\)" ","
2400 Help "=" "STRING_TOKEN" "\(" SH:Number "\)" ","
2401 minMaxTimeStepDefault[Val.time, 2]
2402 <<
2403 mCVfrQuestionDB.RegisterOldTimeQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);
2404 TObj.SetQuestionId (QId);
2405 TObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_TIME_STORAGE_TIME);
2406 TObj.SetPrompt (_STOSID(HP->getText()));
2407 TObj.SetHelp (_STOSID(HH->getText()));
2408 if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }
2409 >>
2410 << {CIfrDefault DefaultObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_TIME, Val); DefaultObj.SetLineNo(L->getLine());} >>
2411 )
2412 ( vfrStatementInconsistentIf )*
2413 )
2414 E:EndTime << CRT_END_OP (E); >>
2415 ";"
2416 ;
2417
2418 minMaxTimeStepDefault[EFI_HII_TIME & T, UINT8 KeyValue] :
2419 Minimum "=" Number ","
2420 Maximum "=" Number ","
2421 { "step" "=" Number "," }
2422 {
2423 "default" "=" N:Number "," <<
2424 switch (KeyValue) {
2425 case 0:
2426 T.Hour = _STOU8(N->getText());
2427 if (T.Hour > 23) {
2428 _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Hour default value must be between 0 and 23.");
2429 }
2430 break;
2431 case 1:
2432 T.Minute = _STOU8(N->getText());
2433 if (T.Minute > 59) {
2434 _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Minute default value must be between 0 and 59.");
2435 }
2436 break;
2437 case 2:
2438 T.Second = _STOU8(N->getText());
2439 if (T.Second > 59) {
2440 _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Second default value must be between 0 and 59.");
2441 }
2442 break;
2443 }
2444 >>
2445 }
2446 ;
2447
2448 vfrTimeFlags [CIfrTime & TObj, UINT32 LineNum] :
2449 << UINT8 LFlags = 0; >>
2450 timeFlagsField[LFlags] ( "\|" timeFlagsField[LFlags] )*
2451 << _PCATCH(TObj.SetFlags(EFI_IFR_QUESTION_FLAG_DEFAULT, LFlags), LineNum); >>
2452 ;
2453
2454 timeFlagsField [UINT8 & Flags] :
2455 N:Number << $Flags |= _STOU8(N->getText()); >>
2456 | "HOUR_SUPPRESS" << $Flags |= 0x01; >>
2457 | "MINUTE_SUPPRESS" << $Flags |= 0x02; >>
2458 | "SECOND_SUPPRESS" << $Flags |= 0x04; >>
2459 | "STORAGE_NORMAL" << $Flags |= 0x00; >>
2460 | "STORAGE_TIME" << $Flags |= 0x10; >>
2461 | "STORAGE_WAKEUP" << $Flags |= 0x20; >>
2462 ;
2463
2464 vfrStatementQuestionTag :
2465 vfrStatementStatTag "," |
2466 vfrStatementInconsistentIf |
2467 vfrStatementNoSubmitIf |
2468 vfrStatementDisableIfQuest |
2469 vfrStatementRefresh |
2470 vfrStatementVarstoreDevice |
2471 vfrStatementExtension |
2472 vfrStatementRefreshEvent
2473 ;
2474
2475 vfrStatementQuestionTagList :
2476 ( vfrStatementQuestionTag )*
2477 ;
2478
2479 vfrStatementQuestionOptionTag :
2480 vfrStatementSuppressIfQuest |
2481 vfrStatementGrayOutIfQuest |
2482 vfrStatementValue |
2483 vfrStatementDefault |
2484 vfrStatementRead |
2485 vfrStatementWrite |
2486 vfrStatementOptions
2487 ;
2488
2489 vfrStatementQuestionOptionList :
2490 (
2491 vfrStatementQuestionTag |
2492 vfrStatementQuestionOptionTag
2493 )*
2494 ;
2495
2496 vfrStatementStatList :
2497 vfrStatementStat |
2498 vfrStatementQuestions |
2499 vfrStatementConditionalNew |
2500 vfrStatementLabel |
2501 vfrStatementExtension |
2502 // Just for framework vfr compatibility
2503 vfrStatementInvalid
2504 ;
2505
2506 vfrStatementStatListOld :
2507 vfrStatementStat |
2508 vfrStatementQuestions |
2509 vfrStatementLabel |
2510 // Just for framework vfr compatibility
2511 vfrStatementInvalid
2512 ;
2513
2514 vfrStatementDisableIfStat :
2515 <<
2516 CIfrDisableIf DIObj;
2517 >>
2518 L:DisableIf << DIObj.SetLineNo(L->getLine()); >>
2519 vfrStatementExpression[0] ";"
2520 ( vfrStatementStatList )*
2521 E:EndIf << CRT_END_OP (E); >>
2522 ";"
2523 ;
2524
2525 vfrStatementInconsistentIfStat :
2526 << CIfrInconsistentIf IIObj; >>
2527 L:InconsistentIf <<
2528 if (!mCompatibleMode) {
2529 _PCATCH (VFR_RETURN_UNSUPPORTED, L);
2530 }
2531 IIObj.SetLineNo(L->getLine());
2532 >>
2533 Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" "," << IIObj.SetError (_STOSID(S->getText())); >>
2534 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2535 vfrStatementExpression[0]
2536 E:EndIf << CRT_END_OP (E); >>
2537 ";"
2538 ;
2539
2540 //
2541 // Compatible for framework vfr file
2542 //
2543 vfrStatementgrayoutIfSuppressIf:
2544 << CIfrSuppressIf SIObj; >>
2545 L:SuppressIf << SIObj.SetLineNo(L->getLine()); >>
2546 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2547 vfrStatementExpression[0]
2548 ";"
2549 ;
2550
2551 vfrStatementsuppressIfGrayOutIf:
2552 << CIfrGrayOutIf GOIObj; >>
2553 L:GrayOutIf << GOIObj.SetLineNo(L->getLine()); >>
2554 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2555 vfrStatementExpression[0]
2556 ";"
2557 ;
2558
2559 vfrStatementSuppressIfStatNew :
2560 << CIfrSuppressIf SIObj;>>
2561 L:SuppressIf << SIObj.SetLineNo(L->getLine()); >>
2562 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2563 vfrStatementExpression[0]
2564 ";"
2565 ( vfrStatementStatList )*
2566 E: EndIf ";" << CRT_END_OP (E); >>
2567 ;
2568
2569 vfrStatementGrayOutIfStatNew :
2570 << CIfrGrayOutIf GOIObj;>>
2571 L:GrayOutIf << GOIObj.SetLineNo(L->getLine()); >>
2572 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2573 vfrStatementExpression[0]
2574 ";"
2575 ( vfrStatementStatList )*
2576 E: EndIf ";" << CRT_END_OP (E); >>
2577 ;
2578
2579 vfrStatementSuppressIfStatOld :
2580 <<
2581 CIfrSuppressIf SIObj;
2582 BOOLEAN GrayOutExist = FALSE;
2583 >>
2584 L:SuppressIf << SIObj.SetLineNo(L->getLine()); >>
2585 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2586 vfrStatementExpression[0]
2587 ";"
2588 {
2589 vfrStatementsuppressIfGrayOutIf
2590 << GrayOutExist = TRUE; >>
2591 }
2592 ( vfrStatementStatListOld )*
2593 E: EndIf ";" << if (GrayOutExist) CRT_END_OP (E); CRT_END_OP (E);>>
2594 ;
2595
2596 vfrStatementGrayOutIfStatOld :
2597 <<
2598 CIfrGrayOutIf GOIObj;
2599 BOOLEAN SuppressExist = FALSE;
2600 >>
2601 L:GrayOutIf << GOIObj.SetLineNo(L->getLine()); >>
2602 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2603 vfrStatementExpression[0]
2604 ";"
2605 {
2606 vfrStatementgrayoutIfSuppressIf
2607 << SuppressExist = TRUE; >>
2608 }
2609 ( vfrStatementStatListOld )*
2610 E: EndIf ";" << if (SuppressExist) CRT_END_OP (E); CRT_END_OP (E); >>
2611 ;
2612
2613 vfrImageTag :
2614 << CIfrImage IObj; >>
2615 L:Image "=" "IMAGE_TOKEN" "\(" S1:Number "\)" << IObj.SetImageId (_STOSID(S1->getText())); IObj.SetLineNo(L->getLine()); >>
2616 ;
2617
2618 vfrLockedTag :
2619 << CIfrLocked LObj; >>
2620 L:Locked << LObj.SetLineNo(L->getLine()); >>
2621 ;
2622
2623 vfrModalTag :
2624 << CIfrModal MObj; >>
2625 L:Modal << MObj.SetLineNo(L->getLine()); >>
2626 ;
2627
2628 vfrStatementStatTag :
2629 vfrImageTag |
2630 vfrLockedTag
2631 ;
2632
2633 vfrStatementStatTagList :
2634 vfrStatementStatTag ( "," vfrStatementStatTag )*
2635 ;
2636
2637 vfrStatementImage :
2638 vfrImageTag
2639 ";"
2640 ;
2641
2642 vfrStatementModal :
2643 vfrModalTag
2644 ";"
2645 ;
2646
2647 vfrStatementLocked :
2648 vfrLockedTag
2649 ";"
2650 ;
2651
2652 vfrStatementInconsistentIf :
2653 << CIfrInconsistentIf IIObj; >>
2654 L:InconsistentIf << IIObj.SetLineNo(L->getLine()); >>
2655 Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" "," << IIObj.SetError (_STOSID(S->getText())); >>
2656 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2657 vfrStatementExpression[0]
2658 E:EndIf << CRT_END_OP (E); >>
2659 ;
2660
2661 vfrStatementNoSubmitIf :
2662 << CIfrNoSubmitIf NSIObj; >>
2663 L:NoSubmitIf << NSIObj.SetLineNo(L->getLine()); >>
2664 Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" "," << NSIObj.SetError (_STOSID(S->getText())); >>
2665 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2666 vfrStatementExpression[0]
2667 E:EndIf << CRT_END_OP (E); >>
2668 ;
2669
2670 vfrStatementDisableIfQuest :
2671 <<
2672 CIfrDisableIf DIObj;
2673 >>
2674 L:DisableIf << DIObj.SetLineNo(L->getLine()); >>
2675 vfrStatementExpression[0] ";"
2676 vfrStatementQuestionOptionList
2677 E:EndIf << CRT_END_OP (E); >>
2678 ;
2679
2680 vfrStatementRefresh :
2681 << CIfrRefresh RObj; >>
2682 L:Refresh << RObj.SetLineNo(L->getLine()); >>
2683 Interval "=" I:Number << RObj.SetRefreshInterval (_STOU8(I->getText())); >>
2684 ;
2685
2686 vfrStatementRefreshEvent :
2687 <<
2688 CIfrRefreshId RiObj;
2689 EFI_GUID Guid;
2690 >>
2691 L:RefreshGuid << RiObj.SetLineNo(L->getLine()); >>
2692 "=" guidDefinition[Guid] "," << RiObj.SetRefreshEventGroutId (&Guid); >>
2693 ;
2694
2695 vfrStatementVarstoreDevice :
2696 << CIfrVarStoreDevice VDObj; >>
2697 L:VarstoreDevice << VDObj.SetLineNo(L->getLine()); >>
2698 "=" "STRING_TOKEN" "\(" S:Number "\)" "," << VDObj.SetDevicePath (_STOSID(S->getText())); >>
2699 ;
2700
2701 vfrStatementSuppressIfQuest :
2702 << CIfrSuppressIf SIObj; >>
2703 L:SuppressIf << SIObj.SetLineNo(L->getLine()); >>
2704 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2705 vfrStatementExpression[0] ";"
2706 vfrStatementQuestionOptionList
2707 E:EndIf << CRT_END_OP (E); >>
2708 ;
2709
2710 vfrStatementGrayOutIfQuest :
2711 << CIfrGrayOutIf GOIObj; >>
2712 L:GrayOutIf << GOIObj.SetLineNo(L->getLine()); >>
2713 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2714 vfrStatementExpression[0] ";"
2715 vfrStatementQuestionOptionList
2716 E:EndIf << CRT_END_OP (E); >>
2717 ;
2718
2719 vfrStatementOptions :
2720 vfrStatementOneOfOption
2721 ;
2722
2723 vfrStatementOneOfOption :
2724 <<
2725 EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue;
2726 CIfrOneOfOption OOOObj;
2727 CHAR8 *VarStoreName = NULL;
2728 >>
2729 L:Option << OOOObj.SetLineNo(L->getLine()); >>
2730 Text "=" "STRING_TOKEN" "\(" S:Number "\)" "," << OOOObj.SetOption (_STOSID(S->getText())); >>
2731 Value "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] >[Val] ","
2732 <<
2733 if (gCurrentMinMaxData != NULL) {
2734 //set min/max value for oneof opcode
2735 UINT64 Step = gCurrentMinMaxData->GetStepData(_GET_CURRQEST_DATATYPE());
2736 switch (_GET_CURRQEST_DATATYPE()) {
2737 case EFI_IFR_TYPE_NUM_SIZE_64:
2738 gCurrentMinMaxData->SetMinMaxStepData(Val.u64, Val.u64, Step);
2739 break;
2740 case EFI_IFR_TYPE_NUM_SIZE_32:
2741 gCurrentMinMaxData->SetMinMaxStepData(Val.u32, Val.u32, (UINT32) Step);
2742 break;
2743 case EFI_IFR_TYPE_NUM_SIZE_16:
2744 gCurrentMinMaxData->SetMinMaxStepData(Val.u16, Val.u16, (UINT16) Step);
2745 break;
2746 case EFI_IFR_TYPE_NUM_SIZE_8:
2747 gCurrentMinMaxData->SetMinMaxStepData(Val.u8, Val.u8, (UINT8) Step);
2748 break;
2749 default:
2750 break;
2751 }
2752 }
2753 OOOObj.SetType (_GET_CURRQEST_DATATYPE());
2754 OOOObj.SetValue (Val);
2755 >>
2756 F:FLAGS "=" vfrOneOfOptionFlags[OOOObj, F->getLine()]
2757 <<
2758 _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), L->getLine());
2759 if (OOOObj.GetFlags () & 0x10) {
2760 _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
2761 EFI_HII_DEFAULT_CLASS_STANDARD,
2762 _GET_CURRQEST_VARTINFO(),
2763 VarStoreName,
2764 _GET_CURRQEST_DATATYPE (),
2765 Val
2766 ), L->getLine());
2767 }
2768 if (OOOObj.GetFlags () & 0x20) {
2769 _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
2770 EFI_HII_DEFAULT_CLASS_MANUFACTURING,
2771 _GET_CURRQEST_VARTINFO(),
2772 VarStoreName,
2773 _GET_CURRQEST_DATATYPE (),
2774 Val
2775 ), L->getLine());
2776 }
2777 >>
2778 {
2779 "," Key "=" KN:Number <<
2780 if (!mCompatibleMode) {
2781 _PCATCH (VFR_RETURN_UNSUPPORTED, KN);
2782 }
2783 //
2784 // Guid Option Key
2785 //
2786 CIfrOptionKey IfrOptionKey (
2787 gCurrentQuestion->QUESTION_ID(),
2788 Val,
2789 _STOQID(KN->getText())
2790 );
2791 SET_LINE_INFO (IfrOptionKey, KN);
2792 >>
2793 }
2794 (
2795 T:"," vfrImageTag << OOOObj.SetScope (1); CRT_END_OP (T); >>
2796 )*
2797 ";"
2798 ;
2799
2800 vfrOneOfOptionFlags [CIfrOneOfOption & OOOObj, UINT32 LineNum] :
2801 <<
2802 UINT8 LFlags = _GET_CURRQEST_DATATYPE();
2803 UINT8 HFlags = 0;
2804 >>
2805 oneofoptionFlagsField[HFlags, LFlags] ( "\|" oneofoptionFlagsField[HFlags, LFlags] )*
2806 << _PCATCH(gCurrentQuestion->SetFlags(HFlags), LineNum); >>
2807 << _PCATCH(OOOObj.SetFlags(LFlags), LineNum); >>
2808 ;
2809
2810 oneofoptionFlagsField [UINT8 & HFlags, UINT8 & LFlags] :
2811 N:Number << $LFlags |= _STOU8(N->getText()); >>
2812 | "OPTION_DEFAULT" << $LFlags |= 0x10; >>
2813 | "OPTION_DEFAULT_MFG" << $LFlags |= 0x20; >>
2814 | InteractiveFlag << $HFlags |= 0x04; >>
2815 | NVAccessFlag << $HFlags |= 0x08; >>
2816 | ResetRequiredFlag << $HFlags |= 0x10; >>
2817 | LateCheckFlag << $HFlags |= 0x20; >>
2818 | ManufacturingFlag << $LFlags |= 0x20; >>
2819 | DefaultFlag << $LFlags |= 0x10; >>
2820 ;
2821
2822 vfrStatementLabel :
2823 L:Label
2824 N:Number <<
2825 if (mCompatibleMode) {
2826 //
2827 // Add end Label for Framework Vfr
2828 //
2829 CIfrLabel LObj1;
2830 LObj1.SetLineNo(L->getLine());
2831 LObj1.SetNumber (0xffff); //add end label for UEFI, label number hardcode 0xffff
2832 }
2833
2834 {
2835 CIfrLabel LObj2;
2836 LObj2.SetLineNo(L->getLine());
2837 LObj2.SetNumber (_STOU16(N->getText()));
2838 }
2839 >>
2840 ";"
2841 ;
2842
2843 vfrStatementBanner :
2844 << CIfrBanner BObj; >>
2845 B:Banner { "," } << BObj.SetLineNo(B->getLine()); >>
2846 Title "=" "STRING_TOKEN" "\(" S:Number "\)" "," << BObj.SetTitle (_STOSID(S->getText())); >>
2847 (
2848 (
2849 Line L:Number "," << BObj.SetLine (_STOU16(L->getText())); >>
2850 Align
2851 (
2852 Left << BObj.SetAlign (0); >>
2853 | Center << BObj.SetAlign (1); >>
2854 | Right << BObj.SetAlign (2); >>
2855 ) ";"
2856 )
2857 |
2858 (
2859 Timeout "=" T:Number ";" << {CIfrTimeout TObj(_STOU16(T->getText()));} >>
2860 )
2861 )
2862 ;
2863
2864 //******************************************************************************
2865 //
2866 // keep some syntax for compatibility but not generate any IFR object
2867 //
2868 vfrStatementInvalidHidden :
2869 L:Hidden <<
2870 if (!mCompatibleMode) {
2871 _PCATCH (VFR_RETURN_UNSUPPORTED, L);
2872 }
2873 >>
2874 Value "=" Number ","
2875 Key "=" Number ";"
2876 ;
2877
2878 vfrStatementInvalidInconsistentIf :
2879 InconsistentIf
2880 Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" ","
2881 { FLAGS "=" flagsField ( "\|" flagsField )* "," }
2882 vfrStatementExpression[0]
2883 EndIf
2884 ";"
2885 ;
2886
2887 vfrStatementInvalidInventory :
2888 L:Inventory <<
2889 if (!mCompatibleMode) {
2890 _PCATCH (VFR_RETURN_UNSUPPORTED, L);
2891 }
2892 >>
2893 Help "=" "STRING_TOKEN" "\(" Number "\)" ","
2894 Text "=" "STRING_TOKEN" "\(" Number "\)" ","
2895 {
2896 Text "=" "STRING_TOKEN" "\(" Number "\)"
2897 }
2898 ";"
2899 ;
2900
2901 vfrStatementInvalidSaveRestoreDefaults :
2902 (
2903 L:Save <<
2904 if (!mCompatibleMode) {
2905 _PCATCH (VFR_RETURN_UNSUPPORTED, L);
2906 }
2907 >>
2908 |
2909 K:Restore <<
2910 if (!mCompatibleMode) {
2911 _PCATCH (VFR_RETURN_UNSUPPORTED, K);
2912 }
2913 >>
2914 )
2915 Defaults ","
2916 FormId "=" Number ","
2917 Prompt "=" "STRING_TOKEN" "\(" Number "\)" ","
2918 Help "=" "STRING_TOKEN" "\(" Number "\)"
2919 { "," FLAGS "=" flagsField ( "\|" flagsField )* }
2920 { "," Key "=" Number }
2921 ";"
2922 ;
2923
2924 //******************************************************************************
2925 //
2926 // The syntax of expression
2927 //
2928 #token Dup("dup") "dup"
2929 #token VarEqVal("vareqval") "vareqval"
2930 #token Var("var") "var"
2931 #token IdEqVal("ideqval") "ideqval"
2932 #token IdEqId("ideqid") "ideqid"
2933 #token IdEqValList("ideqvallist") "ideqvallist"
2934 #token QuestionRef("questionref") "questionref"
2935 #token RuleRef("ruleref") "ruleref"
2936 #token StringRef("stringref") "stringref"
2937 #token PushThis("pushthis") "pushthis"
2938 #token Security("security") "security"
2939 #token Get("get") "get"
2940 #token True("TRUE") "TRUE"
2941 #token False("FALSE") "FALSE"
2942 #token One("ONE") "ONE"
2943 #token Ones("ONES") "ONES"
2944 #token Zero("ZERO") "ZERO"
2945 #token Undefined("UNDEFINED") "UNDEFINED"
2946 #token Version("VERSION") "VERSION"
2947 #token Length("length") "length"
2948 #token AND("AND") "AND"
2949 #token OR("OR") "OR"
2950 #token NOT("NOT") "NOT"
2951 #token Set("set") "set"
2952 #token BitWiseNot("~") "\~"
2953 #token BoolVal("boolval") "boolval"
2954 #token StringVal("stringval") "stringval"
2955 #token UnIntVal("unintval") "unintval"
2956 #token ToUpper("toupper") "toupper"
2957 #token ToLower("tolower") "tolower"
2958 #token Match("match") "match"
2959 #token Catenate("catenate") "catenate"
2960 #token QuestionRefVal("questionrefval") "questionrefval"
2961 #token StringRefVal("stringrefval") "stringrefval"
2962 #token Map("map") "map"
2963 #token RefreshGuid("refreshguid") "refreshguid"
2964
2965 //
2966 // Root expression extension function called by other function.
2967 //
2968 vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :
2969 << 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 ();} >>
2970 andTerm[$RootLevel, $ExpOpCount]
2971 (
2972 L:OR andTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrOr OObj(L->getLine()); >>
2973 )*
2974 <<
2975 //
2976 // Extend OpCode Scope only for the root expression.
2977 //
2978 if ($ExpOpCount > 1 && $RootLevel == 0) {
2979 if (_SET_SAVED_OPHDR_SCOPE()) {
2980 CIfrEnd EObj;
2981 if (mCIfrOpHdrLineNo[mCIfrOpHdrIndex] != 0) {
2982 EObj.SetLineNo (mCIfrOpHdrLineNo[mCIfrOpHdrIndex]);
2983 }
2984 }
2985 }
2986
2987 if ($RootLevel == 0) {
2988 mCIfrOpHdrIndex --;
2989 }
2990 >>
2991 ;
2992
2993 //
2994 // Add new sub function for the sub expression extension to remember the ExpOpCount
2995 // This funciton is only called by sub expression.
2996 //
2997 vfrStatementExpressionSub [UINT32 RootLevel, UINT32 & ExpOpCount] :
2998 andTerm[$RootLevel, $ExpOpCount]
2999 (
3000 L:OR andTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrOr OObj(L->getLine()); >>
3001 )*
3002 ;
3003
3004 andTerm[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3005 bitwiseorTerm[$RootLevel, $ExpOpCount]
3006 (
3007 L:AND bitwiseorTerm [$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrAnd AObj(L->getLine()); >>
3008 )*
3009 ;
3010
3011 bitwiseorTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3012 bitwiseandTerm[$RootLevel, $ExpOpCount]
3013 (
3014 L:"\|" bitwiseandTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrBitWiseOr BWOObj(L->getLine()); >>
3015 )*
3016 ;
3017
3018 bitwiseandTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3019 equalTerm[$RootLevel, $ExpOpCount]
3020 (
3021 L:"&" equalTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrBitWiseAnd BWAObj(L->getLine()); >>
3022 )*
3023 ;
3024
3025 equalTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3026 compareTerm[$RootLevel, $ExpOpCount]
3027 (
3028 (
3029 L1:"==" compareTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrEqual EObj(L1->getLine()); >>
3030 )
3031 |
3032 (
3033 L2:"!=" compareTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrNotEqual NEObj(L2->getLine()); >>
3034 )
3035 )*
3036 ;
3037
3038 compareTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3039 shiftTerm[$RootLevel, $ExpOpCount]
3040 (
3041 (
3042 L1:"<" shiftTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrLessThan LTObj(L1->getLine()); >>
3043 )
3044 |
3045 (
3046 L2:"<=" shiftTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrLessEqual LEObj(L2->getLine()); >>
3047 )
3048 |
3049 (
3050 L3:">" shiftTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrGreaterThan GTObj(L3->getLine()); >>
3051 )
3052 |
3053 (
3054 L4:">=" shiftTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrGreaterEqual GEObj(L4->getLine()); >>
3055 )
3056 )*
3057 ;
3058
3059 shiftTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3060 addMinusTerm[$RootLevel, $ExpOpCount]
3061 (
3062 (
3063 L1:"\<<" addMinusTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrShiftLeft SLObj(L1->getLine()); >>
3064 )
3065 |
3066 (
3067 L2:"\>>" addMinusTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrShiftRight SRObj(L2->getLine()); >>
3068 )
3069 )*
3070 ;
3071
3072 addMinusTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3073 multdivmodTerm[$RootLevel, $ExpOpCount]
3074 (
3075 (
3076 L1:"\+" multdivmodTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrAdd AObj(L1->getLine()); >>
3077 )
3078 |
3079 (
3080 L2:"\-" multdivmodTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrSubtract SObj(L2->getLine()); >>
3081 )
3082 )*
3083 ;
3084
3085 multdivmodTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3086 castTerm[$RootLevel, $ExpOpCount]
3087 (
3088 (
3089 L1:"\*" castTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrMultiply MObj(L1->getLine()); >>
3090 )
3091 |
3092 (
3093 L2:"/" castTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrDivide DObj(L2->getLine()); >>
3094 )
3095 |
3096 (
3097 L3:"%" castTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrModulo MObj(L3->getLine()); >>
3098 )
3099 )*
3100 ;
3101
3102 castTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3103 << UINT8 CastType = 0xFF; >>
3104 (
3105 L:"\("
3106 (
3107 Boolean << CastType = 0; >>
3108 | Uint64 << CastType = 1; >>
3109 | Uint32 << CastType = 1; >>
3110 | Uint16 << CastType = 1; >>
3111 | Uint8 << CastType = 1; >>
3112 )
3113 "\)"
3114 )*
3115 atomTerm[$RootLevel, $ExpOpCount]
3116 <<
3117 switch (CastType) {
3118 case 0: { CIfrToBoolean TBObj(L->getLine()); $ExpOpCount++; } break;
3119 case 1: { CIfrToUint TUObj(L->getLine()); $ExpOpCount++; } break;
3120 }
3121 >>
3122 ;
3123
3124 atomTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3125 vfrExpressionCatenate[$RootLevel, $ExpOpCount]
3126 | vfrExpressionMatch[$RootLevel, $ExpOpCount]
3127 | vfrExpressionParen[$RootLevel, $ExpOpCount]
3128 | vfrExpressionBuildInFunction[$RootLevel, $ExpOpCount]
3129 | vfrExpressionConstant[$RootLevel, $ExpOpCount]
3130 | vfrExpressionUnaryOp[$RootLevel, $ExpOpCount]
3131 | vfrExpressionTernaryOp[$RootLevel, $ExpOpCount]
3132 | vfrExpressionMap[$RootLevel, $ExpOpCount]
3133 | (
3134 L:NOT
3135 atomTerm[$RootLevel, $ExpOpCount] << { CIfrNot NObj(L->getLine()); $ExpOpCount++; } >>
3136 )
3137 ;
3138
3139 vfrExpressionCatenate [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3140 L:Catenate
3141 "\("
3142 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3143 ","
3144 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3145 "\)" << { CIfrCatenate CObj(L->getLine()); $ExpOpCount++; } >>
3146 ;
3147
3148 vfrExpressionMatch [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3149 L:Match
3150 "\("
3151 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3152 ","
3153 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3154 "\)" << { CIfrMatch MObj(L->getLine()); $ExpOpCount++; } >>
3155 ;
3156
3157 vfrExpressionParen [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3158 "\("
3159 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3160 "\)"
3161 ;
3162
3163 vfrExpressionBuildInFunction [UINT32 & RootLevel, UINT32 & ExpOpCount] :
3164 dupExp[$RootLevel, $ExpOpCount]
3165 | vareqvalExp[$RootLevel, $ExpOpCount] //Compatible for Framework vareqval
3166 | ideqvalExp[$RootLevel, $ExpOpCount]
3167 | ideqidExp[$RootLevel, $ExpOpCount]
3168 | ideqvallistExp[$RootLevel, $ExpOpCount]
3169 | questionref13Exp[$RootLevel, $ExpOpCount]
3170 | rulerefExp[$RootLevel, $ExpOpCount]
3171 | stringref1Exp[$RootLevel, $ExpOpCount]
3172 | pushthisExp[$RootLevel, $ExpOpCount]
3173 | securityExp[$RootLevel, $ExpOpCount]
3174 | getExp[$RootLevel, $ExpOpCount]
3175 ;
3176
3177 dupExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :
3178 L:Dup << { CIfrDup DObj(L->getLine()); _SAVE_OPHDR_COND(DObj, ($ExpOpCount == 0), L->getLine()); $ExpOpCount++; } >>
3179 ;
3180
3181 vareqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :
3182 <<
3183 EFI_QUESTION_ID QId;
3184 UINT32 Mask;
3185 UINT16 ConstVal;
3186 CHAR8 *VarIdStr;
3187 UINT32 LineNo;
3188 EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
3189 EFI_VFR_RETURN_CODE VfrReturnCode = VFR_RETURN_SUCCESS;
3190 >>
3191 L:VarEqVal <<
3192 if (!mCompatibleMode) {
3193 _PCATCH (VFR_RETURN_UNSUPPORTED, L);
3194 }
3195 >>
3196 VK:Var
3197 OpenParen
3198 VN:Number <<
3199 VarIdStr = NULL; _STRCAT(&VarIdStr, VK->getText()); _STRCAT(&VarIdStr, VN->getText());
3200 VfrReturnCode = mCVfrDataStorage.GetVarStoreType (VarIdStr, VarStoreType);
3201 if (VfrReturnCode == VFR_RETURN_UNDEFINED) {
3202 _PCATCH (mCVfrDataStorage.DeclareEfiVarStore (
3203 VarIdStr,
3204 &mFormsetGuid,
3205 _STOSID(VN->getText()),
3206 0x2, //default type is UINT16
3207 FALSE
3208 ), VN);
3209 } else {
3210 _PCATCH (VfrReturnCode, VN);
3211 }
3212 mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, QId, Mask);
3213 LineNo = GET_LINENO(VN);
3214 >>
3215 CloseParen
3216 (
3217 (
3218 "=="
3219 V1:Number << ConstVal = _STOU16(V1->getText()); >>
3220 <<
3221 if (Mask == 0) {
3222 CIfrEqIdVal EIVObj (L->getLine());
3223 _SAVE_OPHDR_COND (EIVObj, ($ExpOpCount == 0), L->getLine());
3224 EIVObj.SetQuestionId (QId, VarIdStr, LineNo);
3225 EIVObj.SetValue (ConstVal);
3226 $ExpOpCount++;
3227 } else {
3228 IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, EQUAL);
3229 }
3230 >>
3231 )
3232 |
3233 (
3234 "<="
3235 V2:Number << ConstVal = _STOU16(V2->getText()); >>
3236 << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, LESS_EQUAL); >>
3237 )
3238 |
3239 (
3240 "<"
3241 V3:Number << ConstVal = _STOU16(V3->getText()); >>
3242 << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, LESS_THAN); >>
3243 )
3244 |
3245 (
3246 ">="
3247 V4:Number << ConstVal = _STOU16(V4->getText()); >>
3248 << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_EQUAL); >>
3249 )
3250 |
3251 (
3252 ">"
3253 V5:Number << ConstVal = _STOU16(V5->getText()); >>
3254 << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_THAN); >>
3255 )
3256 )
3257 ;
3258
3259 ideqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :
3260 <<
3261 EFI_QUESTION_ID QId;
3262 UINT32 Mask;
3263 UINT16 ConstVal;
3264 CHAR8 *VarIdStr;
3265 UINT32 LineNo;
3266 >>
3267 L:IdEqVal
3268 vfrQuestionDataFieldName[QId, Mask, VarIdStr, LineNo]
3269 (
3270 (
3271 "=="
3272 V1:Number << ConstVal = _STOU16(V1->getText()); >>
3273 <<
3274 if (Mask == 0) {
3275 CIfrEqIdVal EIVObj (L->getLine());
3276 _SAVE_OPHDR_COND (EIVObj, ($ExpOpCount == 0), L->getLine());
3277 EIVObj.SetQuestionId (QId, VarIdStr, LineNo);
3278 EIVObj.SetValue (ConstVal);
3279 $ExpOpCount++;
3280 } else {
3281 IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, EQUAL);
3282 }
3283 >>
3284 )
3285 |
3286 (
3287 "<="
3288 V2:Number << ConstVal = _STOU16(V2->getText()); >>
3289 << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, LESS_EQUAL); >>
3290 )
3291 |
3292 (
3293 "<"
3294 V3:Number << ConstVal = _STOU16(V3->getText()); >>
3295 << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, LESS_THAN); >>
3296 )
3297 |
3298 (
3299 ">="
3300 V4:Number << ConstVal = _STOU16(V4->getText()); >>
3301 << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_EQUAL); >>
3302 )
3303 |
3304 (
3305 ">"
3306 V5:Number << ConstVal = _STOU16(V5->getText()); >>
3307 << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_THAN); >>
3308 )
3309 )
3310 ;
3311
3312 ideqidExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3313 <<
3314 EFI_QUESTION_ID QId[2];
3315 UINT32 Mask[2];
3316 CHAR8 *VarIdStr[2];
3317 UINT32 LineNo[2];
3318 >>
3319 L:IdEqId
3320 vfrQuestionDataFieldName[QId[0], Mask[0], VarIdStr[0], LineNo[0]]
3321 (
3322 (
3323 "=="
3324 vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]
3325 <<
3326 if (Mask[0] & Mask[1]) {
3327 IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], EQUAL);
3328 } else {
3329 CIfrEqIdId EIIObj(L->getLine());
3330 _SAVE_OPHDR_COND (EIIObj, ($ExpOpCount == 0), L->getLine());
3331 EIIObj.SetQuestionId1 (QId[0], VarIdStr[0], LineNo[0]);
3332 EIIObj.SetQuestionId2 (QId[1], VarIdStr[1], LineNo[1]);
3333 $ExpOpCount++;
3334 }
3335 >>
3336 )
3337 |
3338 (
3339 "<="
3340 vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]
3341 << IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], LESS_EQUAL); >>
3342 )
3343 |
3344 (
3345 "<"
3346 vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]
3347 << IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], LESS_THAN); >>
3348 )
3349 |
3350 (
3351 ">="
3352 vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]
3353 << IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], GREATER_EQUAL); >>
3354 )
3355 |
3356 (
3357 ">"
3358 vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]
3359 << IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], GREATER_THAN); >>
3360 )
3361 )
3362 ;
3363
3364 ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3365 <<
3366 UINT16 ListLen = 0;
3367 EFI_QUESTION_ID QId;
3368 UINT32 Mask;
3369 UINT16 ValueList[EFI_IFR_MAX_LENGTH] = {0,};
3370 CHAR8 *VarIdStr;
3371 UINT32 LineNo;
3372 >>
3373 L:IdEqValList
3374 vfrQuestionDataFieldName[QId, Mask, VarIdStr, LineNo]
3375 "=="
3376 (
3377 V:Number << ValueList[ListLen] = _STOU16(V->getText()); ListLen++; >>
3378 )+
3379 <<
3380 if (Mask != 0) {
3381 IdEqListDoSpecial ($ExpOpCount, LineNo, QId, VarIdStr, Mask, ListLen, ValueList);
3382 } else {
3383 UINT16 Index;
3384 CIfrEqIdList EILObj(L->getLine());
3385 if (QId != EFI_QUESTION_ID_INVALID) {
3386 EILObj.SetQuestionId (QId, VarIdStr, LineNo);
3387 }
3388 EILObj.SetListLength (ListLen);
3389 for (Index = 0; Index < ListLen; Index++) {
3390 EILObj.SetValueList (Index, ValueList[Index]);
3391 }
3392
3393 EILObj.UpdateIfrBuffer();
3394 _SAVE_OPHDR_COND (EILObj, ($ExpOpCount == 0), L->getLine());
3395
3396 if (QId == EFI_QUESTION_ID_INVALID) {
3397 EILObj.SetQuestionId (QId, VarIdStr, LineNo);
3398 }
3399 $ExpOpCount++;
3400 }
3401 >>
3402 ;
3403
3404 questionref13Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3405 <<
3406 UINT8 Type = 0x1;
3407 EFI_STRING_ID DevPath = EFI_STRING_ID_INVALID;
3408 EFI_GUID Guid = {0,};
3409 EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
3410 UINT32 BitMask;
3411 CHAR8 *QName = NULL;
3412 UINT32 LineNo = 0;
3413 >>
3414 L:QuestionRef
3415 (
3416 (
3417 << Type = 0x3; >>
3418 {
3419 Path "=" "STRING_TOKEN" "\(" S:Number "\)" << Type = 0x4; DevPath = _STOSID(S->getText()); >>
3420 }
3421 {
3422 Uuid "=" guidDefinition[Guid] << Type = 0x5; >>
3423 }
3424 )
3425 |
3426 (
3427 "\("
3428 (
3429 QN:StringIdentifier <<
3430 QName = QN->getText();
3431 LineNo = QN->getLine();
3432 mCVfrQuestionDB.GetQuestionId (QN->getText(), NULL, QId, BitMask);
3433 >>
3434 | ID:Number << QId = _STOQID(ID->getText()); >>
3435 )
3436 "\)"
3437 )
3438 )
3439 <<
3440 switch (Type) {
3441 case 0x1: {CIfrQuestionRef1 QR1Obj(L->getLine()); _SAVE_OPHDR_COND (QR1Obj, ($ExpOpCount == 0), L->getLine()); QR1Obj.SetQuestionId (QId, QName, LineNo); break;}
3442 case 0x3: {CIfrQuestionRef3 QR3Obj(L->getLine()); _SAVE_OPHDR_COND (QR3Obj, ($ExpOpCount == 0), L->getLine()); break;}
3443 case 0x4: {CIfrQuestionRef3_2 QR3_2Obj(L->getLine()); _SAVE_OPHDR_COND (QR3_2Obj, ($ExpOpCount == 0), L->getLine()); QR3_2Obj.SetDevicePath (DevPath); break;}
3444 case 0x5: {CIfrQuestionRef3_3 QR3_3Obj(L->getLine()); _SAVE_OPHDR_COND (QR3_3Obj, ($ExpOpCount == 0), L->getLine()); QR3_3Obj.SetDevicePath (DevPath); QR3_3Obj.SetGuid (&Guid); break;}
3445 }
3446 $ExpOpCount++;
3447 >>
3448 ;
3449
3450 rulerefExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3451 L:RuleRef
3452 "\(" RN:StringIdentifier "\)" << { CIfrRuleRef RRObj(L->getLine()); _SAVE_OPHDR_COND (RRObj, ($ExpOpCount == 0), L->getLine()); RRObj.SetRuleId (mCVfrRulesDB.GetRuleId (RN->getText())); } $ExpOpCount++; >>
3453 ;
3454
3455 //******************************************************
3456 // PARSE:
3457 // stringref (STR_FORM_SET_TITLE)
3458 //
3459 stringref1Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3460 <<
3461 EFI_STRING_ID RefStringId = EFI_STRING_ID_INVALID;
3462 >>
3463 L:StringRef
3464 "\("
3465 (
3466 "STRING_TOKEN"
3467 "\("
3468 S:Number << RefStringId = _STOSID(S->getText()); >>
3469 "\)"
3470 | I:Number << RefStringId = _STOSID(I->getText()); >>
3471 )
3472 "\)" << { CIfrStringRef1 SR1Obj(L->getLine()); _SAVE_OPHDR_COND (SR1Obj, ($ExpOpCount == 0), L->getLine()); SR1Obj.SetStringId (RefStringId); $ExpOpCount++; } >>
3473 ;
3474
3475 pushthisExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3476 L:PushThis << { CIfrThis TObj(L->getLine()); _SAVE_OPHDR_COND (TObj, ($ExpOpCount == 0), L->getLine()); $ExpOpCount++; } >>
3477 ;
3478
3479 securityExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3480 <<
3481 EFI_GUID Guid;
3482 >>
3483 L:Security
3484 "\(" guidDefinition[Guid] "\)" << { CIfrSecurity SObj(L->getLine()); _SAVE_OPHDR_COND (SObj, ($ExpOpCount == 0), L->getLine()); SObj.SetPermissions (&Guid); } $ExpOpCount++; >>
3485 ;
3486
3487 numericVarStoreType [UINT8 & VarType] :
3488 "NUMERIC_SIZE_1" << $VarType = EFI_IFR_NUMERIC_SIZE_1; >>
3489 | "NUMERIC_SIZE_2" << $VarType = EFI_IFR_NUMERIC_SIZE_2; >>
3490 | "NUMERIC_SIZE_4" << $VarType = EFI_IFR_NUMERIC_SIZE_4; >>
3491 | "NUMERIC_SIZE_8" << $VarType = EFI_IFR_NUMERIC_SIZE_8; >>
3492 ;
3493
3494 getExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3495 <<
3496 EFI_VARSTORE_INFO Info;
3497 CHAR8 *VarIdStr = NULL;
3498 EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
3499 UINT32 Mask = 0;
3500 EFI_QUESION_TYPE QType = QUESTION_NORMAL;
3501 UINT8 VarType = EFI_IFR_TYPE_UNDEFINED;
3502 UINT32 VarSize = 0;
3503 Info.mVarStoreId = 0;
3504 >>
3505 L:Get
3506 "\("
3507 vfrStorageVarId[Info, VarIdStr, FALSE]
3508 {"\|" FLAGS "=" numericVarStoreType [VarType] }
3509 "\)" <<
3510 {
3511 if (Info.mVarStoreId == 0) {
3512 // support Date/Time question
3513 mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, QId, Mask, &QType);
3514 if (QId == EFI_QUESTION_ID_INVALID || Mask == 0 || QType == QUESTION_NORMAL) {
3515 _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode can't get the enough varstore information");
3516 }
3517 if (QType == QUESTION_DATE) {
3518 Info.mVarType = EFI_IFR_TYPE_DATE;
3519 } else if (QType == QUESTION_TIME) {
3520 Info.mVarType = EFI_IFR_TYPE_TIME;
3521 }
3522 switch (Mask) {
3523 case DATE_YEAR_BITMASK:
3524 Info.mInfo.mVarOffset = 0;
3525 break;
3526 case DATE_DAY_BITMASK:
3527 Info.mInfo.mVarOffset = 3;
3528 break;
3529 case TIME_HOUR_BITMASK:
3530 Info.mInfo.mVarOffset = 0;
3531 break;
3532 case TIME_MINUTE_BITMASK:
3533 Info.mInfo.mVarOffset = 1;
3534 break;
3535 case TIME_SECOND_BITMASK:
3536 Info.mInfo.mVarOffset = 2;
3537 break;
3538 default:
3539 _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode can't get the enough varstore information");
3540 break;
3541 }
3542 } else {
3543 if ((mCVfrDataStorage.GetVarStoreType(Info.mVarStoreId) == EFI_VFR_VARSTORE_NAME) && (VarType == EFI_IFR_TYPE_UNDEFINED)) {
3544 _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode don't support name string");
3545 }
3546 if (VarType != EFI_IFR_TYPE_UNDEFINED) {
3547 Info.mVarType = VarType;
3548 _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize (Info.mVarType, &VarSize), L->getLine(), "Get/Set opcode can't get var type size");
3549 Info.mVarTotalSize = VarSize;
3550 }
3551 _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize (Info.mVarType, &VarSize), L->getLine(), "Get/Set opcode can't get var type size");
3552 if (VarSize != Info.mVarTotalSize) {
3553 _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode don't support data array");
3554 }
3555 }
3556 CIfrGet GObj(L->getLine());
3557 _SAVE_OPHDR_COND (GObj, ($ExpOpCount == 0), L->getLine());
3558 GObj.SetVarInfo (&Info);
3559 delete VarIdStr;
3560 $ExpOpCount++;
3561 }
3562 >>
3563 ;
3564
3565 vfrExpressionConstant[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3566 L1:True << CIfrTrue TObj(L1->getLine()); _SAVE_OPHDR_COND (TObj, ($ExpOpCount == 0), L1->getLine()); $ExpOpCount++; >>
3567 | L2:False << CIfrFalse FObj(L2->getLine()); _SAVE_OPHDR_COND (FObj, ($ExpOpCount == 0), L2->getLine()); $ExpOpCount++; >>
3568 | L3:One << CIfrOne OObj(L3->getLine()); _SAVE_OPHDR_COND (OObj, ($ExpOpCount == 0), L3->getLine()); $ExpOpCount++; >>
3569 | L4:Ones << CIfrOnes OObj(L4->getLine()); _SAVE_OPHDR_COND (OObj, ($ExpOpCount == 0), L4->getLine()); $ExpOpCount++; >>
3570 | L5:Zero << CIfrZero ZObj(L5->getLine()); _SAVE_OPHDR_COND (ZObj, ($ExpOpCount == 0), L5->getLine()); $ExpOpCount++; >>
3571 | L6:Undefined << CIfrUndefined UObj(L6->getLine()); _SAVE_OPHDR_COND (UObj, ($ExpOpCount == 0), L6->getLine()); $ExpOpCount++; >>
3572 | L7:Version << CIfrVersion VObj(L7->getLine()); _SAVE_OPHDR_COND (VObj, ($ExpOpCount == 0), L7->getLine()); $ExpOpCount++; >>
3573 | V:Number << CIfrUint64 U64Obj(V->getLine()); U64Obj.SetValue (_STOU64(V->getText())); _SAVE_OPHDR_COND (U64Obj, ($ExpOpCount == 0), V->getLine()); $ExpOpCount++; >>
3574 ;
3575
3576 vfrExpressionUnaryOp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3577 lengthExp[$RootLevel, $ExpOpCount]
3578 | bitwisenotExp[$RootLevel, $ExpOpCount]
3579 | question2refExp[$RootLevel, $ExpOpCount]
3580 | stringref2Exp[$RootLevel, $ExpOpCount]
3581 | toboolExp[$RootLevel, $ExpOpCount]
3582 | unintExp[$RootLevel, $ExpOpCount]
3583 | toupperExp[$RootLevel, $ExpOpCount]
3584 | tolwerExp[$RootLevel, $ExpOpCount]
3585 | setExp[$RootLevel, $ExpOpCount]
3586 ;
3587
3588 lengthExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3589 L:Length
3590 "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"
3591 << { CIfrLength LObj(L->getLine()); $ExpOpCount++; } >>
3592 ;
3593
3594 bitwisenotExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3595 L:BitWiseNot
3596 "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"
3597 << { CIfrBitWiseNot BWNObj(L->getLine()); $ExpOpCount++; } >>
3598 ;
3599
3600 question2refExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3601 L:QuestionRefVal
3602 "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"
3603 << { CIfrQuestionRef2 QR2Obj(L->getLine()); $ExpOpCount++; } >>
3604 ;
3605
3606 stringref2Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3607 L:StringRefVal
3608 "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"
3609 << { CIfrStringRef2 SR2Obj(L->getLine()); $ExpOpCount++; } >>
3610 ;
3611
3612 toboolExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3613 L:BoolVal
3614 "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"
3615 << { CIfrToBoolean TBObj(L->getLine()); $ExpOpCount++; } >>
3616 ;
3617
3618 tostringExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3619 << UINT8 Fmt = 0; >>
3620 L:StringVal
3621 {
3622 Format "=" F:Number "," << Fmt = _STOU8(F->getText()); >>
3623 }
3624 "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"
3625 << { CIfrToString TSObj(L->getLine()); TSObj.SetFormat (Fmt); $ExpOpCount++; } >>
3626 ;
3627
3628 unintExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3629 L:UnIntVal
3630 "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"
3631 << { CIfrToUint TUObj(L->getLine()); $ExpOpCount++; } >>
3632 ;
3633
3634 toupperExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3635 L:ToUpper
3636 "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"
3637 << { CIfrToUpper TUObj(L->getLine()); $ExpOpCount++; } >>
3638 ;
3639
3640 tolwerExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3641 L:ToLower
3642 "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"
3643 << { CIfrToLower TLObj(L->getLine()); $ExpOpCount++; } >>
3644 ;
3645
3646 setExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3647 <<
3648 EFI_VARSTORE_INFO Info;
3649 CHAR8 *VarIdStr = NULL;
3650 EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
3651 UINT32 Mask = 0;
3652 EFI_QUESION_TYPE QType = QUESTION_NORMAL;
3653 UINT8 VarType = EFI_IFR_TYPE_UNDEFINED;
3654 UINT32 VarSize = 0;
3655 Info.mVarStoreId = 0;
3656 >>
3657 L:Set
3658 "\("
3659 vfrStorageVarId[Info, VarIdStr, FALSE]
3660 {"\|" FLAG "=" numericVarStoreType [VarType] }
3661 "," vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3662 "\)"
3663 <<
3664 {
3665 if (Info.mVarStoreId == 0) {
3666 // support Date/Time question
3667 mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, QId, Mask, &QType);
3668 if (QId == EFI_QUESTION_ID_INVALID || Mask == 0 || QType == QUESTION_NORMAL) {
3669 _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode can't get the enough varstore information");
3670 }
3671 if (QType == QUESTION_DATE) {
3672 Info.mVarType = EFI_IFR_TYPE_DATE;
3673 } else if (QType == QUESTION_TIME) {
3674 Info.mVarType = EFI_IFR_TYPE_TIME;
3675 }
3676 switch (Mask) {
3677 case DATE_YEAR_BITMASK:
3678 Info.mInfo.mVarOffset = 0;
3679 break;
3680 case DATE_DAY_BITMASK:
3681 Info.mInfo.mVarOffset = 3;
3682 break;
3683 case TIME_HOUR_BITMASK:
3684 Info.mInfo.mVarOffset = 0;
3685 break;
3686 case TIME_MINUTE_BITMASK:
3687 Info.mInfo.mVarOffset = 1;
3688 break;
3689 case TIME_SECOND_BITMASK:
3690 Info.mInfo.mVarOffset = 2;
3691 break;
3692 default:
3693 _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode can't get the enough varstore information");
3694 break;
3695 }
3696 } else {
3697 if ((mCVfrDataStorage.GetVarStoreType(Info.mVarStoreId) == EFI_VFR_VARSTORE_NAME) && (VarType == EFI_IFR_TYPE_UNDEFINED)) {
3698 _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode don't support name string");
3699 }
3700 if (VarType != EFI_IFR_TYPE_UNDEFINED) {
3701 Info.mVarType = VarType;
3702 _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize (Info.mVarType, &VarSize), L->getLine(), "Get/Set opcode can't get var type size");
3703 Info.mVarTotalSize = VarSize;
3704 }
3705 _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize (Info.mVarType, &VarSize), L->getLine(), "Get/Set opcode can't get var type size");
3706 if (VarSize != Info.mVarTotalSize) {
3707 _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode don't support data array");
3708 }
3709 }
3710 CIfrSet TSObj(L->getLine());
3711 TSObj.SetVarInfo (&Info);
3712 delete VarIdStr;
3713 $ExpOpCount++;
3714 }
3715 >>
3716 ;
3717
3718 vfrExpressionTernaryOp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3719 conditionalExp[$RootLevel, $ExpOpCount]
3720 | findExp[$RootLevel, $ExpOpCount]
3721 | midExp[$RootLevel, $ExpOpCount]
3722 | tokenExp[$RootLevel, $ExpOpCount]
3723 | spanExp[$RootLevel, $ExpOpCount]
3724 ;
3725
3726 #token Cond("cond") "cond"
3727 #token Find("find") "find"
3728 #token Mid("mid") "mid"
3729 #token Tok("token") "token"
3730 #token Span("span") "span"
3731
3732 conditionalExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3733 L:Cond "\("
3734 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3735 "?"
3736 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3737 ":"
3738 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3739 "\)" << { CIfrConditional CObj(L->getLine()); $ExpOpCount++; } >>
3740 ;
3741
3742 findExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3743 << UINT8 Format; >>
3744 L:Find "\("
3745 findFormat[Format] ( "\|" findFormat[Format] )*
3746 ","
3747 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3748 ","
3749 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3750 ","
3751 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3752 "\)" << { CIfrFind FObj(L->getLine()); FObj.SetFormat (Format); $ExpOpCount++; } >>
3753 ;
3754
3755 findFormat [UINT8 & Format] :
3756 "SENSITIVE" << $Format = 0x00; >>
3757 | "INSENSITIVE" << $Format = 0x01; >>
3758 ;
3759
3760 midExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3761 L:Mid "\("
3762 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3763 ","
3764 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3765 ","
3766 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3767 "\)" << { CIfrMid MObj(L->getLine()); $ExpOpCount++; } >>
3768 ;
3769
3770 tokenExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3771 L:Tok "\("
3772 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3773 ","
3774 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3775 ","
3776 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3777 "\)" << { CIfrToken TObj(L->getLine()); $ExpOpCount++; } >>
3778 ;
3779
3780 spanExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
3781 << UINT8 Flags = 0; >>
3782 S:Span "\("
3783 FLAGS "=" spanFlags[Flags] ( "\|" spanFlags[Flags] )*
3784 ","
3785 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3786 ","
3787 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3788 ","
3789 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3790 "\)" << { CIfrSpan SObj(S->getLine()); SObj.SetFlags(Flags); $ExpOpCount++; } >>
3791 ;
3792
3793 vfrExpressionMap [UINT32 & RootLevel, UINT32 & ExpOpCount]:
3794 L:Map
3795 "\("
3796 vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
3797 ":" << { CIfrMap MObj(L->getLine()); } >>
3798 (
3799 vfrStatementExpression[0]
3800 ","
3801 vfrStatementExpression[0]
3802 ";"
3803 ) *
3804 E:"\)" << { CIfrEnd EObj; EObj.SetLineNo(E->getLine()); $ExpOpCount++; } >>
3805 ;
3806
3807 spanFlags [UINT8 & Flags] :
3808 N:Number << $Flags |= _STOU8(N->getText()); >>
3809 | "LAST_NON_MATCH" << $Flags |= 0x00; >>
3810 | "FIRST_NON_MATCH" << $Flags |= 0x01; >>
3811 ;
3812
3813 #token StringIdentifier("string identifier") "[A-Za-z_][A-Za-z_0-9]*"
3814 #token Number("numeric value") "(0x[0-9A-Fa-f]+) | [0-9]+"
3815
3816 //******************************************************************************
3817 //
3818 // Parser class definition.
3819 //
3820 class EfiVfrParser {
3821 <<
3822 private:
3823 UINT8 mParserStatus;
3824 BOOLEAN mConstantOnlyInExpression;
3825
3826 CVfrDefaultStore mCVfrDefaultStore;
3827 CVfrDataStorage mCVfrDataStorage;
3828 CVfrQuestionDB mCVfrQuestionDB;
3829 CVfrRulesDB mCVfrRulesDB;
3830
3831 CIfrOpHeader * mCIfrOpHdr[MAX_IFR_EXPRESSION_DEPTH];
3832 UINT32 mCIfrOpHdrLineNo[MAX_IFR_EXPRESSION_DEPTH];
3833 UINT8 mCIfrOpHdrIndex;
3834 VOID _SAVE_OPHDR_COND (IN CIfrOpHeader &, IN BOOLEAN, UINT32 LineNo = 0);
3835 VOID _CLEAR_SAVED_OPHDR (VOID);
3836 BOOLEAN _SET_SAVED_OPHDR_SCOPE (VOID);
3837
3838
3839 EFI_VARSTORE_INFO mCurrQestVarInfo;
3840 EFI_GUID *mOverrideClassGuid;
3841
3842 //
3843 // For framework vfr compatibility
3844 //
3845 BOOLEAN mCompatibleMode;
3846 EFI_GUID mFormsetGuid;
3847
3848 VOID _CRT_OP (IN BOOLEAN);
3849
3850 VOID _SAVE_CURRQEST_VARINFO (IN EFI_VARSTORE_INFO &);
3851 EFI_VARSTORE_INFO & _GET_CURRQEST_VARTINFO (VOID);
3852
3853 UINT8 _GET_CURRQEST_DATATYPE ();
3854 UINT32 _GET_CURRQEST_VARSIZE ();
3855 UINT32 _GET_CURRQEST_ARRAY_SIZE();
3856
3857 public:
3858 VOID _PCATCH (IN INTN, IN INTN, IN ANTLRTokenPtr, IN CONST CHAR8 *);
3859 VOID _PCATCH (IN EFI_VFR_RETURN_CODE);
3860 VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN ANTLRTokenPtr);
3861 VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32);
3862 VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32, IN CONST CHAR8 *);
3863
3864 VOID syn (ANTLRAbstractToken *, ANTLRChar *, SetWordType *, ANTLRTokenType, INT32);
3865
3866 CHAR8* TrimHex (IN CHAR8 *, OUT BOOLEAN *);
3867 CHAR8* _U32TOS (IN UINT32);
3868 UINT8 _STOU8 (IN CHAR8 *);
3869 UINT16 _STOU16 (IN CHAR8 *);
3870 UINT32 _STOU32 (IN CHAR8 *);
3871 UINT64 _STOU64 (IN CHAR8 *);
3872 EFI_HII_DATE _STOD (IN CHAR8 *, IN CHAR8 *, IN CHAR8 *);
3873 EFI_HII_TIME _STOT (IN CHAR8 *, IN CHAR8 *, IN CHAR8 *);
3874 EFI_HII_REF _STOR (IN CHAR8 *, IN CHAR8 *, IN EFI_GUID *, IN CHAR8 *);
3875
3876 EFI_STRING_ID _STOSID (IN CHAR8 *);
3877 EFI_FORM_ID _STOFID (IN CHAR8 *);
3878 EFI_QUESTION_ID _STOQID (IN CHAR8 *);
3879
3880 VOID _STRCAT (IN OUT CHAR8 **, IN CONST CHAR8 *);
3881
3882 VOID _DeclareDefaultLinearVarStore (IN UINT32);
3883 VOID _DeclareStandardDefaultStorage (IN UINT32);
3884 VOID _DeclareDefaultFrameworkVarStore (IN UINT32);
3885
3886 VOID AssignQuestionKey (IN CIfrQuestionHeader &, IN ANTLRTokenPtr);
3887
3888 VOID ConvertIdExpr (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32);
3889 VOID IdEqValDoSpecial (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN UINT16, IN EFI_COMPARE_TYPE);
3890 VOID IdEqIdDoSpecial (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN EFI_COMPARE_TYPE);
3891 VOID IdEqListDoSpecial (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN UINT16, IN UINT16 *);
3892 VOID SetOverrideClassGuid (IN EFI_GUID *);
3893 //
3894 // For framework vfr compatibility
3895 //
3896 VOID SetCompatibleMode (IN BOOLEAN);
3897 >>
3898 }
3899
3900 <<
3901 VOID
3902 EfiVfrParser::_SAVE_OPHDR_COND (
3903 IN CIfrOpHeader &OpHdr,
3904 IN BOOLEAN Cond,
3905 IN UINT32 LineNo
3906 )
3907 {
3908 if (Cond == TRUE) {
3909 if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) {
3910 return ;
3911 }
3912 mCIfrOpHdr[mCIfrOpHdrIndex] = new CIfrOpHeader(OpHdr);
3913 mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = LineNo;
3914 }
3915 }
3916
3917 VOID
3918 EfiVfrParser::_CLEAR_SAVED_OPHDR (
3919 VOID
3920 )
3921 {
3922 mCIfrOpHdr[mCIfrOpHdrIndex] = NULL;
3923 mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0;
3924 }
3925
3926 BOOLEAN
3927 EfiVfrParser::_SET_SAVED_OPHDR_SCOPE (
3928 VOID
3929 )
3930 {
3931 if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) {
3932 mCIfrOpHdr[mCIfrOpHdrIndex]->SetScope (1);
3933 return TRUE;
3934 }
3935
3936 //
3937 // IfrOpHdr is not set, FALSE is return.
3938 //
3939 return FALSE;
3940 }
3941
3942 VOID
3943 EfiVfrParser::_CRT_OP (
3944 IN BOOLEAN Crt
3945 )
3946 {
3947 gCreateOp = Crt;
3948 }
3949
3950 VOID
3951 EfiVfrParser::_SAVE_CURRQEST_VARINFO (
3952 IN EFI_VARSTORE_INFO &Info
3953 )
3954 {
3955 mCurrQestVarInfo = Info;
3956 }
3957
3958 EFI_VARSTORE_INFO &
3959 EfiVfrParser::_GET_CURRQEST_VARTINFO (
3960 VOID
3961 )
3962 {
3963 return mCurrQestVarInfo;
3964 }
3965
3966 UINT32
3967 EfiVfrParser::_GET_CURRQEST_ARRAY_SIZE (
3968 VOID
3969 )
3970 {
3971 UINT8 Size = 1;
3972
3973 switch (mCurrQestVarInfo.mVarType) {
3974 case EFI_IFR_TYPE_NUM_SIZE_8:
3975 Size = 1;
3976 break;
3977
3978 case EFI_IFR_TYPE_NUM_SIZE_16:
3979 Size = 2;
3980 break;
3981
3982 case EFI_IFR_TYPE_NUM_SIZE_32:
3983 Size = 4;
3984 break;
3985
3986 case EFI_IFR_TYPE_NUM_SIZE_64:
3987 Size = 8;
3988 break;
3989
3990 default:
3991 break;
3992 }
3993
3994 return (mCurrQestVarInfo.mVarTotalSize / Size);
3995 }
3996
3997 UINT8
3998 EfiVfrParser::_GET_CURRQEST_DATATYPE (
3999 VOID
4000 )
4001 {
4002 return mCurrQestVarInfo.mVarType;
4003 }
4004
4005 UINT32
4006 EfiVfrParser::_GET_CURRQEST_VARSIZE (
4007 VOID
4008 )
4009 {
4010 return mCurrQestVarInfo.mVarTotalSize;
4011 }
4012
4013 VOID
4014 EfiVfrParser::_PCATCH (
4015 IN INTN ReturnCode,
4016 IN INTN ExpectCode,
4017 IN ANTLRTokenPtr Tok,
4018 IN CONST CHAR8 *ErrorMsg
4019 )
4020 {
4021 if (ReturnCode != ExpectCode) {
4022 mParserStatus++;
4023 gCVfrErrorHandle.PrintMsg (Tok->getLine(), Tok->getText(), "Error", ErrorMsg);
4024 }
4025 }
4026
4027 VOID
4028 EfiVfrParser::_PCATCH (
4029 IN EFI_VFR_RETURN_CODE ReturnCode
4030 )
4031 {
4032 mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode);
4033 }
4034
4035 VOID
4036 EfiVfrParser::_PCATCH (
4037 IN EFI_VFR_RETURN_CODE ReturnCode,
4038 IN ANTLRTokenPtr Tok
4039 )
4040 {
4041 mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode, Tok->getLine(), Tok->getText());
4042 }
4043
4044 VOID
4045 EfiVfrParser::_PCATCH (
4046 IN EFI_VFR_RETURN_CODE ReturnCode,
4047 IN UINT32 LineNum
4048 )
4049 {
4050 mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode, LineNum);
4051 }
4052
4053 VOID
4054 EfiVfrParser::_PCATCH (
4055 IN EFI_VFR_RETURN_CODE ReturnCode,
4056 IN UINT32 LineNum,
4057 IN CONST CHAR8 *ErrorMsg
4058 )
4059 {
4060 mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode, LineNum, (CHAR8 *) ErrorMsg);
4061 }
4062
4063 VOID
4064 EfiVfrParser::syn (
4065 ANTLRAbstractToken *Tok,
4066 ANTLRChar *Egroup,
4067 SetWordType *Eset,
4068 ANTLRTokenType ETok,
4069 INT32 Huh
4070 )
4071 {
4072 gCVfrErrorHandle.HandleError (VFR_RETURN_MISMATCHED, Tok->getLine(), Tok->getText());
4073
4074 mParserStatus += 1;
4075 }
4076
4077 CHAR8 *
4078 EfiVfrParser::TrimHex (
4079 IN CHAR8 *Str,
4080 OUT BOOLEAN *IsHex
4081 )
4082 {
4083 *IsHex = FALSE;
4084
4085 while (*Str && *Str == ' ') {
4086 Str++;
4087 }
4088 while (*Str && *Str == '0') {
4089 Str++;
4090 }
4091 if (*Str && (*Str == 'x' || *Str == 'X')) {
4092 Str++;
4093 *IsHex = TRUE;
4094 }
4095
4096 return Str;
4097 }
4098
4099 CHAR8 *
4100 EfiVfrParser::_U32TOS (
4101 IN UINT32 Value
4102 )
4103 {
4104 CHAR8 *Str;
4105 Str = new CHAR8[20];
4106 sprintf (Str, "%d", Value);
4107 return Str;
4108 }
4109
4110 UINT8
4111 EfiVfrParser::_STOU8 (
4112 IN CHAR8*Str
4113 )
4114 {
4115 BOOLEAN IsHex;
4116 UINT8 Value;
4117 CHAR8 c;
4118
4119 Str = TrimHex (Str, &IsHex);
4120 for (Value = 0; (c = *Str) != '\0'; Str++) {
4121 //
4122 // BUG: does not handle overflow here
4123 //
4124 (IsHex == TRUE) ? (Value <<= 4) : (Value *= 10);
4125
4126 if ((IsHex == TRUE) && (c >= 'a') && (c <= 'f')) {
4127 Value += (c - 'a' + 10);
4128 }
4129 if ((IsHex == TRUE) && (c >= 'A') && (c <= 'F')) {
4130 Value += (c - 'A' + 10);
4131 }
4132 if (c >= '0' && c <= '9') {
4133 Value += (c - '0');
4134 }
4135 }
4136
4137 return Value;
4138 }
4139
4140 UINT16
4141 EfiVfrParser::_STOU16 (
4142 IN CHAR8*Str
4143 )
4144 {
4145 BOOLEAN IsHex;
4146 UINT16 Value;
4147 CHAR8 c;
4148
4149 Str = TrimHex (Str, &IsHex);
4150 for (Value = 0; (c = *Str) != '\0'; Str++) {
4151 //
4152 // BUG: does not handle overflow here
4153 //
4154 (IsHex == TRUE) ? (Value <<= 4) : (Value *= 10);
4155
4156 if ((IsHex == TRUE) && (c >= 'a') && (c <= 'f')) {
4157 Value += (c - 'a' + 10);
4158 }
4159 if ((IsHex == TRUE) && (c >= 'A') && (c <= 'F')) {
4160 Value += (c - 'A' + 10);
4161 }
4162 if (c >= '0' && c <= '9') {
4163 Value += (c - '0');
4164 }
4165 }
4166
4167 return Value;
4168 }
4169
4170 UINT32
4171 EfiVfrParser::_STOU32 (
4172 IN CHAR8*Str
4173 )
4174 {
4175 BOOLEAN IsHex;
4176 UINT32 Value;
4177 CHAR8 c;
4178
4179 Str = TrimHex (Str, &IsHex);
4180 for (Value = 0; (c = *Str) != '\0'; Str++) {
4181 //
4182 // BUG: does not handle overflow here
4183 //
4184 (IsHex == TRUE) ? (Value <<= 4) : (Value *= 10);
4185
4186 if ((IsHex == TRUE) && (c >= 'a') && (c <= 'f')) {
4187 Value += (c - 'a' + 10);
4188 }
4189 if ((IsHex == TRUE) && (c >= 'A') && (c <= 'F')) {
4190 Value += (c - 'A' + 10);
4191 }
4192 if (c >= '0' && c <= '9') {
4193 Value += (c - '0');
4194 }
4195 }
4196
4197 return Value;
4198 }
4199
4200 UINT64
4201 EfiVfrParser::_STOU64 (
4202 IN CHAR8*Str
4203 )
4204 {
4205 BOOLEAN IsHex;
4206 UINT64 Value;
4207 CHAR8 c;
4208
4209 Str = TrimHex (Str, &IsHex);
4210 for (Value = 0; (c = *Str) != '\0'; Str++) {
4211 //
4212 // BUG: does not handle overflow here
4213 //
4214 (IsHex == TRUE) ? (Value <<= 4) : (Value *= 10);
4215
4216 if ((IsHex == TRUE) && (c >= 'a') && (c <= 'f')) {
4217 Value += (c - 'a' + 10);
4218 }
4219 if ((IsHex == TRUE) && (c >= 'A') && (c <= 'F')) {
4220 Value += (c - 'A' + 10);
4221 }
4222 if (c >= '0' && c <= '9') {
4223 Value += (c - '0');
4224 }
4225 }
4226
4227 return Value;
4228 }
4229
4230 EFI_HII_DATE
4231 EfiVfrParser::_STOD (
4232 IN CHAR8 *Year,
4233 IN CHAR8 *Month,
4234 IN CHAR8 *Day
4235 )
4236 {
4237 EFI_HII_DATE Date;
4238
4239 Date.Year = _STOU16 (Year);
4240 Date.Month = _STOU8 (Month);
4241 Date.Day = _STOU8 (Day);
4242
4243 return Date;
4244 }
4245
4246 EFI_HII_TIME
4247 EfiVfrParser::_STOT (
4248 IN CHAR8 *Hour,
4249 IN CHAR8 *Minute,
4250 IN CHAR8 *Second
4251 )
4252 {
4253 EFI_HII_TIME Time;
4254
4255 Time.Hour = _STOU8 (Hour);
4256 Time.Minute = _STOU8 (Minute);
4257 Time.Second = _STOU8 (Second);
4258
4259 return Time;
4260 }
4261
4262 EFI_STRING_ID
4263 EfiVfrParser::_STOSID (
4264 IN CHAR8 *Str
4265 )
4266 {
4267 return (EFI_STRING_ID)_STOU16(Str);
4268 }
4269
4270 EFI_FORM_ID
4271 EfiVfrParser::_STOFID (
4272 IN CHAR8 *Str
4273 )
4274 {
4275 return (EFI_FORM_ID)_STOU16(Str);
4276 }
4277
4278 EFI_QUESTION_ID
4279 EfiVfrParser::_STOQID (
4280 IN CHAR8 *Str
4281 )
4282 {
4283 return (EFI_QUESTION_ID)_STOU16(Str);
4284 }
4285
4286 VOID
4287 EfiVfrParser::_STRCAT (
4288 IN OUT CHAR8 **Dest,
4289 IN CONST CHAR8 *Src
4290 )
4291 {
4292 CHAR8 *NewStr;
4293 UINT32 Len;
4294
4295 if ((Dest == NULL) || (Src == NULL)) {
4296 return;
4297 }
4298
4299 Len = (*Dest == NULL) ? 0 : strlen (*Dest);
4300 Len += strlen (Src);
4301 if ((NewStr = new CHAR8[Len + 1]) == NULL) {
4302 return;
4303 }
4304 NewStr[0] = '\0';
4305 if (*Dest != NULL) {
4306 strcpy (NewStr, *Dest);
4307 delete *Dest;
4308 }
4309 strcat (NewStr, Src);
4310
4311 *Dest = NewStr;
4312 }
4313
4314 EFI_HII_REF
4315 EfiVfrParser::_STOR (
4316 IN CHAR8 *QuestionId,
4317 IN CHAR8 *FormId,
4318 IN EFI_GUID *FormSetGuid,
4319 IN CHAR8 *DevicePath
4320 )
4321 {
4322 EFI_HII_REF Ref;
4323 UINT32 Index;
4324
4325 memcpy (&Ref.FormSetGuid, FormSetGuid, sizeof (EFI_GUID));
4326 Ref.QuestionId = _STOQID (QuestionId);
4327 Ref.FormId = _STOFID (FormId);
4328 Ref.DevicePath = _STOSID (DevicePath);
4329
4330 return Ref;
4331 }
4332
4333 //
4334 // framework vfr to default declare varstore for each structure
4335 //
4336 VOID
4337 EfiVfrParser::_DeclareDefaultFrameworkVarStore (
4338 IN UINT32 LineNo
4339 )
4340 {
4341 SVfrVarStorageNode *pNode;
4342 UINT32 TypeSize;
4343 BOOLEAN FirstNode;
4344 CONST CHAR8 VarName[] = "Setup";
4345
4346 FirstNode = TRUE;
4347 pNode = mCVfrDataStorage.GetBufferVarStoreList();
4348 if (pNode == NULL && gCVfrVarDataTypeDB.mFirstNewDataTypeName != NULL) {
4349 //
4350 // Create the default Buffer Var Store when no VarStore is defined.
4351 // its name should be "Setup"
4352 //
4353 gCVfrVarDataTypeDB.GetDataTypeSize (gCVfrVarDataTypeDB.mFirstNewDataTypeName, &TypeSize);
4354 CIfrVarStore VSObj;
4355 VSObj.SetLineNo (LineNo);
4356 VSObj.SetVarStoreId (0x1); //the first and only one Buffer Var Store
4357 VSObj.SetSize ((UINT16) TypeSize);
4358 //VSObj.SetName (gCVfrVarDataTypeDB.mFirstNewDataTypeName);
4359 VSObj.SetName ((CHAR8 *) VarName);
4360 VSObj.SetGuid (&mFormsetGuid);
4361 #ifdef VFREXP_DEBUG
4362 printf ("Create the default VarStoreName is %s\n", gCVfrVarDataTypeDB.mFirstNewDataTypeName);
4363 #endif
4364 } else {
4365 for (; pNode != NULL; pNode = pNode->mNext) {
4366 //
4367 // create the default varstore opcode for not declared varstore
4368 // the first varstore name should be "Setup"
4369 //
4370 if (!pNode->mAssignedFlag) {
4371 CIfrVarStore VSObj;
4372 VSObj.SetLineNo (LineNo);
4373 VSObj.SetVarStoreId (pNode->mVarStoreId);
4374 VSObj.SetSize ((UINT16) pNode->mStorageInfo.mDataType->mTotalSize);
4375 if (FirstNode) {
4376 VSObj.SetName ((CHAR8 *) VarName);
4377 FirstNode = FALSE;
4378 } else {
4379 VSObj.SetName (pNode->mVarStoreName);
4380 }
4381 VSObj.SetGuid (&pNode->mGuid);
4382 #ifdef VFREXP_DEBUG
4383 printf ("undefined VarStoreName is %s and Id is 0x%x\n", pNode->mVarStoreName, pNode->mVarStoreId);
4384 #endif
4385 }
4386 }
4387 }
4388
4389 pNode = mCVfrDataStorage.GetEfiVarStoreList();
4390 for (; pNode != NULL; pNode = pNode->mNext) {
4391 //
4392 // create the default efi varstore opcode for not exist varstore
4393 //
4394 if (!pNode->mAssignedFlag) {
4395 CIfrVarStoreEfi VSEObj;
4396 VSEObj.SetLineNo (LineNo);
4397 VSEObj.SetAttributes (0x00000002); //hardcode EFI_VARIABLE_BOOTSERVICE_ACCESS attribute
4398 VSEObj.SetGuid (&pNode->mGuid);
4399 VSEObj.SetVarStoreId (pNode->mVarStoreId);
4400 // Generate old efi varstore storage structure for compatiable with old "VarEqVal" opcode,
4401 // which is 3 bytes less than new structure define in UEFI Spec 2.3.1.
4402 VSEObj.SetBinaryLength (sizeof (EFI_IFR_VARSTORE_EFI) - 3);
4403 #ifdef VFREXP_DEBUG
4404 printf ("undefined Efi VarStoreName is %s and Id is 0x%x\n", pNode->mVarStoreName, pNode->mVarStoreId);
4405 #endif
4406 }
4407 }
4408
4409 }
4410
4411 VOID
4412 EfiVfrParser::_DeclareDefaultLinearVarStore (
4413 IN UINT32 LineNo
4414 )
4415 {
4416 UINT32 Index;
4417 CHAR8 **TypeNameList;
4418 UINT32 ListSize;
4419 CONST CHAR8 DateName[] = "Date";
4420 CONST CHAR8 TimeName[] = "Time";
4421 CONST CHAR8 DateType[] = "EFI_HII_DATE";
4422 CONST CHAR8 TimeType[] = "EFI_HII_TIME";
4423
4424 gCVfrVarDataTypeDB.GetUserDefinedTypeNameList (&TypeNameList, &ListSize);
4425
4426 for (Index = 0; Index < ListSize; Index++) {
4427 UINT32 Size;
4428 EFI_VARSTORE_ID VarStoreId;
4429 CIfrVarStore VSObj;
4430
4431 VSObj.SetLineNo (LineNo);
4432 mCVfrDataStorage.DeclareBufferVarStore (
4433 TypeNameList[Index],
4434 &mFormsetGuid,
4435 &gCVfrVarDataTypeDB,
4436 TypeNameList[Index],
4437 EFI_VARSTORE_ID_INVALID
4438 );
4439 mCVfrDataStorage.GetVarStoreId(TypeNameList[Index], &VarStoreId);
4440 VSObj.SetVarStoreId (VarStoreId);
4441 gCVfrVarDataTypeDB.GetDataTypeSize(TypeNameList[Index], &Size);
4442 VSObj.SetSize ((UINT16) Size);
4443 VSObj.SetName (TypeNameList[Index]);
4444 VSObj.SetGuid (&mFormsetGuid);
4445 }
4446
4447 //
4448 // not required to declare Date and Time VarStore,
4449 // because code to support old format Data and Time
4450 //
4451 if (gCVfrVarDataTypeDB.IsTypeNameDefined ((CHAR8 *) DateName) == FALSE) {
4452 UINT32 Size;
4453 EFI_VARSTORE_ID VarStoreId;
4454 CIfrVarStore VSObj;
4455
4456 VSObj.SetLineNo (LineNo);
4457 mCVfrDataStorage.DeclareBufferVarStore (
4458 (CHAR8 *) DateName,
4459 &mFormsetGuid,
4460 &gCVfrVarDataTypeDB,
4461 (CHAR8 *) DateType,
4462 EFI_VARSTORE_ID_INVALID
4463 );
4464 mCVfrDataStorage.GetVarStoreId((CHAR8 *) DateName, &VarStoreId);
4465 VSObj.SetVarStoreId (VarStoreId);
4466 gCVfrVarDataTypeDB.GetDataTypeSize((CHAR8 *) DateType, &Size);
4467 VSObj.SetSize ((UINT16) Size);
4468 VSObj.SetName ((CHAR8 *) DateName);
4469 VSObj.SetGuid (&mFormsetGuid);
4470 }
4471
4472 if (gCVfrVarDataTypeDB.IsTypeNameDefined ((CHAR8 *) TimeName) == FALSE) {
4473 UINT32 Size;
4474 EFI_VARSTORE_ID VarStoreId;
4475 CIfrVarStore VSObj;
4476
4477 VSObj.SetLineNo (LineNo);
4478 mCVfrDataStorage.DeclareBufferVarStore (
4479 (CHAR8 *) TimeName,
4480 &mFormsetGuid,
4481 &gCVfrVarDataTypeDB,
4482 (CHAR8 *) TimeType,
4483 EFI_VARSTORE_ID_INVALID
4484 );
4485 mCVfrDataStorage.GetVarStoreId((CHAR8 *) TimeName, &VarStoreId);
4486 VSObj.SetVarStoreId (VarStoreId);
4487 gCVfrVarDataTypeDB.GetDataTypeSize((CHAR8 *) TimeType, &Size);
4488 VSObj.SetSize ((UINT16) Size);
4489 VSObj.SetName ((CHAR8 *) TimeName);
4490 VSObj.SetGuid (&mFormsetGuid);
4491 }
4492 }
4493
4494 VOID
4495 EfiVfrParser::_DeclareStandardDefaultStorage (
4496 IN UINT32 LineNo
4497 )
4498 {
4499 //
4500 // Default Store is declared.
4501 //
4502 CIfrDefaultStore DSObj;
4503
4504 mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), (CHAR8 *) "Standard Defaults", EFI_STRING_ID_INVALID, EFI_HII_DEFAULT_CLASS_STANDARD);
4505 DSObj.SetLineNo (LineNo);
4506 DSObj.SetDefaultName (EFI_STRING_ID_INVALID);
4507 DSObj.SetDefaultId (EFI_HII_DEFAULT_CLASS_STANDARD);
4508
4509 //
4510 // Default MANUFACTURING Store is declared.
4511 //
4512 CIfrDefaultStore DSObjMF;
4513
4514 mCVfrDefaultStore.RegisterDefaultStore (DSObjMF.GetObjBinAddr(), (CHAR8 *) "Standard ManuFacturing", EFI_STRING_ID_INVALID, EFI_HII_DEFAULT_CLASS_MANUFACTURING);
4515 DSObjMF.SetLineNo (LineNo);
4516 DSObjMF.SetDefaultName (EFI_STRING_ID_INVALID);
4517 DSObjMF.SetDefaultId (EFI_HII_DEFAULT_CLASS_MANUFACTURING);
4518 }
4519
4520 VOID
4521 EfiVfrParser::AssignQuestionKey (
4522 IN CIfrQuestionHeader &QHObj,
4523 IN ANTLRTokenPtr KeyTok
4524 )
4525 {
4526 UINT16 KeyValue;
4527
4528 if (KeyTok == NULL) {
4529 return;
4530 }
4531
4532 KeyValue = _STOU16 (KeyTok->getText());
4533
4534 if (QHObj.FLAGS () & EFI_IFR_FLAG_CALLBACK) {
4535 /*
4536 * if the question is not CALLBACK ignore the key.
4537 */
4538 _PCATCH(mCVfrQuestionDB.UpdateQuestionId (QHObj.QUESTION_ID(), KeyValue), KeyTok);
4539 QHObj.SetQuestionId (KeyValue);
4540 }
4541 }
4542
4543 VOID
4544 EfiVfrParser::ConvertIdExpr (
4545 IN UINT32 &ExpOpCount,
4546 IN UINT32 LineNo,
4547 IN EFI_QUESTION_ID QId,
4548 IN CHAR8 *VarIdStr,
4549 IN UINT32 BitMask
4550 )
4551 {
4552 CIfrQuestionRef1 QR1Obj(LineNo);
4553 QR1Obj.SetQuestionId (QId, VarIdStr, LineNo);
4554 _SAVE_OPHDR_COND (QR1Obj, (ExpOpCount == 0));
4555
4556 if (BitMask != 0) {
4557 CIfrUint32 U32Obj(LineNo);
4558 U32Obj.SetValue (BitMask);
4559
4560 CIfrBitWiseAnd BWAObj(LineNo);
4561
4562 CIfrUint8 U8Obj(LineNo);
4563 switch (BitMask) {
4564 case DATE_YEAR_BITMASK : U8Obj.SetValue (0); break;
4565 case TIME_SECOND_BITMASK : U8Obj.SetValue (0x10); break;
4566 case DATE_DAY_BITMASK : U8Obj.SetValue (0x18); break;
4567 case TIME_HOUR_BITMASK : U8Obj.SetValue (0); break;
4568 case TIME_MINUTE_BITMASK : U8Obj.SetValue (0x8); break;
4569 }
4570
4571 CIfrShiftRight SRObj(LineNo);
4572 }
4573
4574 ExpOpCount += 4;
4575 }
4576
4577 VOID
4578 EfiVfrParser::IdEqValDoSpecial (
4579 IN UINT32 &ExpOpCount,
4580 IN UINT32 LineNo,
4581 IN EFI_QUESTION_ID QId,
4582 IN CHAR8 *VarIdStr,
4583 IN UINT32 BitMask,
4584 IN UINT16 ConstVal,
4585 IN EFI_COMPARE_TYPE CompareType
4586 )
4587 {
4588 ConvertIdExpr (ExpOpCount, LineNo, QId, VarIdStr, BitMask);
4589
4590 if (ConstVal > 0xFF) {
4591 CIfrUint16 U16Obj(LineNo);
4592 U16Obj.SetValue (ConstVal);
4593 } else {
4594 CIfrUint8 U8Obj(LineNo);
4595 U8Obj.SetValue ((UINT8)ConstVal);
4596 }
4597
4598 switch (CompareType) {
4599 case EQUAL :
4600 {
4601 CIfrEqual EObj(LineNo);
4602 break;
4603 }
4604 case LESS_EQUAL :
4605 {
4606 CIfrLessEqual LEObj(LineNo);
4607 break;
4608 }
4609 case LESS_THAN :
4610 {
4611 CIfrLessThan LTObj(LineNo);
4612 break;
4613 }
4614 case GREATER_EQUAL :
4615 {
4616 CIfrGreaterEqual GEObj(LineNo);
4617 break;
4618 }
4619 case GREATER_THAN :
4620 {
4621 CIfrGreaterThan GTObj(LineNo);
4622 break;
4623 }
4624 }
4625
4626 ExpOpCount += 2;
4627 }
4628
4629 VOID
4630 EfiVfrParser::IdEqIdDoSpecial (
4631 IN UINT32 &ExpOpCount,
4632 IN UINT32 LineNo,
4633 IN EFI_QUESTION_ID QId1,
4634 IN CHAR8 *VarId1Str,
4635 IN UINT32 BitMask1,
4636 IN EFI_QUESTION_ID QId2,
4637 IN CHAR8 *VarId2Str,
4638 IN UINT32 BitMask2,
4639 IN EFI_COMPARE_TYPE CompareType
4640 )
4641 {
4642 ConvertIdExpr (ExpOpCount, LineNo, QId1, VarId1Str, BitMask1);
4643 ConvertIdExpr (ExpOpCount, LineNo, QId2, VarId2Str, BitMask2);
4644
4645 switch (CompareType) {
4646 case EQUAL :
4647 {
4648 CIfrEqual EObj(LineNo);
4649 break;
4650 }
4651 case LESS_EQUAL :
4652 {
4653 CIfrLessEqual LEObj(LineNo);
4654 break;
4655 }
4656 case LESS_THAN :
4657 {
4658 CIfrLessThan LTObj(LineNo);
4659 break;
4660 }
4661 case GREATER_EQUAL :
4662 {
4663 CIfrGreaterEqual GEObj(LineNo);
4664 break;
4665 }
4666 case GREATER_THAN :
4667 {
4668 CIfrGreaterThan GTObj(LineNo);
4669 break;
4670 }
4671 }
4672
4673 ExpOpCount++;
4674 }
4675
4676 VOID
4677 EfiVfrParser::IdEqListDoSpecial (
4678 IN UINT32 &ExpOpCount,
4679 IN UINT32 LineNo,
4680 IN EFI_QUESTION_ID QId,
4681 IN CHAR8 *VarIdStr,
4682 IN UINT32 BitMask,
4683 IN UINT16 ListLen,
4684 IN UINT16 *ValueList
4685 )
4686 {
4687 UINT16 Index;
4688
4689 if (ListLen == 0) {
4690 return;
4691 }
4692
4693 IdEqValDoSpecial (ExpOpCount, LineNo, QId, VarIdStr, BitMask, ValueList[0], EQUAL);
4694 for (Index = 1; Index < ListLen; Index++) {
4695 IdEqValDoSpecial (ExpOpCount, LineNo, QId, VarIdStr, BitMask, ValueList[Index], EQUAL);
4696 CIfrOr OObj (LineNo);
4697 ExpOpCount++;
4698 }
4699 }
4700
4701 VOID
4702 EfiVfrParser::SetOverrideClassGuid (IN EFI_GUID *OverrideClassGuid)
4703 {
4704 mOverrideClassGuid = OverrideClassGuid;
4705 }
4706
4707 //
4708 // For framework vfr compatibility
4709 //
4710 VOID
4711 EfiVfrParser::SetCompatibleMode (IN BOOLEAN Mode)
4712 {
4713 mCompatibleMode = Mode;
4714 mCVfrQuestionDB.SetCompatibleMode (Mode);
4715 }
4716 >>