Lab 6. Updating the Menu: Creating a String to Name a Saved Configuration

In this lab, you’ll create a string to name a saved configuration that will be stored into the NVRAM variable space. This lab uses the VFR term “string” to prompt the user to enter a string value. The VFR can determine the minimum and maximum number of characters of the string length with the terms “minsize” and “maxsize”. Since there is also an enable/disable switch, the VFR can use the “grayoutif” term again to allow or disallow changes to this field.

Figure 6 : Menu with a string item
  1. Update the MyWizardDriver.vfr file
  2. Add the following code to the location at approx. line 77 and before the “resetbutton” item (as shown below):
    //
    // Define a string (EFI_IFR_STRING) to name the configuration in the 
    // NVRAM variable
    //
    grayoutif  ideqval MWD_IfrNVData.MyWizardDriverChooseToEnable == 0x0;
    string    varid    = MWD_IfrNVData.MyWizardDriverStringData,
              prompt   = STRING_TOKEN(STR_MY_STRING_PROMPT),
              help     = STRING_TOKEN(STR_MY_STRING_HELP),
              minsize  = 3,
              maxsize  = 20,
    endstring;
    endif;
    
  3. Save MyWizardDriver.vfr
  4. Update MyWizardDriver.uni
  5. Add the following code to the bottom of the file:

#string STR_MY_STRING_PROMPT           #language en "Name of Configuration"
#string STR_MY_STRING_HELP             #language en "Enter a name for this configuration. This string can is 3 to 20 characters"


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"
  7. Select “Name of Configuration” then Press “Enter”
    Notice the string text pop up menu gets displayed.
  8. Test the “minsize” by only typing your choice of a two character string. Then Press “Enter”
    Notice the an error message validating that you need to enter at least three or more characters.
  9. Press “Enter” to clear the message
  10. Press “Enter” again to re-enter pop up menu
  11. Test by typing more than “maxsize” of 20 characters** Then Press “Enter” .
    Notice** that the Browser only allows the maximum number of 20 characters to be entered with a forced stop. There is no error message but no more characters are allowed to be typed into the pop up menu.
  12. Press “Enter”
    Notice that the “Configuration changed” message is displayed
  13. Test the grayoutif by selecting “Enable My XYZ Device”
  14. Press the “Spacebar” to toggle off/disable. Then Press the “Spacebar” again to Enable.
    Notice that the “Select Base Address” and “Name of Configruation” fields are now grayed out and not selectable
  15. Press “F10” to save.
  16. Press “Escape” to exit
  17. Press “Escape” to exit the “Device Manager”
  18. Select “Continue” and then Press “Enter”
  19. At the Shell Prompt, type dmpstore -all
    Notice the unicode string “12345678901234567890” (or the 20 character value you typed) is now stored because you entered those characters in the HII form menu. This is because the file WizardDriverNVDataStruc.h has the data structure stored in NVRAM with the GUID define name MWD_IfrNVDataof type MYWIZARDDRIVER_CONFIGURATION. Notice that string data is the first 20 bytes in the data structure MWD_IfrNVData.MyWizardDriverStringData.
  20. Type “reset” and then “Enter" at the Shell prompt to return to the Visual Studio Command Prompt

For any build issues copy the solution files from C:\Fw\LabSolutions\LessonE.6

NOTE: Del Directory C:\fw\edk2\Build\NT32IA32\DEBUG_VS2010x86\IA32\MyWizardDriver before the Build command to build the MyWizardDriver Clean.

End of Lab 6