diff mbox series

[1/4] uefi: uefidump: add dumping for BluetoothLE device path

Message ID 1509010943-6892-1-git-send-email-ivan.hu@canonical.com
State Accepted
Headers show
Series [1/4] uefi: uefidump: add dumping for BluetoothLE device path | expand

Commit Message

Ivan Hu Oct. 26, 2017, 9:42 a.m. UTC
BluetoothLE device path was added on UEFI spec version 2.7

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/lib/include/fwts_uefi.h  | 9 ++++++++-
 src/uefi/uefidump/uefidump.c | 9 +++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

Comments

Colin Ian King Oct. 26, 2017, 10:14 a.m. UTC | #1
On 26/10/17 11:42, Ivan Hu wrote:
> BluetoothLE device path was added on UEFI spec version 2.7
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/lib/include/fwts_uefi.h  | 9 ++++++++-
>  src/uefi/uefidump/uefidump.c | 9 +++++++++
>  2 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
> index 5afc968..db83f2f 100644
> --- a/src/lib/include/fwts_uefi.h
> +++ b/src/lib/include/fwts_uefi.h
> @@ -253,7 +253,8 @@ typedef enum {
>  	FWTS_UEFI_SD_DEVICE_PATH_SUBTYPE = 		(0x1a),
>  	FWTS_UEFI_BLUETOOTH_DEVICE_PATH_SUBTYPE = 	(0x1b),
>  	FWTS_UEFI_WIRELESS_DEVICE_PATH_SUBTYPE = 	(0x1c),
> -	FWTS_UEFI_EMMC_DEVICE_PATH_SUBTYPE =		(0x1d)
> +	FWTS_UEFI_EMMC_DEVICE_PATH_SUBTYPE =		(0x1d),
> +	FWTS_UEFI_BLUETOOTHLE_DEVICE_PATH_SUBTYPE =	(0x1e)
>  } messaging_dev_path_subtypes;
>  
>  typedef enum {
> @@ -558,6 +559,12 @@ typedef struct {
>  
>  typedef struct {
>  	fwts_uefi_dev_path dev_path;
> +	uint8_t bluetooth_addr[6];
> +	uint8_t addr_type;
> +} __attribute__((packed)) fwts_uefi_bluetoothle_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 c4c44b1..af20f85 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -540,6 +540,15 @@ static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path, c
>  				path = uefidump_vprintf(path, "\\eMMC(0x%" PRIx8 ")", e->slot_num);
>  			}
>  			break;
> +		case FWTS_UEFI_BLUETOOTHLE_DEVICE_PATH_SUBTYPE:
> +			if (dev_path_len >= sizeof(fwts_uefi_bluetoothle_dev_path)) {
> +				fwts_uefi_bluetoothle_dev_path *b = (fwts_uefi_bluetoothle_dev_path *)dev_path;
> +				path = uefidump_vprintf(path, "\\BluetoothLE("
> +					"%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 ",0x%" PRIx8 ")",
> +					b->bluetooth_addr[0], b->bluetooth_addr[1], b->bluetooth_addr[2],
> +					b->bluetooth_addr[3], b->bluetooth_addr[4], b->bluetooth_addr[5], b->addr_type);
> +			}
> +			break;
>  		default:
>  			path = uefidump_vprintf(path, "\\Unknown-MESSAGING-DEV-PATH(0x%" PRIx8 ")", dev_path->subtype);
>  			break;
> 
Acked-by: Colin Ian King <colin.king@canonical.com>
Colin Ian King Oct. 26, 2017, 10:15 a.m. UTC | #2
On 26/10/17 11:42, Ivan Hu wrote:
> BluetoothLE device path is defined in UEFI spec version 2.7
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/uefi/uefibootpath/uefibootpath.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/src/uefi/uefibootpath/uefibootpath.c b/src/uefi/uefibootpath/uefibootpath.c
> index e2e3bfe..5a18297 100644
> --- a/src/uefi/uefibootpath/uefibootpath.c
> +++ b/src/uefi/uefibootpath/uefibootpath.c
> @@ -622,6 +622,25 @@ static int uefibootpath_check_dev_path(fwts_framework *fw, fwts_uefi_dev_path *d
>  				errors++;
>  			}
>  			break;
> +		case FWTS_UEFI_BLUETOOTHLE_DEVICE_PATH_SUBTYPE:
> +			if (len != sizeof(fwts_uefi_bluetoothle_dev_path)) {
> +				fwts_failed(fw, LOG_LEVEL_MEDIUM, "UEFIBTLEDevPathLength",
> +					"The length of BluetoothLE device path is %" PRIu16 " bytes "
> +					"and differs from UEFI specification defined %" PRIu16 " bytes.",
> +					len,
> +					(uint16_t)sizeof(fwts_uefi_bluetoothle_dev_path));
> +				errors++;
> +			}
> +
> +			fwts_uefi_bluetoothle_dev_path *b = (fwts_uefi_bluetoothle_dev_path *)dev_path;
> +			if (b->addr_type > 1) {
> +				fwts_failed(fw, LOG_LEVEL_MEDIUM, "UEFIBTLEDevPathTypeInvalid",
> +					"The Address Type of BluetoothLE Device Path is %" PRIu8
> +					" which is out of UEFI specification defined range 0 or 1.",
> +					b->addr_type);
> +				errors++;
> +			}
> +			break;
>  		default:
>  			fwts_log_info_verbatim(fw, "Unknown subtype of Messaging Device Path.");
>  			break;
> 
Acked-by: Colin Ian King <colin.king@canonical.com>
Colin Ian King Oct. 26, 2017, 10:15 a.m. UTC | #3
On 26/10/17 11:42, Ivan Hu wrote:
> DNS device path is defined in UEFI spec version 2.7
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/uefi/uefibootpath/uefibootpath.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/src/uefi/uefibootpath/uefibootpath.c b/src/uefi/uefibootpath/uefibootpath.c
> index 5a18297..ca646a7 100644
> --- a/src/uefi/uefibootpath/uefibootpath.c
> +++ b/src/uefi/uefibootpath/uefibootpath.c
> @@ -641,6 +641,24 @@ static int uefibootpath_check_dev_path(fwts_framework *fw, fwts_uefi_dev_path *d
>  				errors++;
>  			}
>  			break;
> +		case FWTS_UEFI_DNS_DEVICE_PATH_SUBTYPE:
> +			if (len <= sizeof(fwts_uefi_dns_dev_path)) {
> +				fwts_failed(fw, LOG_LEVEL_MEDIUM, "UEFIDNSDevPathLength",
> +					"The length of DNS device path is %" PRIu16 " bytes, "
> +					"it should also include one or more instances of the DNS server "
> +					"address.", len);
> +				errors++;
> +			}
> +
> +			fwts_uefi_dns_dev_path *d = (fwts_uefi_dns_dev_path *)dev_path;
> +			if (d->isipv6 > 1) {
> +				fwts_failed(fw, LOG_LEVEL_MEDIUM, "UEFIDNSDevPathTypeInvalid",
> +					"The Ip type of DNS Device Path is %" PRIu8
> +					" which is out of UEFI specification defined range 0 or 1.",
> +					d->isipv6);
> +				errors++;
> +			}
> +			break;
>  		default:
>  			fwts_log_info_verbatim(fw, "Unknown subtype of Messaging Device Path.");
>  			break;
> 
Acked-by: Colin Ian King <colin.king@canonical.com>
diff mbox series

Patch

diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
index 5afc968..db83f2f 100644
--- a/src/lib/include/fwts_uefi.h
+++ b/src/lib/include/fwts_uefi.h
@@ -253,7 +253,8 @@  typedef enum {
 	FWTS_UEFI_SD_DEVICE_PATH_SUBTYPE = 		(0x1a),
 	FWTS_UEFI_BLUETOOTH_DEVICE_PATH_SUBTYPE = 	(0x1b),
 	FWTS_UEFI_WIRELESS_DEVICE_PATH_SUBTYPE = 	(0x1c),
-	FWTS_UEFI_EMMC_DEVICE_PATH_SUBTYPE =		(0x1d)
+	FWTS_UEFI_EMMC_DEVICE_PATH_SUBTYPE =		(0x1d),
+	FWTS_UEFI_BLUETOOTHLE_DEVICE_PATH_SUBTYPE =	(0x1e)
 } messaging_dev_path_subtypes;
 
 typedef enum {
@@ -558,6 +559,12 @@  typedef struct {
 
 typedef struct {
 	fwts_uefi_dev_path dev_path;
+	uint8_t bluetooth_addr[6];
+	uint8_t addr_type;
+} __attribute__((packed)) fwts_uefi_bluetoothle_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 c4c44b1..af20f85 100644
--- a/src/uefi/uefidump/uefidump.c
+++ b/src/uefi/uefidump/uefidump.c
@@ -540,6 +540,15 @@  static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path, c
 				path = uefidump_vprintf(path, "\\eMMC(0x%" PRIx8 ")", e->slot_num);
 			}
 			break;
+		case FWTS_UEFI_BLUETOOTHLE_DEVICE_PATH_SUBTYPE:
+			if (dev_path_len >= sizeof(fwts_uefi_bluetoothle_dev_path)) {
+				fwts_uefi_bluetoothle_dev_path *b = (fwts_uefi_bluetoothle_dev_path *)dev_path;
+				path = uefidump_vprintf(path, "\\BluetoothLE("
+					"%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 ",0x%" PRIx8 ")",
+					b->bluetooth_addr[0], b->bluetooth_addr[1], b->bluetooth_addr[2],
+					b->bluetooth_addr[3], b->bluetooth_addr[4], b->bluetooth_addr[5], b->addr_type);
+			}
+			break;
 		default:
 			path = uefidump_vprintf(path, "\\Unknown-MESSAGING-DEV-PATH(0x%" PRIx8 ")", dev_path->subtype);
 			break;