diff mbox

ACPI: Fix up GTDT corrections as in ACPI 5.1 (LP: #1348618)

Message ID 1406291969-3510-1-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King July 25, 2014, 12:39 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Re-sync the definitions of the GTDT for ACPI 5.1 and fix up
acpidump accordingly.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/acpidump/acpidump.c | 30 +++++++++++++++++++++++++-----
 src/lib/include/fwts_acpi.h  | 12 ++++++++++--
 2 files changed, 35 insertions(+), 7 deletions(-)

Comments

Alex Hung July 30, 2014, 3:07 a.m. UTC | #1
On 07/25/2014 08:39 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Re-sync the definitions of the GTDT for ACPI 5.1 and fix up
> acpidump accordingly.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/acpidump/acpidump.c | 30 +++++++++++++++++++++++++-----
>  src/lib/include/fwts_acpi.h  | 12 ++++++++++--
>  2 files changed, 35 insertions(+), 7 deletions(-)
> 
> diff --git a/src/acpi/acpidump/acpidump.c b/src/acpi/acpidump/acpidump.c
> index 02a0d23..18de789 100644
> --- a/src/acpi/acpidump/acpidump.c
> +++ b/src/acpi/acpidump/acpidump.c
> @@ -1561,21 +1561,41 @@ static void acpidump_bgrt(fwts_framework *fw, const fwts_acpi_table_info *table)
>   */
>  static void acpidump_gtdt(fwts_framework *fw, const fwts_acpi_table_info *table)
>  {
> +	uint8_t *data = (uint8_t *)table->data, *ptr = data;
> +
>  	static const fwts_acpidump_field gtdt_fields[] = {
> -		FIELD_UINT("Physical Address", 		fwts_acpi_table_gtdt, phys_addr),
> -		FIELD_UINT("Global Flags", 		fwts_acpi_table_gtdt, global_flags),
> +		FIELD_UINT("Count Ctrl Physical Addr", 	fwts_acpi_table_gtdt, cnt_control_base_phys_addr),
> +		FIELD_UINT("Reserved", 			fwts_acpi_table_gtdt, reserved),
>  		FIELD_UINT("Secure PL1 Timer GSIV", 	fwts_acpi_table_gtdt, secure_PL1_timer_GSIV),
>  		FIELD_UINT("Secure PL1 Timer Flags", 	fwts_acpi_table_gtdt, secure_PL1_timer_flags),
>  		FIELD_UINT("Non-Secure PL1 Timer GSIV", fwts_acpi_table_gtdt, non_secure_PL1_timer_GSIV),
> -		FIELD_UINT("Non-Secure PL1 Timer Flags", fwts_acpi_table_gtdt, non_secure_PL1_timer_flags),
> +		FIELD_UINT("Non-Secure PL1 Timer Flags",fwts_acpi_table_gtdt, non_secure_PL1_timer_flags),
>  		FIELD_UINT("Virtual Timer GSIV", 	fwts_acpi_table_gtdt, virtual_timer_GSIV),
>  		FIELD_UINT("Virtual Timer flags", 	fwts_acpi_table_gtdt, virtual_timer_flags),
>  		FIELD_UINT("Non-Secure PL2 Timer GSIV", fwts_acpi_table_gtdt, non_secure_PL2_timer_GSIV),
> -		FIELD_UINT("Non-Secure PL2 Timer Flags", fwts_acpi_table_gtdt, non_secure_PL2_timer_flags),
> +		FIELD_UINT("Non-Secure PL2 Timer Flags",fwts_acpi_table_gtdt, non_secure_PL2_timer_flags),
> +		FIELD_UINT("Count Read Physical Addr",	fwts_acpi_table_gtdt, cnt_read_base_phys_addr),
> +		FIELD_UINT("Platform Timer Count",	fwts_acpi_table_gtdt, platform_timer_count),
> +		FIELD_UINT("Platform Timer Offset",	fwts_acpi_table_gtdt, platform_timer_offset),
> +		FIELD_END
> +	};
> +
> +	static const fwts_acpidump_field gtdt_platform_timer_fields[] = {
> +		FIELD_BITF("  Timer Interrupt Mode", 	fwts_acpi_table_gtdt_platform_timer, timer_flags, 1, 0),
> +		FIELD_BITF("  Timer Interrupt Polarity",fwts_acpi_table_gtdt_platform_timer, timer_flags, 1, 1),
> +		FIELD_BITF("  Always-on Capability", 	fwts_acpi_table_gtdt_platform_timer, timer_flags, 1, 2),
>  		FIELD_END
>  	};
>  
> -	acpi_dump_table_fields(fw, table->data, gtdt_fields, 0, table->length);
> +	acpi_dump_table_fields(fw, data, gtdt_fields, 0, table->length);
> +
> +	ptr += sizeof(fwts_acpi_table_gtdt);
> +
> +	/* Now scan through the array of platform timer structures */
> +	while (ptr < data + table->length) {
> +		__acpi_dump_table_fields(fw, ptr, gtdt_platform_timer_fields, ptr - data);
> +		ptr += sizeof(fwts_acpi_table_gtdt_platform_timer);
> +	}
>  }
>  
>  /*
> diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h
> index de7a889..b5d6863 100644
> --- a/src/lib/include/fwts_acpi.h
> +++ b/src/lib/include/fwts_acpi.h
> @@ -682,8 +682,8 @@ typedef struct {
>  
>  /* 5.2.24 Generic Timer Description Table (GTDT) ACPI 5.0 Spec */
>  typedef struct {
> -	uint64_t	phys_addr;
> -	uint32_t	global_flags;
> +	uint64_t	cnt_control_base_phys_addr;
> +	uint32_t	reserved;
>  	uint32_t	secure_PL1_timer_GSIV;
>  	uint32_t	secure_PL1_timer_flags;
>  	uint32_t	non_secure_PL1_timer_GSIV;
> @@ -692,8 +692,16 @@ typedef struct {
>  	uint32_t	virtual_timer_flags;
>  	uint32_t	non_secure_PL2_timer_GSIV;
>  	uint32_t	non_secure_PL2_timer_flags;
> +	uint64_t	cnt_read_base_phys_addr;
> +	uint32_t	platform_timer_count;
> +	uint32_t	platform_timer_offset;
>  } __attribute__ ((packed)) fwts_acpi_table_gtdt;
>  
> +/* 5.2.24 Generic Timer Description Table (GTDT) ACPI 5.0 Spec, table 5-117 */
> +typedef struct {
> +	uint32_t	timer_flags;
> +} __attribute__ ((packed)) fwts_acpi_table_gtdt_platform_timer;
> +
>  /* 5.2.20 ACPI RAS FeatureTable (RASF) */
>  typedef struct {
>          uint8_t         platform_cc_id[12];
> 

The patch looks good; however, I found the above PL1s becomes EL1s in
ACPI spec 5.1. I will send a patch for this change.

Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu Aug. 1, 2014, 3:32 a.m. UTC | #2
On 07/25/2014 08:39 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Re-sync the definitions of the GTDT for ACPI 5.1 and fix up
> acpidump accordingly.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/acpidump/acpidump.c | 30 +++++++++++++++++++++++++-----
>   src/lib/include/fwts_acpi.h  | 12 ++++++++++--
>   2 files changed, 35 insertions(+), 7 deletions(-)
>
> diff --git a/src/acpi/acpidump/acpidump.c b/src/acpi/acpidump/acpidump.c
> index 02a0d23..18de789 100644
> --- a/src/acpi/acpidump/acpidump.c
> +++ b/src/acpi/acpidump/acpidump.c
> @@ -1561,21 +1561,41 @@ static void acpidump_bgrt(fwts_framework *fw, const fwts_acpi_table_info *table)
>    */
>   static void acpidump_gtdt(fwts_framework *fw, const fwts_acpi_table_info *table)
>   {
> +	uint8_t *data = (uint8_t *)table->data, *ptr = data;
> +
>   	static const fwts_acpidump_field gtdt_fields[] = {
> -		FIELD_UINT("Physical Address", 		fwts_acpi_table_gtdt, phys_addr),
> -		FIELD_UINT("Global Flags", 		fwts_acpi_table_gtdt, global_flags),
> +		FIELD_UINT("Count Ctrl Physical Addr", 	fwts_acpi_table_gtdt, cnt_control_base_phys_addr),
> +		FIELD_UINT("Reserved", 			fwts_acpi_table_gtdt, reserved),
>   		FIELD_UINT("Secure PL1 Timer GSIV", 	fwts_acpi_table_gtdt, secure_PL1_timer_GSIV),
>   		FIELD_UINT("Secure PL1 Timer Flags", 	fwts_acpi_table_gtdt, secure_PL1_timer_flags),
>   		FIELD_UINT("Non-Secure PL1 Timer GSIV", fwts_acpi_table_gtdt, non_secure_PL1_timer_GSIV),
> -		FIELD_UINT("Non-Secure PL1 Timer Flags", fwts_acpi_table_gtdt, non_secure_PL1_timer_flags),
> +		FIELD_UINT("Non-Secure PL1 Timer Flags",fwts_acpi_table_gtdt, non_secure_PL1_timer_flags),
>   		FIELD_UINT("Virtual Timer GSIV", 	fwts_acpi_table_gtdt, virtual_timer_GSIV),
>   		FIELD_UINT("Virtual Timer flags", 	fwts_acpi_table_gtdt, virtual_timer_flags),
>   		FIELD_UINT("Non-Secure PL2 Timer GSIV", fwts_acpi_table_gtdt, non_secure_PL2_timer_GSIV),
> -		FIELD_UINT("Non-Secure PL2 Timer Flags", fwts_acpi_table_gtdt, non_secure_PL2_timer_flags),
> +		FIELD_UINT("Non-Secure PL2 Timer Flags",fwts_acpi_table_gtdt, non_secure_PL2_timer_flags),
> +		FIELD_UINT("Count Read Physical Addr",	fwts_acpi_table_gtdt, cnt_read_base_phys_addr),
> +		FIELD_UINT("Platform Timer Count",	fwts_acpi_table_gtdt, platform_timer_count),
> +		FIELD_UINT("Platform Timer Offset",	fwts_acpi_table_gtdt, platform_timer_offset),
> +		FIELD_END
> +	};
> +
> +	static const fwts_acpidump_field gtdt_platform_timer_fields[] = {
> +		FIELD_BITF("  Timer Interrupt Mode", 	fwts_acpi_table_gtdt_platform_timer, timer_flags, 1, 0),
> +		FIELD_BITF("  Timer Interrupt Polarity",fwts_acpi_table_gtdt_platform_timer, timer_flags, 1, 1),
> +		FIELD_BITF("  Always-on Capability", 	fwts_acpi_table_gtdt_platform_timer, timer_flags, 1, 2),
>   		FIELD_END
>   	};
>
> -	acpi_dump_table_fields(fw, table->data, gtdt_fields, 0, table->length);
> +	acpi_dump_table_fields(fw, data, gtdt_fields, 0, table->length);
> +
> +	ptr += sizeof(fwts_acpi_table_gtdt);
> +
> +	/* Now scan through the array of platform timer structures */
> +	while (ptr < data + table->length) {
> +		__acpi_dump_table_fields(fw, ptr, gtdt_platform_timer_fields, ptr - data);
> +		ptr += sizeof(fwts_acpi_table_gtdt_platform_timer);
> +	}
>   }
>
>   /*
> diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h
> index de7a889..b5d6863 100644
> --- a/src/lib/include/fwts_acpi.h
> +++ b/src/lib/include/fwts_acpi.h
> @@ -682,8 +682,8 @@ typedef struct {
>
>   /* 5.2.24 Generic Timer Description Table (GTDT) ACPI 5.0 Spec */
>   typedef struct {
> -	uint64_t	phys_addr;
> -	uint32_t	global_flags;
> +	uint64_t	cnt_control_base_phys_addr;
> +	uint32_t	reserved;
>   	uint32_t	secure_PL1_timer_GSIV;
>   	uint32_t	secure_PL1_timer_flags;
>   	uint32_t	non_secure_PL1_timer_GSIV;
> @@ -692,8 +692,16 @@ typedef struct {
>   	uint32_t	virtual_timer_flags;
>   	uint32_t	non_secure_PL2_timer_GSIV;
>   	uint32_t	non_secure_PL2_timer_flags;
> +	uint64_t	cnt_read_base_phys_addr;
> +	uint32_t	platform_timer_count;
> +	uint32_t	platform_timer_offset;
>   } __attribute__ ((packed)) fwts_acpi_table_gtdt;
>
> +/* 5.2.24 Generic Timer Description Table (GTDT) ACPI 5.0 Spec, table 5-117 */
> +typedef struct {
> +	uint32_t	timer_flags;
> +} __attribute__ ((packed)) fwts_acpi_table_gtdt_platform_timer;
> +
>   /* 5.2.20 ACPI RAS FeatureTable (RASF) */
>   typedef struct {
>           uint8_t         platform_cc_id[12];
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox

Patch

diff --git a/src/acpi/acpidump/acpidump.c b/src/acpi/acpidump/acpidump.c
index 02a0d23..18de789 100644
--- a/src/acpi/acpidump/acpidump.c
+++ b/src/acpi/acpidump/acpidump.c
@@ -1561,21 +1561,41 @@  static void acpidump_bgrt(fwts_framework *fw, const fwts_acpi_table_info *table)
  */
 static void acpidump_gtdt(fwts_framework *fw, const fwts_acpi_table_info *table)
 {
+	uint8_t *data = (uint8_t *)table->data, *ptr = data;
+
 	static const fwts_acpidump_field gtdt_fields[] = {
-		FIELD_UINT("Physical Address", 		fwts_acpi_table_gtdt, phys_addr),
-		FIELD_UINT("Global Flags", 		fwts_acpi_table_gtdt, global_flags),
+		FIELD_UINT("Count Ctrl Physical Addr", 	fwts_acpi_table_gtdt, cnt_control_base_phys_addr),
+		FIELD_UINT("Reserved", 			fwts_acpi_table_gtdt, reserved),
 		FIELD_UINT("Secure PL1 Timer GSIV", 	fwts_acpi_table_gtdt, secure_PL1_timer_GSIV),
 		FIELD_UINT("Secure PL1 Timer Flags", 	fwts_acpi_table_gtdt, secure_PL1_timer_flags),
 		FIELD_UINT("Non-Secure PL1 Timer GSIV", fwts_acpi_table_gtdt, non_secure_PL1_timer_GSIV),
-		FIELD_UINT("Non-Secure PL1 Timer Flags", fwts_acpi_table_gtdt, non_secure_PL1_timer_flags),
+		FIELD_UINT("Non-Secure PL1 Timer Flags",fwts_acpi_table_gtdt, non_secure_PL1_timer_flags),
 		FIELD_UINT("Virtual Timer GSIV", 	fwts_acpi_table_gtdt, virtual_timer_GSIV),
 		FIELD_UINT("Virtual Timer flags", 	fwts_acpi_table_gtdt, virtual_timer_flags),
 		FIELD_UINT("Non-Secure PL2 Timer GSIV", fwts_acpi_table_gtdt, non_secure_PL2_timer_GSIV),
-		FIELD_UINT("Non-Secure PL2 Timer Flags", fwts_acpi_table_gtdt, non_secure_PL2_timer_flags),
+		FIELD_UINT("Non-Secure PL2 Timer Flags",fwts_acpi_table_gtdt, non_secure_PL2_timer_flags),
+		FIELD_UINT("Count Read Physical Addr",	fwts_acpi_table_gtdt, cnt_read_base_phys_addr),
+		FIELD_UINT("Platform Timer Count",	fwts_acpi_table_gtdt, platform_timer_count),
+		FIELD_UINT("Platform Timer Offset",	fwts_acpi_table_gtdt, platform_timer_offset),
+		FIELD_END
+	};
+
+	static const fwts_acpidump_field gtdt_platform_timer_fields[] = {
+		FIELD_BITF("  Timer Interrupt Mode", 	fwts_acpi_table_gtdt_platform_timer, timer_flags, 1, 0),
+		FIELD_BITF("  Timer Interrupt Polarity",fwts_acpi_table_gtdt_platform_timer, timer_flags, 1, 1),
+		FIELD_BITF("  Always-on Capability", 	fwts_acpi_table_gtdt_platform_timer, timer_flags, 1, 2),
 		FIELD_END
 	};
 
-	acpi_dump_table_fields(fw, table->data, gtdt_fields, 0, table->length);
+	acpi_dump_table_fields(fw, data, gtdt_fields, 0, table->length);
+
+	ptr += sizeof(fwts_acpi_table_gtdt);
+
+	/* Now scan through the array of platform timer structures */
+	while (ptr < data + table->length) {
+		__acpi_dump_table_fields(fw, ptr, gtdt_platform_timer_fields, ptr - data);
+		ptr += sizeof(fwts_acpi_table_gtdt_platform_timer);
+	}
 }
 
 /*
diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h
index de7a889..b5d6863 100644
--- a/src/lib/include/fwts_acpi.h
+++ b/src/lib/include/fwts_acpi.h
@@ -682,8 +682,8 @@  typedef struct {
 
 /* 5.2.24 Generic Timer Description Table (GTDT) ACPI 5.0 Spec */
 typedef struct {
-	uint64_t	phys_addr;
-	uint32_t	global_flags;
+	uint64_t	cnt_control_base_phys_addr;
+	uint32_t	reserved;
 	uint32_t	secure_PL1_timer_GSIV;
 	uint32_t	secure_PL1_timer_flags;
 	uint32_t	non_secure_PL1_timer_GSIV;
@@ -692,8 +692,16 @@  typedef struct {
 	uint32_t	virtual_timer_flags;
 	uint32_t	non_secure_PL2_timer_GSIV;
 	uint32_t	non_secure_PL2_timer_flags;
+	uint64_t	cnt_read_base_phys_addr;
+	uint32_t	platform_timer_count;
+	uint32_t	platform_timer_offset;
 } __attribute__ ((packed)) fwts_acpi_table_gtdt;
 
+/* 5.2.24 Generic Timer Description Table (GTDT) ACPI 5.0 Spec, table 5-117 */
+typedef struct {
+	uint32_t	timer_flags;
+} __attribute__ ((packed)) fwts_acpi_table_gtdt_platform_timer;
+
 /* 5.2.20 ACPI RAS FeatureTable (RASF) */
 typedef struct {
         uint8_t         platform_cc_id[12];