Patchwork uefi: uefidump: extend the Messaging Device Path type Vedor subtype-10 (LP: #1262095)

login
register
mail settings
Submitter Ivan Hu
Date Dec. 20, 2013, 6:30 a.m.
Message ID <1387521011-24847-1-git-send-email-ivan.hu@canonical.com>
Download mbox | patch
Permalink /patch/303912/
State Rejected
Headers show

Comments

Ivan Hu - Dec. 20, 2013, 6:30 a.m.
Extend the Vendor subtype 10 support on messaging device path follow the UEFI spec2.4.

1. PC-ANSI, VT-100, VT-100+, and VT-UTF8 support, sec, 9.3.5.17
2. UART Flow Control Messaging Path support, sec. 9.3.5.18
3. Serial Attached SCSI (SAS) Device Path support, sec. 9.3.5.19

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/lib/include/fwts_uefi.h  |   28 ++++++++++++++++++++++
 src/uefi/uefidump/uefidump.c |   54 +++++++++++++++++++++++++++++++++++-------
 2 files changed, 74 insertions(+), 8 deletions(-)
Colin King - Dec. 20, 2013, 9:47 a.m.
On 20/12/13 06:30, Ivan Hu wrote:
> Extend the Vendor subtype 10 support on messaging device path follow the UEFI spec2.4.
> 
> 1. PC-ANSI, VT-100, VT-100+, and VT-UTF8 support, sec, 9.3.5.17
> 2. UART Flow Control Messaging Path support, sec. 9.3.5.18
> 3. Serial Attached SCSI (SAS) Device Path support, sec. 9.3.5.19
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/lib/include/fwts_uefi.h  |   28 ++++++++++++++++++++++
>  src/uefi/uefidump/uefidump.c |   54 +++++++++++++++++++++++++++++++++++-------
>  2 files changed, 74 insertions(+), 8 deletions(-)
> 
> diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
> index dd9bbb0..cec2722 100644
> --- a/src/lib/include/fwts_uefi.h
> +++ b/src/lib/include/fwts_uefi.h
> @@ -131,6 +131,24 @@ enum {
>  #define EFI_CERT_X509_SHA512_GUID \
>  { 0x446dbf63, 0x2502, 0x4cda, { 0xbc, 0xfa, 0x24, 0x65, 0xd2, 0xb0, 0xfe, 0x9d }}
>  
> +#define EFI_PC_ANSI_GUID \
> +{ 0xe0c14753, 0xf9be, 0x11d2, { 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d }}
> +
> +#define EFI_VT_100_GUID \
> +{ 0xdfa66065, 0xb419, 0x11d3, { 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d }}
> +
> +#define EFI_VT_100_PLUS_GUID \
> +{ 0x7baec70b, 0x57e0, 0x4c76, { 0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43 }}
> +
> +#define EFI_VT_UTF8_GUID \
> +{ 0xad15a0d6, 0x8bec, 0x4acf, { 0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88 }}
> +
> +#define EFI_UART_DEVICE_PATH_GUID \
> +{ 0x37499a9d, 0x542f, 0x4c89, { 0xa0, 0x26, 0x35, 0xda, 0x14, 0x20, 0x94, 0xe4 }}
> +
> +#define EFI_SAS_DEVICE_PATH_GUID \
> +{ 0xd487ddb4, 0x008b, 0x11d9, { 0xaf, 0xdc, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d }}
> +
>  #if 0
>  typedef struct {
>  	char *description;
> @@ -382,6 +400,16 @@ typedef struct {
>  
>  typedef struct {
>  	fwts_uefi_dev_path dev_path;
> +	fwts_uefi_guid guid;
> +	uint32_t reserved;
> +	uint64_t sas_addr;
> +	uint64_t lun;
> +	uint16_t dev_topology_info;
> +	uint16_t rtp;
> +} __attribute__((packed)) fwts_uefi_sas_messaging_dev_path;
> +
> +typedef struct {
> +	fwts_uefi_dev_path dev_path;
>  	uint32_t reserved;
>  	uint64_t wwn;
>  	uint64_t lun;
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index 8beb179..02ef1ef 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -326,14 +326,52 @@ static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path, c
>  			break;
>  		case FWTS_UEFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE:
>  			if (dev_path_len >= sizeof(fwts_uefi_vendor_messaging_dev_path)) {
> -				fwts_uefi_vendor_messaging_dev_path *v = (fwts_uefi_vendor_messaging_dev_path*)dev_path;
> -				path = uefidump_vprintf(path, "\\VENDOR("
> -					"%08" PRIx32 "-%04" PRIx16 "-%04" PRIx16 "-"
> -					"%02" PRIx8 "-%02" PRIx8 "-"
> -					"%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 ")",
> -					v->guid.info1, v->guid.info2, v->guid.info3,
> -					v->guid.info4[0], v->guid.info4[1], v->guid.info4[2], v->guid.info4[3],
> -					v->guid.info4[4], v->guid.info4[5], v->guid.info4[6], v->guid.info4[7]);
> +				fwts_uefi_vendor_messaging_dev_path *v = (fwts_uefi_vendor_messaging_dev_path *)dev_path;
> +				size_t i;
> +				fwts_uefi_guid guid[] = {
> +					EFI_PC_ANSI_GUID,
> +					EFI_VT_100_GUID,
> +					EFI_VT_100_PLUS_GUID,
> +					EFI_VT_UTF8_GUID,
> +					EFI_UART_DEVICE_PATH_GUID,
> +					EFI_SAS_DEVICE_PATH_GUID
> +				};

minor thing, but guid[] and str[] probably should be static const

> +				char *str[] = {
> +					"PC-ANSI",
> +					"VT-100",
> +					"VT-100+",
> +					"VT-UTF8",
> +					"UARTFLOWCTRL",
> +					"SAS",
> +					"UnknownGUID"
> +				};
> +				for (i = 0; i < sizeof(guid)/sizeof(guid[0]); i++)
> +					if (memcmp(&v->guid, &guid[i], sizeof(fwts_uefi_guid)) == 0)
> +						break;
> +				path = uefidump_vprintf(path, "\\VENDOR(%s", str[i]);
> +				if (i == 4) {
> +					uint32_t flow_control_map = v->vendor_defined_data[0]
> +							+ (((uint32_t)v->vendor_defined_data[1]) << 8)
> +							+ (((uint32_t)v->vendor_defined_data[2]) << 16)
> +							+ (((uint32_t)v->vendor_defined_data[3] << 24));
> +					path = uefidump_vprintf(path, ",0x%" PRIx32, flow_control_map);
> +				}			
> +				if (i == 5 && dev_path_len >= sizeof(fwts_uefi_sas_messaging_dev_path)) {
> +					fwts_uefi_sas_messaging_dev_path *s = (fwts_uefi_sas_messaging_dev_path *)dev_path;
> +					path = uefidump_vprintf(path, ",0x%" PRIx64
> +						",0x%" PRIx64 ",0x%" PRIx16 ",0x%" PRIx16 ,
> +						s->sas_addr, s->lun, s->dev_topology_info, s->rtp);
> +				}
> +				if (i == 6)
> +					path = uefidump_vprintf(path, " %08" PRIx32 
> +						"-%04" PRIx16 "-%04" PRIx16 "-%02" PRIx8
> +						"-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 
> +						"-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 ,
> +						v->guid.info1, v->guid.info2, v->guid.info3,
> +						v->guid.info4[0], v->guid.info4[1], v->guid.info4[2], v->guid.info4[3],
> +						v->guid.info4[4], v->guid.info4[5], v->guid.info4[6], v->guid.info4[7]);
> +
> +				path = uefidump_vprintf(path, ")");
>  			}
>  			break;
>  		case FWTS_UEFI_FIBRE_CHANNEL_EX_DEVICE_PATH_SUBTYPE:
>

Patch

diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
index dd9bbb0..cec2722 100644
--- a/src/lib/include/fwts_uefi.h
+++ b/src/lib/include/fwts_uefi.h
@@ -131,6 +131,24 @@  enum {
 #define EFI_CERT_X509_SHA512_GUID \
 { 0x446dbf63, 0x2502, 0x4cda, { 0xbc, 0xfa, 0x24, 0x65, 0xd2, 0xb0, 0xfe, 0x9d }}
 
+#define EFI_PC_ANSI_GUID \
+{ 0xe0c14753, 0xf9be, 0x11d2, { 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d }}
+
+#define EFI_VT_100_GUID \
+{ 0xdfa66065, 0xb419, 0x11d3, { 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d }}
+
+#define EFI_VT_100_PLUS_GUID \
+{ 0x7baec70b, 0x57e0, 0x4c76, { 0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43 }}
+
+#define EFI_VT_UTF8_GUID \
+{ 0xad15a0d6, 0x8bec, 0x4acf, { 0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88 }}
+
+#define EFI_UART_DEVICE_PATH_GUID \
+{ 0x37499a9d, 0x542f, 0x4c89, { 0xa0, 0x26, 0x35, 0xda, 0x14, 0x20, 0x94, 0xe4 }}
+
+#define EFI_SAS_DEVICE_PATH_GUID \
+{ 0xd487ddb4, 0x008b, 0x11d9, { 0xaf, 0xdc, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d }}
+
 #if 0
 typedef struct {
 	char *description;
@@ -382,6 +400,16 @@  typedef struct {
 
 typedef struct {
 	fwts_uefi_dev_path dev_path;
+	fwts_uefi_guid guid;
+	uint32_t reserved;
+	uint64_t sas_addr;
+	uint64_t lun;
+	uint16_t dev_topology_info;
+	uint16_t rtp;
+} __attribute__((packed)) fwts_uefi_sas_messaging_dev_path;
+
+typedef struct {
+	fwts_uefi_dev_path dev_path;
 	uint32_t reserved;
 	uint64_t wwn;
 	uint64_t lun;
diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
index 8beb179..02ef1ef 100644
--- a/src/uefi/uefidump/uefidump.c
+++ b/src/uefi/uefidump/uefidump.c
@@ -326,14 +326,52 @@  static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path, c
 			break;
 		case FWTS_UEFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE:
 			if (dev_path_len >= sizeof(fwts_uefi_vendor_messaging_dev_path)) {
-				fwts_uefi_vendor_messaging_dev_path *v = (fwts_uefi_vendor_messaging_dev_path*)dev_path;
-				path = uefidump_vprintf(path, "\\VENDOR("
-					"%08" PRIx32 "-%04" PRIx16 "-%04" PRIx16 "-"
-					"%02" PRIx8 "-%02" PRIx8 "-"
-					"%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 ")",
-					v->guid.info1, v->guid.info2, v->guid.info3,
-					v->guid.info4[0], v->guid.info4[1], v->guid.info4[2], v->guid.info4[3],
-					v->guid.info4[4], v->guid.info4[5], v->guid.info4[6], v->guid.info4[7]);
+				fwts_uefi_vendor_messaging_dev_path *v = (fwts_uefi_vendor_messaging_dev_path *)dev_path;
+				size_t i;
+				fwts_uefi_guid guid[] = {
+					EFI_PC_ANSI_GUID,
+					EFI_VT_100_GUID,
+					EFI_VT_100_PLUS_GUID,
+					EFI_VT_UTF8_GUID,
+					EFI_UART_DEVICE_PATH_GUID,
+					EFI_SAS_DEVICE_PATH_GUID
+				};
+				char *str[] = {
+					"PC-ANSI",
+					"VT-100",
+					"VT-100+",
+					"VT-UTF8",
+					"UARTFLOWCTRL",
+					"SAS",
+					"UnknownGUID"
+				};
+				for (i = 0; i < sizeof(guid)/sizeof(guid[0]); i++)
+					if (memcmp(&v->guid, &guid[i], sizeof(fwts_uefi_guid)) == 0)
+						break;
+				path = uefidump_vprintf(path, "\\VENDOR(%s", str[i]);
+				if (i == 4) {
+					uint32_t flow_control_map = v->vendor_defined_data[0]
+							+ (((uint32_t)v->vendor_defined_data[1]) << 8)
+							+ (((uint32_t)v->vendor_defined_data[2]) << 16)
+							+ (((uint32_t)v->vendor_defined_data[3] << 24));
+					path = uefidump_vprintf(path, ",0x%" PRIx32, flow_control_map);
+				}			
+				if (i == 5 && dev_path_len >= sizeof(fwts_uefi_sas_messaging_dev_path)) {
+					fwts_uefi_sas_messaging_dev_path *s = (fwts_uefi_sas_messaging_dev_path *)dev_path;
+					path = uefidump_vprintf(path, ",0x%" PRIx64
+						",0x%" PRIx64 ",0x%" PRIx16 ",0x%" PRIx16 ,
+						s->sas_addr, s->lun, s->dev_topology_info, s->rtp);
+				}
+				if (i == 6)
+					path = uefidump_vprintf(path, " %08" PRIx32 
+						"-%04" PRIx16 "-%04" PRIx16 "-%02" PRIx8
+						"-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 
+						"-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 "-%02" PRIx8 ,
+						v->guid.info1, v->guid.info2, v->guid.info3,
+						v->guid.info4[0], v->guid.info4[1], v->guid.info4[2], v->guid.info4[3],
+						v->guid.info4[4], v->guid.info4[5], v->guid.info4[6], v->guid.info4[7]);
+
+				path = uefidump_vprintf(path, ")");
 			}
 			break;
 		case FWTS_UEFI_FIBRE_CHANNEL_EX_DEVICE_PATH_SUBTYPE: