ACK: [PATCH 06/30] acpi: move XSDT test from acpitables into new XSDT test

ivanhu ivan.hu at canonical.com
Wed Jun 24 06:16:43 UTC 2015



On 2015年06月18日 16:49, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Re-organise XSDT test, move it out of acpitables and into
> a new acpi XSDT test
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>   src/Makefile.am                  |  1 +
>   src/acpi/acpitables/acpitables.c | 18 ---------
>   src/acpi/xsdt/xsdt.c             | 85 ++++++++++++++++++++++++++++++++++++++++
>   3 files changed, 86 insertions(+), 18 deletions(-)
>   create mode 100644 src/acpi/xsdt/xsdt.c
>
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 70cc5d8..6a20bf2 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -67,6 +67,7 @@ fwts_SOURCES = main.c 				\
>   	acpi/syntaxcheck/syntaxcheck.c 		\
>   	acpi/wakealarm/wakealarm.c 		\
>   	acpi/wmi/wmi.c 				\
> +	acpi/xsdt/xsdt.c			\
>   	apic/apicedge/apicedge.c 		\
>   	bios/bios_info/bios_info.c 		\
>   	bios/bios32/bios32.c 			\
> diff --git a/src/acpi/acpitables/acpitables.c b/src/acpi/acpitables/acpitables.c
> index e42c1e9..8822eb4 100644
> --- a/src/acpi/acpitables/acpitables.c
> +++ b/src/acpi/acpitables/acpitables.c
> @@ -296,23 +296,6 @@ static void acpi_table_check_sbst(fwts_framework *fw, fwts_acpi_table_info *tabl
>   	}
>   }
>   
> -static void acpi_table_check_xsdt(fwts_framework *fw, fwts_acpi_table_info *table)
> -{
> -	int i;
> -	int n;
> -	fwts_acpi_table_xsdt *xsdt = (fwts_acpi_table_xsdt*)table->data;
> -
> -	n = (table->length - sizeof(fwts_acpi_table_header)) / sizeof(uint64_t);
> -	for (i=0; i<n; i++)  {
> -		if (xsdt->entries[i] == 0) {
> -			fwts_failed(fw, LOG_LEVEL_MEDIUM, "XSDTEntryNull", "XSDT Entry %d is null, should not be non-zero.", i);
> -			fwts_advice(fw, "A XSDT pointer is null and therefore erroneously points to an invalid 64 bit "
> -					"ACPI table header. At worse this will cause the kernel to oops, at best the kernel "
> -					"may ignore this.  However, it should be fixed where possible.");
> -		}
> -	}
> -}
> -
>   static void acpi_table_check_mcfg(fwts_framework *fw, fwts_acpi_table_info *table)
>   {
>   	FWTS_UNUSED(fw);
> @@ -332,7 +315,6 @@ static acpi_table_check_table check_table[] = {
>   	{ "RSDT", acpi_table_check_rsdt },
>   	{ "RSDP", acpi_table_check_rsdp },
>   	{ "SBST", acpi_table_check_sbst },
> -	{ "XSDT", acpi_table_check_xsdt },
>   	{ NULL  , NULL },
>   } ;
>   
> diff --git a/src/acpi/xsdt/xsdt.c b/src/acpi/xsdt/xsdt.c
> new file mode 100644
> index 0000000..779038a
> --- /dev/null
> +++ b/src/acpi/xsdt/xsdt.c
> @@ -0,0 +1,85 @@
> +/*
> + * 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 xsdt_init(fwts_framework *fw)
> +{
> +	if (fwts_acpi_find_table(fw, "XSDT", 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 XSDT table does not exist, skipping test");
> +		return FWTS_SKIP;
> +	}
> +	return FWTS_OK;
> +}
> +
> +/*
> + *  XSDT Extended System Description Table
> + */
> +static int xsdt_test1(fwts_framework *fw)
> +{
> +	fwts_acpi_table_xsdt *xsdt = (fwts_acpi_table_xsdt*)table->data;
> +	size_t i, n;
> +	bool passed = true;
> +
> +	n = (table->length - sizeof(fwts_acpi_table_header)) / sizeof(uint64_t);
> +	for (i = 0; i < n; i++) {
> +		if (xsdt->entries[i] == 0) {
> +			passed = false;
> +			fwts_failed(fw, LOG_LEVEL_MEDIUM,
> +				"XSDTEntryNull",
> +				"XSDT Entry %zd is null, should not be non-zero.", i);
> +			fwts_advice(fw,
> +				"A XSDT pointer is null and therefore erroneously "
> +				"points to an invalid 64 bit ACPI table header. "
> +				"At worse this will cause the kernel to oops, at "
> +				"best the kernel may ignore this.  However, it "
> +				"should be fixed where possible.");
> +		}
> +	}
> +	if (passed)
> +		fwts_passed(fw, "No issues found in XSDT table.");
> +
> +	return FWTS_OK;
> +}
> +
> +static fwts_framework_minor_test xsdt_tests[] = {
> +	{ xsdt_test1, "XSDT Extended System Description Table test." },
> +	{ NULL, NULL }
> +};
> +
> +static fwts_framework_ops xsdt_ops = {
> +	.description = "XSDT Extended System Description Table test.",
> +	.init        = xsdt_init,
> +	.minor_tests = xsdt_tests
> +};
> +
> +FWTS_REGISTER("xsdt", &xsdt_ops, FWTS_TEST_ANYTIME, FWTS_FLAG_BATCH | FWTS_FLAG_ROOT_PRIV | FWTS_FLAG_TEST_ACPI)
Acked-by: Ivan Hu<ivan.hu at canonical.com>



More information about the fwts-devel mailing list