mirror of https://github.com/acidanthera/audk.git
MdeModulePkg: Make boot option description unique
When there are multiple network boot options, user will see multiple "UEFI Network" boot options. It's hard to distinguish them using the description. The patch enhances the boot option generation logic to append " 2" /" 3"/" 4"/... number suffix to the non-first network boot options. So the 2nd one becomes "UEFI Network 2". Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Eric Dong <eric.dong@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18062 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
1999fb3180
commit
d948fe96a5
|
@ -1868,6 +1868,66 @@ BmMatchPartitionDevicePathNode (
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Enumerate all boot option descriptions and append " 2"/" 3"/... to make
|
||||
unique description.
|
||||
|
||||
@param BootOptions Array of boot options.
|
||||
@param BootOptionCount Count of boot options.
|
||||
**/
|
||||
VOID
|
||||
BmMakeBootOptionDescriptionUnique (
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions,
|
||||
UINTN BootOptionCount
|
||||
)
|
||||
{
|
||||
UINTN Base;
|
||||
UINTN Index;
|
||||
UINTN DescriptionSize;
|
||||
UINTN MaxSuffixSize;
|
||||
BOOLEAN *Visited;
|
||||
UINTN MatchCount;
|
||||
|
||||
if (BootOptionCount == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate the maximum buffer size for the number suffix.
|
||||
// The initial sizeof (CHAR16) is for the blank space before the number.
|
||||
//
|
||||
MaxSuffixSize = sizeof (CHAR16);
|
||||
for (Index = BootOptionCount; Index != 0; Index = Index / 10) {
|
||||
MaxSuffixSize += sizeof (CHAR16);
|
||||
}
|
||||
|
||||
Visited = AllocateZeroPool (sizeof (BOOLEAN) * BootOptionCount);
|
||||
ASSERT (Visited != NULL);
|
||||
|
||||
for (Base = 0; Base < BootOptionCount; Base++) {
|
||||
if (!Visited[Base]) {
|
||||
MatchCount = 1;
|
||||
Visited[Base] = TRUE;
|
||||
DescriptionSize = StrSize (BootOptions[Base].Description);
|
||||
for (Index = Base + 1; Index < BootOptionCount; Index++) {
|
||||
if (!Visited[Index] && StrCmp (BootOptions[Base].Description, BootOptions[Index].Description) == 0) {
|
||||
Visited[Index] = TRUE;
|
||||
MatchCount++;
|
||||
FreePool (BootOptions[Index].Description);
|
||||
BootOptions[Index].Description = AllocatePool (DescriptionSize + MaxSuffixSize);
|
||||
UnicodeSPrint (
|
||||
BootOptions[Index].Description, DescriptionSize + MaxSuffixSize,
|
||||
L"%s %d",
|
||||
BootOptions[Base].Description, MatchCount
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (Visited);
|
||||
}
|
||||
|
||||
/**
|
||||
Emuerate all possible bootable medias in the following order:
|
||||
1. Removable BlockIo - The boot option only points to the removable media
|
||||
|
@ -2054,6 +2114,7 @@ BmEnumerateBootOptions (
|
|||
FreePool (Handles);
|
||||
}
|
||||
|
||||
BmMakeBootOptionDescriptionUnique (BootOptions, *BootOptionCount);
|
||||
return BootOptions;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue