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