summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2010-03-04 06:48:52 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2010-03-04 06:48:52 +0000
commit59aefb7e0dc811a3e66ae23c1730028365354361 (patch)
treebabbb70bfd114b0c20187722bb4058de4e1502aa /EdkCompatibilityPkg
parent5bdfa4e58ad64cbc825d03397b15f5b2bcebda4e (diff)
downloadedk2-platforms-59aefb7e0dc811a3e66ae23c1730028365354361.tar.xz
Update HiiConfigAccess.ExtractConfig interface to support NULL request string and ConfigHdr request string.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10180 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg')
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/ConfigAccess.c229
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/FrameworkHiiOnUefiHiiThunk.inf1
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.h1
3 files changed, 179 insertions, 52 deletions
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/ConfigAccess.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/ConfigAccess.c
index c49ffe66c6..cdf4b09e15 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/ConfigAccess.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/ConfigAccess.c
@@ -147,6 +147,10 @@ GetStorageFromConfigString (
FORMSET_STORAGE *Storage;
CHAR16 *Name;
+ if (ConfigString == NULL) {
+ return NULL;
+ }
+
StorageList = GetFirstNode (&FormSet->StorageListHead);
while (!IsNull (&FormSet->StorageListHead, StorageList)) {
@@ -165,7 +169,7 @@ GetStorageFromConfigString (
StorageList = GetNextNode (&FormSet->StorageListHead, StorageList);
}
- return NULL;
+ return NULL;
}
/**
@@ -419,73 +423,194 @@ ThunkExtractConfig (
OUT EFI_STRING *Results
)
{
- EFI_STATUS Status;
- CONFIG_ACCESS_PRIVATE *ConfigAccess;
- FORMSET_STORAGE *BufferStorage;
- VOID *Data;
- UINTN DataSize;
-
- if (Request == NULL) {
+ EFI_STATUS Status;
+ CONFIG_ACCESS_PRIVATE *ConfigAccess;
+ FORMSET_STORAGE *BufferStorage;
+ VOID *Data;
+ UINTN DataSize;
+ FORM_BROWSER_FORMSET *FormSetContext;
+ CHAR16 *VarStoreName;
+ EFI_STRING ConfigRequestHdr;
+ EFI_STRING ConfigRequest;
+ UINTN Size;
+ BOOLEAN AllocatedRequest;
+ LIST_ENTRY *StorageList;
+ EFI_STRING SingleResult;
+ EFI_STRING FinalResults;
+ EFI_STRING StrPointer;
+
+ if (Progress == NULL || Results == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ *Progress = Request;
+
+ Status = EFI_SUCCESS;
+ Data = NULL;
+ StrPointer = NULL;
+ SingleResult = NULL;
+ FinalResults = NULL;
+ ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This);
+ FormSetContext = ConfigAccess->ThunkContext->FormSet;
+ if (IsListEmpty (&FormSetContext->StorageListHead)) {
+ //
+ // No VarStorage does exist in this form.
+ //
return EFI_NOT_FOUND;
}
+ StorageList = GetFirstNode (&FormSetContext->StorageListHead);
- Data = NULL;
- ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This);
+ do {
+ if (Request != NULL) {
+ BufferStorage = GetStorageFromConfigString (ConfigAccess->ThunkContext->FormSet, Request);
+ if (BufferStorage == NULL) {
+ return EFI_NOT_FOUND;
+ }
+ } else {
+ if (IsNull (&FormSetContext->StorageListHead, StorageList)) {
+ //
+ // No Storage to be extracted into the results.
+ //
+ break;
+ }
+ BufferStorage = FORMSET_STORAGE_FROM_LINK (StorageList);
+ StorageList = GetNextNode (&FormSetContext->StorageListHead, StorageList);
+ }
+
+ VarStoreName = NULL;
+ ConfigRequestHdr = NULL;
+ ConfigRequest = NULL;
+ Size = 0;
+ AllocatedRequest = FALSE;
- BufferStorage = GetStorageFromConfigString (ConfigAccess->ThunkContext->FormSet, Request);
+ if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
+ //
+ // NvMapOverride is not used. Get the Storage data from EFI Variable or Framework Form Callback.
+ //
+ if (ConfigAccess->FormCallbackProtocol == NULL ||
+ ConfigAccess->FormCallbackProtocol->NvRead == NULL) {
+ Status = GetUefiVariable (
+ BufferStorage,
+ &Data,
+ &DataSize
+ );
+ } else {
+ Status = CallFormCallBack (
+ BufferStorage,
+ ConfigAccess->FormCallbackProtocol,
+ &Data,
+ &DataSize
+ );
+ }
+ } else {
+ //
+ // Use the NvMapOverride.
+ //
+ DataSize = BufferStorage->Size;
+ Data = AllocateCopyPool (DataSize, ConfigAccess->ThunkContext->NvMapOverride);
+
+ if (Data != NULL) {
+ Status = EFI_SUCCESS;
+ } else {
+ Status = EFI_OUT_OF_RESOURCES;
+ }
+ }
+
+ if (!EFI_ERROR (Status)) {
+ ConfigRequest = Request;
+ if (Request == NULL || (StrStr (Request, L"OFFSET") == NULL)) {
+ //
+ // Request is without any request element, construct full request string.
+ //
- if (BufferStorage == NULL) {
- *Progress = (EFI_STRING) Request;
- return EFI_NOT_FOUND;
- }
+ if ((BufferStorage->VarStoreId == FormSetContext->DefaultVarStoreId) && (FormSetContext->OriginalDefaultVarStoreName != NULL)) {
+ VarStoreName = FormSetContext->OriginalDefaultVarStoreName;
+ } else {
+ VarStoreName = BufferStorage->Name;
+ }
- if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
+ //
+ // First Set ConfigRequestHdr string.
+ //
+ ConfigRequestHdr = HiiConstructConfigHdr (&BufferStorage->Guid, VarStoreName, ConfigAccess->ThunkContext->UefiHiiDriverHandle);
+ ASSERT (ConfigRequestHdr != NULL);
+
+ //
+ // 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);
+ ASSERT (ConfigRequest != NULL);
+ AllocatedRequest = TRUE;
+ UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)DataSize);
+ FreePool (ConfigRequestHdr);
+ }
+ Status = mHiiConfigRoutingProtocol->BlockToConfig (
+ mHiiConfigRoutingProtocol,
+ ConfigRequest,
+ Data,
+ DataSize,
+ &SingleResult,
+ Progress
+ );
+ //
+ // Free the allocated config request string.
+ //
+ if (AllocatedRequest) {
+ FreePool (ConfigRequest);
+ ConfigRequest = NULL;
+ }
+ }
//
- // NvMapOverride is not used. Get the Storage data from EFI Variable or Framework Form Callback.
+ // Free the allocated Data
//
- if (ConfigAccess->FormCallbackProtocol == NULL ||
- ConfigAccess->FormCallbackProtocol->NvRead == NULL) {
- Status = GetUefiVariable (
- BufferStorage,
- &Data,
- &DataSize
- );
- } else {
- Status = CallFormCallBack (
- BufferStorage,
- ConfigAccess->FormCallbackProtocol,
- &Data,
- &DataSize
- );
+ if (Data != NULL) {
+ FreePool (Data);
}
- } else {
//
- // Use the NvMapOverride.
+ // Directly return when meet with error
//
- DataSize = BufferStorage->Size;
- Data = AllocateCopyPool (DataSize, ConfigAccess->ThunkContext->NvMapOverride);
-
- if (Data != NULL) {
- Status = EFI_SUCCESS;
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ //
+ // Merge result into the final results.
+ //
+ if (FinalResults == NULL) {
+ FinalResults = SingleResult;
+ SingleResult = NULL;
} else {
- Status = EFI_OUT_OF_RESOURCES;
+ Size = StrLen (FinalResults);
+ Size = Size + 1;
+ Size = Size + StrLen (SingleResult) + 1;
+ StrPointer = AllocateZeroPool (Size * sizeof (CHAR16));
+ ASSERT (StrPointer != NULL);
+ StrCpy (StrPointer, FinalResults);
+ FreePool (FinalResults);
+ FinalResults = StrPointer;
+ StrPointer = StrPointer + StrLen (StrPointer);
+ *StrPointer = L'&';
+ StrCpy (StrPointer + 1, SingleResult);
+ FreePool (SingleResult);
}
- }
-
+ } while (Request == NULL);
+
if (!EFI_ERROR (Status)) {
- Status = mHiiConfigRoutingProtocol->BlockToConfig (
- mHiiConfigRoutingProtocol,
- Request,
- Data,
- DataSize,
- Results,
- Progress
- );
+ *Results = FinalResults;
+ } else {
+ if (FinalResults != NULL) {
+ FreePool (FinalResults);
+ }
}
-
- if (Data != NULL) {
- FreePool (Data);
+ //
+ // Set Progress string to the original request string.
+ //
+ if (Request == NULL) {
+ *Progress = NULL;
+ } else if (StrStr (Request, L"OFFSET") == NULL) {
+ *Progress = Request + StrLen (Request);
}
+
return Status;
}
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/FrameworkHiiOnUefiHiiThunk.inf b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/FrameworkHiiOnUefiHiiThunk.inf
index 3b3a54a104..d3f0234db0 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/FrameworkHiiOnUefiHiiThunk.inf
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/FrameworkHiiOnUefiHiiThunk.inf
@@ -80,6 +80,7 @@
UefiLib
PcdLib
LanguageLib
+ PrintLib
[Guids]
gEfiIfrTianoGuid
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.h b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.h
index 7d78029808..4df0b313cb 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.h
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.h
@@ -48,6 +48,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/UefiLib.h>
#include <Library/PcdLib.h>
#include <Library/LanguageLib.h>
+#include <Library/PrintLib.h>
#include <Guid/MdeModuleHii.h>