From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Mon, 24 Jun 2019 15:36:51 -0700 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BAA3630821DF; Mon, 24 Jun 2019 22:36:50 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-226.ams2.redhat.com [10.36.116.226]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8AEDA60BE2; Mon, 24 Jun 2019 22:36:49 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 4/7] MdeModulePkg/UefiBootManagerLib: export EfiBootManagerGetBootDescription() To: devel@edk2.groups.io, dwmw2@infradead.org Cc: Ray Ni References: <20190621223156.701502-1-dwmw2@infradead.org> <20190621223156.701502-4-dwmw2@infradead.org> From: "Laszlo Ersek" Message-ID: <4846fdf9-5f36-5994-b21b-a5f57a059f8f@redhat.com> Date: Tue, 25 Jun 2019 00:36:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190621223156.701502-4-dwmw2@infradead.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 24 Jun 2019 22:36:50 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 06/22/19 00:31, David Woodhouse wrote: > It would be useful for LegacyBiosDxe to be able to get descriptive names > for block devices, for legacy boot options. It gets a bit confusing when > they're all called "Harddisk". > > Since we have a collection of the special cases for various types of > device already in BmGetBootDescription(), let's export that with a > minor tweak to let the caller set the "UEFI " vs. "Legacy " prefix. > > There's no way we want to reproduce all those device-specific special > cases again in the LegacyBiosDxe. It's bad enough that they exist in > UefiBootManagerLib in the first place, instead of being in a protocol > provided by the individual disk drivers themselves. > > Signed-off-by: David Woodhouse > --- > .../Include/Library/UefiBootManagerLib.h | 16 ++++++++++++ > .../UefiBootManagerLib/BmBootDescription.c | 26 ++++++++++++++++--- > 2 files changed, 38 insertions(+), 4 deletions(-) > > diff --git a/MdeModulePkg/Include/Library/UefiBootManagerLib.h b/MdeModulePkg/Include/Library/UefiBootManagerLib.h > index 0b69a6021d..a9d6bfda88 100644 > --- a/MdeModulePkg/Include/Library/UefiBootManagerLib.h > +++ b/MdeModulePkg/Include/Library/UefiBootManagerLib.h > @@ -249,6 +249,22 @@ EfiBootManagerFindLoadOption ( > IN UINTN Count > ); > > +/** > + Return the boot description for the controller. > + > + @param Prefix String prefix (e.g "UEFI " or "Legacy "). > + @param Handle Controller handle. > + > + @return The description string. > +**/ > +CHAR16 * > +EFIAPI > +EfiBootManagerGetBootDescription ( > + IN CHAR16 *Prefix, > + IN EFI_HANDLE Handle > + ); > + > + > // > // Boot Manager hot key library functions. > // > diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c > index aa891feb17..dd4d160f31 100644 > --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c > +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c > @@ -758,12 +758,15 @@ BM_GET_BOOT_DESCRIPTION mBmBootDescriptionHandlers[] = { > /** > Return the boot description for the controller. > > + @param Prefix String prefix (e.g "UEFI " or "Legacy "). > @param Handle Controller handle. > > @return The description string. > **/ > CHAR16 * > -BmGetBootDescription ( > +EFIAPI > +EfiBootManagerGetBootDescription ( > + IN CHAR16 *Prefix, > IN EFI_HANDLE Handle > ) > { > @@ -785,10 +788,10 @@ BmGetBootDescription ( > // Avoid description confusion between UEFI & Legacy boot option by adding "UEFI " prefix > // ONLY for core provided boot description handler. > // > - Temp = AllocatePool (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix)); > + Temp = AllocatePool (StrSize (DefaultDescription) + StrSize (Prefix)); > ASSERT (Temp != NULL); > - StrCpyS (Temp, (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix)) / sizeof (CHAR16), mBmUefiPrefix); > - StrCatS (Temp, (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix)) / sizeof (CHAR16), DefaultDescription); > + StrCpyS (Temp, (StrSize (DefaultDescription) + StrSize (Prefix)) / sizeof (CHAR16), Prefix); > + StrCatS (Temp, (StrSize (DefaultDescription) + StrSize (Prefix)) / sizeof (CHAR16), DefaultDescription); > FreePool (DefaultDescription); > DefaultDescription = Temp; > break; I first thought this would be redundant wrt. platform description handlers registered with EfiBootManagerRegisterBootDescriptionHandler(), which BmGetBootDescription() asks for "better" descriptions. But, in such a platform callback, we'd still only want to rely on "mBmBootDescriptionHandlers", just with a different prefix. So this idea looks fine to me, after all. > @@ -814,6 +817,21 @@ BmGetBootDescription ( > return DefaultDescription; > } > > +/** > + Return the boot description for the controller, for UEFI boot. > + > + @param Handle Controller handle. > + > + @return The description string. > +**/ > +CHAR16 * > +BmGetBootDescription ( > + IN EFI_HANDLE Handle > + ) > +{ > + return EfiBootManagerGetBootDescription(mBmUefiPrefix, Handle); I noticed this elsewhere (in earlier patches in this series) but I didn't want to annoy you with obsessing about it :) (1) Please insert a space character before the opening paren, after the function designator. (Applies to the sizeof operator, and to function-like macro invocations, too.) With this fixed: Reviewed-by: Laszlo Ersek Thanks > +} > + > /** > Enumerate all boot option descriptions and append " 2"/" 3"/... to make > unique description. >