mirror of https://github.com/acidanthera/audk.git
ShellPkg: Add extended USB decoding for consistent device names
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: jaben carsey <jaben.carsey@intel.com> Reviewed-by: Joe Peterson <joe.peterson@intel.com> Reviewed-by: Tapan Shah <tapandshah@hp.com> Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16423 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
431dac9441
commit
0db3fade2c
|
@ -15,6 +15,7 @@
|
|||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/SortLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Protocol/UsbIo.h>
|
||||
|
||||
typedef enum {
|
||||
MTDTypeUnknown,
|
||||
|
@ -41,10 +42,12 @@ typedef struct {
|
|||
CHAR16 *Name;
|
||||
} MTD_NAME;
|
||||
|
||||
typedef VOID (EFIAPI *SerialDecodeFucntion) (EFI_DEVICE_PATH_PROTOCOL *DevPath, DEVICE_CONSIST_MAPPING_INFO *MapInfo,EFI_DEVICE_PATH_PROTOCOL *);
|
||||
|
||||
typedef struct {
|
||||
UINT8 Type;
|
||||
UINT8 SubType;
|
||||
VOID (EFIAPI *SerialFun) (EFI_DEVICE_PATH_PROTOCOL *DevPath, DEVICE_CONSIST_MAPPING_INFO *MapInfo);
|
||||
SerialDecodeFucntion SerialFun;
|
||||
INTN (EFIAPI *CompareFun) (EFI_DEVICE_PATH_PROTOCOL *DevPath, EFI_DEVICE_PATH_PROTOCOL *DevPath2);
|
||||
} DEV_PATH_CONSIST_MAPPING_TABLE;
|
||||
|
||||
|
@ -428,7 +431,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialHardDrive (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
HARDDRIVE_DEVICE_PATH *Hd;
|
||||
|
@ -454,7 +458,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialAtapi (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
ATAPI_DEVICE_PATH *Atapi;
|
||||
|
@ -476,7 +481,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialCdRom (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
CDROM_DEVICE_PATH *Cd;
|
||||
|
@ -499,7 +505,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialFibre (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
FIBRECHANNEL_DEVICE_PATH *Fibre;
|
||||
|
@ -522,7 +529,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialUart (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
UART_DEVICE_PATH *Uart;
|
||||
|
@ -547,10 +555,16 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialUsb (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
USB_DEVICE_PATH *Usb;
|
||||
USB_DEVICE_PATH *Usb;
|
||||
EFI_USB_IO_PROTOCOL *UsbIo;
|
||||
EFI_HANDLE TempHandle;
|
||||
EFI_STATUS Status;
|
||||
USB_INTERFACE_DESCRIPTOR InterfaceDesc;
|
||||
|
||||
|
||||
ASSERT(DevicePathNode != NULL);
|
||||
ASSERT(MappingItem != NULL);
|
||||
|
@ -558,6 +572,35 @@ DevPathSerialUsb (
|
|||
Usb = (USB_DEVICE_PATH *) DevicePathNode;
|
||||
AppendCSDNum (MappingItem, Usb->ParentPortNumber);
|
||||
AppendCSDNum (MappingItem, Usb->InterfaceNumber);
|
||||
|
||||
if (PcdGetBool(PcdUsbExtendedDecode)) {
|
||||
Status = gBS->LocateDevicePath( &gEfiUsbIoProtocolGuid, &DevicePath, &TempHandle );
|
||||
UsbIo = NULL;
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = gBS->OpenProtocol(TempHandle, &gEfiUsbIoProtocolGuid, (VOID**)&UsbIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR(Status)) {
|
||||
ASSERT(UsbIo != NULL);
|
||||
Status = UsbIo->UsbGetInterfaceDescriptor(UsbIo, &InterfaceDesc);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
if (InterfaceDesc.InterfaceClass == USB_MASS_STORE_CLASS && MappingItem->Mtd == MTDTypeUnknown) {
|
||||
switch (InterfaceDesc.InterfaceSubClass){
|
||||
case USB_MASS_STORE_SCSI:
|
||||
MappingItem->Mtd = MTDTypeHardDisk;
|
||||
break;
|
||||
case USB_MASS_STORE_8070I:
|
||||
case USB_MASS_STORE_UFI:
|
||||
MappingItem->Mtd = MTDTypeFloppy;
|
||||
break;
|
||||
case USB_MASS_STORE_8020I:
|
||||
MappingItem->Mtd = MTDTypeCDRom;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -571,7 +614,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialVendor (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
VENDOR_DEVICE_PATH *Vendor;
|
||||
|
@ -603,14 +647,14 @@ DevPathSerialVendor (
|
|||
ASSERT(Buffer != NULL);
|
||||
if (Buffer == NULL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Build the string data
|
||||
//
|
||||
for (Index = 0; Index < TargetNameLength; Index++) {
|
||||
Buffer = CatSPrint (Buffer, L"%02x", *((UINT8*)Vendor + sizeof (VENDOR_DEVICE_PATH) + Index));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Append the new data block
|
||||
|
@ -632,7 +676,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialLun (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
DEVICE_LOGICAL_UNIT_DEVICE_PATH *Lun;
|
||||
|
@ -654,7 +699,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialSata (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
SATA_DEVICE_PATH *Sata;
|
||||
|
@ -678,7 +724,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialIScsi (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
ISCSI_DEVICE_PATH *IScsi;
|
||||
|
@ -721,7 +768,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialI2O (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
I2O_DEVICE_PATH *DevicePath_I20;
|
||||
|
@ -743,7 +791,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialMacAddr (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
MAC_ADDR_DEVICE_PATH *Mac;
|
||||
|
@ -779,7 +828,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialInfiniBand (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
INFINIBAND_DEVICE_PATH *InfiniBand;
|
||||
|
@ -811,7 +861,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialIPv4 (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
IPv4_DEVICE_PATH *Ip;
|
||||
|
@ -855,7 +906,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialIPv6 (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
IPv6_DEVICE_PATH *Ip;
|
||||
|
@ -891,7 +943,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialScsi (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
SCSI_DEVICE_PATH *Scsi;
|
||||
|
@ -914,7 +967,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerial1394 (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
F1394_DEVICE_PATH *DevicePath_F1394;
|
||||
|
@ -938,7 +992,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialAcpi (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
ACPI_HID_DEVICE_PATH *Acpi;
|
||||
|
@ -967,7 +1022,8 @@ VOID
|
|||
EFIAPI
|
||||
DevPathSerialDefault (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem
|
||||
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
return;
|
||||
|
@ -1209,21 +1265,22 @@ GetDeviceConsistMappingInfo (
|
|||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
VOID (EFIAPI *SerialFun) (EFI_DEVICE_PATH_PROTOCOL *, DEVICE_CONSIST_MAPPING_INFO *);
|
||||
|
||||
UINTN Index;
|
||||
SerialDecodeFucntion SerialFun;
|
||||
UINTN Index;
|
||||
EFI_DEVICE_PATH_PROTOCOL *OriginalDevicePath;
|
||||
|
||||
ASSERT(DevicePath != NULL);
|
||||
ASSERT(MappingItem != NULL);
|
||||
|
||||
SetMem (&MappingItem->Csd, sizeof (POOL_PRINT), 0);
|
||||
OriginalDevicePath = DevicePath;
|
||||
|
||||
while (!IsDevicePathEnd (DevicePath)) {
|
||||
//
|
||||
// Find the handler to dump this device path node
|
||||
// Find the handler to dump this device path node and
|
||||
// initialize with generic function in case nothing is found
|
||||
//
|
||||
SerialFun = NULL;
|
||||
for (Index = 0; DevPathConsistMappingTable[Index].SerialFun != NULL; Index += 1) {
|
||||
for (SerialFun = DevPathSerialDefault, Index = 0; DevPathConsistMappingTable[Index].SerialFun != NULL; Index += 1) {
|
||||
|
||||
if (DevicePathType (DevicePath) == DevPathConsistMappingTable[Index].Type &&
|
||||
DevicePathSubType (DevicePath) == DevPathConsistMappingTable[Index].SubType
|
||||
|
@ -1232,14 +1289,8 @@ GetDeviceConsistMappingInfo (
|
|||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
// If not found, use a generic function
|
||||
//
|
||||
if (!SerialFun) {
|
||||
SerialFun = DevPathSerialDefault;
|
||||
}
|
||||
|
||||
SerialFun (DevicePath, MappingItem);
|
||||
SerialFun (DevicePath, MappingItem, OriginalDevicePath);
|
||||
|
||||
//
|
||||
// Next device path node
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
gEfiShellProtocolGuid # ALWAYS_CONSUMED
|
||||
gEfiShellParametersProtocolGuid # ALWAYS_CONSUMED
|
||||
gEfiShellDynamicCommandProtocolGuid # SOMETIMES_CONSUMED
|
||||
gEfiUsbIoProtocolGuid ## SOMETIMES_CONSUMED
|
||||
|
||||
[Guids]
|
||||
gEfiSasDevicePathGuid # ALWAYS_CONSUMED
|
||||
|
@ -60,6 +61,7 @@
|
|||
[Pcd.common]
|
||||
gEfiShellPkgTokenSpaceGuid.PcdShellSupportLevel ## ALWAYS_CONSUMED
|
||||
gEfiShellPkgTokenSpaceGuid.PcdShellMapNameLength ## ALWAYS_CONSUMED
|
||||
gEfiShellPkgTokenSpaceGuid.PcdUsbExtendedDecode ## SOMETIMES_CONSUMED
|
||||
gEfiShellPkgTokenSpaceGuid.PcdShellDecodeIScsiMapNames ## SOMETIMES_CONSUMED
|
||||
gEfiShellPkgTokenSpaceGuid.PcdShellVendorExtendedDecode ## SOMETIMES_CONSUMED
|
||||
|
||||
|
|
|
@ -129,6 +129,9 @@
|
|||
## Unicode string of the shell supplier
|
||||
gEfiShellPkgTokenSpaceGuid.PcdShellSupplier|L"EDK II"|VOID*|0x00000010
|
||||
|
||||
## Do extended decode of USB for determining media type
|
||||
gEfiShellPkgTokenSpaceGuid.PcdUsbExtendedDecode|TRUE|BOOLEAN|0x00000011
|
||||
|
||||
## Do iSCSI decode for map names.
|
||||
# This is disabled by default due to the length of generated strings
|
||||
gEfiShellPkgTokenSpaceGuid.PcdShellDecodeIScsiMapNames|FALSE|BOOLEAN|0x00000012
|
||||
|
|
Loading…
Reference in New Issue