Lab 7. Updating the Menu: Numeric Entry
In this lab, you’ll learn how to add a numeric entry to your driver menu. This lab uses the VFR term “numeric
” that prompts the user to enter a free-form numeric value. The VFR determines the minimum and maximum values with the terms “minimum
” and “maximum
”. Since there is also an enable/disable switch, the VFR uses the “suppressif
” term to display or hide this field when disabled. Also this field displays as decimal (default) or hexadecimal with the “flags
” switch.
Figure 7 : Menu with Numeric item entry
- Update the MyWizardDriver.vfr file
- Add the following code in the location shown below at approx. Line 90 and before the “
resetbutton
” item:// // Define a numeric free form menu item // suppressif ideqval MWD_IfrNVData.MyWizardDriverChooseToEnable == 0x0; numeric varid = MWD_IfrNVData.MyWizardDriverHexData, prompt = STRING_TOKEN(STR_DATA_HEX_PROMPT), help = STRING_TOKEN(STR_NUMERIC_HELP), flags = DISPLAY_UINT_HEX , // Display in HEX format (if not specified, default is in decimal format) minimum = 0,
- Save MyWizardDriver.vfr
- Update the MyWizardDriver.uni file
- Add the following code to the bottom of the file:
#string STR_DATA_HEX_PROMPT #language en "Enter ZY Base (Hex)"
#string STR_NUMERIC_HELP #language en "This is the help for entering a Base address in Hex. The valid range in this case is from 0 to 250."
6). Save MyWizardDriver.uni
Build and test MyWizardDriver
- Open the Visual Studio Command Prompt
- Type build
- Type build run
- At the UEFI Shell prompt,type exit
- Now at the setup front page menu, select “Device Manager”
- Inside the Device Manager menu press the down arrow to “My Wizard Driver Sample Formset” Press "Enter"
Notice the value for “Enter ZY Base(Hex)” is022
. Hex is the default because of the VFR field “default = 0x22
” - Select “Enter ZY Base(Hex)” and then Press “Enter”
Test by typing a “
M
” character
Notice that only Numeric characters are allowed and also only values00
to0FA
Hex. When values outside the range or non-numeric characters are entered the red “!!” sting is displayed at the bottom of the menu.
The string “!!” is part of the Browser engine :MdeModulePkg\Universal\SetupBrowserDxe\SetupBrowserStr.uni
#string INPUT_ERROR_MESSAGE #language en-US "!!"
Press “Enter” again
- Test by typing a value of ‘
99
’ Hex and then Press “Enter”
Notice that the “Configuration changed” message is displayed. - Test the “
surpressif
” by pressing the “spacebar” to “Enable My XYZ Device” then press the “Space” bar to toggle off or “Disabled”.
Notice the “Select Base Address” and “Name of Configuration” fields are now grayed out and not selectable and the “Enter ZY Base(Hex)” does not appear at all. - Press “Space bar” again to “Enable My XYZ Device” and the“Enter ZY Base(Hex)” is displayed again
- Press “F10” to save, then “Escape” to exit
- Press “Escape” to exit the “Device Manager”
- Select “Continue” and then Press "Enter”
- At the Shell Prompt, type
dmpstore –all
Notice bymodifyingMyWizardDriverNVDataStruc.h
our data structure stored in NVRAM is namedMWD_IfrNVData
of typeMYWIZARDDRIVER_CONFIGURATION
. 17 Type “reset” at the Shell prompt and then Press “Enter” to return to the Visual Studio Command Prompt
For any build issues copy the solution files from C:\Fw\LabSolutions\LessonE.7
NOTE: Del Directory C:\fw\edk2\Build\NT32IA32\DEBUG_VS2010x86\IA32\MyWizardDriver before the Build command to build the MyWizardDriver Clean.