git: 492d9953fa2a - main - libefivar: Handle AcpiExp device path when optional para is not specified
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 27 Feb 2022 16:47:52 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=492d9953fa2a2bfe961e3f361462f0a97bec1ee7 commit 492d9953fa2a2bfe961e3f361462f0a97bec1ee7 Author: Jose Luis Duran <jlduran@gmail.com> AuthorDate: 2022-02-23 17:04:02 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2022-02-27 16:13:31 +0000 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: https://github.com/tianocore/edk2/commit/a8b5750901faa63ff5570634851e648b8e335e5a Pull Request: https://github.com/freebsd/freebsd-src/pull/581 --- lib/libefivar/efivar-dp-format.c | 23 ++++++++++++++++------- lib/libefivar/efivar-dp-parse.c | 11 ++++++++++- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/lib/libefivar/efivar-dp-format.c b/lib/libefivar/efivar-dp-format.c index e2a5e666ce7b..0062216ac307 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 a4c7cff57c06..c6ea7bc00a57 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));