[PATCH 1/2][V2] acpi: Add DBGP table test (LP: #1465441)
Colin King
colin.king at canonical.com
Thu Jun 18 06:24:34 UTC 2015
From: Colin Ian King <colin.king at canonical.com>
This table is trival, just a few minor checks on the
table size, generic address structure and the
interface type. Tested against a few hundred examples
in my ACPI database.
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
src/Makefile.am | 1 +
src/acpi/dbgp/dbgp.c | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 140 insertions(+)
create mode 100644 src/acpi/dbgp/dbgp.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 4aa1986..e94e100 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -39,6 +39,7 @@ fwts_SOURCES = main.c \
acpi/crsdump/crsdump.c \
acpi/crsdump/prsdump.c \
acpi/cstates/cstates.c \
+ acpi/dbgp/dbgp.c \
acpi/dmar/dmar.c \
acpi/ecdt/ecdt.c \
acpi/fadt/fadt.c \
diff --git a/src/acpi/dbgp/dbgp.c b/src/acpi/dbgp/dbgp.c
new file mode 100644
index 0000000..2943047
--- /dev/null
+++ b/src/acpi/dbgp/dbgp.c
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2015 Canonical
+ *
+ * Portions of this code original from the Linux-ready Firmware Developer Kit
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#include "fwts.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <inttypes.h>
+#include <string.h>
+
+static fwts_acpi_table_info *table;
+
+static int dbgp_init(fwts_framework *fw)
+{
+
+ if (fwts_acpi_find_table(fw, "DBGP", 0, &table) != FWTS_OK) {
+ fwts_log_error(fw, "Cannot read ACPI tables.");
+ return FWTS_ERROR;
+ }
+ if (table == NULL || (table && table->length == 0)) {
+ fwts_log_error(fw, "ACPI DBGP table does not exist, skipping test");
+ return FWTS_SKIP;
+ }
+
+ return FWTS_OK;
+}
+
+/*
+ * DBGP Table
+ * see https://msdn.microsoft.com/en-us/library/windows/hardware/dn639130%28v=vs.85%29.aspx
+ */
+static int dbgp_test1(fwts_framework *fw)
+{
+ bool passed = true;
+ char *interface_type;
+ fwts_acpi_table_dbgp *dbgp = (fwts_acpi_table_dbgp *)table->data;
+
+ if (table->length < sizeof(fwts_acpi_table_dbgp)) {
+ passed = false;
+ fwts_failed(fw, LOG_LEVEL_HIGH,
+ "DBGPTooShort",
+ "DBGP table too short, expecting %zu bytes, "
+ "instead got %zu bytes",
+ sizeof(fwts_acpi_table_dbgp), table->length);
+ goto done;
+ }
+
+ switch (dbgp->interface_type) {
+ case 0:
+ interface_type = "Full 16550 interface";
+ break;
+ case 1:
+ interface_type = "16550 subset interface";
+ break;
+ default:
+ interface_type = "Reserved";
+ break;
+ }
+
+ fwts_log_info_verbatum(fw, "DBGP Table:");
+ fwts_log_info_verbatum(fw, " Interface Type 0x%2.2" PRIx8 " (%s)",
+ dbgp->interface_type, interface_type);
+ fwts_log_info_verbatum(fw, " Reserved: 0x%2.2" PRIx8, dbgp->reserved1[0]);
+ fwts_log_info_verbatum(fw, " Reserved: 0x%2.2" PRIx8, dbgp->reserved1[1]);
+ fwts_log_info_verbatum(fw, " Reserved: 0x%2.2" PRIx8, dbgp->reserved1[2]);
+ fwts_log_info_verbatum(fw, " Base Address:");
+ fwts_log_info_verbatum(fw, " Address Space ID: 0x%2.2" PRIx8, dbgp->base_address.address_space_id);
+ fwts_log_info_verbatum(fw, " Register Bit Width 0x%2.2" PRIx8, dbgp->base_address.register_bit_width);
+ fwts_log_info_verbatum(fw, " Register Bit Offset 0x%2.2" PRIx8, dbgp->base_address.register_bit_offset);
+ fwts_log_info_verbatum(fw, " Access Size 0x%2.2" PRIx8, dbgp->base_address.access_width);
+ fwts_log_info_verbatum(fw, " Address 0x%16.16" PRIx64, dbgp->base_address.address);
+ fwts_log_nl(fw);
+
+ if (dbgp->interface_type > 2) {
+ passed = false;
+ fwts_failed(fw, LOG_LEVEL_HIGH,
+ "DBGPReservedInterfaceType",
+ "DBGP Interface Type is 0x%2.2" PRIx8
+ " which is a reserved interface type. Expecting "
+ " 0x00 (Full 16550) or 0x01 (16550 subset)",
+ dbgp->interface_type);
+ }
+ if (dbgp->base_address.register_bit_width == 0) {
+ passed = false;
+ fwts_failed(fw, LOG_LEVEL_HIGH,
+ "DBGPBaseAddrBitWidthZero",
+ "DBGP Base Address Bit Width is zero.");
+ }
+ switch (dbgp->base_address.address_space_id) {
+ case 0x05 ... 0x09:
+ case 0x0b ... 0x7e:
+ case 0x80 ... 0xbf:
+ passed = false;
+ fwts_failed(fw, LOG_LEVEL_HIGH,
+ "DBGPBaseAddrAddrSpaceID",
+ "DBGP Base Address, Address Space ID 0x%" PRIx8
+ " which is a reserved value.",
+ dbgp->base_address.address_space_id);
+ break;
+ default:
+ break;
+ }
+done:
+ if (passed)
+ fwts_passed(fw, "No issues found in DBGP table.");
+
+ return FWTS_OK;
+}
+
+static fwts_framework_minor_test dbgp_tests[] = {
+ { dbgp_test1, "DBGP (Debug Port) Table test." },
+ { NULL, NULL }
+};
+
+static fwts_framework_ops dbgp_ops = {
+ .description = "DBGP (Debug Port) Table test.",
+ .init = dbgp_init,
+ .minor_tests = dbgp_tests
+};
+
+FWTS_REGISTER("dbgp", &dbgp_ops, FWTS_TEST_ANYTIME, FWTS_FLAG_BATCH | FWTS_FLAG_ROOT_PRIV | FWTS_FLAG_TEST_ACPI)
--
2.1.4
More information about the fwts-devel
mailing list