ACK: [PATCH 1/2] acpi: add XENV table test

ivanhu ivan.hu at canonical.com
Mon Jul 6 09:18:20 UTC 2015



On 2015年07月06日 15:29, Alex Hung wrote:
> Signed-off-by: Alex Hung <alex.hung at canonical.com>
> ---
>   src/Makefile.am             |   1 +
>   src/acpi/xenv/xenv.c        | 103 ++++++++++++++++++++++++++++++++++++++++++++
>   src/lib/include/fwts_acpi.h |   9 ++++
>   3 files changed, 113 insertions(+)
>   create mode 100644 src/acpi/xenv/xenv.c
>
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 7cf5125..3ee3b4e 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -81,6 +81,7 @@ fwts_SOURCES = main.c 				\
>   	acpi/wakealarm/wakealarm.c 		\
>   	acpi/wmi/wmi.c 				\
>   	acpi/xsdt/xsdt.c			\
> +	acpi/xenv/xenv.c			\
>   	apic/apicedge/apicedge.c 		\
>   	bios/bios_info/bios_info.c 		\
>   	bios/bios32/bios32.c 			\
> diff --git a/src/acpi/xenv/xenv.c b/src/acpi/xenv/xenv.c
> new file mode 100644
> index 0000000..c33942b
> --- /dev/null
> +++ b/src/acpi/xenv/xenv.c
> @@ -0,0 +1,103 @@
> +/*
> + * Copyright (C) 2006, Intel Corporation
> + * Copyright (C) 2010-2015 Canonical
> + *
> + * This code was originally part of 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 <string.h>
> +#include <inttypes.h>
> +
> +#include "fwts.h"
> +
> +static fwts_acpi_table_info *table;
> +
> +static int xenv_init(fwts_framework *fw)
> +{
> +	if (fwts_acpi_find_table(fw, "XENV", 0, &table) != FWTS_OK) {
> +		fwts_log_error(fw, "Cannot load ACPI table");
> +		return FWTS_ERROR;
> +	}
> +	if (table == NULL) {
> +		fwts_log_error(fw, "ACPI XENV table does not exist, skipping test");
> +		return FWTS_ERROR;
> +	}
> +
> +	return FWTS_OK;
> +}
> +
> +/*
> + * Sanity check XENV table, see:
> + *    http://wiki.xenproject.org/mediawiki/images/c/c4/Xen-environment-table.pdf
> + */
> +static int xenv_test1(fwts_framework *fw)
> +{
> +	fwts_acpi_table_xenv *xenv = (fwts_acpi_table_xenv*)table->data;
> +	bool passed = true;
> +
> +	if (table->length < sizeof(fwts_acpi_table_xenv)) {
> +		fwts_failed(fw, LOG_LEVEL_HIGH, "XENVAcpiTableTooSmall",
> +			"XENV ACPI table is %zd bytes long which is smaller "
> +			"than the expected size of %zd bytes.",
> +			table->length, sizeof(fwts_acpi_table_xenv));
> +		return FWTS_ERROR;
> +	}
> +
> +	if (xenv->header.revision != 1) {
> +		passed = false;
> +		fwts_failed(fw, LOG_LEVEL_HIGH,
> +			"XENVBadRevision",
> +			"XENV revision is incorrect, expecting 0x01, "
> +			"instead got 0x%2.2" PRIx8,
> +			xenv->header.revision);
> +	}
> +
> +	fwts_log_info_verbatum(fw, "XENV Table:");
> +	fwts_log_info_verbatum(fw, "  GNT Start Address                0x%16.16" PRIx64, xenv->gnt_start);
> +	fwts_log_info_verbatum(fw, "  GNT Sizne                        0x%16.16" PRIx64, xenv->gnt_size);
> +	fwts_log_info_verbatum(fw, "  Evtchn Intr:                     0x%8.8"   PRIx32, xenv->evtchn_intr);
> +	fwts_log_info_verbatum(fw, "  Evtchn Intr Flags:               0x%2.2"   PRIx8,  xenv->evtchn_intr_flags);
> +
> +	if (xenv->evtchn_intr_flags & ~3) {
> +		passed = false;
> +		fwts_failed(fw, LOG_LEVEL_HIGH,
> +			"XENVBadEvtchnIntrFlags",
> +			"XENV Evtchn Intr Flags was 0x%2.2" PRIx8
> +			" and reserved bits [7:2] are not zero.",
> +			xenv->evtchn_intr_flags);
> +	}
> +
> +	if (passed)
> +		fwts_passed(fw, "No issues found in XENV table.");
> +
> +	return FWTS_OK;
> +}
> +
> +static fwts_framework_minor_test xenv_tests[] = {
> +	{ xenv_test1, "Validate XEVN table." },
> +	{ NULL, NULL }
> +};
> +
> +static fwts_framework_ops xenv_check_ops = {
> +	.description = "Xen Environment Table tests.",
> +	.init        = xenv_init,
> +	.minor_tests = xenv_tests
> +};
> +
> +FWTS_REGISTER("xenv", &xenv_check_ops, FWTS_TEST_ANYTIME,
> +	FWTS_FLAG_BATCH | FWTS_FLAG_TEST_ACPI)
> +
> diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h
> index 93d3817..e4d7288 100644
> --- a/src/lib/include/fwts_acpi.h
> +++ b/src/lib/include/fwts_acpi.h
> @@ -535,6 +535,15 @@ typedef struct {
>   	};
>   }  __attribute__ ((packed)) fwts_acpi_table_tcpa;
>   
> +/* From http://wiki.xenproject.org/mediawiki/images/c/c4/Xen-environment-table.pdf */
> +typedef struct {
> +	fwts_acpi_table_header	header;
> +	uint64_t	gnt_start;
> +	uint64_t	gnt_size;
> +	uint32_t	evtchn_intr;
> +	uint8_t		evtchn_intr_flags;
> +}  __attribute__ ((packed)) fwts_acpi_table_xenv;
> +
>   /* Following ASF definitions from
>      http://dmtf.org/documents/asf/alert-standard-format-asf-specification-200 */
>   typedef struct {
Acked-by: Ivan Hu<ivan.hu at canonical.com>



More information about the fwts-devel mailing list