Patchwork uefi: uefidump: add more subtype support on acpi device path type for uefidump (LP:#1253000)

login
register
mail settings
Submitter Ivan Hu
Date Nov. 22, 2013, 6:20 a.m.
Message ID <1385101221-16078-1-git-send-email-ivan.hu@canonical.com>
Download mbox | patch
Permalink /patch/293339/
State Accepted
Headers show

Comments

Ivan Hu - Nov. 22, 2013, 6:20 a.m.
Add the ACPI Device Path type, Sub-Type 3 _ADR Device Path support on uefidump, UEFI spec section 9.3.4

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/lib/include/fwts_uefi.h  |    8 +++++++-
 src/uefi/uefidump/uefidump.c |   17 +++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)
Colin King - Nov. 22, 2013, 1:36 p.m.
On 22/11/13 06:20, Ivan Hu wrote:
> Add the ACPI Device Path type, Sub-Type 3 _ADR Device Path support on uefidump, UEFI spec section 9.3.4
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/lib/include/fwts_uefi.h  |    8 +++++++-
>  src/uefi/uefidump/uefidump.c |   17 +++++++++++++++++
>  2 files changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
> index 9f9fd5c..f21d2c7 100644
> --- a/src/lib/include/fwts_uefi.h
> +++ b/src/lib/include/fwts_uefi.h
> @@ -186,7 +186,8 @@ typedef enum {
>  
>  typedef enum {
>  	FWTS_UEFI_ACPI_DEVICE_PATH_SUBTYPE = 		(0x01),
> -	FWTS_UEFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE = 	(0x02)
> +	FWTS_UEFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE = 	(0x02),
> +	FWTS_UEFI_ACPI_ADR_DEVICE_PATH_SUBTYPE = 	(0x03)
>  } acpi_dev_path_subtypes;
>  
>  typedef enum {
> @@ -269,6 +270,11 @@ typedef struct {
>  
>  typedef struct {
>  	fwts_uefi_dev_path dev_path;
> +	uint32_t adr;
> +} fwts_uefi_acpi_adr_dev_path;
> +
> +typedef struct {
> +	fwts_uefi_dev_path dev_path;
>  	uint8_t primary_secondary;
>  	uint8_t slave_master;
>  	uint16_t lun;
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index bc659b2..cd57422 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -182,6 +182,23 @@ static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path, c
>  					path = uefidump_vprintf(path, "%s,", hidstr);
>  			}
>  			break;
> +		case FWTS_UEFI_ACPI_ADR_DEVICE_PATH_SUBTYPE:
> +			if (dev_path_len >= sizeof(fwts_uefi_acpi_adr_dev_path)) {
> +				fwts_uefi_acpi_adr_dev_path *a = (fwts_uefi_acpi_adr_dev_path *)dev_path;
> +				uint16_t len = a->dev_path.length[0] | (((uint16_t)a->dev_path.length[1]) << 8);
> +				path = uefidump_vprintf(path, "\\ACPI_ADR(0x%" PRIx32, a->adr);
> +
> +				/* Adding additional _ADR */
> +				uint8_t *adr_add = (uint8_t *)a + sizeof(fwts_uefi_acpi_adr_dev_path);
> +				size_t offset = 0;
> +				while ((len - sizeof(fwts_uefi_acpi_adr_dev_path) - offset) >= sizeof(uint32_t)) {
> +					path = uefidump_vprintf(path, ", 0x%" PRIx32 , *(uint32_t *)(adr_add + offset));
> +					offset += sizeof(uint32_t);
> +				}
> +
> +				path = uefidump_vprintf(path, ")");
> +			}
> +			break;
>  		default:
>  			path = uefidump_vprintf(path, "\\Unknown-ACPI-DEV-PATH(0x%" PRIx8 ")", dev_path->subtype);
>  			break;
> 
Acked-by: Colin Ian King <colin.king@canonical.com>
Alex Hung - Nov. 27, 2013, 2:46 a.m.
On 11/22/2013 02:20 PM, Ivan Hu wrote:
> Add the ACPI Device Path type, Sub-Type 3 _ADR Device Path support on uefidump, UEFI spec section 9.3.4
>
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>   src/lib/include/fwts_uefi.h  |    8 +++++++-
>   src/uefi/uefidump/uefidump.c |   17 +++++++++++++++++
>   2 files changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
> index 9f9fd5c..f21d2c7 100644
> --- a/src/lib/include/fwts_uefi.h
> +++ b/src/lib/include/fwts_uefi.h
> @@ -186,7 +186,8 @@ typedef enum {
>
>   typedef enum {
>   	FWTS_UEFI_ACPI_DEVICE_PATH_SUBTYPE = 		(0x01),
> -	FWTS_UEFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE = 	(0x02)
> +	FWTS_UEFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE = 	(0x02),
> +	FWTS_UEFI_ACPI_ADR_DEVICE_PATH_SUBTYPE = 	(0x03)
>   } acpi_dev_path_subtypes;
>
>   typedef enum {
> @@ -269,6 +270,11 @@ typedef struct {
>
>   typedef struct {
>   	fwts_uefi_dev_path dev_path;
> +	uint32_t adr;
> +} fwts_uefi_acpi_adr_dev_path;
> +
> +typedef struct {
> +	fwts_uefi_dev_path dev_path;
>   	uint8_t primary_secondary;
>   	uint8_t slave_master;
>   	uint16_t lun;
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index bc659b2..cd57422 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -182,6 +182,23 @@ static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path, c
>   					path = uefidump_vprintf(path, "%s,", hidstr);
>   			}
>   			break;
> +		case FWTS_UEFI_ACPI_ADR_DEVICE_PATH_SUBTYPE:
> +			if (dev_path_len >= sizeof(fwts_uefi_acpi_adr_dev_path)) {
> +				fwts_uefi_acpi_adr_dev_path *a = (fwts_uefi_acpi_adr_dev_path *)dev_path;
> +				uint16_t len = a->dev_path.length[0] | (((uint16_t)a->dev_path.length[1]) << 8);
> +				path = uefidump_vprintf(path, "\\ACPI_ADR(0x%" PRIx32, a->adr);
> +
> +				/* Adding additional _ADR */
> +				uint8_t *adr_add = (uint8_t *)a + sizeof(fwts_uefi_acpi_adr_dev_path);
> +				size_t offset = 0;
> +				while ((len - sizeof(fwts_uefi_acpi_adr_dev_path) - offset) >= sizeof(uint32_t)) {
> +					path = uefidump_vprintf(path, ", 0x%" PRIx32 , *(uint32_t *)(adr_add + offset));
> +					offset += sizeof(uint32_t);
> +				}
> +
> +				path = uefidump_vprintf(path, ")");
> +			}
> +			break;
>   		default:
>   			path = uefidump_vprintf(path, "\\Unknown-ACPI-DEV-PATH(0x%" PRIx8 ")", dev_path->subtype);
>   			break;
>

Acked-by: Alex Hung <alex.hung@canonical.com>

Patch

diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
index 9f9fd5c..f21d2c7 100644
--- a/src/lib/include/fwts_uefi.h
+++ b/src/lib/include/fwts_uefi.h
@@ -186,7 +186,8 @@  typedef enum {
 
 typedef enum {
 	FWTS_UEFI_ACPI_DEVICE_PATH_SUBTYPE = 		(0x01),
-	FWTS_UEFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE = 	(0x02)
+	FWTS_UEFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE = 	(0x02),
+	FWTS_UEFI_ACPI_ADR_DEVICE_PATH_SUBTYPE = 	(0x03)
 } acpi_dev_path_subtypes;
 
 typedef enum {
@@ -269,6 +270,11 @@  typedef struct {
 
 typedef struct {
 	fwts_uefi_dev_path dev_path;
+	uint32_t adr;
+} fwts_uefi_acpi_adr_dev_path;
+
+typedef struct {
+	fwts_uefi_dev_path dev_path;
 	uint8_t primary_secondary;
 	uint8_t slave_master;
 	uint16_t lun;
diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
index bc659b2..cd57422 100644
--- a/src/uefi/uefidump/uefidump.c
+++ b/src/uefi/uefidump/uefidump.c
@@ -182,6 +182,23 @@  static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path, c
 					path = uefidump_vprintf(path, "%s,", hidstr);
 			}
 			break;
+		case FWTS_UEFI_ACPI_ADR_DEVICE_PATH_SUBTYPE:
+			if (dev_path_len >= sizeof(fwts_uefi_acpi_adr_dev_path)) {
+				fwts_uefi_acpi_adr_dev_path *a = (fwts_uefi_acpi_adr_dev_path *)dev_path;
+				uint16_t len = a->dev_path.length[0] | (((uint16_t)a->dev_path.length[1]) << 8);
+				path = uefidump_vprintf(path, "\\ACPI_ADR(0x%" PRIx32, a->adr);
+
+				/* Adding additional _ADR */
+				uint8_t *adr_add = (uint8_t *)a + sizeof(fwts_uefi_acpi_adr_dev_path);
+				size_t offset = 0;
+				while ((len - sizeof(fwts_uefi_acpi_adr_dev_path) - offset) >= sizeof(uint32_t)) {
+					path = uefidump_vprintf(path, ", 0x%" PRIx32 , *(uint32_t *)(adr_add + offset));
+					offset += sizeof(uint32_t);
+				}
+
+				path = uefidump_vprintf(path, ")");
+			}
+			break;
 		default:
 			path = uefidump_vprintf(path, "\\Unknown-ACPI-DEV-PATH(0x%" PRIx8 ")", dev_path->subtype);
 			break;