aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Luis Duran <jlduran@gmail.com>2022-02-23 17:04:02 +0000
committerWarner Losh <imp@FreeBSD.org>2022-02-27 16:13:31 +0000
commit492d9953fa2a2bfe961e3f361462f0a97bec1ee7 (patch)
treeef2aba712ab9e62225fb23d7877222054bcab8c2
parent965f85271c11e6c5901c09984472fa74d2266e1c (diff)
downloadsrc-492d9953fa2a2bfe961e3f361462f0a97bec1ee7.tar.gz
src-492d9953fa2a2bfe961e3f361462f0a97bec1ee7.zip
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
-rw-r--r--lib/libefivar/efivar-dp-format.c23
-rw-r--r--lib/libefivar/efivar-dp-parse.c11
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));