3 // Sample Setup formset.
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
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.
17 #include "NVDataStruc.h"
20 // Formset class used by Device Manager
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
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
39 // EFI Variable attributes
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
47 // NV data structure definition
58 #define LABEL_1_VALUE 0x01
59 #define LABEL_2_VALUE 0x1000
60 #define LABEL_UPDATE_BBS 0x2222
61 #define LABEL_END 0x2223
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,
71 // Define a Buffer Storage (EFI_IFR_VARSTORE)
73 varstore DRIVER_SAMPLE_CONFIGURATION, // This is the data structure type
74 varid = 0x1234, // Optional VarStore ID
75 name = MyIfrNVData, // Define referenced name in vfr
76 guid = FORMSET_GUID; // GUID of this buffer storage
79 // Define another Buffer Storage
86 // Define a EFI variable Storage (EFI_IFR_VARSTORE_EFI)
88 efivarstore MyEfiVar, // Define referenced name in vfr
89 attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS, // EFI variable attribures
90 name = STRING_TOKEN(STR_VAR_NAME), // EFI variable name
91 varsize = 1, // Size of the EFI variable
92 guid = FORMSET_GUID; // EFI variable GUID
95 // Define a Form (EFI_IFR_FORM)
97 form formid = 1, // Form ID
98 title = STRING_TOKEN(STR_FORM1_TITLE); // Form title
100 subtitle text = STRING_TOKEN(STR_SUBTITLE_TEXT);
102 subtitle text = STRING_TOKEN(STR_SUBTITLE_TEXT2);
105 // Define a display only text (EFI_IFR_TEXT)
108 help = STRING_TOKEN(STR_TEXT_HELP), // Help string
109 text = STRING_TOKEN(STR_CPU_STRING), // Prompt string
110 text = STRING_TOKEN(STR_CPU_STRING2); // TextTwo
113 help = STRING_TOKEN(STR_EXIT_TEXT),
114 text = STRING_TOKEN(STR_EXIT_TEXT),
115 text = STRING_TOKEN(STR_EXIT_TEXT),
120 help = STRING_TOKEN(STR_SAVE_TEXT),
121 text = STRING_TOKEN(STR_SAVE_TEXT),
122 text = STRING_TOKEN(STR_SAVE_TEXT),
127 // Define oneof (EFI_IFR_ONE_OF)
129 oneof varid = MyIfrNVData.SuppressGrayOutSomething, // Use "DataStructure.Member" to reference Buffer Storage
130 prompt = STRING_TOKEN(STR_ONE_OF_PROMPT),
131 help = STRING_TOKEN(STR_ONE_OF_HELP),
133 // Define an option (EFI_IFR_ONE_OF_OPTION)
135 option text = STRING_TOKEN(STR_ONE_OF_TEXT4), value = 0x0, flags = 0;
136 option text = STRING_TOKEN(STR_ONE_OF_TEXT5), value = 0x1, flags = 0;
138 // DEFAULT indicate this option will be marked with EFI_IFR_OPTION_DEFAULT
140 option text = STRING_TOKEN(STR_ONE_OF_TEXT6), value = 0x2, flags = DEFAULT;
143 oneof varid = MyIfrNVData.BootOrderLarge,
144 prompt = STRING_TOKEN(STR_ONE_OF_PROMPT),
145 help = STRING_TOKEN(STR_ONE_OF_HELP),
146 option text = STRING_TOKEN(STR_BOOT_ORDER1), value = 0x0, flags = 0;
147 option text = STRING_TOKEN(STR_BOOT_ORDER2), value = 0x1, flags = DEFAULT;
150 grayoutif ideqval MyIfrNVData.SuppressGrayOutSomething == 0x1;
151 suppressif ideqval MyIfrNVData.SuppressGrayOutSomething == 0x0;
153 checkbox varid = MyIfrNVData.ChooseToActivateNuclearWeaponry,
154 prompt = STRING_TOKEN(STR_CHECK_BOX_PROMPT),
155 help = STRING_TOKEN(STR_CHECK_BOX_HELP),
157 // CHECKBOX_DEFAULT indicate this checkbox is marked with EFI_IFR_CHECKBOX_DEFAULT
159 flags = CHECKBOX_DEFAULT,
168 // sizeof(MyIfrNVData) storage must be UINT8 array, and
169 // size written for the variable must be size of the entire
173 suppressif ideqval MyIfrNVData.SuppressGrayOutSomething == 0x0;
176 // label is defined as an anchor where you want to insert some dynamic
177 // opcodes created on-the-fly
179 label LABEL_UPDATE_BBS;
182 varid = MyIfrNVData.BootOrder,
183 prompt = STRING_TOKEN(STR_BOOT_OPTIONS),
184 help = STRING_TOKEN(STR_NULL_STRING),
185 option text = STRING_TOKEN(STR_BOOT_OPTION2), value = 2, flags = RESET_REQUIRED;
186 option text = STRING_TOKEN(STR_BOOT_OPTION1), value = 1, flags = RESET_REQUIRED;
187 option text = STRING_TOKEN(STR_BOOT_OPTION3), value = 3, flags = RESET_REQUIRED;
188 suppressif ideqval MyIfrNVData.BootOrderLarge == 0;
189 option text = STRING_TOKEN(STR_BOOT_OPTION4), value = 4, flags = 0;
194 // label should be paired with each other
198 endif; // end suppressif
200 suppressif ideqval MyIfrNVData.SuppressGrayOutSomething == 0x2;
202 varid = MyIfrNVData.OrderedList,
203 prompt = STRING_TOKEN(STR_TEST_OPCODE),
204 help = STRING_TOKEN(STR_TEXT_HELP),
205 option text = STRING_TOKEN(STR_ONE_OF_TEXT1), value = 3, flags = RESET_REQUIRED;
206 option text = STRING_TOKEN(STR_ONE_OF_TEXT2), value = 2, flags = RESET_REQUIRED;
207 option text = STRING_TOKEN(STR_ONE_OF_TEXT3), value = 1, flags = RESET_REQUIRED;
214 // Define a hyperlink (EFI_IFR_REF)
216 goto 0x1234, // Destination Form ID
217 prompt = STRING_TOKEN(STR_GOTO_DYNAMIC), // Prompt string
218 help = STRING_TOKEN(STR_GOTO_HELP), // Help string
219 flags = INTERACTIVE, // INTERACTIVE indicate it's marked with EFI_IFR_FLAG_CALLBACK
220 key = 0x1234; // Question ID which will be passed-in in COnfigAccess.Callback()
223 prompt = STRING_TOKEN(STR_GOTO_DYNAMIC2),
224 help = STRING_TOKEN(STR_GOTO_HELP),
228 oneof varid = MyIfrNVData.TestLateCheck,
229 prompt = STRING_TOKEN(STR_TEST_OPCODE),
230 help = STRING_TOKEN(STR_ONE_OF_HELP),
231 option text = STRING_TOKEN(STR_ONE_OF_TEXT1), value = 0, flags = RESET_REQUIRED;
232 option text = STRING_TOKEN(STR_ONE_OF_TEXT2), value = 1, flags = DEFAULT | RESET_REQUIRED;
236 oneof varid = MyIfrNVData.TestLateCheck2,
237 prompt = STRING_TOKEN(STR_TEST_OPCODE2),
238 help = STRING_TOKEN(STR_ONE_OF_HELP),
239 option text = STRING_TOKEN(STR_ONE_OF_TEXT1), value = 0, flags = DEFAULT | RESET_REQUIRED;
240 option text = STRING_TOKEN(STR_ONE_OF_TEXT2), value = 1, flags = RESET_REQUIRED;
242 inconsistentif prompt = STRING_TOKEN(STR_ERROR_POPUP),
243 ideqid MyIfrNVData.TestLateCheck == MyIfrNVData.TestLateCheck2
248 oneof varid = MyIfrNVData.QuestionAboutTreeHugging,
249 prompt = STRING_TOKEN(STR_ONE_OF_PROMPT),
250 help = STRING_TOKEN(STR_ONE_OF_HELP),
251 option text = STRING_TOKEN(STR_ONE_OF_TEXT1), value = 0, flags = RESET_REQUIRED;
252 option text = STRING_TOKEN(STR_ONE_OF_TEXT2), value = 1, flags = DEFAULT | RESET_REQUIRED;
253 option text = STRING_TOKEN(STR_ONE_OF_TEXT3), value = 0x03, flags = RESET_REQUIRED;
258 // Define a string (EFI_IFR_STRING)
260 string varid = MyIfrNVData.MyStringData,
261 prompt = STRING_TOKEN(STR_MY_STRING_PROMPT2),
262 help = STRING_TOKEN(STR_MY_STRING_HELP2),
270 // Define a numeric (EFI_IFR_NUMERIC)
272 numeric varid = MyIfrNVData.HowOldAreYouInYearsManual,
273 prompt = STRING_TOKEN(STR_NUMERIC_READONLY_PROMPT),
274 help = STRING_TOKEN(STR_NUMERIC_HELP0),
275 flags = READ_ONLY, // READ_ONLY indicate it's marked with EFI_IFR_FLAG_READ_ONLY
278 step = 0, // Stepping of 0 equates to a manual entering
279 // of a value, otherwise it will be adjusted by "+"/"-"
284 numeric varid = MyIfrNVData.HowOldAreYouInYearsManual,
285 prompt = STRING_TOKEN(STR_NUMERIC_MANUAL_PROMPT),
286 help = STRING_TOKEN(STR_NUMERIC_HELP0),
292 inconsistentif prompt = STRING_TOKEN(STR_ERROR_POPUP),
293 ideqval MyIfrNVData.HowOldAreYouInYearsManual == 99
295 ideqid MyIfrNVData.HowOldAreYouInYearsManual == MyEfiVar
297 ideqvallist MyIfrNVData.HowOldAreYouInYearsManual == 1 3 5 7
302 numeric varid = MyEfiVar, // Reference of EFI variable storage
303 prompt = STRING_TOKEN(STR_TALL_HEX_PROMPT),
304 help = STRING_TOKEN(STR_NUMERIC_HELP1),
305 flags = DISPLAY_UINT_HEX, // Display in HEX format (if not specified, default is in decimal format)
315 grayoutif ideqval MyIfrNVData.HowOldAreYouInYearsManual == 23 AND ideqval MyIfrNVData.SuppressGrayOutSomething == 0x1;
316 numeric varid = MyIfrNVData.HowOldAreYouInYears,
317 prompt = STRING_TOKEN(STR_NUMERIC_STEP_PROMPT),
318 help = STRING_TOKEN(STR_NUMERIC_HELP2),
328 // Non-interactive password, validate by Setup Browser
330 password varid = MyIfrNVData.WhatIsThePassword,
331 prompt = STRING_TOKEN(STR_PASSWORD_PROMPT),
332 help = STRING_TOKEN(STR_PASSWORD_HELP),
334 maxsize = 20, // new opcode
337 string varid = MyIfrNVData.PasswordClearText,
338 prompt = STRING_TOKEN(STR_MY_STRING_PROMPT),
339 help = STRING_TOKEN(STR_MY_STRING_HELP),
345 // Interactive password, validate via ConfigAccess.Callback()
347 password varid = MyIfrNVData.WhatIsThePassword2,
348 prompt = STRING_TOKEN(STR_PASSWORD_CALLBACK_PROMPT),
349 help = STRING_TOKEN(STR_PASSWORD_HELP),
353 maxsize = 20, // new opcode
357 prompt = STRING_TOKEN(STR_GOTO_FORM2), //SecondSetupPage // this too has no end-op and basically it's a jump to a form ONLY
358 help = STRING_TOKEN(STR_GOTO_HELP);
361 prompt = STRING_TOKEN(STR_GOTO_FORM3), //ThirdSetupPage // this too has no end-op and basically it's a jump to a form ONLY
362 help = STRING_TOKEN(STR_GOTO_HELP);
366 form formid = 2, // SecondSetupPage,
367 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
370 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
371 prompt = STRING_TOKEN(STR_DATE_PROMPT),
372 help = STRING_TOKEN(STR_DATE_YEAR_HELP),
378 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
379 prompt = STRING_TOKEN(STR_DATE_PROMPT),
380 help = STRING_TOKEN(STR_DATE_MONTH_HELP),
386 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
387 prompt = STRING_TOKEN(STR_DATE_PROMPT),
388 help = STRING_TOKEN(STR_DATE_DAY_HELP),
394 inconsistentif prompt = STRING_TOKEN(STR_ERROR_POPUP),
395 ideqval Date.Day == 31
397 ideqvallist Date.Month == 2 4 6 9 11
401 // If the day is 30 AND month is 2
403 inconsistentif prompt = STRING_TOKEN(STR_ERROR_POPUP),
404 ideqval Date.Day == 30
406 ideqval Date.Month == 2
410 // If the day is 29 AND month is 2 AND it year is NOT a leapyear
412 inconsistentif prompt = STRING_TOKEN(STR_ERROR_POPUP),
413 ideqval Date.Day == 0x1D
415 ideqval Date.Month == 2
418 ideqvallist Date.Year == 2004 2008 20012 20016 2020 2024 2028 2032 2036
423 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
424 prompt = STRING_TOKEN(STR_TIME_PROMPT),
425 help = STRING_TOKEN(STR_TIME_HOUR_HELP),
431 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
432 prompt = STRING_TOKEN(STR_TIME_PROMPT),
433 help = STRING_TOKEN(STR_TIME_MINUTE_HELP),
439 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
440 prompt = STRING_TOKEN(STR_TIME_PROMPT),
441 help = STRING_TOKEN(STR_TIME_SECOND_HELP),
449 checkbox varid = MyIfrNVData.ChooseToActivateNuclearWeaponry,
450 prompt = STRING_TOKEN(STR_CHECK_BOX_PROMPT),
451 help = STRING_TOKEN(STR_CHECK_BOX_HELP),
452 flags = CHECKBOX_DEFAULT,
457 help = STRING_TOKEN(STR_TEXT_HELP),
458 text = STRING_TOKEN(STR_TEXT_TEXT_1);
461 help = STRING_TOKEN(STR_TEXT_HELP),
462 text = STRING_TOKEN(STR_TEXT_TEXT_1),
463 text = STRING_TOKEN(STR_TEXT_TEXT_2);
466 prompt = STRING_TOKEN(STR_GOTO_FORM1), //MainSetupPage // this too has no end-op and basically it's a jump to a form ONLY
467 help = STRING_TOKEN(STR_GOTO_HELP);
471 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
473 grayoutif ideqval MyIfrNVData.SuppressGrayOutSomething == 0x1;
475 help = STRING_TOKEN(STR_TEXT_HELP),
476 text = STRING_TOKEN(STR_TEXT_TEXT_1);
481 form formid = 4, title = STRING_TOKEN(STR_FORM3_TITLE);
485 form formid = 0x1234, // Dynamically created page,
486 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
490 // This is where we will insert dynamic created opcodes