ACK: [PATCH 1/3] lib: add fwts_acpi_fixed_value_check function to check fixed values

Colin Ian King colin.king at canonical.com
Tue Jan 5 08:49:41 UTC 2021


On 05/01/2021 04:19, Alex Hung wrote:
> Also add a macro fwts_acpi_revision_check for common "revision" fields.
> 
> Signed-off-by: Alex Hung <alex.hung at canonical.com>
> ---
>  src/lib/include/fwts_acpi_tables.h |  3 +++
>  src/lib/src/fwts_acpi_tables.c     | 26 ++++++++++++++++++++++++++
>  2 files changed, 29 insertions(+)
> 
> diff --git a/src/lib/include/fwts_acpi_tables.h b/src/lib/include/fwts_acpi_tables.h
> index 1f95b74b..740e112c 100644
> --- a/src/lib/include/fwts_acpi_tables.h
> +++ b/src/lib/include/fwts_acpi_tables.h
> @@ -26,6 +26,8 @@
>  
>  #define ACPI_MAX_TABLES		(128)
>  
> +#define fwts_acpi_revision_check(table, actual, must_be, passed) fwts_acpi_fixed_value_check(fw, LOG_LEVEL_HIGH, table, "Revision", actual, must_be, passed)
> +
>  typedef enum {
>  	FWTS_ACPI_TABLE_FROM_FIRMWARE,	/* directly from firmware */
>  	FWTS_ACPI_TABLE_FROM_FILE,	/* loaded from file, e.g. from acpidump */
> @@ -67,6 +69,7 @@ void fwts_acpi_reserved_bits_check(fwts_framework *fw, const char *table, const
>  void fwts_acpi_reserved_type_check(fwts_framework *fw, const char *table, uint8_t value, uint8_t min, uint8_t reserved, bool *passed);
>  bool fwts_acpi_table_length_check(fwts_framework *fw, const char *table, uint32_t length, uint32_t size);
>  bool fwts_acpi_structure_length_check(fwts_framework *fw, const char *table, uint8_t subtable_type, uint32_t subtable_length, uint32_t size);
> +void fwts_acpi_fixed_value_check(fwts_framework *fw, fwts_log_level level, const char *table, const char *field, uint8_t actual, uint8_t must_be, bool *passed);
>  
>  uint32_t fwts_get_acpi_version(fwts_framework *fw);
>  
> diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
> index af4736b3..7bfef910 100644
> --- a/src/lib/src/fwts_acpi_tables.c
> +++ b/src/lib/src/fwts_acpi_tables.c
> @@ -1509,6 +1509,32 @@ void fwts_acpi_reserved_zero_array_check(
>  	}
>  }
>  
> +/*
> + *  fwts_acpi_fixed_value_check()
> + *  verify whether a field matches the designed fixed value
> + */
> +void fwts_acpi_fixed_value_check(
> +	fwts_framework *fw,
> +	fwts_log_level level,
> +	const char *table,
> +	const char *field,
> +	uint8_t actual,
> +	uint8_t must_be,
> +	bool *passed)
> +{
> +	char label[20];
> +
> +	strncpy(label, table, 4);	/* ACPI table name is 4 char long */
> +	strncpy(label + 4, "BadFieldValue", sizeof(label) - 4);
> +
> +	if (actual != must_be) {
> +		fwts_failed(fw, level, label,
> +			"%4.4s %s field must be %" PRIu8 ", got %" PRIu8 " instead.",
> +			table, field, must_be, actual);
> +		*passed = false;
> +	}
> +}
> +
>  /*
>   *  fwts_acpi_reserved_bits_check()
>   *  verify whether the reserved bits are zero
> 

Thanks, this is a good idea.

Acked-by: Colin Ian King <colin.king at canonical.com>



More information about the fwts-devel mailing list