Skip to content

Commit

Permalink
MdePkg: Handle AcpiExp device path when optional para is not specified
Browse files Browse the repository at this point in the history
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1243

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.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
  • Loading branch information
dandanbi authored and lgao4 committed Oct 24, 2018
1 parent 3874108 commit a8b5750
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
11 changes: 10 additions & 1 deletion MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,16 @@ DevPathFromTextAcpiExp (
);

AcpiEx->HID = EisaIdFromText (HIDStr);
AcpiEx->CID = EisaIdFromText (CIDStr);
//
// According to UEFI spec, the CID parametr is optional and has a default value of 0.
// So when the CID parametr 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 == L'\0' || *CIDStr == L'0') {
AcpiEx->CID = 0;
} else {
AcpiEx->CID = EisaIdFromText (CIDStr);
}
AcpiEx->UID = 0;

AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
Expand Down
23 changes: 16 additions & 7 deletions MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,13 +480,22 @@ DevPathToTextAcpiEx (
//
// use AcpiExp()
//
UefiDevicePathLibCatPrint (
Str,
L"AcpiExp(%s,%s,%a)",
HIDText,
CIDText,
UIDStr
);
if (AcpiEx->CID == 0) {
UefiDevicePathLibCatPrint (
Str,
L"AcpiExp(%s,0,%a)",
HIDText,
UIDStr
);
} else {
UefiDevicePathLibCatPrint (
Str,
L"AcpiExp(%s,%s,%a)",
HIDText,
CIDText,
UIDStr
);
}
} else {
if (AllowShortcuts) {
//
Expand Down

0 comments on commit a8b5750

Please sign in to comment.