From: "Ni, Ruiyu" <ruiyu.ni@intel.com>
To: "Wang, Sunny (HPS SW)" <sunnywang@hpe.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Tian, Feng" <feng.tian@intel.com>,
"Haskell, Darrell" <darrell.haskell@hpe.com>
Subject: Re: [PATCH] MdeModulePkg/UefiBootManagerLib: Generate boot description for NVME
Date: Mon, 13 Mar 2017 02:24:23 +0000 [thread overview]
Message-ID: <734D49CCEBEEF84792F5B80ED585239D5B8C88CB@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <CS1PR84MB029502C0B7D9665F32815525A8200@CS1PR84MB0295.NAMPRD84.PROD.OUTLOOK.COM>
I didn't find this library in EDKII.
When I firstly saw your comments, I was a little bit unwilling to change
UefiBootManagerLib to depend on UefiNvmExpressLib. Because it would
require all platforms to include UefiNvmExpressLib in DSC.
But since now I find no such library, I feel much better😊
Thanks/Ray
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Wang, Sunny (HPS SW)
> Sent: Friday, March 10, 2017 6:11 PM
> To: Ni, Ruiyu <ruiyu.ni@intel.com>; edk2-devel@lists.01.org
> Cc: Tian, Feng <feng.tian@intel.com>; Haskell, Darrell
> <darrell.haskell@hpe.com>
> Subject: Re: [edk2] [PATCH] MdeModulePkg/UefiBootManagerLib:
> Generate boot description for NVME
>
> Hi Ray,
> Just a question out of curiosity. Why don't we use UefiNvmExpressLib's
> NvmExpressIdentify() for sending ADMIN_IDENTIFY command to NVME
> controller?
> Others look good to me.
>
> Regards,
> Sunny Wang
>
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Ruiyu Ni
> Sent: Friday, March 10, 2017 3:58 PM
> To: edk2-devel@lists.01.org
> Cc: Feng Tian <feng.tian@intel.com>
> Subject: [edk2] [PATCH] MdeModulePkg/UefiBootManagerLib: Generate
> boot description for NVME
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Feng Tian <feng.tian@intel.com>
> ---
> .../Library/UefiBootManagerLib/BmBootDescription.c | 104
> ++++++++++++++++++++-
> .../Library/UefiBootManagerLib/InternalBm.h | 4 +-
> .../UefiBootManagerLib/UefiBootManagerLib.inf | 1 +
> 3 files changed, 107 insertions(+), 2 deletions(-)
>
> diff --git
> a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> index 050647d..501a0cc 100644
> --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> @@ -1,7 +1,7 @@
> /** @file
> Library functions which relate with boot option description.
>
> -Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
> (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR> This
> program and the accompanying materials are licensed and made available
> under the terms and conditions of the BSD License @@ -501,6 +501,107 @@
> BmGetLoadFileDescription ( }
>
> /**
> + Return the boot description for NVME boot device.
> +
> + @param Handle Controller handle.
> +
> + @return The description string.
> +**/
> +CHAR16 *
> +BmGetNvmeDescription (
> + IN EFI_HANDLE Handle
> + )
> +{
> + EFI_STATUS Status;
> + EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *NvmePassthru;
> + EFI_DEV_PATH_PTR DevicePath;
> + EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
> + EFI_NVM_EXPRESS_COMMAND Command;
> + EFI_NVM_EXPRESS_COMPLETION Completion;
> + NVME_ADMIN_CONTROLLER_DATA ControllerData;
> + CHAR16 *Description;
> + CHAR16 *Char;
> + UINTN Index;
> +
> + Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid,
> + (VOID **) &DevicePath.DevPath); if (EFI_ERROR (Status)) {
> + return NULL;
> + }
> +
> + Status = gBS->LocateDevicePath (&gEfiNvmExpressPassThruProtocolGuid,
> + &DevicePath.DevPath, &Handle); if (EFI_ERROR (Status) ||
> + (DevicePathType (DevicePath.DevPath) != MESSAGING_DEVICE_PATH)
> ||
> + (DevicePathSubType (DevicePath.DevPath) !=
> MSG_NVME_NAMESPACE_DP)) {
> + //
> + // Do not return description when the Handle is not a child of NVME
> controller.
> + //
> + return NULL;
> + }
> +
> + //
> + // Send ADMIN_IDENTIFY command to NVME controller to get the model
> and serial number.
> + //
> + Status = gBS->HandleProtocol (Handle,
> + &gEfiNvmExpressPassThruProtocolGuid, (VOID **) &NvmePassthru);
> + ASSERT_EFI_ERROR (Status);
> +
> + ZeroMem (&CommandPacket,
> + sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
> + ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
> ZeroMem
> + (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
> +
> + Command.Cdw0.Opcode = NVME_ADMIN_IDENTIFY_CMD; // //
> According to
> + Nvm Express 1.1 spec Figure 38, When not used, the field shall be cleared
> to 0h.
> + // For the Identify command, the Namespace Identifier is only used for the
> Namespace data structure.
> + //
> + Command.Nsid = 0;
> + CommandPacket.NvmeCmd = &Command;
> + CommandPacket.NvmeCompletion = &Completion;
> + CommandPacket.TransferBuffer = &ControllerData;
> + CommandPacket.TransferLength = sizeof (ControllerData);
> + CommandPacket.CommandTimeout = EFI_TIMER_PERIOD_SECONDS (5);
> + CommandPacket.QueueType = NVME_ADMIN_QUEUE;
> + //
> + // Set bit 0 (Cns bit) to 1 to identify a controller //
> + Command.Cdw10 = 1;
> + Command.Flags = CDW10_VALID;
> +
> + Status = NvmePassthru->PassThru (
> + NvmePassthru,
> + 0,
> + &CommandPacket,
> + NULL
> + );
> + if (EFI_ERROR (Status)) {
> + return NULL;
> + }
> +
> + Description = AllocateZeroPool (
> + (ARRAY_SIZE (ControllerData.Mn) + 1
> + + ARRAY_SIZE (ControllerData.Sn) + 1
> + + MAXIMUM_VALUE_CHARACTERS + 1
> + ) * sizeof (CHAR16)); if (Description != NULL) {
> + Char = Description;
> + for (Index = 0; Index < ARRAY_SIZE (ControllerData.Mn); Index++) {
> + *(Char++) = (CHAR16) ControllerData.Mn[Index];
> + }
> + *(Char++) = L' ';
> + for (Index = 0; Index < ARRAY_SIZE (ControllerData.Sn); Index++) {
> + *(Char++) = (CHAR16) ControllerData.Sn[Index];
> + }
> + *(Char++) = L' ';
> + UnicodeValueToStringS (
> + Char, sizeof (CHAR16) * (MAXIMUM_VALUE_CHARACTERS + 1),
> + 0, DevicePath.NvmeNamespace->NamespaceId, 0
> + );
> + BmEliminateExtraSpaces (Description); }
> +
> + return Description;
> +}
> +
> +/**
> Return the boot description for the controller based on the type.
>
> @param Handle Controller handle.
> @@ -606,6 +707,7 @@ BM_GET_BOOT_DESCRIPTION
> mBmBootDescriptionHandlers[] = {
> BmGetDescriptionFromDiskInfo,
> BmGetNetworkDescription,
> BmGetLoadFileDescription,
> + BmGetNvmeDescription,
> BmGetMiscDescription
> };
>
> diff --git a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
> b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
> index 444d4a5..8d7215a 100644
> --- a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
> +++ b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
> @@ -1,7 +1,7 @@
> /** @file
> BDS library definition, include the file and data structure
>
> -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
> (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR> This
> program and the accompanying materials are licensed and made available
> under the terms and conditions of the BSD License @@ -22,6 +22,7 @@
> WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> #include <IndustryStandard/PeImage.h>
> #include <IndustryStandard/Atapi.h>
> #include <IndustryStandard/Scsi.h>
> +#include <IndustryStandard/Nvme.h>
>
> #include <Protocol/PciRootBridgeIo.h>
> #include <Protocol/BlockIo.h>
> @@ -38,6 +39,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
> KIND, EITHER EXPRESS OR IMPLIED.
> #include <Protocol/GraphicsOutput.h>
> #include <Protocol/UsbIo.h>
> #include <Protocol/DiskInfo.h>
> +#include <Protocol/NvmExpressPassthru.h>
> #include <Protocol/IdeControllerInit.h> #include <Protocol/BootLogo.h>
> #include <Protocol/DriverHealth.h> diff --git
> a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> index 6442f22..264d726 100644
> --- a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> +++
> b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> @@ -109,6 +109,7 @@ [Protocols]
> gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
> gEfiGraphicsOutputProtocolGuid ## SOMETIMES_CONSUMES
> gEfiUsbIoProtocolGuid ## SOMETIMES_CONSUMES
> + gEfiNvmExpressPassThruProtocolGuid ## SOMETIMES_CONSUMES
> gEfiDiskInfoProtocolGuid ## SOMETIMES_CONSUMES
> gEfiDriverHealthProtocolGuid ## SOMETIMES_CONSUMES
> gEfiFormBrowser2ProtocolGuid ## SOMETIMES_CONSUMES
> --
> 2.9.0.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
next prev parent reply other threads:[~2017-03-13 2:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-10 7:57 [PATCH] MdeModulePkg/UefiBootManagerLib: Generate boot description for NVME Ruiyu Ni
2017-03-10 10:11 ` Wang, Sunny (HPS SW)
2017-03-13 2:24 ` Ni, Ruiyu [this message]
2017-03-13 2:31 ` Tian, Feng
2017-03-13 2:32 ` Wang, Sunny (HPS SW)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=734D49CCEBEEF84792F5B80ED585239D5B8C88CB@SHSMSX104.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox