[PATCH 1/3] lib: fwts_acpi_tables: add a new function to check reserved bits
Alex Hung
alex.hung at canonical.com
Fri Sep 8 09:07:11 UTC 2017
Signed-off-by: Alex Hung <alex.hung at canonical.com>
---
src/lib/include/fwts_acpi_tables.h | 1 +
src/lib/src/fwts_acpi_tables.c | 52 ++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/src/lib/include/fwts_acpi_tables.h b/src/lib/include/fwts_acpi_tables.h
index d478d99..011a4c3 100644
--- a/src/lib/include/fwts_acpi_tables.h
+++ b/src/lib/include/fwts_acpi_tables.h
@@ -54,6 +54,7 @@ bool fwts_acpi_obj_find(fwts_framework *fw, const char *obj_name);
fwts_bool fwts_acpi_is_reduced_hardware(const fwts_acpi_table_fadt *fadt);
void fwts_acpi_reserved_zero_check(fwts_framework *fw, const char *table, const char *field, uint64_t value, uint8_t size, bool *passed);
+void fwts_acpi_reserved_bits_check(fwts_framework *fw, const char *table, const char *field, uint64_t value, uint8_t size, uint8_t min, uint8_t max, bool *passed);
#endif
diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
index 4ac70f8..15d07f4 100644
--- a/src/lib/src/fwts_acpi_tables.c
+++ b/src/lib/src/fwts_acpi_tables.c
@@ -1426,4 +1426,56 @@ void fwts_acpi_reserved_zero_check(
}
}
+/*
+ * fwts_acpi_reserved_bits_check()
+ * verify whether the reserved bits are zero
+ */
+void fwts_acpi_reserved_bits_check(
+ fwts_framework *fw,
+ const char *table,
+ const char *field,
+ uint64_t value,
+ uint8_t size,
+ uint8_t min,
+ uint8_t max,
+ bool *passed)
+{
+ uint64_t mask = 0;
+ uint8_t i;
+
+ for (i = min; i <= max; i++) {
+ mask |= (1ULL << i);
+ }
+
+ if (value & mask) {
+ char label[24];
+ strncpy(label, table, 4); /* ACPI table name is 4 char long */
+ strncpy(label + 4, "ReservedBitsNonZero", sizeof(label) - 4);
+
+ switch (size) {
+ case sizeof(uint8_t):
+ fwts_failed(fw, LOG_LEVEL_HIGH, label,
+ "%4.4s %s Bits [%" PRIu8 "..%" PRIu8 "] must be zero, got "
+ "0x%2.2" PRIx8 " instead", table, field, max, min, (uint8_t)value);
+ break;
+ case sizeof(uint16_t):
+ fwts_failed(fw, LOG_LEVEL_HIGH, label,
+ "%4.4s %s Bits [%" PRIu8 "..%" PRIu8 "] must be zero, got "
+ "0x%4.4" PRIx16 " instead", table, field, max, min, (uint16_t)value);
+ break;
+ case sizeof(uint32_t):
+ fwts_failed(fw, LOG_LEVEL_HIGH, label,
+ "%4.4s %s Bits [%" PRIu8 "..%" PRIu8 "] must be zero, got "
+ "0x%8.8" PRIx32 " instead", table, field, max, min, (uint32_t)value);
+ break;
+ case sizeof(uint64_t):
+ fwts_failed(fw, LOG_LEVEL_HIGH, label,
+ "%4.4s %s Bits [%" PRIu8 "..%" PRIu8 "] must be zero, got "
+ "0x%16.16" PRIx64 " instead", table, field, max, min, value);
+ break;
+ }
+ *passed = false;
+ }
+}
+
#endif
--
2.7.4
More information about the fwts-devel
mailing list