libefivar: Handle AcpiExp device path when optional para is not specified

AcpiExp text device path: AcpiExp(HID,CID,UIDSTR)
And according to UEFI spec, the CID parameter is optional
and has a default value of 0. But current implementation
miss to check following cases for the AcpiExp.
FromText: when text device is AcpiExp(HID,,UIDSTR)/AcpiExp(HID,0,UIDSTR)
ToText: when the CID is 0 in the node structure

This commit is to do the enhancement.

Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=1243
Obtained from:	a8b5750901
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
This commit is contained in:
Jose Luis Duran 2022-02-23 14:04:02 -03:00 committed by Warner Losh
parent 965f85271c
commit 492d9953fa
2 changed files with 26 additions and 8 deletions

View file

@ -539,13 +539,22 @@ DevPathToTextAcpiEx (
//
// use AcpiExp()
//
UefiDevicePathLibCatPrint (
Str,
"AcpiExp(%s,%s,%s)",
HIDText,
CIDText,
UIDStr
);
if (AcpiEx->CID == 0) {
UefiDevicePathLibCatPrint (
Str,
"AcpiExp(%s,0,%s)",
HIDText,
UIDStr
);
} else {
UefiDevicePathLibCatPrint (
Str,
"AcpiExp(%s,%s,%s)",
HIDText,
CIDText,
UIDStr
);
}
} else {
if (AllowShortcuts) {
//

View file

@ -1014,7 +1014,16 @@ DevPathFromTextAcpiExp (
);
AcpiEx->HID = EisaIdFromText (HIDStr);
AcpiEx->CID = EisaIdFromText (CIDStr);
//
// According to UEFI spec, the CID parameter is optional and has a default value of 0.
// So when the CID parameter is not specified or specified as 0 in the text device node.
// Set the CID to 0 in the ACPI extension device path structure.
//
if (*CIDStr == '\0' || *CIDStr == '0') {
AcpiEx->CID = 0;
} else {
AcpiEx->CID = EisaIdFromText (CIDStr);
}
AcpiEx->UID = 0;
AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));