* [PATCH] MdeModulePkg: Improved ScsiDiskDxe driver updates ControllerNameTable with common string SCSI Disk Device for all SCSI disk
@ 2022-10-17 6:52 Cheripally Gopi
2022-10-18 4:05 ` Wu, Hao A
0 siblings, 1 reply; 4+ messages in thread
From: Cheripally Gopi @ 2022-10-17 6:52 UTC (permalink / raw)
To: devel@edk2.groups.io; +Cc: Sundaresan S, Vasudevan S, Vasudevan S, Gaoliming
ScsiDiskDxe driver updates ControllerNameTable with common string SCSI Disk Device for all SCSI disk.due to this, when multiple SCSI disk devices connected, facing difficulty in identifying correct SCSI disk device.
As per SCSI spec, standard Inquiry Data is having the fields to know Vendor and Product information.
Update "ControllerNameTable" with Vendor and Product information. So that, device specific name can be retrieved using ComponentName protocol.
Signed-off-by:
Cheripally Gopi <gopic@ami.com>
CC: Sundaresan S <sundaresans@ami.com>
CC: Vasudevan S <vasudevans@ami.com>
CC: Gaoliming <gaoliming@byosoft.com.cn>
---
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 49 ++++++++++++++++++-
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h | 8 +++
.../Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf | 1 +
3 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
index 98e84b4ea8..3d05b01f8d 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
+++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
@@ -67,6 +67,32 @@ FreeAlignedBuffer (
}
}
+/**
+ Remove trailing spaces from the string
+
+ @param String The ASCII string to remove the trailing spaces
+
+ @retval the new length of the string
+**/
+UINTN
+RemoveTrailingSpaces (
+ IN OUT CHAR8 *String
+)
+{
+ UINTN Length = AsciiStrLen (String);
+
+ if (Length == 0) {
+ return 0;
+ }
+
+ while ((Length > 0) && (String[Length-1] == ' ')) {
+ Length--;
+ }
+
+ String[Length] = 0;
+ return Length;
+}
+
/**
The user Entry Point for module ScsiDisk.
@@ -203,6 +229,9 @@ ScsiDiskDriverBindingStart (
UINT8 MaxRetry;
BOOLEAN NeedRetry;
BOOLEAN MustReadCapacity;
+ CHAR8 VendorStr[VENDOR_IDENTIFICATION_LENGTH + 1];
+ CHAR8 ProductStr[PRODUCT_IDENTIFICATION_LENGTH + 1];
+ CHAR16 DeviceStr[VENDOR_IDENTIFICATION_LENGTH + PRODUCT_IDENTIFICATION_LENGTH + 2];
MustReadCapacity = TRUE;
@@ -354,19 +383,35 @@ ScsiDiskDriverBindingStart (
}
}
+ CopyMem (
+ VendorStr,
+ &ScsiDiskDevice->InquiryData.Reserved_5_95[VENDOR_IDENTIFICATION_OFFSET],
+ VENDOR_IDENTIFICATION_LENGTH);
+ VendorStr[VENDOR_IDENTIFICATION_LENGTH] = 0;
+ RemoveTrailingSpaces (VendorStr);
+
+ CopyMem (
+ ProductStr,
+ &ScsiDiskDevice->InquiryData.Reserved_5_95[PRODUCT_IDENTIFICATION_OFFSET],
+ PRODUCT_IDENTIFICATION_LENGTH);
+ ProductStr[PRODUCT_IDENTIFICATION_LENGTH] = 0;
+ RemoveTrailingSpaces (ProductStr);
+
+ UnicodeSPrint (DeviceStr, sizeof (DeviceStr), L"%a %a", VendorStr, ProductStr);
+
ScsiDiskDevice->ControllerNameTable = NULL;
AddUnicodeString2 (
"eng",
gScsiDiskComponentName.SupportedLanguages,
&ScsiDiskDevice->ControllerNameTable,
- L"SCSI Disk Device",
+ DeviceStr,
TRUE
);
AddUnicodeString2 (
"en",
gScsiDiskComponentName2.SupportedLanguages,
&ScsiDiskDevice->ControllerNameTable,
- L"SCSI Disk Device",
+ DeviceStr,
FALSE
);
return EFI_SUCCESS;
diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
index d54282df5f..1a43c5030e 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
+++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
@@ -30,6 +30,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/UefiScsiLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DevicePathLib.h>
+#include <Library/PrintLib.h>
#include <IndustryStandard/Scsi.h>
#include <IndustryStandard/Atapi.h>
@@ -179,6 +180,13 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2;
#define SCSI_COMMAND_VERSION_2 0x02
#define SCSI_COMMAND_VERSION_3 0x03
+// Per SCSI spec, EFI_SCSI_INQUIRY_DATA.Reserved_5_95[3 - 10] has the Vendor identification
+// EFI_SCSI_INQUIRY_DATA.Reserved_5_95[11 - 26] has the product identification
+#define VENDOR_IDENTIFICATION_OFFSET 3
+#define VENDOR_IDENTIFICATION_LENGTH 8
+#define PRODUCT_IDENTIFICATION_OFFSET 11
+#define PRODUCT_IDENTIFICATION_LENGTH 16
+
//
// SCSI Disk Timeout Experience Value
//
diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
index 40818e669b..f03ba1b1ea 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
+++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
@@ -46,6 +46,7 @@
UefiDriverEntryPoint
DebugLib
DevicePathLib
+ PrintLib
[Protocols]
gEfiDiskInfoProtocolGuid ## BY_START
--
2.33.0.windows.2
-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] MdeModulePkg: Improved ScsiDiskDxe driver updates ControllerNameTable with common string SCSI Disk Device for all SCSI disk
2022-10-17 6:52 [PATCH] MdeModulePkg: Improved ScsiDiskDxe driver updates ControllerNameTable with common string SCSI Disk Device for all SCSI disk Cheripally Gopi
@ 2022-10-18 4:05 ` Wu, Hao A
2022-10-26 13:44 ` [edk2-devel] " gopic
0 siblings, 1 reply; 4+ messages in thread
From: Wu, Hao A @ 2022-10-18 4:05 UTC (permalink / raw)
To: devel@edk2.groups.io, gopic@ami.com
Cc: Selvaraj, Sundaresan, Sambandan, Vasudevan, Gao, Liming
Thanks for the patch.
Could you help to do a favor and create a pull request for the proposed patch?
You can follow the steps 10 & 11 in the below wiki link to do so:
https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Development-Process#the-developer-process-for-the-edk-ii-project
Best Regards,
Hao Wu
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Cheripally
> Gopi via groups.io
> Sent: Monday, October 17, 2022 2:53 PM
> To: devel@edk2.groups.io
> Cc: Selvaraj, Sundaresan <sundaresans@ami.com>; Sambandan, Vasudevan
> <vasudevans@ami.com>; Sambandan, Vasudevan <vasudevans@ami.com>;
> Gao, Liming <gaoliming@byosoft.com.cn>
> Subject: [edk2-devel] [PATCH] MdeModulePkg: Improved ScsiDiskDxe driver
> updates ControllerNameTable with common string SCSI Disk Device for all SCSI
> disk
>
> ScsiDiskDxe driver updates ControllerNameTable with common string SCSI Disk
> Device for all SCSI disk.due to this, when multiple SCSI disk devices connected,
> facing difficulty in identifying correct SCSI disk device.
> As per SCSI spec, standard Inquiry Data is having the fields to know Vendor and
> Product information.
> Update "ControllerNameTable" with Vendor and Product information. So that,
> device specific name can be retrieved using ComponentName protocol.
>
> Signed-off-by:
> Cheripally Gopi <gopic@ami.com>
>
> CC: Sundaresan S <sundaresans@ami.com>
> CC: Vasudevan S <vasudevans@ami.com>
> CC: Gaoliming <gaoliming@byosoft.com.cn>
>
>
> ---
> MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 49 ++++++++++++++++++-
> MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h | 8 +++
> .../Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf | 1 +
> 3 files changed, 56 insertions(+), 2 deletions(-)
>
> diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> index 98e84b4ea8..3d05b01f8d 100644
> --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> @@ -67,6 +67,32 @@ FreeAlignedBuffer (
> }
>
> }
>
>
>
> +/**
>
> + Remove trailing spaces from the string
>
> +
>
> + @param String The ASCII string to remove the trailing spaces
>
> +
>
> + @retval the new length of the string
>
> +**/
>
> +UINTN
>
> +RemoveTrailingSpaces (
>
> + IN OUT CHAR8 *String
>
> +)
>
> +{
>
> + UINTN Length = AsciiStrLen (String);
>
> +
>
> + if (Length == 0) {
>
> + return 0;
>
> + }
>
> +
>
> + while ((Length > 0) && (String[Length-1] == ' ')) {
>
> + Length--;
>
> + }
>
> +
>
> + String[Length] = 0;
>
> + return Length;
>
> +}
>
> +
>
> /**
>
> The user Entry Point for module ScsiDisk.
>
>
>
> @@ -203,6 +229,9 @@ ScsiDiskDriverBindingStart (
> UINT8 MaxRetry;
>
> BOOLEAN NeedRetry;
>
> BOOLEAN MustReadCapacity;
>
> + CHAR8 VendorStr[VENDOR_IDENTIFICATION_LENGTH + 1];
>
> + CHAR8 ProductStr[PRODUCT_IDENTIFICATION_LENGTH + 1];
>
> + CHAR16 DeviceStr[VENDOR_IDENTIFICATION_LENGTH +
> PRODUCT_IDENTIFICATION_LENGTH + 2];
>
>
>
> MustReadCapacity = TRUE;
>
>
>
> @@ -354,19 +383,35 @@ ScsiDiskDriverBindingStart (
> }
>
> }
>
>
>
> + CopyMem (
>
> + VendorStr,
>
> +
> + &ScsiDiskDevice-
> >InquiryData.Reserved_5_95[VENDOR_IDENTIFICATION_OFFSE
> + T],
>
> + VENDOR_IDENTIFICATION_LENGTH);
>
> + VendorStr[VENDOR_IDENTIFICATION_LENGTH] = 0;
>
> + RemoveTrailingSpaces (VendorStr);
>
> +
>
> + CopyMem (
>
> + ProductStr,
>
> +
> + &ScsiDiskDevice-
> >InquiryData.Reserved_5_95[PRODUCT_IDENTIFICATION_OFFS
> + ET],
>
> + PRODUCT_IDENTIFICATION_LENGTH);
>
> + ProductStr[PRODUCT_IDENTIFICATION_LENGTH] = 0;
>
> + RemoveTrailingSpaces (ProductStr);
>
> +
>
> + UnicodeSPrint (DeviceStr, sizeof (DeviceStr), L"%a %a",
> + VendorStr, ProductStr);
>
> +
>
> ScsiDiskDevice->ControllerNameTable = NULL;
>
> AddUnicodeString2 (
>
> "eng",
>
> gScsiDiskComponentName.SupportedLanguages,
>
> &ScsiDiskDevice->ControllerNameTable,
>
> - L"SCSI Disk Device",
>
> + DeviceStr,
>
> TRUE
>
> );
>
> AddUnicodeString2 (
>
> "en",
>
> gScsiDiskComponentName2.SupportedLanguages,
>
> &ScsiDiskDevice->ControllerNameTable,
>
> - L"SCSI Disk Device",
>
> + DeviceStr,
>
> FALSE
>
> );
>
> return EFI_SUCCESS;
>
> diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
> b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
> index d54282df5f..1a43c5030e 100644
> --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
> +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
> @@ -30,6 +30,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include
> <Library/UefiScsiLib.h>
>
> #include <Library/UefiBootServicesTableLib.h>
>
> #include <Library/DevicePathLib.h>
>
> +#include <Library/PrintLib.h>
>
>
>
> #include <IndustryStandard/Scsi.h>
>
> #include <IndustryStandard/Atapi.h>
>
> @@ -179,6 +180,13 @@ extern EFI_COMPONENT_NAME2_PROTOCOL
> gScsiDiskComponentName2; #define SCSI_COMMAND_VERSION_2 0x02
>
> #define SCSI_COMMAND_VERSION_3 0x03
>
>
>
> +// Per SCSI spec, EFI_SCSI_INQUIRY_DATA.Reserved_5_95[3 - 10] has the
> +Vendor identification
>
> +// EFI_SCSI_INQUIRY_DATA.Reserved_5_95[11 - 26] has the product
> +identification
>
> +#define VENDOR_IDENTIFICATION_OFFSET 3
>
> +#define VENDOR_IDENTIFICATION_LENGTH 8
>
> +#define PRODUCT_IDENTIFICATION_OFFSET 11
>
> +#define PRODUCT_IDENTIFICATION_LENGTH 16
>
> +
>
> //
>
> // SCSI Disk Timeout Experience Value
>
> //
>
> diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
> b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
> index 40818e669b..f03ba1b1ea 100644
> --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
> +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
> @@ -46,6 +46,7 @@
> UefiDriverEntryPoint
>
> DebugLib
>
> DevicePathLib
>
> + PrintLib
>
>
>
> [Protocols]
>
> gEfiDiskInfoProtocolGuid ## BY_START
>
> --
> 2.33.0.windows.2
> -The information contained in this message may be confidential and
> proprietary to American Megatrends (AMI). This communication is intended to
> be read only by the individual or entity to whom it is addressed or by their
> designee. If the reader of this message is not the intended recipient, you are on
> notice that any distribution of this message, in any form, is strictly prohibited.
> Please promptly notify the sender by reply e-mail or by telephone at 770-246-
> 8600, and then delete or destroy all copies of the transmission.
>
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [edk2-devel] [PATCH] MdeModulePkg: Improved ScsiDiskDxe driver updates ControllerNameTable with common string SCSI Disk Device for all SCSI disk
2022-10-18 4:05 ` Wu, Hao A
@ 2022-10-26 13:44 ` gopic
2022-10-27 2:48 ` Wu, Hao A
0 siblings, 1 reply; 4+ messages in thread
From: gopic @ 2022-10-26 13:44 UTC (permalink / raw)
To: Wu, Hao A, devel
[-- Attachment #1: Type: text/plain, Size: 234 bytes --]
created pull request.
Pull request link: MdeModulePkg/ScsiDiskDxe: Update proper device name for ScsiDisk drives by GopiCheripally · Pull Request #3537 · tianocore/edk2 (github.com) ( https://github.com/tianocore/edk2/pull/3537 )
[-- Attachment #2: Type: text/html, Size: 265 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [edk2-devel] [PATCH] MdeModulePkg: Improved ScsiDiskDxe driver updates ControllerNameTable with common string SCSI Disk Device for all SCSI disk
2022-10-26 13:44 ` [edk2-devel] " gopic
@ 2022-10-27 2:48 ` Wu, Hao A
0 siblings, 0 replies; 4+ messages in thread
From: Wu, Hao A @ 2022-10-27 2:48 UTC (permalink / raw)
To: gopic@ami.com, devel@edk2.groups.io
[-- Attachment #1: Type: text/plain, Size: 1055 bytes --]
Thanks a lot.
Just one minor comment, in RemoveTrailingSpaces(), could you help to refine:
String[Length] = 0;
to:
String[Length] = '\0';
Also, could you help to send a V2 patch (the change made in the below pull request) to the mailing list?
(Mainly step 12 in https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Development-Process#the-developer-process-for-the-edk-ii-project)
I will follow up with the code reviewing and merging. Thanks in advance.
Best Regards,
Hao Wu
From: gopic via groups.io <gopic=ami.com@groups.io>
Sent: Wednesday, October 26, 2022 9:44 PM
To: Wu; Wu, Hao A <hao.a.wu@intel.com>; devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg: Improved ScsiDiskDxe driver updates ControllerNameTable with common string SCSI Disk Device for all SCSI disk
created pull request.
Pull request link: MdeModulePkg/ScsiDiskDxe: Update proper device name for ScsiDisk drives by GopiCheripally · Pull Request #3537 · tianocore/edk2 (github.com)<https://github.com/tianocore/edk2/pull/3537>
[-- Attachment #2: Type: text/html, Size: 3771 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-10-27 2:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-17 6:52 [PATCH] MdeModulePkg: Improved ScsiDiskDxe driver updates ControllerNameTable with common string SCSI Disk Device for all SCSI disk Cheripally Gopi
2022-10-18 4:05 ` Wu, Hao A
2022-10-26 13:44 ` [edk2-devel] " gopic
2022-10-27 2:48 ` Wu, Hao A
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox