summaryrefslogtreecommitdiff
path: root/IntelFrameworkModulePkg/Universal
diff options
context:
space:
mode:
authorEric Dong <eric.dong@intel.com>2014-04-23 02:57:25 +0000
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2014-04-23 02:57:25 +0000
commitd78687fc47647a5f13c31bd9dcbbf7cc31b10a98 (patch)
treec32bc4759c2b345d106ffcf2a814354cc27959bc /IntelFrameworkModulePkg/Universal
parent5aecd343253d06393f3e56be0fd3fe8aa95eef99 (diff)
downloadedk2-platforms-d78687fc47647a5f13c31bd9dcbbf7cc31b10a98.tar.xz
Update code logic to let BDS UI can shows more than one formsets in one HiiHandle.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Gao, Liming <liming,gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15479 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'IntelFrameworkModulePkg/Universal')
-rw-r--r--IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c125
1 files changed, 117 insertions, 8 deletions
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
index 14e71e3e52..6a76c33f26 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
@@ -208,8 +208,10 @@ InitializeDeviceManager (
@param Handle The HII handle.
@param SetupClassGuid The class guid specifies which form set will be displayed.
+ @param SkipCount Skip some formsets which has processed before.
@param FormSetTitle Formset title string.
@param FormSetHelp Formset help string.
+ @param FormSetGuid Return the formset guid for this formset.
@retval TRUE The formset for given HII handle will be displayed.
@return FALSE The formset for given HII handle will not be displayed.
@@ -219,8 +221,10 @@ BOOLEAN
ExtractDisplayedHiiFormFromHiiHandle (
IN EFI_HII_HANDLE Handle,
IN EFI_GUID *SetupClassGuid,
+ IN UINTN SkipCount,
OUT EFI_STRING_ID *FormSetTitle,
- OUT EFI_STRING_ID *FormSetHelp
+ OUT EFI_STRING_ID *FormSetHelp,
+ OUT EFI_GUID **FormSetGuid
)
{
EFI_STATUS Status;
@@ -286,8 +290,14 @@ ExtractDisplayedHiiFormFromHiiHandle (
Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);
while (Offset2 < PackageHeader.Length) {
OpCodeData = Package + Offset2;
+ Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_FORM_SET_OP) {
+ if (SkipCount != 0) {
+ SkipCount --;
+ continue;
+ }
+
if (((EFI_IFR_OP_HEADER *) OpCodeData)->Length > OFFSET_OF (EFI_IFR_FORM_SET, Flags)) {
//
// Find FormSet OpCode
@@ -298,6 +308,8 @@ ExtractDisplayedHiiFormFromHiiHandle (
if (CompareGuid (SetupClassGuid, ClassGuid)) {
CopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));
CopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));
+ *FormSetGuid = AllocateCopyPool (sizeof (EFI_GUID), &((EFI_IFR_FORM_SET *) OpCodeData)->Guid);
+ ASSERT (*FormSetGuid != NULL);
FreePool (HiiPackageList);
return TRUE;
}
@@ -306,15 +318,12 @@ ExtractDisplayedHiiFormFromHiiHandle (
} else {
CopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));
CopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));
+ *FormSetGuid = AllocateCopyPool (sizeof (EFI_GUID), &((EFI_IFR_FORM_SET *) OpCodeData)->Guid);
+ ASSERT (*FormSetGuid != NULL);
FreePool (HiiPackageList);
return TRUE;
}
}
-
- //
- // Go to next opcode
- //
- Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
}
}
@@ -700,6 +709,71 @@ Done:
}
/**
+ Get HiiHandle total number.
+
+ @param HiiHandles The input HiiHandle array.
+
+ @retval the Hiihandle count.
+
+**/
+UINTN
+GetHiiHandleCount (
+ IN EFI_HII_HANDLE *HiiHandles
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; HiiHandles[Index] != NULL; Index++) {
+ }
+
+ return Index;
+}
+
+/**
+ Insert the new HiiHandle + FormsetGuid at the NewPair[InsertOffset].
+
+ @param HiiHandles The input HiiHandle array.
+ @param GuidLists The input form set guid lists.
+ @param ArrayCount The input array count, new array will be arraycount + 1 size.
+ @param Offset The current used HiiHandle's Offset.
+ @param FormSetGuid The new found formset guid.
+
+**/
+VOID
+AdjustArrayData (
+ IN OUT EFI_HII_HANDLE **HiiHandles,
+ IN OUT EFI_GUID ***GuidLists,
+ IN UINTN ArrayCount,
+ IN UINTN Offset,
+ IN EFI_GUID *FormSetGuid
+ )
+{
+ EFI_HII_HANDLE *NewHiiHandles;
+ EFI_GUID **NewGuidLists;
+
+ //
+ // +2 means include the new HiiHandle and the last empty NULL pointer.
+ //
+ NewHiiHandles = AllocateZeroPool ((ArrayCount + 2) * sizeof (EFI_HII_HANDLE));
+ ASSERT (NewHiiHandles != NULL);
+
+ CopyMem (NewHiiHandles, *HiiHandles, Offset * sizeof (EFI_HII_HANDLE));
+ NewHiiHandles[Offset] = NewHiiHandles[Offset - 1];
+ CopyMem (NewHiiHandles + Offset + 1, *HiiHandles + Offset, (ArrayCount - Offset) * sizeof (EFI_HII_HANDLE));
+
+ NewGuidLists = AllocateZeroPool ((ArrayCount + 2) * sizeof (EFI_GUID *));
+ ASSERT (NewGuidLists != NULL);
+
+ CopyMem (NewGuidLists, *GuidLists, Offset * sizeof (EFI_GUID *));
+ NewGuidLists[Offset] = FormSetGuid;
+
+ FreePool (*HiiHandles);
+ *HiiHandles = NewHiiHandles;
+ FreePool (*GuidLists);
+ *GuidLists = NewGuidLists;
+}
+
+/**
Call the browser and display the device manager to allow user
to configure the platform.
@@ -736,7 +810,12 @@ CallDeviceManager (
UINTN AddItemCount;
UINTN NewStringLen;
EFI_STRING NewStringTitle;
+ EFI_GUID **GuidLists;
+ UINTN HandleNum;
+ UINTN SkipCount;
+ EFI_GUID *FormSetGuid;
+ GuidLists = NULL;
HiiHandles = NULL;
Status = EFI_SUCCESS;
gCallbackKey = 0;
@@ -744,6 +823,8 @@ CallDeviceManager (
DriverHealthHandles = NULL;
AddNetworkMenu = FALSE;
AddItemCount = 0;
+ SkipCount = 0;
+ FormSetGuid = NULL;
//
// Connect all prior to entering the platform setup menu.
@@ -825,6 +906,10 @@ CallDeviceManager (
HiiHandles = HiiGetHiiHandles (NULL);
ASSERT (HiiHandles != NULL);
+ HandleNum = GetHiiHandleCount (HiiHandles);
+ GuidLists = AllocateZeroPool ((HandleNum + 1) * sizeof (EFI_GUID *));
+ ASSERT (GuidLists != NULL);
+
//
// Search for formset of each class type
//
@@ -836,10 +921,21 @@ CallDeviceManager (
//
ASSERT(Index < MAX_KEY_SECTION_LEN);
- if (!ExtractDisplayedHiiFormFromHiiHandle (HiiHandles[Index], &gEfiHiiPlatformSetupFormsetGuid, &FormSetTitle, &FormSetHelp)) {
+ if (!ExtractDisplayedHiiFormFromHiiHandle (HiiHandles[Index], &gEfiHiiPlatformSetupFormsetGuid, SkipCount, &FormSetTitle, &FormSetHelp, &FormSetGuid)) {
+ SkipCount = 0;
continue;
}
+ //
+ // One HiiHandle has more than one formset can be shown,
+ // Insert a new pair of HiiHandle + Guid to the HiiHandles and GuidLists list.
+ //
+ if (SkipCount > 0) {
+ AdjustArrayData (&HiiHandles, &GuidLists, HandleNum, Index + 1, FormSetGuid);
+ HandleNum ++;
+ Index ++;
+ }
+
String = HiiGetString (HiiHandles[Index], FormSetTitle, NULL);
if (String == NULL) {
String = HiiGetString (HiiHandle, STR_MISSING_STRING, NULL);
@@ -919,6 +1015,12 @@ CallDeviceManager (
);
}
}
+
+ //
+ // Try to find more formset in this HiiHandle.
+ //
+ SkipCount++;
+ Index--;
}
Status = gBS->LocateHandleBuffer (
@@ -994,7 +1096,7 @@ CallDeviceManager (
gFormBrowser2,
&HiiHandles[gCallbackKey - DEVICE_KEY_OFFSET],
1,
- NULL,
+ GuidLists[gCallbackKey - DEVICE_KEY_OFFSET],
0,
NULL,
&ActionRequest
@@ -1062,6 +1164,13 @@ Done:
HiiFreeOpCodeHandle (EndOpCodeHandle);
FreePool (HiiHandles);
+ for (Index = 0; Index < HandleNum; Index++) {
+ if (GuidLists[Index] != NULL) {
+ FreePool (GuidLists[Index]);
+ }
+ }
+ FreePool (GuidLists);
+
return Status;
}