Patchwork [2/4,Resend] uefi: uefidump: add the USB WWID subtype-16 support on messaging device path type for uefidump (LP: #1255387)

login
register
mail settings
Submitter Ivan Hu
Date Nov. 29, 2013, 12:58 a.m.
Message ID <1385686695-15832-1-git-send-email-ivan.hu@canonical.com>
Download mbox | patch
Permalink /patch/295064/
State Rejected
Headers show

Comments

Ivan Hu - Nov. 29, 2013, 12:58 a.m.
From: IvanHu <ivan.hu@canonical.com>

Add the USB WWID subtype 16 support on messaging device path follow the section 9.3.5.7 on UEFI spec2.4.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/lib/include/fwts_uefi.h  |    9 +++++++++
 src/uefi/uefidump/uefidump.c |   23 +++++++++++++++++++++++
 2 files changed, 32 insertions(+)
Ivan Hu - Nov. 29, 2013, 1:01 a.m.
wrong title, please ignore this.

Ivan

Patch

diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
index 28d4c81..1b387a4 100644
--- a/src/lib/include/fwts_uefi.h
+++ b/src/lib/include/fwts_uefi.h
@@ -203,6 +203,7 @@  typedef enum {
 	FWTS_UEFI_IPV6_DEVICE_PATH_SUBTYPE =		(0x0d),
 	FWTS_UEFI_UART_DEVICE_PATH_SUBTYPE =		(0x0e),
 	FWTS_UEFI_USB_CLASS_DEVICE_PATH_SUBTYPE =	(0x0f),
+	FWTS_UEFI_USB_WWID_DEVICE_PATH_SUBTYPE =	(0x10),
 	FWTS_UEFI_SATA_DEVICE_PATH_SUBTYPE = 		(0x12),
 	FWTS_UEFI_FIBRE_CHANNEL_EX_DEVICE_PATH_SUBTYPE = (0x15)
 
@@ -383,6 +384,14 @@  typedef struct {
 
 typedef struct {
 	fwts_uefi_dev_path dev_path;
+	uint16_t interface_num;
+	uint16_t vendor_id;
+	uint16_t product_id;
+	uint16_t serial_number[0];
+} fwts_uefi_usb_wwid_dev_path;
+
+typedef struct {
+	fwts_uefi_dev_path dev_path;
 	uint32_t partition_number;
 	uint64_t partition_start;
 	uint64_t partition_size;
diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
index fb9d5f3..075168b 100644
--- a/src/uefi/uefidump/uefidump.c
+++ b/src/uefi/uefidump/uefidump.c
@@ -330,6 +330,29 @@  static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path, c
 					s->hbapn, s->pmpn, s->lun);
 			}
 			break;
+		case FWTS_UEFI_USB_WWID_DEVICE_PATH_SUBTYPE:
+			if (dev_path_len >= sizeof(fwts_uefi_usb_wwid_dev_path)) {
+				fwts_uefi_usb_wwid_dev_path *u = (fwts_uefi_usb_wwid_dev_path *)dev_path;
+				path = uefidump_vprintf(path, "\\USBWWID(0x%" PRIx16 ",0x%" PRIx16 ",0x%" PRIx16,
+					u->interface_num, u->vendor_id, u->product_id);
+
+				/* Adding Serial Number */
+				char *tmp;
+				uint16_t len = u->dev_path.length[0] | (((uint16_t)u->dev_path.length[1]) << 8);
+
+				if (len <= sizeof(fwts_uefi_usb_wwid_dev_path)) {
+					path = uefidump_vprintf(path, ")");
+					break;
+				}
+				tmp = malloc((len - sizeof(fwts_uefi_usb_wwid_dev_path))/sizeof(uint16_t) + 1);
+				if (tmp) {	
+					fwts_uefi_str16_to_str(tmp, (len - sizeof(fwts_uefi_usb_wwid_dev_path))/sizeof(uint16_t) + 1, u->serial_number);
+					path = uefidump_vprintf(path, ",%s", tmp);
+					free(tmp);
+				}
+				path = uefidump_vprintf(path, ")");
+			}
+			break;
 		default:
 			path = uefidump_vprintf(path, "\\Unknown-MESSAGING-DEV-PATH(0x%" PRIx8 ")", dev_path->subtype);
 			break;