diff --git a/lib/libefivar/efivar-dp-format.c b/lib/libefivar/efivar-dp-format.c index e2a5e666ce7..0062216ac30 100644 --- a/lib/libefivar/efivar-dp-format.c +++ b/lib/libefivar/efivar-dp-format.c @@ -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) { // diff --git a/lib/libefivar/efivar-dp-parse.c b/lib/libefivar/efivar-dp-parse.c index a4c7cff57c0..c6ea7bc00a5 100644 --- a/lib/libefivar/efivar-dp-parse.c +++ b/lib/libefivar/efivar-dp-parse.c @@ -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));