]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr
Add the example for default opcode usage.
[mirror_edk2.git] / MdeModulePkg / Universal / DriverSampleDxe / Vfr.vfr
1 ///** @file
2 //
3 // Sample Setup formset.
4 //
5 // Copyright (c) 2004 - 2008, Intel Corporation. <BR>
6 // All rights reserved. This program and the accompanying materials
7 // are licensed and made available under the terms and conditions of the BSD License
8 // which accompanies this distribution. The full text of the license may be found at
9 // http://opensource.org/licenses/bsd-license.php
10 //
11 // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 //
14 //**/
15
16
17 #include "NVDataStruc.h"
18
19 //
20 // Formset class used by Device Manager
21 //
22 #define EFI_NON_DEVICE_CLASS 0x00
23 #define EFI_DISK_DEVICE_CLASS 0x01
24 #define EFI_VIDEO_DEVICE_CLASS 0x02
25 #define EFI_NETWORK_DEVICE_CLASS 0x04
26 #define EFI_INPUT_DEVICE_CLASS 0x08
27 #define EFI_ON_BOARD_DEVICE_CLASS 0x10
28 #define EFI_OTHER_DEVICE_CLASS 0x20
29
30 //
31 // Formset subclass
32 //
33 #define EFI_SETUP_APPLICATION_SUBCLASS 0x00
34 #define EFI_GENERAL_APPLICATION_SUBCLASS 0x01
35 #define EFI_FRONT_PAGE_SUBCLASS 0x02
36 #define EFI_SINGLE_USE_SUBCLASS 0x03
37
38 //
39 // EFI Variable attributes
40 //
41 #define EFI_VARIABLE_NON_VOLATILE 0x00000001
42 #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
43 #define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
44 #define EFI_VARIABLE_READ_ONLY 0x00000008
45
46 //
47 // Labels definition
48 //
49 #define LABEL_1_VALUE 0x01
50 #define LABEL_2_VALUE 0x1000
51 #define LABEL_UPDATE_BBS 0x2222
52
53 formset
54 guid = FORMSET_GUID,
55 title = STRING_TOKEN(STR_FORM_SET_TITLE),
56 help = STRING_TOKEN(STR_FORM_SET_TITLE_HELP),
57 classguid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID,
58
59 //
60 // Notes: VfrCompiler will insert a Standard Default Storage declaration
61 // after the formset declaration. >00000040: 5C 06 00 00 00 00.
62 // So we don't need to declare the Standard Default.
63 // Please check the vfr.lst file for details.
64 // To enable list file for VFR, add "-l" to VfrCompile <Command> in [Build.Visual-Form-Representation-File] as follows:
65 // VfrCompile -l --no-pre-processing --output-directory ${d_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
66 //
67
68 //
69 // Define a Buffer Storage (EFI_IFR_VARSTORE)
70 //
71 varstore DRIVER_SAMPLE_CONFIGURATION, // This is the data structure type
72 varid = CONFIGURATION_VARSTORE_ID, // Optional VarStore ID
73 name = MyIfrNVData, // Define referenced name in vfr
74 guid = FORMSET_GUID; // GUID of this buffer storage
75
76 //
77 // Define another Buffer Storage
78 //
79 varstore MY_DATA2,
80 name = MyIfrNVData2,
81 guid = FORMSET_GUID;
82
83 //
84 // Define a EFI variable Storage (EFI_IFR_VARSTORE_EFI)
85 //
86 efivarstore MyEfiVar, // Define referenced name in vfr
87 attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS, // EFI variable attribures
88 name = STRING_TOKEN(STR_VAR_NAME), // EFI variable name
89 varsize = 1, // Size of the EFI variable
90 guid = FORMSET_GUID; // EFI variable GUID
91
92 defaultstore MyStandardDefault,
93 prompt = STRING_TOKEN(STR_STANDARD_DEFAULT_PROMPT),
94 attribute = 0x0000; // Default ID: 0000 standard default
95
96 defaultstore MyManufactureDefault,
97 prompt = STRING_TOKEN(STR_MANUFACTURE_DEFAULT_PROMPT),
98 attribute = 0x0001; // Default ID: 0001 manufacture default
99
100 //
101 // Define a Form (EFI_IFR_FORM)
102 //
103 form formid = 1, // Form ID
104 title = STRING_TOKEN(STR_FORM1_TITLE); // Form title
105
106 subtitle text = STRING_TOKEN(STR_SUBTITLE_TEXT);
107
108 subtitle text = STRING_TOKEN(STR_SUBTITLE_TEXT2);
109
110 //
111 // Define a display only text (EFI_IFR_TEXT)
112 //
113 text
114 help = STRING_TOKEN(STR_TEXT_HELP), // Help string
115 text = STRING_TOKEN(STR_CPU_STRING), // Prompt string
116 text = STRING_TOKEN(STR_CPU_STRING2); // TextTwo
117
118 //
119 // Define action button (EFI_IFR_ACTION)
120 //
121 text
122 help = STRING_TOKEN(STR_EXIT_TEXT),
123 text = STRING_TOKEN(STR_EXIT_TEXT),
124 text = STRING_TOKEN(STR_EXIT_TEXT),
125 flags = INTERACTIVE, // VfrCompiler will generate opcode EFI_IFR_ACTION for Text marked as INTERACTIVE
126 key = 0x1237;
127
128 text
129 help = STRING_TOKEN(STR_SAVE_TEXT),
130 text = STRING_TOKEN(STR_SAVE_TEXT),
131 text = STRING_TOKEN(STR_SAVE_TEXT),
132 flags = INTERACTIVE,
133 key = 0x1238;
134
135 //
136 // Define oneof (EFI_IFR_ONE_OF)
137 //
138 oneof name = MyOneOf, // Define reference name for Question
139 varid = MyIfrNVData.SuppressGrayOutSomething, // Use "DataStructure.Member" to reference Buffer Storage
140 prompt = STRING_TOKEN(STR_ONE_OF_PROMPT),
141 help = STRING_TOKEN(STR_ONE_OF_HELP),
142 //
143 // Define an option (EFI_IFR_ONE_OF_OPTION)
144 //
145 option text = STRING_TOKEN(STR_ONE_OF_TEXT4), value = 0x0, flags = 0;
146 option text = STRING_TOKEN(STR_ONE_OF_TEXT5), value = 0x1, flags = 0;
147 //
148 // DEFAULT indicate this option will be marked with EFI_IFR_OPTION_DEFAULT
149 //
150 option text = STRING_TOKEN(STR_ONE_OF_TEXT6), value = 0x2, flags = DEFAULT;
151 endoneof;
152
153 oneof varid = MyIfrNVData.BootOrderLarge,
154 prompt = STRING_TOKEN(STR_ONE_OF_PROMPT),
155 help = STRING_TOKEN(STR_ONE_OF_HELP),
156 default value = cond (questionref(MyOneOf) == 0x0 ? 0 : 1),
157 option text = STRING_TOKEN(STR_BOOT_ORDER1), value = 0x0, flags = 0;
158 option text = STRING_TOKEN(STR_BOOT_ORDER2), value = 0x1, flags = DEFAULT;
159 endoneof;
160
161 grayoutif ideqval MyIfrNVData.SuppressGrayOutSomething == 0x1;
162 suppressif questionref(MyOneOf) == 0x0;
163
164 checkbox varid = MyIfrNVData.ChooseToActivateNuclearWeaponry,
165 prompt = STRING_TOKEN(STR_CHECK_BOX_PROMPT),
166 help = STRING_TOKEN(STR_CHECK_BOX_HELP),
167 //
168 // CHECKBOX_DEFAULT indicate this checkbox is marked with EFI_IFR_CHECKBOX_DEFAULT
169 // CHECKBOX_DEFAULT_MFG indicate EFI_IFR_CHECKBOX_DEFAULT_MFG.
170 //
171 flags = CHECKBOX_DEFAULT | CHECKBOX_DEFAULT_MFG,
172 key = 0,
173 default = 1,
174 endcheckbox;
175 endif;
176 endif;
177
178 //
179 // Ordered list:
180 // sizeof(MyIfrNVData) storage must be UINT8 array, and
181 // size written for the variable must be size of the entire
182 // variable.
183 //
184 //
185 suppressif ideqval MyIfrNVData.SuppressGrayOutSomething == 0x0;
186
187 //
188 // label is defined as an anchor where you want to insert some dynamic
189 // opcodes created on-the-fly
190 //
191 label LABEL_UPDATE_BBS;
192
193 orderedlist
194 varid = MyIfrNVData.BootOrder,
195 prompt = STRING_TOKEN(STR_BOOT_OPTIONS),
196 help = STRING_TOKEN(STR_NULL_STRING),
197 option text = STRING_TOKEN(STR_BOOT_OPTION2), value = 2, flags = RESET_REQUIRED;
198 option text = STRING_TOKEN(STR_BOOT_OPTION1), value = 1, flags = RESET_REQUIRED;
199 option text = STRING_TOKEN(STR_BOOT_OPTION3), value = 3, flags = RESET_REQUIRED;
200 suppressif ideqval MyIfrNVData.BootOrderLarge == 0;
201 option text = STRING_TOKEN(STR_BOOT_OPTION4), value = 4, flags = RESET_REQUIRED;
202 endif
203 endlist;
204
205 //
206 // label should be paired with each other
207 //
208 label LABEL_END;
209
210 endif; // end suppressif
211
212 suppressif ideqval MyIfrNVData.SuppressGrayOutSomething == 0x2;
213 orderedlist
214 varid = MyIfrNVData.OrderedList,
215 prompt = STRING_TOKEN(STR_TEST_OPCODE),
216 help = STRING_TOKEN(STR_TEXT_HELP),
217 option text = STRING_TOKEN(STR_ONE_OF_TEXT1), value = 3, flags = RESET_REQUIRED;
218 option text = STRING_TOKEN(STR_ONE_OF_TEXT2), value = 2, flags = RESET_REQUIRED;
219 option text = STRING_TOKEN(STR_ONE_OF_TEXT3), value = 1, flags = RESET_REQUIRED;
220 endlist;
221 endif;
222
223 label 100;
224
225 //
226 // Define a hyperlink (EFI_IFR_REF)
227 //
228 goto 0x1234, // Destination Form ID
229 prompt = STRING_TOKEN(STR_GOTO_DYNAMIC), // Prompt string
230 help = STRING_TOKEN(STR_GOTO_HELP), // Help string
231 flags = INTERACTIVE, // INTERACTIVE indicate it's marked with EFI_IFR_FLAG_CALLBACK
232 key = 0x1234; // Question ID which will be passed-in in COnfigAccess.Callback()
233
234 goto 0x1234,
235 prompt = STRING_TOKEN(STR_GOTO_DYNAMIC2),
236 help = STRING_TOKEN(STR_GOTO_HELP),
237 flags = INTERACTIVE,
238 key = 0x1235;
239
240 oneof varid = MyIfrNVData.TestLateCheck,
241 prompt = STRING_TOKEN(STR_TEST_OPCODE),
242 help = STRING_TOKEN(STR_ONE_OF_HELP),
243 option text = STRING_TOKEN(STR_ONE_OF_TEXT1), value = 0, flags = RESET_REQUIRED;
244 option text = STRING_TOKEN(STR_ONE_OF_TEXT2), value = 1, flags = DEFAULT | RESET_REQUIRED;
245
246 endoneof;
247
248 oneof varid = MyIfrNVData.TestLateCheck2,
249 prompt = STRING_TOKEN(STR_TEST_OPCODE2),
250 help = STRING_TOKEN(STR_ONE_OF_HELP),
251 option text = STRING_TOKEN(STR_ONE_OF_TEXT1), value = 0, flags = DEFAULT | RESET_REQUIRED;
252 option text = STRING_TOKEN(STR_ONE_OF_TEXT2), value = 1, flags = RESET_REQUIRED;
253
254 inconsistentif prompt = STRING_TOKEN(STR_ERROR_POPUP),
255 ideqid MyIfrNVData.TestLateCheck == MyIfrNVData.TestLateCheck2
256 endif
257
258 endoneof;
259
260 oneof varid = MyIfrNVData.QuestionAboutTreeHugging,
261 prompt = STRING_TOKEN(STR_ONE_OF_PROMPT),
262 help = STRING_TOKEN(STR_ONE_OF_HELP),
263 option text = STRING_TOKEN(STR_ONE_OF_TEXT1), value = 0, flags = RESET_REQUIRED;
264 option text = STRING_TOKEN(STR_ONE_OF_TEXT2), value = 1, flags = DEFAULT | RESET_REQUIRED;
265 option text = STRING_TOKEN(STR_ONE_OF_TEXT3), value = 0x03, flags = RESET_REQUIRED;
266
267 endoneof;
268
269 //
270 // Define a string (EFI_IFR_STRING)
271 //
272 string varid = MyIfrNVData.MyStringData,
273 prompt = STRING_TOKEN(STR_MY_STRING_PROMPT2),
274 help = STRING_TOKEN(STR_MY_STRING_HELP2),
275 flags = INTERACTIVE,
276 key = 0x1236,
277 minsize = 6,
278 maxsize = 40,
279 endstring;
280
281 //
282 // Define a numeric (EFI_IFR_NUMERIC)
283 //
284 numeric varid = MyIfrNVData.HowOldAreYouInYearsManual,
285 prompt = STRING_TOKEN(STR_NUMERIC_READONLY_PROMPT),
286 help = STRING_TOKEN(STR_NUMERIC_HELP0),
287 flags = READ_ONLY, // READ_ONLY indicate it's marked with EFI_IFR_FLAG_READ_ONLY
288 minimum = 0,
289 maximum = 0xf0,
290 step = 0, // Stepping of 0 equates to a manual entering
291 // of a value, otherwise it will be adjusted by "+"/"-"
292 default = 21, // defaultstore could be used to specify the default type
293 // If no defaultstore is specified, it implies Standard Default
294
295 endnumeric;
296
297 numeric varid = MyIfrNVData.HowOldAreYouInYearsManual,
298 prompt = STRING_TOKEN(STR_NUMERIC_MANUAL_PROMPT),
299 help = STRING_TOKEN(STR_NUMERIC_HELP0),
300 minimum = 0,
301 maximum = 0xf0,
302 step = 0,
303 default = 21,
304
305 inconsistentif prompt = STRING_TOKEN(STR_ERROR_POPUP),
306 ideqval MyIfrNVData.HowOldAreYouInYearsManual == 99
307 OR
308 ideqid MyIfrNVData.HowOldAreYouInYearsManual == MyEfiVar
309 OR
310 ideqvallist MyIfrNVData.HowOldAreYouInYearsManual == 1 3 5 7
311 endif
312
313 endnumeric;
314
315 numeric varid = MyEfiVar, // Reference of EFI variable storage
316 prompt = STRING_TOKEN(STR_TALL_HEX_PROMPT),
317 help = STRING_TOKEN(STR_NUMERIC_HELP1),
318 flags = DISPLAY_UINT_HEX, // Display in HEX format (if not specified, default is in decimal format)
319 minimum = 0,
320 maximum = 250,
321 default = 175,
322
323 endnumeric;
324
325 label LABEL_1_VALUE;
326 label LABEL_2_VALUE;
327
328 grayoutif ideqval MyIfrNVData.HowOldAreYouInYearsManual == 23 AND ideqval MyIfrNVData.SuppressGrayOutSomething == 0x1;
329 numeric varid = MyIfrNVData.HowOldAreYouInYears,
330 prompt = STRING_TOKEN(STR_NUMERIC_STEP_PROMPT),
331 help = STRING_TOKEN(STR_NUMERIC_HELP2),
332 minimum = 0,
333 maximum = 243,
334 step = 1,
335 default = 18, defaultstore = MyStandardDefault, // This is standard default value
336 default = 19, defaultstore = MyManufactureDefault, // This is manufacture default value
337
338 endnumeric;
339 endif;
340
341 resetbutton
342 defaultstore = MyStandardDefault,
343 prompt = STRING_TOKEN(STR_STANDARD_DEFAULT_PROMPT),
344 help = STRING_TOKEN(STR_STANDARD_DEFAULT_HELP),
345 endresetbutton;
346
347 resetbutton
348 defaultstore = MyManufactureDefault,
349 prompt = STRING_TOKEN(STR_MANUFACTURE_DEFAULT_PROMPT),
350 help = STRING_TOKEN(STR_MANUFACTURE_DEFAULT_HELP),
351 endresetbutton;
352
353 //
354 // Non-interactive password, validate by Setup Browser
355 //
356 password varid = MyIfrNVData.WhatIsThePassword,
357 prompt = STRING_TOKEN(STR_PASSWORD_PROMPT),
358 help = STRING_TOKEN(STR_PASSWORD_HELP),
359 minsize = 6,
360 maxsize = 20,
361 endpassword;
362
363 string varid = MyIfrNVData.PasswordClearText,
364 prompt = STRING_TOKEN(STR_MY_STRING_PROMPT),
365 help = STRING_TOKEN(STR_MY_STRING_HELP),
366 minsize = 6,
367 maxsize = 0x14,
368 endstring;
369
370 //
371 // Interactive password, validate via ConfigAccess.Callback()
372 //
373 password varid = MyIfrNVData.WhatIsThePassword2,
374 prompt = STRING_TOKEN(STR_PASSWORD_CALLBACK_PROMPT),
375 help = STRING_TOKEN(STR_PASSWORD_HELP),
376 flags = INTERACTIVE,
377 key = 0x2000,
378 minsize = 6,
379 maxsize = 20,
380 endpassword;
381
382 goto 2,
383 prompt = STRING_TOKEN(STR_GOTO_FORM2), //SecondSetupPage // this too has no end-op and basically it's a jump to a form ONLY
384 help = STRING_TOKEN(STR_GOTO_HELP);
385
386 goto 3,
387 prompt = STRING_TOKEN(STR_GOTO_FORM3), //ThirdSetupPage // this too has no end-op and basically it's a jump to a form ONLY
388 help = STRING_TOKEN(STR_GOTO_HELP);
389
390 endform;
391
392 form formid = 2, // SecondSetupPage,
393 title = STRING_TOKEN(STR_FORM2_TITLE); // note formid is a variable (for readability) (UINT16) - also added Form to the line to signify the Op-Code
394
395
396 date year varid = Date.Year, // Note that it is a member of NULL, so the RTC will be the system resource to retrieve and save from
397 prompt = STRING_TOKEN(STR_DATE_PROMPT),
398 help = STRING_TOKEN(STR_DATE_HELP),
399 minimum = 1998,
400 maximum = 2099,
401 step = 1,
402 default = 2004,
403
404 month varid = Date.Month, // Note that it is a member of NULL, so the RTC will be the system resource to retrieve and save from
405 prompt = STRING_TOKEN(STR_DATE_PROMPT),
406 help = STRING_TOKEN(STR_DATE_HELP),
407 minimum = 1,
408 maximum = 12,
409 step = 1,
410 default = 1,
411
412 day varid = Date.Day, // Note that it is a member of NULL, so the RTC will be the system resource to retrieve and save from
413 prompt = STRING_TOKEN(STR_DATE_PROMPT),
414 help = STRING_TOKEN(STR_DATE_HELP),
415 minimum = 1,
416 maximum = 31,
417 step = 0x1,
418 default = 1,
419
420 inconsistentif prompt = STRING_TOKEN(STR_ERROR_POPUP),
421 ideqval Date.Day == 31
422 AND
423 ideqvallist Date.Month == 2 4 6 9 11
424 endif
425
426 //
427 // If the day is 30 AND month is 2
428 //
429 inconsistentif prompt = STRING_TOKEN(STR_ERROR_POPUP),
430 ideqval Date.Day == 30
431 AND
432 ideqval Date.Month == 2
433 endif
434
435 //
436 // If the day is 29 AND month is 2 AND it year is NOT a leapyear
437 //
438 inconsistentif prompt = STRING_TOKEN(STR_ERROR_POPUP),
439 ideqval Date.Day == 0x1D
440 AND
441 ideqval Date.Month == 2
442 AND
443 NOT
444 ideqvallist Date.Year == 2004 2008 20012 20016 2020 2024 2028 2032 2036
445 endif
446
447 enddate;
448
449 time hour varid = Time.Hours, // Note that it is a member of NULL, so the RTC will be the system resource to retrieve and save from
450 prompt = STRING_TOKEN(STR_TIME_PROMPT),
451 help = STRING_TOKEN(STR_TIME_HELP),
452 minimum = 0,
453 maximum = 23,
454 step = 1,
455 default = 0,
456
457 minute varid = Time.Minutes, // Note that it is a member of NULL, so the RTC will be the system resource to retrieve and save from
458 prompt = STRING_TOKEN(STR_TIME_PROMPT),
459 help = STRING_TOKEN(STR_TIME_HELP),
460 minimum = 0,
461 maximum = 59,
462 step = 1,
463 default = 0,
464
465 second varid = Time.Seconds, // Note that it is a member of NULL, so the RTC will be the system resource to retrieve and save from
466 prompt = STRING_TOKEN(STR_TIME_PROMPT),
467 help = STRING_TOKEN(STR_TIME_HELP),
468 minimum = 0,
469 maximum = 59,
470 step = 1,
471 default = 0,
472
473 endtime;
474
475 checkbox varid = MyIfrNVData.ChooseToActivateNuclearWeaponry,
476 prompt = STRING_TOKEN(STR_CHECK_BOX_PROMPT),
477 help = STRING_TOKEN(STR_CHECK_BOX_HELP),
478 flags = CHECKBOX_DEFAULT,
479 key = 0,
480 endcheckbox;
481
482 text
483 help = STRING_TOKEN(STR_TEXT_HELP),
484 text = STRING_TOKEN(STR_TEXT_TEXT_1);
485
486 text
487 help = STRING_TOKEN(STR_TEXT_HELP),
488 text = STRING_TOKEN(STR_TEXT_TEXT_1),
489 text = STRING_TOKEN(STR_TEXT_TEXT_2);
490
491 goto 1,
492 prompt = STRING_TOKEN(STR_GOTO_FORM1), //MainSetupPage // this too has no end-op and basically it's a jump to a form ONLY
493 help = STRING_TOKEN(STR_GOTO_HELP);
494
495 endform;
496
497 form formid = 3, title = STRING_TOKEN(STR_FORM3_TITLE); // note formid is a variable (for readability) (UINT16) - also added Form to the line to signify the Op-Code
498
499 suppressif ideqval MyEfiVar == 111;
500 text
501 help = STRING_TOKEN(STR_TEXT_HELP),
502 text = STRING_TOKEN(STR_TEXT_TEXT_1);
503 endif;
504
505 goto 1,
506 prompt = STRING_TOKEN(STR_GOTO_FORM1), //MainSetupPage
507 help = STRING_TOKEN(STR_GOTO_HELP);
508
509 numeric varid = MyIfrNVData.DynamicRefresh,
510 prompt = STRING_TOKEN(STR_NUMERIC_MANUAL_PROMPT),
511 help = STRING_TOKEN(STR_NUMERIC_HELP0),
512 flags = INTERACTIVE,
513 key = 0x5678,
514 minimum = 0,
515 maximum = 0xff,
516 step = 0,
517 default = 0,
518 refresh interval = 3 // Refresh interval in seconds
519 endnumeric;
520
521 label LABEL_UPDATE2;
522 label LABEL_END;
523
524 endform;
525
526 form formid = 4, title = STRING_TOKEN(STR_FORM3_TITLE);
527
528 endform;
529
530 form formid = 0x1234, // Dynamically created page,
531 title = STRING_TOKEN(STR_DYNAMIC_TITLE); // note formid is a variable (for readability) (UINT16) - also added Form to the line to signify the Op-Code
532
533 label LABEL_UPDATE1;
534 //
535 // This is where we will insert dynamic created opcodes
536 //
537 label LABEL_END;
538
539 endform;
540
541 endformset;