All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Holmes-Mitra <dholmesm@google.com>
To: u-boot@lists.u-boot-project.org
Cc: "Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	"Tom Rini" <trini@konsulko.com>,
	"Vincent Stehlé" <vincent.stehle@arm.com>
Subject: [PATCH 1/2] efi_loader: Add PCI hardware device path node and text conversion
Date: Thu, 03 Dec 2026 02:21:19 GMT	[thread overview]
Message-ID: <20261203022028.05-01-dholmesm@google.com> (raw)
In-Reply-To: <20261203022028.05-00-dholmesm@google.com>

Define DEVICE_PATH_SUB_TYPE_PCI and struct efi_device_path_pci per
UEFI Specification Section 10.3.1.1, format PCI hardware nodes as
Pci(0x<device>,0x<function>) in EFI_DEVICE_PATH_TO_TEXT_PROTOCOL, and
add unit test coverage in efi_selftest_devicepath.

Signed-off-by: Dan Holmes-Mitra <dholmesm@google.com>
---
 include/efi_api.h                          |  7 +++++
 lib/efi_loader/efi_device_path_to_text.c   |  6 ++++
 lib/efi_selftest/efi_selftest_devicepath.c | 33 ++++++++++++++++++++++
 3 files changed, 46 insertions(+)

diff --git a/include/efi_api.h b/include/efi_api.h
index 646581150b..6b199ab8dc 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -646,10 +646,17 @@ struct efi_mac_addr {
 } __packed;
 
 #define DEVICE_PATH_TYPE_HARDWARE_DEVICE	0x01
+#  define DEVICE_PATH_SUB_TYPE_PCI		0x01
 #  define DEVICE_PATH_SUB_TYPE_MEMORY		0x03
 #  define DEVICE_PATH_SUB_TYPE_VENDOR		0x04
 #  define DEVICE_PATH_SUB_TYPE_CONTROLLER	0x05
 
+struct efi_device_path_pci {
+	struct efi_device_path dp;
+	u8 function;
+	u8 device;
+} __packed;
+
 struct efi_device_path_memory {
 	struct efi_device_path dp;
 	u32 memory_type;
diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c
index 452ec1b2e8..01e0b4a6e2 100644
--- a/lib/efi_loader/efi_device_path_to_text.c
+++ b/lib/efi_loader/efi_device_path_to_text.c
@@ -53,6 +53,12 @@ static char *dp_unknown(char *s, struct efi_device_path *dp)
 static char *dp_hardware(char *s, struct efi_device_path *dp)
 {
 	switch (dp->sub_type) {
+	case DEVICE_PATH_SUB_TYPE_PCI: {
+		struct efi_device_path_pci *pdp =
+			(struct efi_device_path_pci *)dp;
+		s += sprintf(s, "Pci(0x%x,0x%x)", pdp->device, pdp->function);
+		break;
+	}
 	case DEVICE_PATH_SUB_TYPE_MEMORY: {
 		struct efi_device_path_memory *mdp =
 			(struct efi_device_path_memory *)dp;
diff --git a/lib/efi_selftest/efi_selftest_devicepath.c b/lib/efi_selftest/efi_selftest_devicepath.c
index 8a22a5d4d9..09f2de2bb3 100644
--- a/lib/efi_selftest/efi_selftest_devicepath.c
+++ b/lib/efi_selftest/efi_selftest_devicepath.c
@@ -405,6 +405,39 @@ static int execute(void)
 		return EFI_ST_FAILURE;
 	}
 
+	/* Test PCI hardware device node conversion */
+	{
+		struct efi_device_path_pci pci_node = {
+			.dp = {
+				.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE,
+				.sub_type = DEVICE_PATH_SUB_TYPE_PCI,
+				.length = sizeof(struct efi_device_path_pci),
+			},
+			.function = 2,
+			.device = 0x1a,
+		};
+
+		struct efi_device_path *dp =
+			(struct efi_device_path *)&pci_node;
+
+		string = device_path_to_text->convert_device_node_to_text(dp,
+								  true, false);
+		if (!string) {
+			efi_st_error("ConvertDeviceNodeToText (PCI) failed\n");
+			return EFI_ST_FAILURE;
+		}
+		if (efi_st_strcmp_16_8(string, "Pci(0x1a,0x2)")) {
+			efi_st_printf("pci_node: %ps\n", string);
+			efi_st_error("Incorrect PCI device node text\n");
+			return EFI_ST_FAILURE;
+		}
+		ret = boottime->free_pool(string);
+		if (ret != EFI_SUCCESS) {
+			efi_st_error("FreePool failed\n");
+			return EFI_ST_FAILURE;
+		}
+	}
+
 	/* Test ConvertDeviceNodeToText */
 	string = device_path_to_text->convert_device_node_to_text(
 			(struct efi_device_path *)&dp_node, true, false);
-- 
2.56.1.911.g883d8bcb20-goog


  reply	other threads:[~2026-12-03  5:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  2:21 [PATCH 0/2] efi_loader: Emit standard ACPI/PCI device paths for PCI DM devices Dan Holmes-Mitra
2026-12-03  2:21 ` Dan Holmes-Mitra [this message]
2026-12-03  2:21 ` [PATCH 2/2] efi_loader: Emit ACPI/PCI device path nodes " Dan Holmes-Mitra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261203022028.05-01-dholmesm@google.com \
    --to=dholmesm@google.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    --cc=vincent.stehle@arm.com \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.