Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/MemoryAllocationLib.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/DevicePath.h>
#include <Guid/PcAnsi.h>
#include <Guid/TtyTerm.h>

VOID
TestPointDumpDevicePath (
Expand Down Expand Up @@ -71,6 +73,42 @@ TestPointDumpDevicePath (
return ;
}

STATIC
BOOLEAN
IsTerminalVendorNode (
EFI_DEVICE_PATH_PROTOCOL *Node
)
{
STATIC CONST EFI_GUID *mTerminalGuids[] = {
&gEfiPcAnsiGuid,
&gEfiVT100Guid,
&gEfiVT100PlusGuid,
&gEfiVTUTF8Guid,
&gEfiTtyTermGuid,
&gEdkiiLinuxTermGuid,
&gEdkiiXtermR6Guid,
&gEdkiiVT400Guid,
&gEdkiiSCOTermGuid
};
UINTN Index;

if ((Node == NULL) ||
(DevicePathType (Node) != MESSAGING_DEVICE_PATH) ||
(DevicePathSubType (Node) != MSG_VENDOR_DP) ||
(DevicePathNodeLength (Node) != sizeof (VENDOR_DEVICE_PATH)))
{
return FALSE;
}

for (Index = 0; Index < ARRAY_SIZE (mTerminalGuids); Index++) {
if (CompareGuid (&((VENDOR_DEVICE_PATH *)Node)->Guid, mTerminalGuids[Index])) {
return TRUE;
}
}

return FALSE;
}

/**
The DevicePathNode is a single instance.
The DevicePathNodeSize must not include END_DEVICE_PATH.
Expand All @@ -88,6 +126,9 @@ IsDevicePathNodeExist (
EFI_STATUS Status;
BOOLEAN Result;
UINTN DevicePathSize;
EFI_DEVICE_PATH_PROTOCOL *Node;
EFI_DEVICE_PATH_PROTOCOL *LastNode;


if (DevicePathType (DevicePathNode) == HARDWARE_DEVICE_PATH ||
DevicePathType (DevicePathNode) == ACPI_DEVICE_PATH) {
Expand All @@ -104,6 +145,14 @@ IsDevicePathNodeExist (
goto Done ;
}

// loop until LastNode holds the node previous to the DevicePath End node
Node = DevicePathNode;
LastNode = NULL;
while (!IsDevicePathEnd (Node)) {
LastNode = Node;
Node = NextDevicePathNode (Node);
}

for (Index = 0; Index < HandleCount; Index++) {
Status = gBS->HandleProtocol (
HandleBuf[Index],
Expand All @@ -117,6 +166,10 @@ IsDevicePathNodeExist (
if (DevicePathSize != DevicePathNodeSize + sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
continue;
}
// If the DevicePath has a Terminal child device, subtract the size of TerminalNode
if (LastNode != NULL && IsTerminalVendorNode (LastNode)) {
DevicePathNodeSize -= sizeof(VENDOR_DEVICE_PATH);
}
if (CompareMem (DevicePath, DevicePathNode, DevicePathNodeSize) == 0) {
Result = TRUE;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@
gEfiImageSecurityDatabaseGuid
gSmiHandlerProfileGuid
gEdkiiPiSmmCommunicationRegionTableGuid
gEfiTtyTermGuid
gEfiPcAnsiGuid
gEfiVT100Guid
gEfiVT100PlusGuid
gEfiVTUTF8Guid
gEfiTtyTermGuid
gEdkiiLinuxTermGuid
gEdkiiXtermR6Guid
gEdkiiVT400Guid
gEdkiiSCOTermGuid

[Protocols]
gEfiPciIoProtocolGuid
Expand Down