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