diff options
author | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-05-18 12:12:56 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-05-18 12:12:56 +0000 |
commit | 8567300ae4047da0891d62eedf50d407a23c5203 (patch) | |
tree | d8464aea4127dc1ed8a2cbda3c5b0b57ec946eb5 /MdeModulePkg | |
parent | d7dfd027aa9d376a6bd74eafaefe004938e4d209 (diff) | |
download | edk2-8567300ae4047da0891d62eedf50d407a23c5203.tar.gz edk2-8567300ae4047da0891d62eedf50d407a23c5203.tar.bz2 edk2-8567300ae4047da0891d62eedf50d407a23c5203.zip |
Fix K8 issues in HiiDataBase
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8325 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r-- | MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 59 | ||||
-rw-r--r-- | MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c | 220 | ||||
-rw-r--r-- | MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h | 28 |
3 files changed, 194 insertions, 113 deletions
diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c index 06c345b128..df73b7b3a1 100644 --- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c +++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c @@ -921,16 +921,17 @@ InternalHiiGetValueOfNumber ( }
/**
- This function shares the same logic to parse ConfigAltResp string
- for setting default value and validating current setting.
-
- @param ConfigResp
- @param HiiPackageList
- @param PackageListLength
- @param VarGuid
- @param VarName
+ This internal function parses IFR data to validate current setting.
+
+ @param ConfigResp ConfigResp string contains the current setting.
+ @param HiiPackageList Point to Hii package list.
+ @param PackageListLength The length of the pacakge.
+ @param VarGuid Guid of the buffer storage.
+ @param VarName Name of the buffer storage.
- @retval EFI_SUCCESS
+ @retval EFI_SUCCESS The current setting is valid.
+ @retval EFI_OUT_OF_RESOURCES The memory is not enough.
+ @retval EFI_INVALID_PARAMETER The config string or the Hii package is invalid.
**/
EFI_STATUS
EFIAPI
@@ -1214,7 +1215,7 @@ InternalHiiValidateCurrentSetting ( }
//
// Find the matched VarStoreId to the input VarGuid and VarName
- //
+ //
IfrVarStore = (EFI_IFR_VARSTORE *) IfrOpHdr;
if (CompareGuid ((EFI_GUID *) (VOID *) &IfrVarStore->Guid, VarGuid)) {
VarStoreName = (CHAR8 *) IfrVarStore->Name;
@@ -1244,10 +1245,17 @@ InternalHiiValidateCurrentSetting ( break;
case EFI_IFR_ONE_OF_OP:
//
- // Check whether current value is the one of option.
+ // Check whether current value is the one of option.
//
//
+ // OneOf question is not in IFR Form. This IFR form is not valid.
+ //
+ if (IfrVarStore == NULL) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+ //
// Check whether this question is for the requested varstore.
//
IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpHdr;
@@ -1299,6 +1307,13 @@ InternalHiiValidateCurrentSetting ( //
//
+ // Numeric question is not in IFR Form. This IFR form is not valid.
+ //
+ if (IfrVarStore == NULL) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+ //
// Check whether this question is for the requested varstore.
//
IfrNumeric = (EFI_IFR_NUMERIC *) IfrOpHdr;
@@ -1382,6 +1397,14 @@ InternalHiiValidateCurrentSetting ( //
//
+ // CheckBox question is not in IFR Form. This IFR form is not valid.
+ //
+ if (IfrVarStore == NULL) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+
+ //
// Check whether this question is for the requested varstore.
//
IfrCheckBox = (EFI_IFR_CHECKBOX *) IfrOpHdr;
@@ -1429,6 +1452,14 @@ InternalHiiValidateCurrentSetting ( //
//
+ // CheckBox question is not in IFR Form. This IFR form is not valid.
+ //
+ if (IfrVarStore == NULL) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+
+ //
// Check whether this question is for the requested varstore.
//
IfrString = (EFI_IFR_STRING *) IfrOpHdr;
@@ -1558,9 +1589,9 @@ Done: }
/**
- This function shares the same logic to parse ConfigAltResp string
- for setting default value and validating current setting.
-
+ This function parses the input ConfigRequest string and its matched IFR code
+ string for setting default value and validating current setting.
+
1. For setting default action, Reset the default value specified by DefaultId
to the driver configuration got by Request string.
2. For validating current setting, Validate the current configuration
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index 2f5118e512..665b951869 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -577,6 +577,10 @@ MergeDefaultString ( SizeAltCfgResp + StrSize (StringPtrDefault),
(VOID *) (*AltCfgResp)
);
+ if (*AltCfgResp == NULL) {
+ FreePool (AltConfigHdr);
+ return EFI_OUT_OF_RESOURCES;
+ }
StrCat (*AltCfgResp, StringPtrDefault);
break;
} else {
@@ -594,11 +598,12 @@ MergeDefaultString ( //
// Find next AltCfg String
- //
+ //
*(AltConfigHdr + HeaderLength) = L'\0';
StringPtrDefault = StrStr (StringPtrDefault + 1, AltConfigHdr);
}
-
+
+ FreePool (AltConfigHdr);
return EFI_SUCCESS;
}
@@ -796,7 +801,7 @@ ParseIfrData ( IN EFI_STRING ConfigHdr,
IN IFR_BLOCK_DATA *RequestBlockArray,
IN OUT IFR_VARSTORAGE_DATA *VarStorageData,
- OUT IFR_DEFAULT_DATA **PIfrDefaultIdArray
+ OUT IFR_DEFAULT_DATA *DefaultIdArray
)
{
EFI_STATUS Status;
@@ -810,7 +815,6 @@ ParseIfrData ( EFI_IFR_CHECKBOX *IfrCheckBox;
EFI_IFR_PASSWORD *IfrPassword;
EFI_IFR_STRING *IfrString;
- IFR_DEFAULT_DATA *DefaultIdArray;
IFR_DEFAULT_DATA *DefaultData;
IFR_BLOCK_DATA *BlockData;
CHAR16 *VarStoreName;
@@ -823,9 +827,6 @@ ParseIfrData ( EFI_STRING TempStr;
UINTN LengthString;
- //
- // Initialize DefaultIdArray to store the map between DeaultId and DefaultName
- //
LengthString = 0;
Status = EFI_SUCCESS;
GuidStr = NULL;
@@ -833,11 +834,6 @@ ParseIfrData ( TempStr = NULL;
BlockData = NULL;
DefaultData = NULL;
- DefaultIdArray = (IFR_DEFAULT_DATA *) AllocateZeroPool (sizeof (IFR_DEFAULT_DATA));
- if (DefaultIdArray == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- InitializeListHead (&DefaultIdArray->Entry);
//
// Go through the form package to parse OpCode one by one.
@@ -936,6 +932,13 @@ ParseIfrData ( //
//
+ // Numeric and OneOf question is not in IFR Form. This IFR form is not valid.
+ //
+ if (VarStorageData->Size == 0) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+ //
// Check whether this question is for the requested varstore.
//
IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpHdr;
@@ -992,7 +995,14 @@ ParseIfrData ( // width by EFI_IFR_ORDERED_LIST MaxContainers * OneofOption Type
// no default value and default id, how to define its default value?
//
-
+
+ //
+ // OrderedList question is not in IFR Form. This IFR form is not valid.
+ //
+ if (VarStorageData->Size == 0) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
//
// Check whether this question is for the requested varstore.
//
@@ -1057,6 +1067,13 @@ ParseIfrData ( //
//
+ // CheckBox question is not in IFR Form. This IFR form is not valid.
+ //
+ if (VarStorageData->Size == 0) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+ //
// Check whether this question is for the requested varstore.
//
IfrCheckBox = (EFI_IFR_CHECKBOX *) IfrOpHdr;
@@ -1171,6 +1188,13 @@ ParseIfrData ( //
//
+ // String question is not in IFR Form. This IFR form is not valid.
+ //
+ if (VarStorageData->Size == 0) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+ //
// Check whether this question is for the requested varstore.
//
IfrString = (EFI_IFR_STRING *) IfrOpHdr;
@@ -1235,6 +1259,13 @@ ParseIfrData ( //
//
+ // Password question is not in IFR Form. This IFR form is not valid.
+ //
+ if (VarStorageData->Size == 0) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+ //
// Check whether this question is for the requested varstore.
//
IfrPassword = (EFI_IFR_PASSWORD *) IfrOpHdr;
@@ -1424,7 +1455,7 @@ ParseIfrData ( break;
case EFI_IFR_END_OP:
//
- // End Opcode is for Var.
+ // End Opcode is for Var question.
//
if (BlockData != NULL && BlockData->Scope > 0) {
BlockData->Scope--;
@@ -1441,11 +1472,6 @@ ParseIfrData ( }
Done:
- //
- // Set the defualt ID array.
- //
- *PIfrDefaultIdArray = DefaultIdArray;
-
return Status;
}
@@ -1456,7 +1482,7 @@ Done: When Request points to NULL string, the request string and default value string
for each varstore in form package will return.
- @param HiiHandle Hii Handle which Hii Packages are registered.
+ @param DataBaseRecord The DataBaseRecord instance contains the found Hii handle and package.
@param DevicePath Device Path which Hii Config Access Protocol is registered.
@param Request Pointer to a null-terminated Unicode string in
<ConfigRequest> format. When it doesn't contain
@@ -1486,24 +1512,22 @@ Done: EFI_STATUS
EFIAPI
GetFullStringFromHiiFormPackages (
- IN EFI_HII_HANDLE HiiHandle,
+ IN HII_DATABASE_RECORD *DataBaseRecord,
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN OUT EFI_STRING *Request,
IN OUT EFI_STRING *AltCfgResp
)
{
EFI_STATUS Status;
- EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
- UINT32 PackageListLength;
- UINTN BufferSize;
+ UINT8 *HiiFormPackage;
+ UINTN PackageSize;
+ UINTN ResultSize;
IFR_BLOCK_DATA *RequestBlockArray;
IFR_BLOCK_DATA *BlockData;
IFR_BLOCK_DATA *NextBlockData;
IFR_DEFAULT_DATA *DefaultValueData;
IFR_DEFAULT_DATA *DefaultId;
IFR_DEFAULT_DATA *DefaultIdArray;
- EFI_HII_PACKAGE_HEADER PacakgeHeader;
- UINT32 PackageOffset;
IFR_VARSTORAGE_DATA *VarStorageData;
EFI_STRING DefaultAltCfgResp;
EFI_STRING FullConfigRequest;
@@ -1524,63 +1548,60 @@ GetFullStringFromHiiFormPackages ( // Initialize the local variables.
//
RequestBlockArray = NULL;
+ DefaultIdArray = NULL;
VarStorageData = NULL;
DefaultAltCfgResp = NULL;
FullConfigRequest = NULL;
ConfigHdr = NULL;
- DefaultIdArray = NULL;
GuidStr = NULL;
NameStr = NULL;
PathStr = NULL;
-
- //
- // 1. Get HiiPackage by HiiHandle
- //
- BufferSize = 0;
- HiiPackageList = NULL;
- Status = HiiExportPackageLists (&mPrivate.HiiDatabase, HiiHandle, &BufferSize, HiiPackageList);
-
- //
- // The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.
+ HiiFormPackage = NULL;
+ ResultSize = 0;
+ PackageSize = 0;
+
//
- if (Status != EFI_BUFFER_TOO_SMALL) {
+ // 0. Get Hii Form Package by HiiHandle
+ //
+ Status = ExportFormPackages (
+ &mPrivate,
+ DataBaseRecord->Handle,
+ DataBaseRecord->PackageList,
+ 0,
+ PackageSize,
+ HiiFormPackage,
+ &ResultSize
+ );
+ if (EFI_ERROR (Status)) {
return Status;
}
-
- HiiPackageList = AllocatePool (BufferSize);
- if (HiiPackageList == NULL) {
- return EFI_OUT_OF_RESOURCES;
+
+ HiiFormPackage = AllocatePool (ResultSize);
+ if (HiiFormPackage == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
}
//
- // Get PackageList on HiiHandle
+ // Get HiiFormPackage by HiiHandle
//
- Status = HiiExportPackageLists (&mPrivate.HiiDatabase, HiiHandle, &BufferSize, HiiPackageList);
+ PackageSize = ResultSize;
+ ResultSize = 0;
+ Status = ExportFormPackages (
+ &mPrivate,
+ DataBaseRecord->Handle,
+ DataBaseRecord->PackageList,
+ 0,
+ PackageSize,
+ HiiFormPackage,
+ &ResultSize
+ );
if (EFI_ERROR (Status)) {
goto Done;
}
//
- // 2. Parse FormPackage to get BlockArray and DefaultId Array for the request BlockArray.
- // 1) Request is NULL.
- // 2) Request is not NULL. And it doesn't contain any BlockArray.
- // 3) Request is not NULL. And it containts BlockArray.
- //
-
- //
- // Initialize VarStorageData to store the var store Block and Default value information.
- //
- VarStorageData = (IFR_VARSTORAGE_DATA *) AllocateZeroPool (sizeof (IFR_VARSTORAGE_DATA));
- if (VarStorageData == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Done;
- }
-
- InitializeListHead (&VarStorageData->Entry);
- InitializeListHead (&VarStorageData->BlockEntry);
-
- //
- // Gte the request block array by Request String
+ // 1. Get the request block array by Request String when Request string containts the block array.
//
StringPtr = NULL;
if (*Request != NULL) {
@@ -1695,39 +1716,36 @@ GetFullStringFromHiiFormPackages ( }
//
- // Get the form package
+ // 2. Parse FormPackage to get BlockArray and DefaultId Array for the request BlockArray.
//
- PackageOffset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
- PackageListLength = ReadUnaligned32 (&HiiPackageList->PackageLength);
- while (PackageOffset < PackageListLength) {
- CopyMem (&PacakgeHeader, (UINT8 *) HiiPackageList + PackageOffset, sizeof (PacakgeHeader));
-
- if (PacakgeHeader.Type == EFI_HII_PACKAGE_FORMS) {
- //
- // Reset VarStorageData
- //
- VarStorageData->Size = 0;
- VarStorageData->VarStoreId = 0;
- if (VarStorageData->Name != NULL) {
- FreePool (VarStorageData->Name);
- VarStorageData->Name = NULL;
- }
- //
- // Parse the opcode in form package
- //
- Status = ParseIfrData ((UINT8 *) HiiPackageList + PackageOffset, PacakgeHeader.Length, *Request, RequestBlockArray, VarStorageData, &DefaultIdArray);
- if (EFI_ERROR (Status)) {
- goto Done;
- }
+ //
+ // Initialize DefaultIdArray to store the map between DeaultId and DefaultName
+ //
+ DefaultIdArray = (IFR_DEFAULT_DATA *) AllocateZeroPool (sizeof (IFR_DEFAULT_DATA));
+ if (DefaultIdArray == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+ InitializeListHead (&DefaultIdArray->Entry);
- //
- // Only one form is in a pacakge list.
- //
- break;
- }
+ //
+ // Initialize VarStorageData to store the var store Block and Default value information.
+ //
+ VarStorageData = (IFR_VARSTORAGE_DATA *) AllocateZeroPool (sizeof (IFR_VARSTORAGE_DATA));
+ if (VarStorageData == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+ InitializeListHead (&VarStorageData->Entry);
+ InitializeListHead (&VarStorageData->BlockEntry);
- PackageOffset += PacakgeHeader.Length;
+ //
+ // Parse the opcode in form pacakge to get the default setting.
+ //
+ Status = ParseIfrData (HiiFormPackage, (UINT32) PackageSize, *Request, RequestBlockArray, VarStorageData, DefaultIdArray);
+ if (EFI_ERROR (Status)) {
+ goto Done;
}
//
@@ -2011,8 +2029,8 @@ Done: //
// Free Pacakge data
//
- if (HiiPackageList != NULL) {
- FreePool (HiiPackageList);
+ if (HiiFormPackage != NULL) {
+ FreePool (HiiFormPackage);
}
return Status;
@@ -2158,6 +2176,7 @@ HiiConfigRoutingExtractConfig ( //
DriverHandle = NULL;
HiiHandle = NULL;
+ Database = NULL;
DevicePathLength = GetDevicePathSize (DevicePath);
for (Link = Private->DatabaseList.ForwardLink;
Link != &Private->DatabaseList;
@@ -2208,7 +2227,7 @@ HiiConfigRoutingExtractConfig ( //
// Get the full request string from IFR when HiiPackage is registered to HiiHandle
//
- Status = GetFullStringFromHiiFormPackages (HiiHandle, DevicePath, &ConfigRequest, &DefaultResults);
+ Status = GetFullStringFromHiiFormPackages (Database, DevicePath, &ConfigRequest, &DefaultResults);
if (EFI_ERROR (Status)) {
goto Done;
}
@@ -2257,7 +2276,7 @@ HiiConfigRoutingExtractConfig ( //
if (HiiHandle != NULL) {
if (DefaultResults == NULL) {
- Status = GetFullStringFromHiiFormPackages (HiiHandle, DevicePath, &ConfigRequest, &AccessResults);
+ Status = GetFullStringFromHiiFormPackages (Database, DevicePath, &ConfigRequest, &AccessResults);
} else {
Status = MergeDefaultString (&AccessResults, DefaultResults);
}
@@ -2425,6 +2444,7 @@ HiiConfigRoutingExportConfig ( HiiHandle = NULL;
ConfigRequest = NULL;
DefaultResults = NULL;
+ Database = NULL;
DevicePath = DevicePathFromHandle (ConfigAccessHandles[Index]);
DevicePathLength = GetDevicePathSize (DevicePath);
if (DevicePath != NULL) {
@@ -2452,7 +2472,7 @@ HiiConfigRoutingExportConfig ( // Update AccessResults by getting default setting from IFR when HiiPackage is registered to HiiHandle
//
if (HiiHandle != NULL && DevicePath != NULL) {
- Status = GetFullStringFromHiiFormPackages (HiiHandle, DevicePath, &ConfigRequest, &DefaultResults);
+ Status = GetFullStringFromHiiFormPackages (Database, DevicePath, &ConfigRequest, &DefaultResults);
}
//
// Can't parse IFR data to get the request string and default string.
@@ -2473,8 +2493,10 @@ HiiConfigRoutingExportConfig ( // Merge the default sting from IFR code into the got setting from driver.
//
if (DefaultResults != NULL) {
- MergeDefaultString (&AccessResults, DefaultResults);
+ Status = MergeDefaultString (&AccessResults, DefaultResults);
+ ASSERT_EFI_ERROR (Status);
FreePool (DefaultResults);
+ DefaultResults = NULL;
}
//
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h index 5d10d46a8c..043770a7c0 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h @@ -484,6 +484,34 @@ FindGlyphBlock ( OUT UINTN *GlyphBufferLen OPTIONAL
);
+/**
+ This function exports Form packages to a buffer.
+ This is a internal function.
+
+ @param Private Hii database private structure.
+ @param Handle Identification of a package list.
+ @param PackageList Pointer to a package list which will be exported.
+ @param UsedSize The length of buffer be used.
+ @param BufferSize Length of the Buffer.
+ @param Buffer Allocated space for storing exported data.
+ @param ResultSize The size of the already exported content of this
+ package list.
+
+ @retval EFI_SUCCESS Form Packages are exported successfully.
+ @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
+
+**/
+EFI_STATUS
+ExportFormPackages (
+ IN HII_DATABASE_PRIVATE_DATA *Private,
+ IN EFI_HII_HANDLE Handle,
+ IN HII_DATABASE_PACKAGE_LIST_INSTANCE *PackageList,
+ IN UINTN UsedSize,
+ IN UINTN BufferSize,
+ IN OUT VOID *Buffer,
+ IN OUT UINTN *ResultSize
+ );
+
//
// EFI_HII_FONT_PROTOCOL protocol interfaces
//
|