Patchwork acpi: acpidump: fix ACPI FPDT dump

login
register
mail settings
Submitter Colin King
Date Jan. 1, 2013, 12:53 a.m.
Message ID <1357001594-30771-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/208898/
State Accepted
Headers show

Comments

Colin King - Jan. 1, 2013, 12:53 a.m.
From: Colin Ian King <colin.king@canonical.com>

Fix the output of the ACPI FPDT dump.  This now prints the
performance record types correctly as well as binary dumps the
reserved fields that are not described in the ACPI specification.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/acpidump/acpidump.c | 54 ++++++++++++++++++++++++++++++++------------
 1 file changed, 39 insertions(+), 15 deletions(-)
Alex Hung - Jan. 2, 2013, 12:49 a.m.
On 01/01/2013 08:53 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Fix the output of the ACPI FPDT dump.  This now prints the
> performance record types correctly as well as binary dumps the
> reserved fields that are not described in the ACPI specification.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/acpidump/acpidump.c | 54 ++++++++++++++++++++++++++++++++------------
>   1 file changed, 39 insertions(+), 15 deletions(-)
>
> diff --git a/src/acpi/acpidump/acpidump.c b/src/acpi/acpidump/acpidump.c
> index 88dbc10..5f3e25e 100644
> --- a/src/acpi/acpidump/acpidump.c
> +++ b/src/acpi/acpidump/acpidump.c
> @@ -1550,6 +1550,7 @@ static void acpidump_fpdt(fwts_framework *fw, fwts_acpi_table_info *table)
>   	uint8_t *data = (uint8_t *)table->data;
>   	uint8_t *ptr  = data;
>   	size_t length = table->length;
> +	const size_t fpdt_hdr_len = sizeof(fwts_acpi_table_fpdt_header);
>
>   	static fwts_acpidump_field fpdt_header_fields[] = {
>   		FIELD_UINT("Type", 		fwts_acpi_table_fpdt_header, type),
> @@ -1558,17 +1559,19 @@ static void acpidump_fpdt(fwts_framework *fw, fwts_acpi_table_info *table)
>   		FIELD_END
>   	};
>
> +	static fwts_acpidump_field fpdt_basic_boot_perf_ptr_fields[] = {
> +		FIELD_UINT("Reserved", 		fwts_acpi_table_fpdt_basic_boot_perf_ptr, reserved),
> +		FIELD_UINT("FBPT Pointer", 	fwts_acpi_table_fpdt_basic_boot_perf_ptr, fbpt_addr),
> +		FIELD_END
> +	};
> +
>   	static fwts_acpidump_field fpdt_s3_perf_ptr_fields[] = {
>   		FIELD_UINT("Reserved", 		fwts_acpi_table_fpdt_s3_perf_ptr, reserved),
>   		FIELD_UINT("S3PT Pointer", 	fwts_acpi_table_fpdt_s3_perf_ptr, s3pt_addr),
>   		FIELD_END
>   	};
>
> -	static fwts_acpidump_field fpdt_basic_boot_perf_ptr_fields[] = {
> -		FIELD_UINT("Reserved", 		fwts_acpi_table_fpdt_basic_boot_perf_ptr, reserved),
> -		FIELD_UINT("FBPT Pointer", 	fwts_acpi_table_fpdt_basic_boot_perf_ptr, fbpt_addr),
> -		FIELD_END
> -	};
> +	ptr += sizeof(fwts_acpi_table_header);
>
>   	/*
>   	 *  Currently we just dump out the various pointer records.  A more complete
> @@ -1578,24 +1581,45 @@ static void acpidump_fpdt(fwts_framework *fw, fwts_acpi_table_info *table)
>   	while (ptr < data + length) {
>   		fwts_acpi_table_fpdt_header *fpdt = (fwts_acpi_table_fpdt_header*)ptr;
>
> -		__acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
> +		fwts_log_nl(fw);
> +
>   		switch (fpdt->type) {
> -		case 0:
> -			fwts_log_info_verbatum(fw, "S3 resume performance record pointer:");
> -			__acpi_dump_table_fields(fw, ptr, fpdt_s3_perf_ptr_fields, ptr - data);
> +		case 0x0000:
> +			fwts_log_info_verbatum(fw, "Basic Boot Performance Data Record pointer:");
> +			__acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
> +			__acpi_dump_table_fields(fw, ptr, fpdt_basic_boot_perf_ptr_fields, ptr - data);
>   			break;
> -		case 1:
> -			fwts_log_info_verbatum(fw, "S3 suspend performance record pointer:");
> +		case 0x0001:
> +			fwts_log_info_verbatum(fw, "S3 Performance Table pointer:");
> +			__acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
>   			__acpi_dump_table_fields(fw, ptr, fpdt_s3_perf_ptr_fields, ptr - data);
>   			break;
> -		case 2:
> -			fwts_log_info_verbatum(fw, "Boot performance record pointer:");
> -			__acpi_dump_table_fields(fw, ptr, fpdt_basic_boot_perf_ptr_fields, ptr - data);
> +		case 0x0002 ... 0x0fff:
> +			fwts_log_info_verbatum(fw, "Reserved for ACPI specification useage:");
> +			__acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
> +			acpi_dump_raw_data(fw, ptr + fpdt_hdr_len, fpdt->length - fpdt_hdr_len, ptr + fpdt_hdr_len - data);
> +			break;
> +		case 0x1000 ... 0x1fff:
> +			fwts_log_info_verbatum(fw, "Reserved for Platform Vendor useage:");
> +			__acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
> +			acpi_dump_raw_data(fw, ptr + fpdt_hdr_len, fpdt->length - fpdt_hdr_len, ptr + fpdt_hdr_len - data);
> +			break;
> +		case 0x2000 ... 0x2fff:
> +			fwts_log_info_verbatum(fw, "Reserved for Hardware Vendor useage:");
> +			__acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
> +			acpi_dump_raw_data(fw, ptr + fpdt_hdr_len, fpdt->length - fpdt_hdr_len, ptr + fpdt_hdr_len - data);
> +			break;
> +		case 0x3000 ... 0x3fff:
> +			fwts_log_info_verbatum(fw, "Reserved for BIOS Vendor useage:");
> +			__acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
> +			acpi_dump_raw_data(fw, ptr + fpdt_hdr_len, fpdt->length - fpdt_hdr_len, ptr + fpdt_hdr_len - data);
>   			break;
>   		default:
> +			fwts_log_info_verbatum(fw, "Reserved for future useage:");
> +			__acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
> +			acpi_dump_raw_data(fw, ptr + fpdt_hdr_len, fpdt->length - fpdt_hdr_len, ptr + fpdt_hdr_len - data);
>   			break;
>   		}
> -
>   		ptr += fpdt->length;
>   	}
>   }
>

Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - Jan. 14, 2013, 6:25 a.m.
On Tue, Jan 1, 2013 at 8:53 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Fix the output of the ACPI FPDT dump.  This now prints the
> performance record types correctly as well as binary dumps the
> reserved fields that are not described in the ACPI specification.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/acpidump/acpidump.c | 54 ++++++++++++++++++++++++++++++++------------
>  1 file changed, 39 insertions(+), 15 deletions(-)
>
> diff --git a/src/acpi/acpidump/acpidump.c b/src/acpi/acpidump/acpidump.c
> index 88dbc10..5f3e25e 100644
> --- a/src/acpi/acpidump/acpidump.c
> +++ b/src/acpi/acpidump/acpidump.c
> @@ -1550,6 +1550,7 @@ static void acpidump_fpdt(fwts_framework *fw, fwts_acpi_table_info *table)
>         uint8_t *data = (uint8_t *)table->data;
>         uint8_t *ptr  = data;
>         size_t length = table->length;
> +       const size_t fpdt_hdr_len = sizeof(fwts_acpi_table_fpdt_header);
>
>         static fwts_acpidump_field fpdt_header_fields[] = {
>                 FIELD_UINT("Type",              fwts_acpi_table_fpdt_header, type),
> @@ -1558,17 +1559,19 @@ static void acpidump_fpdt(fwts_framework *fw, fwts_acpi_table_info *table)
>                 FIELD_END
>         };
>
> +       static fwts_acpidump_field fpdt_basic_boot_perf_ptr_fields[] = {
> +               FIELD_UINT("Reserved",          fwts_acpi_table_fpdt_basic_boot_perf_ptr, reserved),
> +               FIELD_UINT("FBPT Pointer",      fwts_acpi_table_fpdt_basic_boot_perf_ptr, fbpt_addr),
> +               FIELD_END
> +       };
> +
>         static fwts_acpidump_field fpdt_s3_perf_ptr_fields[] = {
>                 FIELD_UINT("Reserved",          fwts_acpi_table_fpdt_s3_perf_ptr, reserved),
>                 FIELD_UINT("S3PT Pointer",      fwts_acpi_table_fpdt_s3_perf_ptr, s3pt_addr),
>                 FIELD_END
>         };
>
> -       static fwts_acpidump_field fpdt_basic_boot_perf_ptr_fields[] = {
> -               FIELD_UINT("Reserved",          fwts_acpi_table_fpdt_basic_boot_perf_ptr, reserved),
> -               FIELD_UINT("FBPT Pointer",      fwts_acpi_table_fpdt_basic_boot_perf_ptr, fbpt_addr),
> -               FIELD_END
> -       };
> +       ptr += sizeof(fwts_acpi_table_header);
>
>         /*
>          *  Currently we just dump out the various pointer records.  A more complete
> @@ -1578,24 +1581,45 @@ static void acpidump_fpdt(fwts_framework *fw, fwts_acpi_table_info *table)
>         while (ptr < data + length) {
>                 fwts_acpi_table_fpdt_header *fpdt = (fwts_acpi_table_fpdt_header*)ptr;
>
> -               __acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
> +               fwts_log_nl(fw);
> +
>                 switch (fpdt->type) {
> -               case 0:
> -                       fwts_log_info_verbatum(fw, "S3 resume performance record pointer:");
> -                       __acpi_dump_table_fields(fw, ptr, fpdt_s3_perf_ptr_fields, ptr - data);
> +               case 0x0000:
> +                       fwts_log_info_verbatum(fw, "Basic Boot Performance Data Record pointer:");
> +                       __acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
> +                       __acpi_dump_table_fields(fw, ptr, fpdt_basic_boot_perf_ptr_fields, ptr - data);
>                         break;
> -               case 1:
> -                       fwts_log_info_verbatum(fw, "S3 suspend performance record pointer:");
> +               case 0x0001:
> +                       fwts_log_info_verbatum(fw, "S3 Performance Table pointer:");
> +                       __acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
>                         __acpi_dump_table_fields(fw, ptr, fpdt_s3_perf_ptr_fields, ptr - data);
>                         break;
> -               case 2:
> -                       fwts_log_info_verbatum(fw, "Boot performance record pointer:");
> -                       __acpi_dump_table_fields(fw, ptr, fpdt_basic_boot_perf_ptr_fields, ptr - data);
> +               case 0x0002 ... 0x0fff:
> +                       fwts_log_info_verbatum(fw, "Reserved for ACPI specification useage:");
> +                       __acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
> +                       acpi_dump_raw_data(fw, ptr + fpdt_hdr_len, fpdt->length - fpdt_hdr_len, ptr + fpdt_hdr_len - data);
> +                       break;
> +               case 0x1000 ... 0x1fff:
> +                       fwts_log_info_verbatum(fw, "Reserved for Platform Vendor useage:");
> +                       __acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
> +                       acpi_dump_raw_data(fw, ptr + fpdt_hdr_len, fpdt->length - fpdt_hdr_len, ptr + fpdt_hdr_len - data);
> +                       break;
> +               case 0x2000 ... 0x2fff:
> +                       fwts_log_info_verbatum(fw, "Reserved for Hardware Vendor useage:");
> +                       __acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
> +                       acpi_dump_raw_data(fw, ptr + fpdt_hdr_len, fpdt->length - fpdt_hdr_len, ptr + fpdt_hdr_len - data);
> +                       break;
> +               case 0x3000 ... 0x3fff:
> +                       fwts_log_info_verbatum(fw, "Reserved for BIOS Vendor useage:");
> +                       __acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
> +                       acpi_dump_raw_data(fw, ptr + fpdt_hdr_len, fpdt->length - fpdt_hdr_len, ptr + fpdt_hdr_len - data);
>                         break;
>                 default:
> +                       fwts_log_info_verbatum(fw, "Reserved for future useage:");
> +                       __acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
> +                       acpi_dump_raw_data(fw, ptr + fpdt_hdr_len, fpdt->length - fpdt_hdr_len, ptr + fpdt_hdr_len - data);
>                         break;
>                 }
> -
>                 ptr += fpdt->length;
>         }
>  }
> --
> 1.8.0
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch

diff --git a/src/acpi/acpidump/acpidump.c b/src/acpi/acpidump/acpidump.c
index 88dbc10..5f3e25e 100644
--- a/src/acpi/acpidump/acpidump.c
+++ b/src/acpi/acpidump/acpidump.c
@@ -1550,6 +1550,7 @@  static void acpidump_fpdt(fwts_framework *fw, fwts_acpi_table_info *table)
 	uint8_t *data = (uint8_t *)table->data;
 	uint8_t *ptr  = data;
 	size_t length = table->length;
+	const size_t fpdt_hdr_len = sizeof(fwts_acpi_table_fpdt_header);
 
 	static fwts_acpidump_field fpdt_header_fields[] = {
 		FIELD_UINT("Type", 		fwts_acpi_table_fpdt_header, type),
@@ -1558,17 +1559,19 @@  static void acpidump_fpdt(fwts_framework *fw, fwts_acpi_table_info *table)
 		FIELD_END
 	};
 
+	static fwts_acpidump_field fpdt_basic_boot_perf_ptr_fields[] = {
+		FIELD_UINT("Reserved", 		fwts_acpi_table_fpdt_basic_boot_perf_ptr, reserved),
+		FIELD_UINT("FBPT Pointer", 	fwts_acpi_table_fpdt_basic_boot_perf_ptr, fbpt_addr),
+		FIELD_END
+	};
+
 	static fwts_acpidump_field fpdt_s3_perf_ptr_fields[] = {
 		FIELD_UINT("Reserved", 		fwts_acpi_table_fpdt_s3_perf_ptr, reserved),
 		FIELD_UINT("S3PT Pointer", 	fwts_acpi_table_fpdt_s3_perf_ptr, s3pt_addr),
 		FIELD_END
 	};
 
-	static fwts_acpidump_field fpdt_basic_boot_perf_ptr_fields[] = {
-		FIELD_UINT("Reserved", 		fwts_acpi_table_fpdt_basic_boot_perf_ptr, reserved),
-		FIELD_UINT("FBPT Pointer", 	fwts_acpi_table_fpdt_basic_boot_perf_ptr, fbpt_addr),
-		FIELD_END
-	};
+	ptr += sizeof(fwts_acpi_table_header);
 
 	/*
 	 *  Currently we just dump out the various pointer records.  A more complete
@@ -1578,24 +1581,45 @@  static void acpidump_fpdt(fwts_framework *fw, fwts_acpi_table_info *table)
 	while (ptr < data + length) {
 		fwts_acpi_table_fpdt_header *fpdt = (fwts_acpi_table_fpdt_header*)ptr;
 
-		__acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
+		fwts_log_nl(fw);
+
 		switch (fpdt->type) {
-		case 0:
-			fwts_log_info_verbatum(fw, "S3 resume performance record pointer:");
-			__acpi_dump_table_fields(fw, ptr, fpdt_s3_perf_ptr_fields, ptr - data);
+		case 0x0000:
+			fwts_log_info_verbatum(fw, "Basic Boot Performance Data Record pointer:");
+			__acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
+			__acpi_dump_table_fields(fw, ptr, fpdt_basic_boot_perf_ptr_fields, ptr - data);
 			break;
-		case 1:
-			fwts_log_info_verbatum(fw, "S3 suspend performance record pointer:");
+		case 0x0001:
+			fwts_log_info_verbatum(fw, "S3 Performance Table pointer:");
+			__acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
 			__acpi_dump_table_fields(fw, ptr, fpdt_s3_perf_ptr_fields, ptr - data);
 			break;
-		case 2:
-			fwts_log_info_verbatum(fw, "Boot performance record pointer:");
-			__acpi_dump_table_fields(fw, ptr, fpdt_basic_boot_perf_ptr_fields, ptr - data);
+		case 0x0002 ... 0x0fff:
+			fwts_log_info_verbatum(fw, "Reserved for ACPI specification useage:");
+			__acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
+			acpi_dump_raw_data(fw, ptr + fpdt_hdr_len, fpdt->length - fpdt_hdr_len, ptr + fpdt_hdr_len - data);
+			break;
+		case 0x1000 ... 0x1fff:
+			fwts_log_info_verbatum(fw, "Reserved for Platform Vendor useage:");
+			__acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
+			acpi_dump_raw_data(fw, ptr + fpdt_hdr_len, fpdt->length - fpdt_hdr_len, ptr + fpdt_hdr_len - data);
+			break;
+		case 0x2000 ... 0x2fff:
+			fwts_log_info_verbatum(fw, "Reserved for Hardware Vendor useage:");
+			__acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
+			acpi_dump_raw_data(fw, ptr + fpdt_hdr_len, fpdt->length - fpdt_hdr_len, ptr + fpdt_hdr_len - data);
+			break;
+		case 0x3000 ... 0x3fff:
+			fwts_log_info_verbatum(fw, "Reserved for BIOS Vendor useage:");
+			__acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
+			acpi_dump_raw_data(fw, ptr + fpdt_hdr_len, fpdt->length - fpdt_hdr_len, ptr + fpdt_hdr_len - data);
 			break;
 		default:
+			fwts_log_info_verbatum(fw, "Reserved for future useage:");
+			__acpi_dump_table_fields(fw, ptr, fpdt_header_fields, ptr - data);
+			acpi_dump_raw_data(fw, ptr + fpdt_hdr_len, fpdt->length - fpdt_hdr_len, ptr + fpdt_hdr_len - data);
 			break;
 		}
-
 		ptr += fpdt->length;
 	}
 }