mirror of https://github.com/acidanthera/audk.git
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:
parent
59ceeabe50
commit
84f9a9ec8f
|
@ -285,6 +285,51 @@ HiiConstructConfigHdr (
|
|||
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.
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -17,13 +17,9 @@
|
|||
|
||||
#include <Uefi.h>
|
||||
|
||||
#include <Protocol/HiiDatabase.h>
|
||||
#include <Protocol/HiiString.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
#include <Protocol/FormBrowser2.h>
|
||||
|
||||
#include <Guid/GlobalVariable.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/HiiLib.h>
|
||||
|
@ -32,39 +28,7 @@
|
|||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/UefiHiiServicesLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/PcdLib.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
|
||||
)
|
||||
;
|
||||
#include <Library/UefiLib.h>
|
||||
|
||||
#endif
|
||||
|
|
|
@ -50,11 +50,7 @@
|
|||
UefiLib
|
||||
UefiHiiServicesLib
|
||||
PrintLib
|
||||
PcdLib
|
||||
|
||||
[Protocols]
|
||||
gEfiFormBrowser2ProtocolGuid ## CONSUMES
|
||||
gEfiDevicePathProtocolGuid ## CONSUMES
|
||||
|
||||
[Pcd]
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang
|
||||
|
|
|
@ -128,6 +128,7 @@ ValidatePassword (
|
|||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
UINTN BufferSize;
|
||||
UINTN PasswordMaxSize;
|
||||
CHAR16 *Password;
|
||||
CHAR16 *EncodedPassword;
|
||||
BOOLEAN OldPassword;
|
||||
|
@ -151,10 +152,11 @@ ValidatePassword (
|
|||
}
|
||||
|
||||
OldPassword = FALSE;
|
||||
PasswordMaxSize = sizeof (PrivateData->Configuration.WhatIsThePassword2);
|
||||
//
|
||||
// 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) {
|
||||
OldPassword = TRUE;
|
||||
break;
|
||||
|
@ -174,7 +176,7 @@ ValidatePassword (
|
|||
if (Password == NULL) {
|
||||
return EFI_NOT_READY;
|
||||
}
|
||||
if (StrLen (Password) > 20) {
|
||||
if (StrSize (Password) > PasswordMaxSize) {
|
||||
FreePool (Password);
|
||||
return EFI_NOT_READY;
|
||||
}
|
||||
|
@ -182,11 +184,11 @@ ValidatePassword (
|
|||
//
|
||||
// Validate old password
|
||||
//
|
||||
EncodedPassword = AllocateZeroPool (21 * sizeof (CHAR16));
|
||||
EncodedPassword = AllocateZeroPool (PasswordMaxSize);
|
||||
ASSERT (EncodedPassword != NULL);
|
||||
StrnCpy (EncodedPassword, Password, 21);
|
||||
EncodePassword (EncodedPassword, 20 * sizeof (CHAR16));
|
||||
if (CompareMem (EncodedPassword, PrivateData->Configuration.WhatIsThePassword2, 20 * sizeof (CHAR16)) != 0) {
|
||||
StrnCpy (EncodedPassword, Password, StrLen (Password));
|
||||
EncodePassword (EncodedPassword, StrLen (EncodedPassword) * sizeof (CHAR16));
|
||||
if (CompareMem (EncodedPassword, PrivateData->Configuration.WhatIsThePassword2, StrLen (EncodedPassword) * sizeof (CHAR16)) != 0) {
|
||||
//
|
||||
// Old password mismatch, return EFI_NOT_READY to prompt for error message
|
||||
//
|
||||
|
@ -250,11 +252,11 @@ SetPassword (
|
|||
if (TempPassword == NULL) {
|
||||
return EFI_NOT_READY;
|
||||
}
|
||||
if (StrLen (TempPassword) > PasswordSize / sizeof (CHAR16)) {
|
||||
if (StrSize (TempPassword) > PasswordSize) {
|
||||
FreePool (TempPassword);
|
||||
return EFI_NOT_READY;
|
||||
}
|
||||
StrnCpy (Password, TempPassword, PasswordSize / sizeof (CHAR16));
|
||||
StrnCpy (Password, TempPassword, StrLen (TempPassword));
|
||||
FreePool (TempPassword);
|
||||
|
||||
//
|
||||
|
@ -266,7 +268,7 @@ SetPassword (
|
|||
//
|
||||
// Update password's clear text in the screen
|
||||
//
|
||||
CopyMem (Configuration->PasswordClearText, Password, PasswordSize);
|
||||
CopyMem (Configuration->PasswordClearText, Password, StrSize (Password));
|
||||
|
||||
//
|
||||
// Update uncommitted data of Browser
|
||||
|
@ -289,7 +291,7 @@ SetPassword (
|
|||
//
|
||||
// Set password
|
||||
//
|
||||
EncodePassword (Password, PasswordSize);
|
||||
EncodePassword (Password, StrLen (Password) * 2);
|
||||
Status = gRT->SetVariable(
|
||||
VariableName,
|
||||
&mFormSetGuid,
|
||||
|
@ -340,61 +342,65 @@ ExtractConfig (
|
|||
UINTN BufferSize;
|
||||
DRIVER_SAMPLE_PRIVATE_DATA *PrivateData;
|
||||
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);
|
||||
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);
|
||||
Status = gRT->GetVariable (
|
||||
gRT->GetVariable (
|
||||
VariableName,
|
||||
&mFormSetGuid,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
&PrivateData->Configuration
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
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) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
ConfigRequestHdr = HiiConstructConfigHdr (&mFormSetGuid, VariableName, PrivateData->DriverHandle[0]);
|
||||
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>.
|
||||
// Note: if only one Storage is used, then this checking could be skipped.
|
||||
//
|
||||
if (!HiiIsConfigHdrMatch (Request, &mFormSetGuid, VariableName)) {
|
||||
*Progress = Request;
|
||||
if (!HiiIsConfigHdrMatch (ConfigRequest, &mFormSetGuid, VariableName)) {
|
||||
if (Request == NULL) {
|
||||
FreePool (ConfigRequest);
|
||||
}
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
@ -403,12 +409,17 @@ ExtractConfig (
|
|||
//
|
||||
Status = HiiConfigRouting->BlockToConfig (
|
||||
HiiConfigRouting,
|
||||
Request,
|
||||
ConfigRequest,
|
||||
(UINT8 *) &PrivateData->Configuration,
|
||||
BufferSize,
|
||||
Results,
|
||||
Progress
|
||||
);
|
||||
|
||||
if (Request == NULL) {
|
||||
FreePool (ConfigRequest);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -451,6 +462,7 @@ RouteConfig (
|
|||
PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);
|
||||
HiiConfigRouting = PrivateData->HiiConfigRouting;
|
||||
|
||||
//
|
||||
// Check routing data in <ConfigHdr>.
|
||||
// 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
|
||||
//
|
||||
BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);
|
||||
Status = gRT->GetVariable (
|
||||
gRT->GetVariable (
|
||||
VariableName,
|
||||
&mFormSetGuid,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
&PrivateData->Configuration
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Convert <ConfigResp> to buffer data by helper function ConfigToBlock()
|
||||
|
@ -550,6 +559,11 @@ DriverCallback (
|
|||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((Type == EFI_IFR_TYPE_STRING) && (Value->string == 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);
|
||||
|
||||
|
@ -805,11 +819,13 @@ DriverSampleInit (
|
|||
CHAR16 *NewString;
|
||||
UINTN BufferSize;
|
||||
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().
|
||||
|
@ -945,34 +961,31 @@ DriverSampleInit (
|
|||
//
|
||||
// Try to read NV config EFI variable first
|
||||
//
|
||||
ExtractIfrDefault = TRUE;
|
||||
ConfigRequestHdr = HiiConstructConfigHdr (&mFormSetGuid, VariableName, DriverHandle[0]);
|
||||
ASSERT (ConfigRequestHdr != NULL);
|
||||
|
||||
BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);
|
||||
Status = gRT->GetVariable (VariableName, &mFormSetGuid, NULL, &BufferSize, Configuration);
|
||||
if (!EFI_ERROR (Status) && (BufferSize == sizeof (DRIVER_SAMPLE_CONFIGURATION))) {
|
||||
ExtractIfrDefault = FALSE;
|
||||
}
|
||||
|
||||
if (ExtractIfrDefault) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// EFI variable for NV config doesn't exit, we should build this variable
|
||||
// based on default values stored in IFR
|
||||
//
|
||||
BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);
|
||||
Status = HiiIfrLibExtractDefault (Configuration, &BufferSize, 1, VfrMyIfrNVDataDefault0000);
|
||||
ActionFlag = HiiSetToDefaults (ConfigRequestHdr, EFI_HII_DEFAULT_CLASS_STANDARD);
|
||||
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.
|
||||
//
|
||||
|
||||
|
@ -1000,7 +1013,7 @@ DriverSampleInit (
|
|||
HiiRemovePackages (HiiHandle[1]);
|
||||
}
|
||||
|
||||
return Status;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,6 +42,7 @@ Revision History
|
|||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/HiiLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
|
||||
#include "NVDataStruc.h"
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
BaseMemoryLib
|
||||
DebugLib
|
||||
HiiLib
|
||||
PrintLib
|
||||
|
||||
[Guids]
|
||||
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_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
|
||||
//
|
||||
|
@ -83,8 +114,6 @@ typedef struct {
|
|||
UINT16 Size;
|
||||
} HII_FORMSET_STORAGE;
|
||||
|
||||
#define HII_FORMSET_STORAGE_FROM_LINK(a) CR (a, HII_FORMSET_STORAGE, Link, HII_FORMSET_STORAGE_SIGNATURE)
|
||||
|
||||
|
||||
//
|
||||
// String Package definitions
|
||||
|
|
Loading…
Reference in New Issue