1. Update the implementation of HII ConfigRouting Protocol in HiiDataBase module to follow new ECRs.
1) ConfigRouting Protocol ExtractConfig interface must return the default values built in IFR that were not returned by ConfigAccess.ExtractConfig. 2) The parameters of ConfigRouting Protocol interfaces are clarified to the specific configuration string syntax. 2. Implement the last two HiiLib interfaces: HiiSetToDefaults and HiiValidateSettings. 3. Update DriverSample driver to use these two APIs. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8313 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
		@@ -285,6 +285,51 @@ HiiConstructConfigHdr (
 | 
				
			|||||||
  IN EFI_HANDLE      DriverHandle
 | 
					  IN EFI_HANDLE      DriverHandle
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					  It has the many same logic to HiiValidateSetting API.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Reset the default value specified by DefaultId to the driver
 | 
				
			||||||
 | 
					  configuration got by Request string. 
 | 
				
			||||||
 | 
					  NULL request string support depends on the ExtractConfig interface of
 | 
				
			||||||
 | 
					  HiiConfigRouting protocol in UEFI specification.
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  @param EFI_STRING  Request    A null-terminated Unicode string in 
 | 
				
			||||||
 | 
					                                <MultiConfigRequest> format. It can be NULL.
 | 
				
			||||||
 | 
					                                If it is NULL, all configuration for the
 | 
				
			||||||
 | 
					                                entirety of the current HII database will be reset.
 | 
				
			||||||
 | 
					  @param UINT16      DefaultId  Specifies the type of defaults to retrieve.
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  @retval TURE    The default value is set successfully.
 | 
				
			||||||
 | 
					  @retval FALSE   The default value can't be found and set.
 | 
				
			||||||
 | 
					**/
 | 
				
			||||||
 | 
					BOOLEAN
 | 
				
			||||||
 | 
					EFIAPI                               
 | 
				
			||||||
 | 
					HiiSetToDefaults (     
 | 
				
			||||||
 | 
					  IN CONST EFI_STRING	Request,  OPTIONAL
 | 
				
			||||||
 | 
					  IN UINT16				    DefaultId
 | 
				
			||||||
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					  Validate the current configuration by parsing HII form IFR opcode.
 | 
				
			||||||
 | 
					  It can share the most logic with HiiSetToDefaults.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  NULL request string support depends on the ExtractConfig interface of
 | 
				
			||||||
 | 
					  HiiConfigRouting protocol in UEFI specification.
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  @param EFI_STRING  Request    A null-terminated Unicode string in 
 | 
				
			||||||
 | 
					                                <MultiConfigRequest> format. It can be NULL.
 | 
				
			||||||
 | 
					                                If it is NULL, all current configuration for the
 | 
				
			||||||
 | 
					                                entirety of the current HII database will be validated.
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  @retval TURE    Current configuration is valid.
 | 
				
			||||||
 | 
					  @retval FALSE   Current configuration is invalid.
 | 
				
			||||||
 | 
					**/
 | 
				
			||||||
 | 
					BOOLEAN
 | 
				
			||||||
 | 
					EFIAPI                               
 | 
				
			||||||
 | 
					HiiValidateSettings (
 | 
				
			||||||
 | 
					  IN CONST EFI_STRING	Request  OPTIONAL
 | 
				
			||||||
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Allocates and returns a Null-terminated Unicode <ConfigAltResp> string.
 | 
					  Allocates and returns a Null-terminated Unicode <ConfigAltResp> string.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -17,13 +17,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <Uefi.h>
 | 
					#include <Uefi.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <Protocol/HiiDatabase.h>
 | 
					 | 
				
			||||||
#include <Protocol/HiiString.h>
 | 
					 | 
				
			||||||
#include <Protocol/DevicePath.h>
 | 
					#include <Protocol/DevicePath.h>
 | 
				
			||||||
#include <Protocol/FormBrowser2.h>
 | 
					#include <Protocol/FormBrowser2.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <Guid/GlobalVariable.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <Library/BaseLib.h>
 | 
					#include <Library/BaseLib.h>
 | 
				
			||||||
#include <Library/BaseMemoryLib.h>
 | 
					#include <Library/BaseMemoryLib.h>
 | 
				
			||||||
#include <Library/HiiLib.h>
 | 
					#include <Library/HiiLib.h>
 | 
				
			||||||
@@ -32,39 +28,7 @@
 | 
				
			|||||||
#include <Library/UefiBootServicesTableLib.h>
 | 
					#include <Library/UefiBootServicesTableLib.h>
 | 
				
			||||||
#include <Library/DevicePathLib.h>
 | 
					#include <Library/DevicePathLib.h>
 | 
				
			||||||
#include <Library/UefiHiiServicesLib.h>
 | 
					#include <Library/UefiHiiServicesLib.h>
 | 
				
			||||||
#include <Library/UefiLib.h>
 | 
					 | 
				
			||||||
#include <Library/PrintLib.h>
 | 
					#include <Library/PrintLib.h>
 | 
				
			||||||
#include <Library/PcdLib.h>
 | 
					#include <Library/UefiLib.h>
 | 
				
			||||||
#include <Library/UefiRuntimeServicesTableLib.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define HII_LIB_DEFAULT_STRING_SIZE     0x200
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
///
 | 
					 | 
				
			||||||
/// The size of a 3 character ISO639 language code.
 | 
					 | 
				
			||||||
///
 | 
					 | 
				
			||||||
#define ISO_639_2_ENTRY_SIZE    3
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern CONST EFI_HII_DATABASE_PROTOCOL         *mHiiDatabaseProt;
 | 
					 | 
				
			||||||
extern CONST EFI_HII_STRING_PROTOCOL           *mHiiStringProt;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
  Extract Hii package list GUID for given HII handle.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  If HiiHandle could not be found in the HII database, then ASSERT.
 | 
					 | 
				
			||||||
  If Guid is NULL, then ASSERT.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  @param  Handle              Hii handle
 | 
					 | 
				
			||||||
  @param  Guid                Package list GUID
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  @retval EFI_SUCCESS            Successfully extract GUID from Hii database.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
**/
 | 
					 | 
				
			||||||
EFI_STATUS
 | 
					 | 
				
			||||||
EFIAPI
 | 
					 | 
				
			||||||
InternalHiiExtractGuidFromHiiHandle (
 | 
					 | 
				
			||||||
  IN      EFI_HII_HANDLE      Handle,
 | 
					 | 
				
			||||||
  OUT     EFI_GUID            *Guid
 | 
					 | 
				
			||||||
  )
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,11 +50,7 @@
 | 
				
			|||||||
  UefiLib
 | 
					  UefiLib
 | 
				
			||||||
  UefiHiiServicesLib
 | 
					  UefiHiiServicesLib
 | 
				
			||||||
  PrintLib
 | 
					  PrintLib
 | 
				
			||||||
  PcdLib
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
[Protocols]
 | 
					[Protocols]
 | 
				
			||||||
  gEfiFormBrowser2ProtocolGuid ## CONSUMES
 | 
					  gEfiFormBrowser2ProtocolGuid ## CONSUMES
 | 
				
			||||||
  gEfiDevicePathProtocolGuid   ## CONSUMES
 | 
					  gEfiDevicePathProtocolGuid   ## CONSUMES
 | 
				
			||||||
 | 
					 | 
				
			||||||
[Pcd]
 | 
					 | 
				
			||||||
  gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -128,6 +128,7 @@ ValidatePassword (
 | 
				
			|||||||
  EFI_STATUS                      Status;
 | 
					  EFI_STATUS                      Status;
 | 
				
			||||||
  UINTN                           Index;
 | 
					  UINTN                           Index;
 | 
				
			||||||
  UINTN                           BufferSize;
 | 
					  UINTN                           BufferSize;
 | 
				
			||||||
 | 
					  UINTN                           PasswordMaxSize;
 | 
				
			||||||
  CHAR16                          *Password;
 | 
					  CHAR16                          *Password;
 | 
				
			||||||
  CHAR16                          *EncodedPassword;
 | 
					  CHAR16                          *EncodedPassword;
 | 
				
			||||||
  BOOLEAN                         OldPassword;
 | 
					  BOOLEAN                         OldPassword;
 | 
				
			||||||
@@ -151,10 +152,11 @@ ValidatePassword (
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  OldPassword = FALSE;
 | 
					  OldPassword = FALSE;
 | 
				
			||||||
 | 
					  PasswordMaxSize = sizeof (PrivateData->Configuration.WhatIsThePassword2);
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  // Check whether we have any old password set
 | 
					  // Check whether we have any old password set
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  for (Index = 0; Index < 20; Index++) {
 | 
					  for (Index = 0; Index < PasswordMaxSize / sizeof (UINT16); Index++) {
 | 
				
			||||||
    if (PrivateData->Configuration.WhatIsThePassword2[Index] != 0) {
 | 
					    if (PrivateData->Configuration.WhatIsThePassword2[Index] != 0) {
 | 
				
			||||||
      OldPassword = TRUE;
 | 
					      OldPassword = TRUE;
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
@@ -174,7 +176,7 @@ ValidatePassword (
 | 
				
			|||||||
  if (Password == NULL) {
 | 
					  if (Password == NULL) {
 | 
				
			||||||
    return EFI_NOT_READY;
 | 
					    return EFI_NOT_READY;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (StrLen (Password) > 20) {
 | 
					  if (StrSize (Password) > PasswordMaxSize) {
 | 
				
			||||||
    FreePool (Password);
 | 
					    FreePool (Password);
 | 
				
			||||||
    return EFI_NOT_READY;
 | 
					    return EFI_NOT_READY;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -182,11 +184,11 @@ ValidatePassword (
 | 
				
			|||||||
  //
 | 
					  //
 | 
				
			||||||
  // Validate old password
 | 
					  // Validate old password
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  EncodedPassword = AllocateZeroPool (21 * sizeof (CHAR16));
 | 
					  EncodedPassword = AllocateZeroPool (PasswordMaxSize);
 | 
				
			||||||
  ASSERT (EncodedPassword != NULL);
 | 
					  ASSERT (EncodedPassword != NULL);
 | 
				
			||||||
  StrnCpy (EncodedPassword, Password, 21);
 | 
					  StrnCpy (EncodedPassword, Password, StrLen (Password));
 | 
				
			||||||
  EncodePassword (EncodedPassword, 20 * sizeof (CHAR16));
 | 
					  EncodePassword (EncodedPassword, StrLen (EncodedPassword) * sizeof (CHAR16));
 | 
				
			||||||
  if (CompareMem (EncodedPassword, PrivateData->Configuration.WhatIsThePassword2, 20 * sizeof (CHAR16)) != 0) {
 | 
					  if (CompareMem (EncodedPassword, PrivateData->Configuration.WhatIsThePassword2, StrLen (EncodedPassword) * sizeof (CHAR16)) != 0) {
 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
    // Old password mismatch, return EFI_NOT_READY to prompt for error message
 | 
					    // Old password mismatch, return EFI_NOT_READY to prompt for error message
 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
@@ -250,11 +252,11 @@ SetPassword (
 | 
				
			|||||||
  if (TempPassword == NULL) {
 | 
					  if (TempPassword == NULL) {
 | 
				
			||||||
    return EFI_NOT_READY;
 | 
					    return EFI_NOT_READY;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (StrLen (TempPassword) > PasswordSize / sizeof (CHAR16)) {
 | 
					  if (StrSize (TempPassword) > PasswordSize) {
 | 
				
			||||||
    FreePool (TempPassword);
 | 
					    FreePool (TempPassword);
 | 
				
			||||||
    return EFI_NOT_READY;
 | 
					    return EFI_NOT_READY;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  StrnCpy (Password, TempPassword, PasswordSize / sizeof (CHAR16));
 | 
					  StrnCpy (Password, TempPassword, StrLen (TempPassword));
 | 
				
			||||||
  FreePool (TempPassword);
 | 
					  FreePool (TempPassword);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
@@ -266,7 +268,7 @@ SetPassword (
 | 
				
			|||||||
    //
 | 
					    //
 | 
				
			||||||
    // Update password's clear text in the screen
 | 
					    // Update password's clear text in the screen
 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
    CopyMem (Configuration->PasswordClearText, Password, PasswordSize);
 | 
					    CopyMem (Configuration->PasswordClearText, Password, StrSize (Password));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
    // Update uncommitted data of Browser
 | 
					    // Update uncommitted data of Browser
 | 
				
			||||||
@@ -289,7 +291,7 @@ SetPassword (
 | 
				
			|||||||
  //
 | 
					  //
 | 
				
			||||||
  // Set password
 | 
					  // Set password
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  EncodePassword (Password, PasswordSize);
 | 
					  EncodePassword (Password, StrLen (Password) * 2);
 | 
				
			||||||
  Status = gRT->SetVariable(
 | 
					  Status = gRT->SetVariable(
 | 
				
			||||||
                  VariableName,
 | 
					                  VariableName,
 | 
				
			||||||
                  &mFormSetGuid,
 | 
					                  &mFormSetGuid,
 | 
				
			||||||
@@ -340,61 +342,65 @@ ExtractConfig (
 | 
				
			|||||||
  UINTN                            BufferSize;
 | 
					  UINTN                            BufferSize;
 | 
				
			||||||
  DRIVER_SAMPLE_PRIVATE_DATA       *PrivateData;
 | 
					  DRIVER_SAMPLE_PRIVATE_DATA       *PrivateData;
 | 
				
			||||||
  EFI_HII_CONFIG_ROUTING_PROTOCOL  *HiiConfigRouting;
 | 
					  EFI_HII_CONFIG_ROUTING_PROTOCOL  *HiiConfigRouting;
 | 
				
			||||||
 | 
					  EFI_STRING                       ConfigRequestHdr;
 | 
				
			||||||
 | 
					  EFI_STRING                       ConfigRequest;
 | 
				
			||||||
 | 
					  UINTN                            Size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  // Initialize the local variables.
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  ConfigRequestHdr = NULL;
 | 
				
			||||||
 | 
					  ConfigRequest    = NULL;
 | 
				
			||||||
 | 
					  Size             = 0;
 | 
				
			||||||
 | 
					  *Progress        = Request;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);
 | 
					  PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);
 | 
				
			||||||
  HiiConfigRouting = PrivateData->HiiConfigRouting;
 | 
					  HiiConfigRouting = PrivateData->HiiConfigRouting;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  //
 | 
					  // Get Buffer Storage data from EFI variable.
 | 
				
			||||||
  // Get Buffer Storage data from EFI variable
 | 
					  // Try to get the current setting from variable.
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);
 | 
					  BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);
 | 
				
			||||||
  Status = gRT->GetVariable (
 | 
					  gRT->GetVariable (
 | 
				
			||||||
        VariableName,
 | 
					        VariableName,
 | 
				
			||||||
        &mFormSetGuid,
 | 
					        &mFormSetGuid,
 | 
				
			||||||
        NULL,
 | 
					        NULL,
 | 
				
			||||||
        &BufferSize,
 | 
					        &BufferSize,
 | 
				
			||||||
        &PrivateData->Configuration
 | 
					        &PrivateData->Configuration
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
  if (EFI_ERROR (Status)) {
 | 
					 | 
				
			||||||
    return Status;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  if (Request == NULL) {
 | 
					  if (Request == NULL) {
 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
    // Request is set to NULL, return all configurable elements together with ALTCFG
 | 
					    // Request is set to NULL, construct full request string.
 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
    *Results = HiiConstructConfigAltResp (
 | 
					 | 
				
			||||||
                 &mFormSetGuid,
 | 
					 | 
				
			||||||
                 VariableName,
 | 
					 | 
				
			||||||
                 PrivateData->DriverHandle[0],
 | 
					 | 
				
			||||||
                 &PrivateData->Configuration,
 | 
					 | 
				
			||||||
                 BufferSize,
 | 
					 | 
				
			||||||
                 VfrMyIfrNVDataBlockName,
 | 
					 | 
				
			||||||
                 STRING_TOKEN (STR_STANDARD_DEFAULT_PROMPT),
 | 
					 | 
				
			||||||
                 VfrMyIfrNVDataDefault0000,
 | 
					 | 
				
			||||||
                 STRING_TOKEN (STR_MANUFACTURE_DEFAULT_PROMPT),
 | 
					 | 
				
			||||||
                 VfrMyIfrNVDataDefault0001,
 | 
					 | 
				
			||||||
                 0,
 | 
					 | 
				
			||||||
                 NULL
 | 
					 | 
				
			||||||
               );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
    // No matched storage is found.
 | 
					    // First Set ConfigRequestHdr string.
 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
    if (*Results == NULL) {
 | 
					    ConfigRequestHdr = HiiConstructConfigHdr (&mFormSetGuid, VariableName, PrivateData->DriverHandle[0]);
 | 
				
			||||||
      return EFI_NOT_FOUND;
 | 
					    ASSERT (ConfigRequestHdr != NULL);
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return EFI_SUCCESS;
 | 
					    //
 | 
				
			||||||
 | 
					    // Allocate and fill a buffer large enough to hold the <ConfigHdr> template 
 | 
				
			||||||
 | 
					    // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
 | 
				
			||||||
 | 
					    ConfigRequest = AllocateZeroPool (Size);
 | 
				
			||||||
 | 
					    UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
 | 
				
			||||||
 | 
					    FreePool (ConfigRequestHdr);
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    ConfigRequest = Request;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  // Check routing data in <ConfigHdr>.
 | 
					  // Check routing data in <ConfigHdr>.
 | 
				
			||||||
  // Note: if only one Storage is used, then this checking could be skipped.
 | 
					  // Note: if only one Storage is used, then this checking could be skipped.
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  if (!HiiIsConfigHdrMatch (Request, &mFormSetGuid, VariableName)) {
 | 
					  if (!HiiIsConfigHdrMatch (ConfigRequest, &mFormSetGuid, VariableName)) {
 | 
				
			||||||
    *Progress = Request;
 | 
					    if (Request == NULL) {
 | 
				
			||||||
 | 
					      FreePool (ConfigRequest);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    return EFI_NOT_FOUND;
 | 
					    return EFI_NOT_FOUND;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -403,12 +409,17 @@ ExtractConfig (
 | 
				
			|||||||
  //
 | 
					  //
 | 
				
			||||||
  Status = HiiConfigRouting->BlockToConfig (
 | 
					  Status = HiiConfigRouting->BlockToConfig (
 | 
				
			||||||
                                HiiConfigRouting,
 | 
					                                HiiConfigRouting,
 | 
				
			||||||
                                Request,
 | 
					                                ConfigRequest,
 | 
				
			||||||
                                (UINT8 *) &PrivateData->Configuration,
 | 
					                                (UINT8 *) &PrivateData->Configuration,
 | 
				
			||||||
                                BufferSize,
 | 
					                                BufferSize,
 | 
				
			||||||
                                Results,
 | 
					                                Results,
 | 
				
			||||||
                                Progress
 | 
					                                Progress
 | 
				
			||||||
                                );
 | 
					                                );
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  if (Request == NULL) {
 | 
				
			||||||
 | 
					    FreePool (ConfigRequest);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return Status;
 | 
					  return Status;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -451,6 +462,7 @@ RouteConfig (
 | 
				
			|||||||
  PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);
 | 
					  PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);
 | 
				
			||||||
  HiiConfigRouting = PrivateData->HiiConfigRouting;
 | 
					  HiiConfigRouting = PrivateData->HiiConfigRouting;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
  // Check routing data in <ConfigHdr>.
 | 
					  // Check routing data in <ConfigHdr>.
 | 
				
			||||||
  // Note: if only one Storage is used, then this checking could be skipped.
 | 
					  // Note: if only one Storage is used, then this checking could be skipped.
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
@@ -463,16 +475,13 @@ RouteConfig (
 | 
				
			|||||||
  // Get Buffer Storage data from EFI variable
 | 
					  // Get Buffer Storage data from EFI variable
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);
 | 
					  BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);
 | 
				
			||||||
  Status = gRT->GetVariable (
 | 
					  gRT->GetVariable (
 | 
				
			||||||
        VariableName,
 | 
					        VariableName,
 | 
				
			||||||
        &mFormSetGuid,
 | 
					        &mFormSetGuid,
 | 
				
			||||||
        NULL,
 | 
					        NULL,
 | 
				
			||||||
        &BufferSize,
 | 
					        &BufferSize,
 | 
				
			||||||
        &PrivateData->Configuration
 | 
					        &PrivateData->Configuration
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
  if (EFI_ERROR (Status)) {
 | 
					 | 
				
			||||||
    return Status;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  // Convert <ConfigResp> to buffer data by helper function ConfigToBlock()
 | 
					  // Convert <ConfigResp> to buffer data by helper function ConfigToBlock()
 | 
				
			||||||
@@ -550,6 +559,11 @@ DriverCallback (
 | 
				
			|||||||
    return EFI_INVALID_PARAMETER;
 | 
					    return EFI_INVALID_PARAMETER;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 | 
					  if ((Type == EFI_IFR_TYPE_STRING) && (Value->string == 0)) {
 | 
				
			||||||
 | 
					    return EFI_INVALID_PARAMETER;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Status = EFI_SUCCESS;
 | 
					  Status = EFI_SUCCESS;
 | 
				
			||||||
  PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);
 | 
					  PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -805,11 +819,13 @@ DriverSampleInit (
 | 
				
			|||||||
  CHAR16                          *NewString;
 | 
					  CHAR16                          *NewString;
 | 
				
			||||||
  UINTN                           BufferSize;
 | 
					  UINTN                           BufferSize;
 | 
				
			||||||
  DRIVER_SAMPLE_CONFIGURATION     *Configuration;
 | 
					  DRIVER_SAMPLE_CONFIGURATION     *Configuration;
 | 
				
			||||||
  BOOLEAN                         ExtractIfrDefault;
 | 
					  BOOLEAN                         ActionFlag;
 | 
				
			||||||
 | 
					  EFI_STRING                      ConfigRequestHdr;  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  // Initialize the library and our protocol.
 | 
					  // Initialize the local variables.
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
 | 
					  ConfigRequestHdr = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  // Initialize screen dimensions for SendForm().
 | 
					  // Initialize screen dimensions for SendForm().
 | 
				
			||||||
@@ -945,34 +961,31 @@ DriverSampleInit (
 | 
				
			|||||||
  //
 | 
					  //
 | 
				
			||||||
  // Try to read NV config EFI variable first
 | 
					  // Try to read NV config EFI variable first
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  ExtractIfrDefault = TRUE;
 | 
					  ConfigRequestHdr = HiiConstructConfigHdr (&mFormSetGuid, VariableName, DriverHandle[0]);
 | 
				
			||||||
 | 
					  ASSERT (ConfigRequestHdr != NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);
 | 
					  BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);
 | 
				
			||||||
  Status = gRT->GetVariable (VariableName, &mFormSetGuid, NULL, &BufferSize, Configuration);
 | 
					  Status = gRT->GetVariable (VariableName, &mFormSetGuid, NULL, &BufferSize, Configuration);
 | 
				
			||||||
  if (!EFI_ERROR (Status) && (BufferSize == sizeof (DRIVER_SAMPLE_CONFIGURATION))) {
 | 
					  if (EFI_ERROR (Status)) {
 | 
				
			||||||
    ExtractIfrDefault = FALSE;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (ExtractIfrDefault) {
 | 
					 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
    // EFI variable for NV config doesn't exit, we should build this variable
 | 
					    // EFI variable for NV config doesn't exit, we should build this variable
 | 
				
			||||||
    // based on default values stored in IFR
 | 
					    // based on default values stored in IFR
 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
    BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);
 | 
					    ActionFlag = HiiSetToDefaults (ConfigRequestHdr, EFI_HII_DEFAULT_CLASS_STANDARD);
 | 
				
			||||||
    Status = HiiIfrLibExtractDefault (Configuration, &BufferSize, 1, VfrMyIfrNVDataDefault0000);
 | 
					    ASSERT (ActionFlag);
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    // EFI variable does exist and Validate Current Setting
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    ActionFlag = HiiValidateSettings (ConfigRequestHdr);
 | 
				
			||||||
 | 
					    ASSERT (ActionFlag);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  FreePool (ConfigRequestHdr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!EFI_ERROR (Status)) {
 | 
					 | 
				
			||||||
      gRT->SetVariable(
 | 
					 | 
				
			||||||
             VariableName,
 | 
					 | 
				
			||||||
             &mFormSetGuid,
 | 
					 | 
				
			||||||
             EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
 | 
					 | 
				
			||||||
             sizeof (DRIVER_SAMPLE_CONFIGURATION),
 | 
					 | 
				
			||||||
             Configuration
 | 
					 | 
				
			||||||
             );
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  // Default this driver is built into Flash device image, 
 | 
					  // In default, this driver is built into Flash device image, 
 | 
				
			||||||
  // the following code doesn't run.
 | 
					  // the following code doesn't run.
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1000,7 +1013,7 @@ DriverSampleInit (
 | 
				
			|||||||
    HiiRemovePackages (HiiHandle[1]);
 | 
					    HiiRemovePackages (HiiHandle[1]);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return Status;
 | 
					  return EFI_SUCCESS;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,6 +42,7 @@ Revision History
 | 
				
			|||||||
#include <Library/MemoryAllocationLib.h>
 | 
					#include <Library/MemoryAllocationLib.h>
 | 
				
			||||||
#include <Library/HiiLib.h>
 | 
					#include <Library/HiiLib.h>
 | 
				
			||||||
#include <Library/DevicePathLib.h>
 | 
					#include <Library/DevicePathLib.h>
 | 
				
			||||||
 | 
					#include <Library/PrintLib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "NVDataStruc.h"
 | 
					#include "NVDataStruc.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -54,6 +54,7 @@
 | 
				
			|||||||
  BaseMemoryLib
 | 
					  BaseMemoryLib
 | 
				
			||||||
  DebugLib
 | 
					  DebugLib
 | 
				
			||||||
  HiiLib
 | 
					  HiiLib
 | 
				
			||||||
 | 
					  PrintLib
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[Guids]
 | 
					[Guids]
 | 
				
			||||||
  gEfiIfrTianoGuid                              ## CONSUMES ## Guid
 | 
					  gEfiIfrTianoGuid                              ## CONSUMES ## Guid
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -62,6 +62,37 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 | 
				
			|||||||
#define BITMAP_LEN_8_BIT(Width, Height)  ((Width) * (Height))
 | 
					#define BITMAP_LEN_8_BIT(Width, Height)  ((Width) * (Height))
 | 
				
			||||||
#define BITMAP_LEN_24_BIT(Width, Height) ((Width) * (Height) * 3)
 | 
					#define BITMAP_LEN_24_BIT(Width, Height) ((Width) * (Height) * 3)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// IFR data structure
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// BASE_CR (a, IFR_DEFAULT_VALUE_DATA, Entry) to get the whole structure.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef struct {
 | 
				
			||||||
 | 
					  LIST_ENTRY          Entry;             // Link to VarStorage
 | 
				
			||||||
 | 
					  EFI_GUID            Guid;
 | 
				
			||||||
 | 
					  CHAR16              *Name;
 | 
				
			||||||
 | 
					  EFI_VARSTORE_ID     VarStoreId;
 | 
				
			||||||
 | 
					  UINT16              Size;
 | 
				
			||||||
 | 
					  LIST_ENTRY          BlockEntry;        // Link to its Block array
 | 
				
			||||||
 | 
					} IFR_VARSTORAGE_DATA;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef struct {
 | 
				
			||||||
 | 
					  LIST_ENTRY          Entry;             // Link to Block array
 | 
				
			||||||
 | 
					  UINT16              Offset;
 | 
				
			||||||
 | 
					  UINT16              Width;
 | 
				
			||||||
 | 
					  EFI_QUESTION_ID     QuestionId;
 | 
				
			||||||
 | 
					  UINT8               OpCode;
 | 
				
			||||||
 | 
					  UINT8               Scope;
 | 
				
			||||||
 | 
					  LIST_ENTRY          DefaultValueEntry; // Link to its default value array
 | 
				
			||||||
 | 
					} IFR_BLOCK_DATA;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef struct {
 | 
				
			||||||
 | 
					  LIST_ENTRY          Entry;
 | 
				
			||||||
 | 
					  EFI_STRING_ID       DefaultName;
 | 
				
			||||||
 | 
					  UINT16              DefaultId;
 | 
				
			||||||
 | 
					  UINT64              Value;
 | 
				
			||||||
 | 
					} IFR_DEFAULT_DATA;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Storage types
 | 
					// Storage types
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
@@ -83,8 +114,6 @@ typedef struct {
 | 
				
			|||||||
  UINT16              Size;
 | 
					  UINT16              Size;
 | 
				
			||||||
} HII_FORMSET_STORAGE;
 | 
					} HII_FORMSET_STORAGE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define HII_FORMSET_STORAGE_FROM_LINK(a)  CR (a, HII_FORMSET_STORAGE, Link, HII_FORMSET_STORAGE_SIGNATURE)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// String Package definitions
 | 
					// String Package definitions
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user