Inconsistent SATA DevicePath naming in UEFI

110 views Asked by At

I am trying to have ability to distinguish various SATA disks in UEFI. I try to use DevicePath for this. I use protocol gEfiDevicePathProtocolGuid to retrieve DevicePath and after i convert it to text by ConvertDevicePathToText function. The issue is naming not being consistent. Sometimes SATA part of DevicePath has 3 fields, and sometimes only 2.

DevicePath for BlockIO handles looks like this:

PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x1,0x0)/HD...

And DevicePath for SimpleFileSystem handles looks like this:

PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x1,0xFFFF,0x0)/HD...

UEFI specification says that number 0xFFFF is PMPN (port multiplier) with default value 0xFFFF and it is optional if there is no port multiplier. Is there a way to reliably get DevicePath with same format (whether PMPN field is always present or always ignored)? I try to distinguish physical disks by comparing their Sata part of DevicePath, and because of this inconsistency i'm unable to do so.

1

There are 1 answers

0
user2779778 On

Functions ConvertDevicePathToText from protocol gEfiDevicePathToTextProtocolGuid and from EDK2 "UEFI Device Path Library" generate different output. Looks like converter from built-in protocol creates invalid path (missing 0xffff field) and converter from EDK2 library is valid.

CHAR16    *InvalidDevicePath = 0;
CHAR16    *ValidDevicePath = 0;

Status = gBS->LocateProtocol( &gEfiDevicePathToTextProtocolGuid, NULL, (VOID**)&Device2TextProtocol );
if (EFI_ERROR(Status)) {    
    return -1;
} 

InvalidDevicePath = Device2TextProtocol->ConvertDevicePathToText(DiskDevicePath, FALSE, FALSE); // Sata(0x1,0x0)
ValidDevicePath = ConvertDevicePathToText(DiskDevicePath, FALSE, FALSE); // Sata(0x1,0xFFFF,0x0)