]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr
Add in example on
[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 // NV data structure definition
48 //
49 typedef struct {
50 UINT8 Field8;
51 UINT16 Field16;
52 UINT8 OrderedList[3];
53 } MY_DATA2;
54
55 //
56 // Labels definition
57 //
58 #define LABEL_1_VALUE 0x01
59 #define LABEL_2_VALUE 0x1000
60 #define LABEL_UPDATE_BBS 0x2222
61 #define LABEL_END 0x2223
62
63 formset
64 guid = FORMSET_GUID,
65 title = STRING_TOKEN(STR_FORM_SET_TITLE),
66 help = STRING_TOKEN(STR_FORM_SET_TITLE_HELP),
67 class = EFI_ON_BOARD_DEVICE_CLASS,
68 subclass = EFI_SETUP_APPLICATION_SUBCLASS,
69
70 //
71 // Notes: VfrCompiler will insert a Standard Default Storage declaration
72 // after the formset declaration. >00000040: 5C 06 00 00 00 00.
73 // So we don't need to declare the Standard Default.
74 // Please check the vfr.lst file for details.
75 // To enable list file for VFR, add "-l" to VfrCompile <Command> in [Build.Visual-Form-Representation-File] as follows:
76 // VfrCompile -l --no-pre-processing --output-directory ${d_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
77 //
78
79 //
80 // Define a Default Storage for Manufacturing Defauls. Attribut = 1 (EFI_HII_DEFAULT_CLASS_MANUFACTURING).
81 // Only if this Default Storage is defined, CHECKBOX_DEFAULT_MFG can be used for CheckBox.
82 //
83 defaultstore MfgDefault, prompt = STRING_TOKEN (STR_DEFAULTSTORE_MFG), attribute = 1;
84
85 //
86 // Define a Safe Deafult Storage. Attribute = 2 (EFI_HII_DEFAULT_CLASS_SAFE) as an example.
87 // It is not referenced.
88 //
89 defaultstore SafeDefault, prompt = STRING_TOKEN (STR_DEFAULTSTORE_SAFE), attribute = 2;
90
91 //
92 // Define a Buffer Storage (EFI_IFR_VARSTORE)
93 //
94 varstore DRIVER_SAMPLE_CONFIGURATION, // This is the data structure type
95 varid = 0x1234, // Optional VarStore ID
96 name = MyIfrNVData, // Define referenced name in vfr
97 guid = FORMSET_GUID; // GUID of this buffer storage
98
99 //
100 // Define another Buffer Storage
101 //
102 varstore MY_DATA2,
103 name = MyIfrNVData2,
104 guid = FORMSET_GUID;
105
106 //
107 // Define a EFI variable Storage (EFI_IFR_VARSTORE_EFI)
108 //
109 efivarstore MyEfiVar, // Define referenced name in vfr
110 attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS, // EFI variable attribures
111 name = STRING_TOKEN(STR_VAR_NAME), // EFI variable name
112 varsize = 1, // Size of the EFI variable
113 guid = FORMSET_GUID; // EFI variable GUID
114
115 //
116 // Define a Form (EFI_IFR_FORM)
117 //
118 form formid = 1, // Form ID
119 title = STRING_TOKEN(STR_FORM1_TITLE); // Form title
120
121 subtitle text = STRING_TOKEN(STR_SUBTITLE_TEXT);
122
123 subtitle text = STRING_TOKEN(STR_SUBTITLE_TEXT2);
124
125 //
126 // Define a display only text (EFI_IFR_TEXT)
127 //
128 text
129 help = STRING_TOKEN(STR_TEXT_HELP), // Help string
130 text = STRING_TOKEN(STR_CPU_STRING), // Prompt string
131 text = STRING_TOKEN(STR_CPU_STRING2); // TextTwo
132
133 text
134 help = STRING_TOKEN(STR_EXIT_TEXT),
135 text = STRING_TOKEN(STR_EXIT_TEXT),
136 text = STRING_TOKEN(STR_EXIT_TEXT),
137 flags = INTERACTIVE,
138 key = 0x1237;
139
140 text
141 help = STRING_TOKEN(STR_SAVE_TEXT),
142 text = STRING_TOKEN(STR_SAVE_TEXT),
143 text = STRING_TOKEN(STR_SAVE_TEXT),
144 flags = INTERACTIVE,
145 key = 0x1238;
146
147 //
148 // Define oneof (EFI_IFR_ONE_OF)
149 //
150 oneof varid = MyIfrNVData.SuppressGrayOutSomething, // Use "DataStructure.Member" to reference Buffer Storage
151 prompt = STRING_TOKEN(STR_ONE_OF_PROMPT),
152 help = STRING_TOKEN(STR_ONE_OF_HELP),
153 //
154 // Define an option (EFI_IFR_ONE_OF_OPTION)
155 //
156 option text = STRING_TOKEN(STR_ONE_OF_TEXT4), value = 0x0, flags = 0;
157 option text = STRING_TOKEN(STR_ONE_OF_TEXT5), value = 0x1, flags = 0;
158 //
159 // DEFAULT indicate this option will be marked with EFI_IFR_OPTION_DEFAULT
160 //
161 option text = STRING_TOKEN(STR_ONE_OF_TEXT6), value = 0x2, flags = DEFAULT;
162 endoneof;
163
164 oneof varid = MyIfrNVData.BootOrderLarge,
165 prompt = STRING_TOKEN(STR_ONE_OF_PROMPT),
166 help = STRING_TOKEN(STR_ONE_OF_HELP),
167 option text = STRING_TOKEN(STR_BOOT_ORDER1), value = 0x0, flags = 0;
168 option text = STRING_TOKEN(STR_BOOT_ORDER2), value = 0x1, flags = DEFAULT;
169 endoneof;
170
171 grayoutif ideqval MyIfrNVData.SuppressGrayOutSomething == 0x1;
172 suppressif ideqval MyIfrNVData.SuppressGrayOutSomething == 0x0;
173
174 checkbox varid = MyIfrNVData.ChooseToActivateNuclearWeaponry,
175 prompt = STRING_TOKEN(STR_CHECK_BOX_PROMPT),
176 help = STRING_TOKEN(STR_CHECK_BOX_HELP),
177 //
178 // CHECKBOX_DEFAULT indicate this checkbox is marked with EFI_IFR_CHECKBOX_DEFAULT
179 // CHECKBOX_DEFAULT_MFG indicate EFI_IFR_CHECKBOX_DEFAULT_MFG.
180 //
181 flags = CHECKBOX_DEFAULT | CHECKBOX_DEFAULT_MFG,
182 key = 0,
183 default = 1,
184 endcheckbox;
185 endif;
186 endif;
187
188 //
189 // Ordered list:
190 // sizeof(MyIfrNVData) storage must be UINT8 array, and
191 // size written for the variable must be size of the entire
192 // variable.
193 //
194 //
195 suppressif ideqval MyIfrNVData.SuppressGrayOutSomething == 0x0;
196
197 //
198 // label is defined as an anchor where you want to insert some dynamic
199 // opcodes created on-the-fly
200 //
201 label LABEL_UPDATE_BBS;
202
203 orderedlist
204 varid = MyIfrNVData.BootOrder,
205 prompt = STRING_TOKEN(STR_BOOT_OPTIONS),
206 help = STRING_TOKEN(STR_NULL_STRING),
207 option text = STRING_TOKEN(STR_BOOT_OPTION2), value = 2, flags = RESET_REQUIRED;
208 option text = STRING_TOKEN(STR_BOOT_OPTION1), value = 1, flags = RESET_REQUIRED;
209 option text = STRING_TOKEN(STR_BOOT_OPTION3), value = 3, flags = RESET_REQUIRED;
210 suppressif ideqval MyIfrNVData.BootOrderLarge == 0;
211 option text = STRING_TOKEN(STR_BOOT_OPTION4), value = 4, flags = 0;
212 endif
213 endlist;
214
215 //
216 // label should be paired with each other
217 //
218 label LABEL_END;
219
220 endif; // end suppressif
221
222 suppressif ideqval MyIfrNVData.SuppressGrayOutSomething == 0x2;
223 orderedlist
224 varid = MyIfrNVData.OrderedList,
225 prompt = STRING_TOKEN(STR_TEST_OPCODE),
226 help = STRING_TOKEN(STR_TEXT_HELP),
227 option text = STRING_TOKEN(STR_ONE_OF_TEXT1), value = 3, flags = RESET_REQUIRED;
228 option text = STRING_TOKEN(STR_ONE_OF_TEXT2), value = 2, flags = RESET_REQUIRED;
229 option text = STRING_TOKEN(STR_ONE_OF_TEXT3), value = 1, flags = RESET_REQUIRED;
230 endlist;
231 endif;
232
233 label 100;
234
235 //
236 // Define a hyperlink (EFI_IFR_REF)
237 //
238 goto 0x1234, // Destination Form ID
239 prompt = STRING_TOKEN(STR_GOTO_DYNAMIC), // Prompt string
240 help = STRING_TOKEN(STR_GOTO_HELP), // Help string
241 flags = INTERACTIVE, // INTERACTIVE indicate it's marked with EFI_IFR_FLAG_CALLBACK
242 key = 0x1234; // Question ID which will be passed-in in COnfigAccess.Callback()
243
244 goto 0x1234,
245 prompt = STRING_TOKEN(STR_GOTO_DYNAMIC2),
246 help = STRING_TOKEN(STR_GOTO_HELP),
247 flags = INTERACTIVE,
248 key = 0x1235;
249
250 oneof varid = MyIfrNVData.TestLateCheck,
251 prompt = STRING_TOKEN(STR_TEST_OPCODE),
252 help = STRING_TOKEN(STR_ONE_OF_HELP),
253 option text = STRING_TOKEN(STR_ONE_OF_TEXT1), value = 0, flags = RESET_REQUIRED;
254 option text = STRING_TOKEN(STR_ONE_OF_TEXT2), value = 1, flags = DEFAULT | RESET_REQUIRED;
255
256 endoneof;
257
258 oneof varid = MyIfrNVData.TestLateCheck2,
259 prompt = STRING_TOKEN(STR_TEST_OPCODE2),
260 help = STRING_TOKEN(STR_ONE_OF_HELP),
261 option text = STRING_TOKEN(STR_ONE_OF_TEXT1), value = 0, flags = DEFAULT | RESET_REQUIRED;
262 option text = STRING_TOKEN(STR_ONE_OF_TEXT2), value = 1, flags = RESET_REQUIRED;
263
264 inconsistentif prompt = STRING_TOKEN(STR_ERROR_POPUP),
265 ideqid MyIfrNVData.TestLateCheck == MyIfrNVData.TestLateCheck2
266 endif
267
268 endoneof;
269
270 oneof varid = MyIfrNVData.QuestionAboutTreeHugging,
271 prompt = STRING_TOKEN(STR_ONE_OF_PROMPT),
272 help = STRING_TOKEN(STR_ONE_OF_HELP),
273 option text = STRING_TOKEN(STR_ONE_OF_TEXT1), value = 0, flags = RESET_REQUIRED;
274 option text = STRING_TOKEN(STR_ONE_OF_TEXT2), value = 1, flags = DEFAULT | RESET_REQUIRED;
275 option text = STRING_TOKEN(STR_ONE_OF_TEXT3), value = 0x03, flags = RESET_REQUIRED;
276
277 endoneof;
278
279 //
280 // Define a string (EFI_IFR_STRING)
281 //
282 string varid = MyIfrNVData.MyStringData,
283 prompt = STRING_TOKEN(STR_MY_STRING_PROMPT2),
284 help = STRING_TOKEN(STR_MY_STRING_HELP2),
285 flags = INTERACTIVE,
286 key = 0x1236,
287 minsize = 6,
288 maxsize = 20,
289 endstring;
290
291 //
292 // Define a numeric (EFI_IFR_NUMERIC)
293 //
294 numeric varid = MyIfrNVData.HowOldAreYouInYearsManual,
295 prompt = STRING_TOKEN(STR_NUMERIC_READONLY_PROMPT),
296 help = STRING_TOKEN(STR_NUMERIC_HELP0),
297 flags = READ_ONLY, // READ_ONLY indicate it's marked with EFI_IFR_FLAG_READ_ONLY
298 minimum = 0,
299 maximum = 0xf0,
300 step = 0, // Stepping of 0 equates to a manual entering
301 // of a value, otherwise it will be adjusted by "+"/"-"
302 default = 20,
303
304 endnumeric;
305
306 numeric varid = MyIfrNVData.HowOldAreYouInYearsManual,
307 prompt = STRING_TOKEN(STR_NUMERIC_MANUAL_PROMPT),
308 help = STRING_TOKEN(STR_NUMERIC_HELP0),
309 minimum = 0,
310 maximum = 0xf0,
311 step = 0,
312 default = 21,
313
314 inconsistentif prompt = STRING_TOKEN(STR_ERROR_POPUP),
315 ideqval MyIfrNVData.HowOldAreYouInYearsManual == 99
316 OR
317 ideqid MyIfrNVData.HowOldAreYouInYearsManual == MyEfiVar
318 OR
319 ideqvallist MyIfrNVData.HowOldAreYouInYearsManual == 1 3 5 7
320 endif
321
322 endnumeric;
323
324 numeric varid = MyEfiVar, // Reference of EFI variable storage
325 prompt = STRING_TOKEN(STR_TALL_HEX_PROMPT),
326 help = STRING_TOKEN(STR_NUMERIC_HELP1),
327 flags = DISPLAY_UINT_HEX, // Display in HEX format (if not specified, default is in decimal format)
328 minimum = 0,
329 maximum = 250,
330 default = 175,
331
332 endnumeric;
333
334 label LABEL_1_VALUE;
335 label LABEL_2_VALUE;
336
337 grayoutif ideqval MyIfrNVData.HowOldAreYouInYearsManual == 23 AND ideqval MyIfrNVData.SuppressGrayOutSomething == 0x1;
338 numeric varid = MyIfrNVData.HowOldAreYouInYears,
339 prompt = STRING_TOKEN(STR_NUMERIC_STEP_PROMPT),
340 help = STRING_TOKEN(STR_NUMERIC_HELP2),
341 minimum = 0,
342 maximum = 243,
343 step = 1,
344 default = 18,
345
346 endnumeric;
347 endif;
348
349 //
350 // Non-interactive password, validate by Setup Browser
351 //
352 password varid = MyIfrNVData.WhatIsThePassword,
353 prompt = STRING_TOKEN(STR_PASSWORD_PROMPT),
354 help = STRING_TOKEN(STR_PASSWORD_HELP),
355 minsize = 6,
356 maxsize = 20, // new opcode
357 endpassword;
358
359 string varid = MyIfrNVData.PasswordClearText,
360 prompt = STRING_TOKEN(STR_MY_STRING_PROMPT),
361 help = STRING_TOKEN(STR_MY_STRING_HELP),
362 minsize = 6,
363 maxsize = 0x14,
364 endstring;
365
366 //
367 // Interactive password, validate via ConfigAccess.Callback()
368 //
369 password varid = MyIfrNVData.WhatIsThePassword2,
370 prompt = STRING_TOKEN(STR_PASSWORD_CALLBACK_PROMPT),
371 help = STRING_TOKEN(STR_PASSWORD_HELP),
372 flags = INTERACTIVE,
373 key = 0x2000,
374 minsize = 6,
375 maxsize = 20, // new opcode
376 endpassword;
377
378 goto 2,
379 prompt = STRING_TOKEN(STR_GOTO_FORM2), //SecondSetupPage // this too has no end-op and basically it's a jump to a form ONLY
380 help = STRING_TOKEN(STR_GOTO_HELP);
381
382 goto 3,
383 prompt = STRING_TOKEN(STR_GOTO_FORM3), //ThirdSetupPage // 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 endform;
387
388 form formid = 2, // SecondSetupPage,
389 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
390
391
392 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
393 prompt = STRING_TOKEN(STR_DATE_PROMPT),
394 help = STRING_TOKEN(STR_DATE_YEAR_HELP),
395 minimum = 1998,
396 maximum = 2099,
397 step = 1,
398 default = 2004,
399
400 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
401 prompt = STRING_TOKEN(STR_DATE_PROMPT),
402 help = STRING_TOKEN(STR_DATE_MONTH_HELP),
403 minimum = 1,
404 maximum = 12,
405 step = 1,
406 default = 1,
407
408 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
409 prompt = STRING_TOKEN(STR_DATE_PROMPT),
410 help = STRING_TOKEN(STR_DATE_DAY_HELP),
411 minimum = 1,
412 maximum = 31,
413 step = 0x1,
414 default = 1,
415
416 inconsistentif prompt = STRING_TOKEN(STR_ERROR_POPUP),
417 ideqval Date.Day == 31
418 AND
419 ideqvallist Date.Month == 2 4 6 9 11
420 endif
421
422 //
423 // If the day is 30 AND month is 2
424 //
425 inconsistentif prompt = STRING_TOKEN(STR_ERROR_POPUP),
426 ideqval Date.Day == 30
427 AND
428 ideqval Date.Month == 2
429 endif
430
431 //
432 // If the day is 29 AND month is 2 AND it year is NOT a leapyear
433 //
434 inconsistentif prompt = STRING_TOKEN(STR_ERROR_POPUP),
435 ideqval Date.Day == 0x1D
436 AND
437 ideqval Date.Month == 2
438 AND
439 NOT
440 ideqvallist Date.Year == 2004 2008 20012 20016 2020 2024 2028 2032 2036
441 endif
442
443 enddate;
444
445 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
446 prompt = STRING_TOKEN(STR_TIME_PROMPT),
447 help = STRING_TOKEN(STR_TIME_HOUR_HELP),
448 minimum = 0,
449 maximum = 23,
450 step = 1,
451 default = 0,
452
453 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
454 prompt = STRING_TOKEN(STR_TIME_PROMPT),
455 help = STRING_TOKEN(STR_TIME_MINUTE_HELP),
456 minimum = 0,
457 maximum = 59,
458 step = 1,
459 default = 0,
460
461 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
462 prompt = STRING_TOKEN(STR_TIME_PROMPT),
463 help = STRING_TOKEN(STR_TIME_SECOND_HELP),
464 minimum = 0,
465 maximum = 59,
466 step = 1,
467 default = 0,
468
469 endtime;
470
471 checkbox varid = MyIfrNVData.ChooseToActivateNuclearWeaponry,
472 prompt = STRING_TOKEN(STR_CHECK_BOX_PROMPT),
473 help = STRING_TOKEN(STR_CHECK_BOX_HELP),
474 flags = CHECKBOX_DEFAULT,
475 key = 0,
476 endcheckbox;
477
478 text
479 help = STRING_TOKEN(STR_TEXT_HELP),
480 text = STRING_TOKEN(STR_TEXT_TEXT_1);
481
482 text
483 help = STRING_TOKEN(STR_TEXT_HELP),
484 text = STRING_TOKEN(STR_TEXT_TEXT_1),
485 text = STRING_TOKEN(STR_TEXT_TEXT_2);
486
487 goto 1,
488 prompt = STRING_TOKEN(STR_GOTO_FORM1), //MainSetupPage // this too has no end-op and basically it's a jump to a form ONLY
489 help = STRING_TOKEN(STR_GOTO_HELP);
490
491 endform;
492
493 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
494
495 grayoutif ideqval MyIfrNVData.SuppressGrayOutSomething == 0x1;
496 text
497 help = STRING_TOKEN(STR_TEXT_HELP),
498 text = STRING_TOKEN(STR_TEXT_TEXT_1);
499 endif;
500
501 endform;
502
503 form formid = 4, title = STRING_TOKEN(STR_FORM3_TITLE);
504
505 endform;
506
507 form formid = 0x1234, // Dynamically created page,
508 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
509
510 label 0x1234;
511 //
512 // This is where we will insert dynamic created opcodes
513 //
514 label LABEL_END;
515
516 endform;
517
518 endformset;