All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 0/3] efi_loader: correct media device paths
@ 2017-12-04  7:10 Heinrich Schuchardt
  2017-12-04  7:10 ` [U-Boot] [PATCH v2 1/3] efi_loader: correctly determine if an MMC device is an SD-card Heinrich Schuchardt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2017-12-04  7:10 UTC (permalink / raw)
  To: u-boot

For each disk we need partition device path with partion number 0.
The device node texts should match the UEFI spec.

v2:
	Do not generate optional device path with partion number
	0 for the whole block device.

Heinrich Schuchardt (3):
  efi_loader: correctly determine if an MMC device is an SD-card
  efi_loader: correctly setup device paths for block devices
  efi_loader: correct DeviceNodeToText for media types

 lib/efi_loader/efi_device_path.c         | 35 +++++++++++++++++++++++++-------
 lib/efi_loader/efi_device_path_to_text.c | 30 +++++++++++++++++----------
 lib/efi_loader/efi_disk.c                |  7 +++++--
 3 files changed, 52 insertions(+), 20 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v2 1/3] efi_loader: correctly determine if an MMC device is an SD-card
  2017-12-04  7:10 [U-Boot] [PATCH v2 0/3] efi_loader: correct media device paths Heinrich Schuchardt
@ 2017-12-04  7:10 ` Heinrich Schuchardt
  2017-12-04  7:10 ` [U-Boot] [PATCH v2 2/3] efi_loader: correctly setup device paths for block devices Heinrich Schuchardt
  2017-12-04  7:10 ` [U-Boot] [PATCH v2 3/3] efi_loader: correct DeviceNodeToText for media types Heinrich Schuchardt
  2 siblings, 0 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2017-12-04  7:10 UTC (permalink / raw)
  To: u-boot

The SD cards and eMMC devices have different device nodes.
The current coding interpretes all MMC devices as eMMC.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2
	no change
---
 lib/efi_loader/efi_device_path.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index b4e2f933cb..42fe6e1185 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -36,6 +36,24 @@ static const struct efi_device_path_vendor ROOT = {
 	.guid = U_BOOT_GUID,
 };
 
+#if defined(CONFIG_DM_MMC) && defined(CONFIG_MMC)
+/*
+ * Determine if an MMC device is an SD card.
+ *
+ * @desc	block device descriptor
+ * @return	true if the device is an SD card
+ */
+static bool is_sd(struct blk_desc *desc)
+{
+	struct mmc *mmc = find_mmc_device(desc->devnum);
+
+	if (!mmc)
+		return false;
+
+	return IS_SD(mmc) != 0U;
+}
+#endif
+
 static void *dp_alloc(size_t sz)
 {
 	void *buf;
@@ -298,9 +316,9 @@ static void *dp_fill(void *buf, struct udevice *dev)
 		struct blk_desc *desc = mmc_get_blk_desc(mmc);
 
 		sddp->dp.type     = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
-		sddp->dp.sub_type = (desc->if_type == IF_TYPE_MMC) ?
-			DEVICE_PATH_SUB_TYPE_MSG_MMC :
-			DEVICE_PATH_SUB_TYPE_MSG_SD;
+		sddp->dp.sub_type = is_sd(desc) ?
+			DEVICE_PATH_SUB_TYPE_MSG_SD :
+			DEVICE_PATH_SUB_TYPE_MSG_MMC;
 		sddp->dp.length   = sizeof(*sddp);
 		sddp->slot_number = dev->seq;
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v2 2/3] efi_loader: correctly setup device paths for block devices
  2017-12-04  7:10 [U-Boot] [PATCH v2 0/3] efi_loader: correct media device paths Heinrich Schuchardt
  2017-12-04  7:10 ` [U-Boot] [PATCH v2 1/3] efi_loader: correctly determine if an MMC device is an SD-card Heinrich Schuchardt
@ 2017-12-04  7:10 ` Heinrich Schuchardt
  2017-12-04  7:10 ` [U-Boot] [PATCH v2 3/3] efi_loader: correct DeviceNodeToText for media types Heinrich Schuchardt
  2 siblings, 0 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2017-12-04  7:10 UTC (permalink / raw)
  To: u-boot

According to the UEFI spec the numbering of partitions has to
start with 1.

Partion number 0 is reserved for the optional device path for
the complete block device.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2
	Do not generate optional device path with partion number 0.
---
 lib/efi_loader/efi_device_path.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 42fe6e1185..6461ea9abc 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -420,7 +420,7 @@ static void *dp_part_fill(void *buf, struct blk_desc *desc, int part)
 	if (desc->part_type == PART_TYPE_ISO) {
 		struct efi_device_path_cdrom_path *cddp = buf;
 
-		cddp->boot_entry = part - 1;
+		cddp->boot_entry = part;
 		cddp->dp.type = DEVICE_PATH_TYPE_MEDIA_DEVICE;
 		cddp->dp.sub_type = DEVICE_PATH_SUB_TYPE_CDROM_PATH;
 		cddp->dp.length = sizeof(*cddp);
@@ -434,7 +434,7 @@ static void *dp_part_fill(void *buf, struct blk_desc *desc, int part)
 		hddp->dp.type = DEVICE_PATH_TYPE_MEDIA_DEVICE;
 		hddp->dp.sub_type = DEVICE_PATH_SUB_TYPE_HARD_DRIVE_PATH;
 		hddp->dp.length = sizeof(*hddp);
-		hddp->partition_number = part - 1;
+		hddp->partition_number = part;
 		hddp->partition_start = info.start;
 		hddp->partition_end = info.size;
 		if (desc->part_type == PART_TYPE_EFI)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v2 3/3] efi_loader: correct DeviceNodeToText for media types
  2017-12-04  7:10 [U-Boot] [PATCH v2 0/3] efi_loader: correct media device paths Heinrich Schuchardt
  2017-12-04  7:10 ` [U-Boot] [PATCH v2 1/3] efi_loader: correctly determine if an MMC device is an SD-card Heinrich Schuchardt
  2017-12-04  7:10 ` [U-Boot] [PATCH v2 2/3] efi_loader: correctly setup device paths for block devices Heinrich Schuchardt
@ 2017-12-04  7:10 ` Heinrich Schuchardt
  2 siblings, 0 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2017-12-04  7:10 UTC (permalink / raw)
  To: u-boot

When converting device nodes and paths to text we should
stick to the UEFI spec.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2
	no change
---
 lib/efi_loader/efi_device_path_to_text.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c
index 7159c974d4..21c5678d20 100644
--- a/lib/efi_loader/efi_device_path_to_text.c
+++ b/lib/efi_loader/efi_device_path_to_text.c
@@ -90,7 +90,7 @@ static char *dp_msging(char *s, struct efi_device_path *dp)
 	case DEVICE_PATH_SUB_TYPE_MSG_USB: {
 		struct efi_device_path_usb *udp =
 			(struct efi_device_path_usb *)dp;
-		s += sprintf(s, "Usb(0x%x,0x%x)", udp->parent_port_number,
+		s += sprintf(s, "USB(0x%x,0x%x)", udp->parent_port_number,
 			     udp->usb_interface);
 		break;
 	}
@@ -124,10 +124,10 @@ static char *dp_msging(char *s, struct efi_device_path *dp)
 	case DEVICE_PATH_SUB_TYPE_MSG_MMC: {
 		const char *typename =
 			(dp->sub_type == DEVICE_PATH_SUB_TYPE_MSG_SD) ?
-					"SDCard" : "MMC";
+					"SD" : "eMMC";
 		struct efi_device_path_sd_mmc_path *sddp =
 			(struct efi_device_path_sd_mmc_path *)dp;
-		s += sprintf(s, "%s(Slot%u)", typename, sddp->slot_number);
+		s += sprintf(s, "%s(%u)", typename, sddp->slot_number);
 		break;
 	}
 	default:
@@ -147,18 +147,26 @@ static char *dp_media(char *s, struct efi_device_path *dp)
 
 		switch (hddp->signature_type) {
 		case SIG_TYPE_MBR:
-			s += sprintf(s, "HD(Part%d,Sig%08x)",
-				     hddp->partition_number,
-				     *(uint32_t *)sig);
+			s += sprintf(
+				s, "HD(%d,MBR,0x%08x,0x%llx,0x%llx)",
+				hddp->partition_number,
+				*(uint32_t *)sig,
+				(unsigned long long int)hddp->partition_start,
+				(unsigned long long int)hddp->partition_end);
 			break;
 		case SIG_TYPE_GUID:
-			s += sprintf(s, "HD(Part%d,Sig%pUl)",
-				     hddp->partition_number, sig);
+			s += sprintf(
+				s, "HD(%d,GPT,%pUl,0x%llx,0x%llx)",
+				hddp->partition_number, sig,
+				(unsigned long long int)hddp->partition_start,
+				(unsigned long long int)hddp->partition_end);
 			break;
 		default:
-			s += sprintf(s, "HD(Part%d,MBRType=%02x,SigType=%02x)",
-				     hddp->partition_number, hddp->partmap_type,
-				     hddp->signature_type);
+			s += sprintf(
+				s, "HD(%d,0x%02x,0,0x%llx,0x%llx)",
+				hddp->partition_number, hddp->partmap_type,
+				(unsigned long long int)hddp->partition_start,
+				(unsigned long long int)hddp->partition_end);
 			break;
 		}
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-04  7:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-04  7:10 [U-Boot] [PATCH v2 0/3] efi_loader: correct media device paths Heinrich Schuchardt
2017-12-04  7:10 ` [U-Boot] [PATCH v2 1/3] efi_loader: correctly determine if an MMC device is an SD-card Heinrich Schuchardt
2017-12-04  7:10 ` [U-Boot] [PATCH v2 2/3] efi_loader: correctly setup device paths for block devices Heinrich Schuchardt
2017-12-04  7:10 ` [U-Boot] [PATCH v2 3/3] efi_loader: correct DeviceNodeToText for media types Heinrich Schuchardt

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.