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
  1. Update the MyWizardDriver.vfr file
  2. 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,
    
  3. Save MyWizardDriver.vfr
  4. Update the MyWizardDriver.uni file
  5. 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

  1. Open the Visual Studio Command Prompt
  2. Type build
  3. Type build run
  4. At the UEFI Shell prompt,type exit
  5. Now at the setup front page menu, select “Device Manager”
  6. 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)” is 022. Hex is the default because of the VFR field “default = 0x22
  7. Select “Enter ZY Base(Hex)” and then Press “Enter”
  8. Test by typing a “M” character
    Notice that only Numeric characters are allowed and also only values 00 to 0FA 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 "!!"

  9. Press “Enter” again

  10. Test by typing a value of ‘99’ Hex and then Press “Enter”
    Notice that the “Configuration changed” message is displayed.
  11. 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.
  12. Press “Space bar” again to “Enable My XYZ Device” and the“Enter ZY Base(Hex)” is displayed again
  13. Press “F10” to save, then “Escape” to exit
  14. Press “Escape” to exit the “Device Manager”
  15. Select “Continue and then Press "Enter”
  16. At the Shell Prompt, type dmpstore –all
    Notice by modifyingMyWizardDriverNVDataStruc.h our data structure stored in NVRAM is named MWD_IfrNVData of type MYWIZARDDRIVER_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.

End of Lab 7