From patchwork Fri Jul 20 17:25:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 172314 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 684292C03AE for ; Sat, 21 Jul 2012 03:25:27 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SsGxB-0005y4-Ol for incoming@patchwork.ozlabs.org; Fri, 20 Jul 2012 17:25:25 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SsGx9-0005xu-GU for fwts-devel@lists.ubuntu.com; Fri, 20 Jul 2012 17:25:23 +0000 Received: from 74-95-45-185-oregon.hfc.comcastbusiness.net ([74.95.45.185] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1SsGx9-0003r6-0H for fwts-devel@lists.ubuntu.com; Fri, 20 Jul 2012 17:25:23 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] acpi: acpidump + acpi headers: Add simple support for FPDT Date: Fri, 20 Jul 2012 10:25:20 -0700 Message-Id: <1342805120-10139-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.7.10.4 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: fwts-devel-bounces@lists.ubuntu.com Errors-To: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King ACPI 5.0 has introduced the FPDT, so add some simple acpidump support for the FPDT and FPDT pointer records. Signed-off-by: Colin Ian King Acked-by: Keng-Yu Lin Acked-by: Ivan Hu --- src/acpi/acpidump/acpidump.c | 61 ++++++++++++++++++++++++++++++++++++++++++ src/lib/include/fwts_acpi.h | 21 +++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/src/acpi/acpidump/acpidump.c b/src/acpi/acpidump/acpidump.c index 0985597..ef7c79d 100644 --- a/src/acpi/acpidump/acpidump.c +++ b/src/acpi/acpidump/acpidump.c @@ -1511,6 +1511,66 @@ static void acpidump_gtdt(fwts_framework *fw, fwts_acpi_table_info *table) acpi_dump_table_fields(fw, data, gtdt_fields, length, length); } +/* + * acpidump_fpdt() + * dump FPDT, see 5.2.23 Firmware Performance Data Table (FPDT) + * of version 5.0 ACPI spec. + */ +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; + + static fwts_acpidump_field fpdt_header_fields[] = { + FIELD_UINT("Type", fwts_acpi_table_fpdt_header, type), + FIELD_UINT("Length", fwts_acpi_table_fpdt_header, length), + FIELD_UINT("Revision", fwts_acpi_table_fpdt_header, revision), + 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 + }; + + /* + * Currently we just dump out the various pointer records. A more complete + * implementation should mmap the memory that the records point to and also + * dump these out. That's an implementation issue for later. + */ + 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); + 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); + break; + case 1: + fwts_log_info_verbatum(fw, "S3 suspend performance record pointer:"); + __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); + break; + default: + break; + } + + ptr += fpdt->length; + } +} + typedef struct { char *name; void (*func)(fwts_framework *fw, fwts_acpi_table_info *table); @@ -1536,6 +1596,7 @@ static acpidump_table_vec table_vec[] = { { "ERST", acpidump_erst, 1 }, { "FACP", acpidump_fadt, 1 }, { "FACS", acpidump_facs, 0 }, + { "FPDT", acpidump_fpdt, 1 }, { "GTDT", acpidump_gtdt, 1 }, { "HEST", acpidump_hest, 1 }, { "HPET", acpidump_hpet, 1 }, diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h index d559468..5e9a24a 100644 --- a/src/lib/include/fwts_acpi.h +++ b/src/lib/include/fwts_acpi.h @@ -603,6 +603,27 @@ typedef struct { uint32_t image_offset_t; } __attribute__ ((packed)) fwts_acpi_table_bgrt; +/* 5.2.23 Firmware Performance Data Table (FPDT) ACPI 5.0 spec */ +typedef struct { + uint16_t type; + uint8_t length; + uint8_t revision; +} __attribute__ ((packed)) fwts_acpi_table_fpdt_header; + +/* 5.2.23.4 S3 Performance Table Pointer Record */ +typedef struct { + fwts_acpi_table_fpdt_header fpdt; + uint32_t reserved; + uint64_t s3pt_addr; +} __attribute__ ((packed)) fwts_acpi_table_fpdt_s3_perf_ptr; + +/* 5.2.23.5 Firmware Basic Boot Performance Pointer Record */ +typedef struct { + fwts_acpi_table_fpdt_header fpdt; + uint32_t reserved; + uint64_t fbpt_addr; +} __attribute__ ((packed)) fwts_acpi_table_fpdt_basic_boot_perf_ptr; + /* 5.2.24 Generic Timer Description Table (GTDT) ACPI 5.0 Spec */ typedef struct { uint64_t phys_addr;