[PATCH 2/3] acpi: replace checks for Flags by fwts_acpi_reserved_bits_check

Alex Hung alex.hung at canonical.com
Fri Sep 8 09:07:12 UTC 2017


Signed-off-by: Alex Hung <alex.hung at canonical.com>
---
 src/acpi/asf/asf.c   |  9 +--------
 src/acpi/drtm/drtm.c |  9 +--------
 src/acpi/einj/einj.c |  9 +--------
 src/acpi/facs/facs.c | 20 ++++----------------
 src/acpi/gtdt/gtdt.c |  8 +-------
 src/acpi/hest/hest.c | 33 +++------------------------------
 src/acpi/hmat/hmat.c | 19 ++-----------------
 src/acpi/iort/iort.c | 29 +++++------------------------
 src/acpi/mpst/mpst.c | 18 ++----------------
 src/acpi/nfit/nfit.c | 24 +++---------------------
 src/acpi/pcct/pcct.c | 34 ++++++++++------------------------
 src/acpi/pmtt/pmtt.c |  9 +--------
 src/acpi/pptt/pptt.c | 18 ++----------------
 src/acpi/spcr/spcr.c | 10 +---------
 src/acpi/srat/srat.c | 39 +++++++--------------------------------
 src/acpi/waet/waet.c | 10 ++--------
 src/acpi/wdat/wdat.c |  9 +--------
 src/acpi/wsmt/wsmt.c |  9 +--------
 src/acpi/xenv/xenv.c |  9 +--------
 19 files changed, 49 insertions(+), 276 deletions(-)

diff --git a/src/acpi/asf/asf.c b/src/acpi/asf/asf.c
index a95c8de..70f5050 100644
--- a/src/acpi/asf/asf.c
+++ b/src/acpi/asf/asf.c
@@ -95,15 +95,8 @@ static void asf_check_info(
 			" and must be in the range 0x02..0xff",
 			info->min_sensor_poll_wait_time);
 	}
-	if (info->flags & ~0x01) {
-		*passed = false;
-		fwts_failed(fw, LOG_LEVEL_HIGH,
-			"ASF!InfoFeatureFlagsReserved",
-			"ASF! ASF_INFO Feature Flags is 0x%" PRIx8
-			", however reserved bits [7:1] must be zero",
-			info->flags);
-	}
 
+	fwts_acpi_reserved_bits_check(fw, "ASF!", "ASF_INFO Feature Flags", info->flags, sizeof(info->flags), 1, 7, passed);
 	fwts_acpi_reserved_zero_check(fw, "ASF!", "ASF_INFO Reserved1", info->reserved1, sizeof(info->reserved1), passed);
 	fwts_acpi_reserved_zero_check(fw, "ASF!", "ASF_INFO Reserved2", info->reserved2, sizeof(info->reserved2), passed);
 	fwts_acpi_reserved_zero_check(fw, "ASF!", "ASF_INFO Reserved3", info->reserved3, sizeof(info->reserved3), passed);
diff --git a/src/acpi/drtm/drtm.c b/src/acpi/drtm/drtm.c
index 8149b27..6e46b1b 100644
--- a/src/acpi/drtm/drtm.c
+++ b/src/acpi/drtm/drtm.c
@@ -66,14 +66,7 @@ static int drtm_test1(fwts_framework *fw)
 	fwts_log_info_verbatim(fw, "  Architecture_Dependent:   0x%16.16" PRIx64, drtm->arch_dependent_address);
 	fwts_log_info_verbatim(fw, "  DRT_Flags:                0x%8.8" PRIx32, drtm->flags);
 
-	if (drtm->flags & ~0x0F) {
-		passed = false;
-		fwts_failed(fw, LOG_LEVEL_MEDIUM,
-			"DRTMBadFlagReservedNonZero",
-			"DRTM DRT_Flags Bits [31:4] are reserved, got 0x%8.8" PRIx32
-			" instead",	drtm->flags);
-	}
-
+	fwts_acpi_reserved_bits_check(fw, "DRTM", "DRT_Flags", drtm->flags, sizeof(drtm->flags), 4, 31, &passed);
 	fwts_log_nl(fw);
 
 	offset = sizeof(fwts_acpi_table_drtm);
diff --git a/src/acpi/einj/einj.c b/src/acpi/einj/einj.c
index 4c2ff8b..1ef0e96 100644
--- a/src/acpi/einj/einj.c
+++ b/src/acpi/einj/einj.c
@@ -63,14 +63,7 @@ static int einj_test1(fwts_framework *fw)
 	fwts_log_info_verbatim(fw, "  Injection Entry Count: 0x%8.8" PRIx32,
 			einj->count);
 
-	if (einj->flags) {
-		fwts_failed(fw, LOG_LEVEL_LOW,
-			    "EINJFlagNonZero",
-			    "EINJ Injection Flags field must be zero, got 0x%"
-			    PRIx8 " instead", einj->flags);
-		passed = false;
-	}
-
+	fwts_acpi_reserved_bits_check(fw, "EINJ", "Injection Flags", einj->flags, sizeof(einj->flags), 0, 31, &passed);
 	fwts_acpi_reserved_zero_check(fw, "EINJ", "Reserved", reserved, sizeof(reserved), &passed);
 
 	fwts_log_nl(fw);
diff --git a/src/acpi/facs/facs.c b/src/acpi/facs/facs.c
index c41b57c..714e473 100644
--- a/src/acpi/facs/facs.c
+++ b/src/acpi/facs/facs.c
@@ -130,22 +130,10 @@ static int facs_test1(fwts_framework *fw)
 			"FACSInvalidReserved1",
 			"FACS: 1st Reserved field is non-zero");
 	}
-	if (facs->flags & ~0x03) {
-		passed = false;
-		fwts_failed(fw, LOG_LEVEL_MEDIUM,
-			"FACSFlagsReservedBitsSet",
-			"FACS: Flags field is 0x%" PRIx32
-			" and some of the reserved bits [31:2] are set",
-			facs->flags);
-	}
-	if (facs->ospm_flags & ~0x01) {
-		passed = false;
-		fwts_failed(fw, LOG_LEVEL_MEDIUM,
-			"FACSFlagsReservedBitsSet",
-			"FACS: OSPM Flags field is 0x%" PRIx32
-			" and some of the reserved bits [31:1] are set",
-			facs->ospm_flags);
-	}
+
+	fwts_acpi_reserved_bits_check(fw, "FACS", "Flags", facs->flags, sizeof(facs->flags), 2, 31, &passed);
+	fwts_acpi_reserved_bits_check(fw, "FACS", "OSPM Flags", facs->ospm_flags, sizeof(facs->ospm_flags), 1, 31, &passed);
+
 	for (i = 0; i < 24; i++) {
 		if (facs->reserved2[i]) {
 			passed = false;
diff --git a/src/acpi/gtdt/gtdt.c b/src/acpi/gtdt/gtdt.c
index f5a10e0..1559d31 100644
--- a/src/acpi/gtdt/gtdt.c
+++ b/src/acpi/gtdt/gtdt.c
@@ -56,13 +56,7 @@ static int gtdt_test1(fwts_framework *fw)
 	uint32_t i = 0, n;
 	const fwts_acpi_table_gtdt *gtdt = (const fwts_acpi_table_gtdt *)table->data;
 
-	if (gtdt->virtual_timer_flags & ~7) {
-		passed = false;
-		fwts_failed(fw, LOG_LEVEL_LOW,
-			"GTDTFlagReservedNonZero",
-			"GTDT flag reserved bits 3 to 31 are non-zero, "
-			"instead got 0x%" PRIx32 ".", gtdt->virtual_timer_flags);
-	}
+	fwts_acpi_reserved_bits_check(fw, "GTDT", "Flags", gtdt->virtual_timer_flags, sizeof(gtdt->virtual_timer_flags), 3, 31, &passed);
 
 	ptr = (uint8_t *)table->data + gtdt->platform_timer_offset;
 	n = gtdt->platform_timer_count;
diff --git a/src/acpi/hest/hest.c b/src/acpi/hest/hest.c
index 6a1bfd2..86a5312 100644
--- a/src/acpi/hest/hest.c
+++ b/src/acpi/hest/hest.c
@@ -399,16 +399,7 @@ static void hest_check_pci_express_root_port_aer(
 	fwts_log_nl(fw);
 
 	fwts_acpi_reserved_zero_check(fw, "HEST", "PCI Express Root Port Reserved1", aer->reserved1, sizeof(aer->reserved1), passed);
-
-	if (aer->flags & ~0x3) {
-		*passed = false;
-		fwts_failed(fw, LOG_LEVEL_MEDIUM,
-			"HESTPciExpressRootPortFlagsReserved",
-			"HEST PCI Express Root Port Flags Reserved bits "
-			"[2:7] must be zero, instead got 0x%" PRIx8,
-			aer->flags);
-	}
-
+	fwts_acpi_reserved_bits_check(fw, "HEST", "PCI Express Root Port Flags", aer->flags, sizeof(aer->flags), 2, 7, passed);
 	fwts_acpi_reserved_zero_check(fw, "HEST", "PCI Express Root Port Reserved2", aer->reserved2, sizeof(aer->reserved2), passed);
 
 	if (aer->number_of_records_to_preallocate < 1) {
@@ -476,16 +467,7 @@ static void hest_check_pci_express_device_aer(
 	fwts_log_nl(fw);
 
 	fwts_acpi_reserved_zero_check(fw, "HEST", "PCI Express Device Reserved1", aer->reserved1, sizeof(aer->reserved1), passed);
-
-	if (aer->flags & ~0x3) {
-		*passed = false;
-		fwts_failed(fw, LOG_LEVEL_MEDIUM,
-			"HESTPciExpressDeviceFlagsReserved",
-			"HEST PCI Express Device Flags Reserved bits "
-			"[2:7] must be zero, instead got 0x%" PRIx8,
-			aer->flags);
-	}
-
+	fwts_acpi_reserved_bits_check(fw, "HEST", "PCI Express Device Flags", aer->flags, sizeof(aer->flags), 2, 7, passed);
 	fwts_acpi_reserved_zero_check(fw, "HEST", "PCI Express Device Reserved2", aer->reserved2, sizeof(aer->reserved2), passed);
 
 	if (aer->number_of_records_to_preallocate < 1) {
@@ -557,16 +539,7 @@ static void hest_heck_pci_express_bridge_aer(
 	fwts_log_nl(fw);
 
 	fwts_acpi_reserved_zero_check(fw, "HEST", "PCI Express Bridge Reserved1", aer->reserved1, sizeof(aer->reserved1), passed);
-
-	if (aer->flags & ~0x3) {
-		*passed = false;
-		fwts_failed(fw, LOG_LEVEL_MEDIUM,
-			"HESTPciExpressBridgeFlagsReserved",
-			"HEST PCI Express Bridge Flags Reserved bits "
-			"[2:7] must be zero, instead got 0x%" PRIx8,
-			aer->flags);
-	}
-
+	fwts_acpi_reserved_bits_check(fw, "HEST", "PCI Express Bridge Flags", aer->flags, sizeof(aer->flags), 2, 7, passed);
 	fwts_acpi_reserved_zero_check(fw, "HEST", "PCI Express Bridge Reserved2", aer->reserved2, sizeof(aer->reserved2), passed);
 
 	if (aer->number_of_records_to_preallocate < 1) {
diff --git a/src/acpi/hmat/hmat.c b/src/acpi/hmat/hmat.c
index 7b5c58c..4459f1b 100644
--- a/src/acpi/hmat/hmat.c
+++ b/src/acpi/hmat/hmat.c
@@ -54,15 +54,7 @@ static void hmat_addr_range_test(fwts_framework *fw, const fwts_acpi_table_hmat_
 	fwts_log_info_verbatim(fw, "    System Phy Addr Range Length:   0x%16.16" PRIx64, entry->phy_addr_length);
 
 	fwts_acpi_reserved_zero_check(fw, "HMAT", "Reserved", entry->header.reserved, sizeof(entry->header.reserved), passed);
-
-	if (entry->flags & ~0x07) {
-		*passed = false;
-		fwts_failed(fw, LOG_LEVEL_HIGH,
-			"HMATBadFlags",
-			"HMAT Flags's Bits[15..3] must be zero, got "
-			"0x%4.4" PRIx16 " instead", entry->flags);
-	}
-
+	fwts_acpi_reserved_bits_check(fw, "HMAT", "Flags", entry->flags, sizeof(entry->flags), 3, 15, passed);
 	fwts_acpi_reserved_zero_check(fw, "HMAT", "Reserved", entry->reserved1, sizeof(entry->reserved1), passed);
 	fwts_acpi_reserved_zero_check(fw, "HMAT", "Reserved", entry->reserved2, sizeof(entry->reserved2), passed);
 }
@@ -84,14 +76,7 @@ static void hmat_locality_test(fwts_framework *fw, const fwts_acpi_table_hmat_lo
 	fwts_log_info_verbatim(fw, "    Entry Base Unit:                0x%16.16" PRIx64, entry->entry_base_unit);
 
 	fwts_acpi_reserved_zero_check(fw, "HMAT", "Reserved", entry->header.reserved, sizeof(entry->header.reserved), passed);
-
-	if (entry->flags & ~0x1f) {
-		*passed = false;
-		fwts_failed(fw, LOG_LEVEL_CRITICAL,
-			"HMATBadFlags",
-			"HMAT Flags's Bits[7..5] must be zero, got "
-			"0x%2.2" PRIx8 " instead", entry->flags);
-	}
+	fwts_acpi_reserved_bits_check(fw, "HMAT", "Flags", entry->flags, sizeof(entry->flags), 5, 7, passed);
 
 	if (entry->data_type > 5) {
 		*passed = false;
diff --git a/src/acpi/iort/iort.c b/src/acpi/iort/iort.c
index b131edd..b7046ea 100644
--- a/src/acpi/iort/iort.c
+++ b/src/acpi/iort/iort.c
@@ -238,14 +238,7 @@ static void iort_smmu_interrupt_flags_check(
 	uint32_t flags,
 	bool *passed)
 {
-	if (flags & ~1) {
-		*passed = false;
-		fwts_failed(fw, LOG_LEVEL_MEDIUM,
-			"IORTSMMUIntrFlagsReservedNonZero",
-			"IORT %s Flags field reserved "
-			"bits [31:1] should be all zero, got 0x%" PRIx32,
-			name, flags);
-	}
+	fwts_acpi_reserved_bits_check(fw, "IORT", name, flags, sizeof(flags), 1, 31, passed);
 }
 
 /*
@@ -588,14 +581,8 @@ static void iort_check_smmu(
 			"IORT SMMU Model is 0x%" PRIx32 " and was expecting "
 			"a model value 0 to 3.", node->model);
 	}
-	if (node->flags & ~3) {
-		*passed = false;
-		fwts_failed(fw, LOG_LEVEL_HIGH,
-			"IORTSmmuReservedFlags",
-			"IORT SMMU Reserved Flags is 0x%" PRIx32 " and has "
-			"some reserved bits [31:2] set when they should be zero.",
-			node->flags);
-	}
+
+	fwts_acpi_reserved_bits_check(fw, "IORT", "SMMU Reserved Flags", node->flags, sizeof(node->flags), 2, 31, passed);
 	fwts_log_nl(fw);
 }
 
@@ -634,14 +621,8 @@ static void iort_check_smmuv3(
 			"IORT SMMUv3 Model is 0x%" PRIx32 " and was expecting "
 			"a model value of 0.", node->model);
 	}
-	if (node->flags & ~3) {
-		*passed = false;
-		fwts_failed(fw, LOG_LEVEL_HIGH,
-			"IORTSmmuv3ReservedFlags",
-			"IORT SMMUv3 Reserved Flags is 0x%" PRIx32 " and has "
-			"some reserved bits [31:2] set when they should be zero.",
-			node->flags);
-	}
+
+	fwts_acpi_reserved_bits_check(fw, "IORT", "SMMUv3 Reserved Flags", node->flags, sizeof(node->flags), 2, 31, passed);
 	fwts_log_nl(fw);
 }
 
diff --git a/src/acpi/mpst/mpst.c b/src/acpi/mpst/mpst.c
index 7a38f78..f5d9555 100644
--- a/src/acpi/mpst/mpst.c
+++ b/src/acpi/mpst/mpst.c
@@ -87,14 +87,7 @@ static int mpst_test1(fwts_framework *fw)
 		fwts_log_info_verbatim(fw, "    Number of Power States:        0x%8.8" PRIx32, power_node->num_states);
 		fwts_log_info_verbatim(fw, "    Number of Physical Components: 0x%8.8" PRIx32, power_node->num_components);
 
-		if (power_node->flags & ~0x7) {
-			passed = false;
-			fwts_failed(fw, LOG_LEVEL_HIGH,
-				"MPSTBadPowerNodeFlags",
-				"MPST Power Node Flags Bit 3..7 be zero, got "
-				"0x%2.2" PRIx8 " instead", power_node->flags);
-		}
-
+		fwts_acpi_reserved_bits_check(fw, "MPST", "Power Node Flags", power_node->flags, sizeof(power_node->flags), 3, 7, &passed);
 		fwts_acpi_reserved_zero_check(fw, "MPST", "Reserved", power_node->reserved, sizeof(power_node->reserved), &passed);
 
 		node_length = sizeof(fwts_acpi_table_mpst_power_node) +
@@ -180,14 +173,7 @@ static int mpst_test1(fwts_framework *fw)
 				"0x%2.2" PRIx8 " instead", (power_char->structure_id & 0xC0) >> 6);
 		}
 
-		if (power_char->flags & ~0x7) {
-			passed = false;
-			fwts_failed(fw, LOG_LEVEL_HIGH,
-				"MPSTBadPowerCharacteristicsFlags",
-				"MPST Power Characteristics Flags Bit 3..7 be zero, got "
-				"0x%2.2" PRIx8 " instead", power_char->flags);
-		}
-
+		fwts_acpi_reserved_bits_check(fw, "MPST", "Power Characteristics Flags", power_char->flags, sizeof(power_char->flags), 3, 7, &passed);
 		fwts_acpi_reserved_zero_check(fw, "MPST", "Reserved1", power_char->reserved1, sizeof(power_char->reserved1), &passed);
 		fwts_acpi_reserved_zero_check(fw, "MPST", "Reserved2", power_char->reserved2, sizeof(power_char->reserved2), &passed);
 
diff --git a/src/acpi/nfit/nfit.c b/src/acpi/nfit/nfit.c
index c3b69db..fc69798 100644
--- a/src/acpi/nfit/nfit.c
+++ b/src/acpi/nfit/nfit.c
@@ -162,13 +162,7 @@ static int nfit_test1(fwts_framework *fw)
 				}
 			}
 
-			if (nfit_struct->flags & ~0x03) {
-				passed = false;
-				fwts_failed(fw, LOG_LEVEL_HIGH,
-					"NFITBadFlags",
-					"NFIT Flags's Bits[15..2] must be zero, got "
-					"0x%8.8" PRIx32 " instead", nfit_struct->flags);
-			}
+			fwts_acpi_reserved_bits_check(fw, "NFIT", "Flags", nfit_struct->flags, sizeof(nfit_struct->flags), 2, 15, &passed);
 
 			if (nfit_struct->reserved != 0)
 				reserved_passed = nfit_struct->reserved;
@@ -199,13 +193,7 @@ static int nfit_test1(fwts_framework *fw)
 			fwts_log_info_verbatim(fw, "    NVDIMM State Flags:                     0x%4.4" PRIx16, nfit_struct->flags);
 			fwts_log_info_verbatim(fw, "    Reserved:                               0x%4.4" PRIx16, nfit_struct->reserved);
 
-			if (nfit_struct->flags & ~0x7F) {
-				passed = false;
-				fwts_failed(fw, LOG_LEVEL_HIGH,
-					"NFITBadFlags",
-					"NFIT Flags's Bits[15..7] must be zero, got "
-					"0x%8.8" PRIx32 " instead", nfit_struct->flags);
-			}
+			fwts_acpi_reserved_bits_check(fw, "NFIT", "NVDIMM State Flags", nfit_struct->flags, sizeof(nfit_struct->flags), 7, 15, &passed);
 
 			if (nfit_struct->reserved != 0)
 				reserved_passed = nfit_struct->reserved;
@@ -304,13 +292,7 @@ static int nfit_test1(fwts_framework *fw)
 					"0x%2.2" PRIx8 " instead", nfit_struct->valid_fields);
 			}
 
-			if (nfit_struct->flags & ~0x01) {
-				passed = false;
-				fwts_failed(fw, LOG_LEVEL_HIGH,
-					"NFITBadFlags",
-					"NFIT Flags's Bits[15..1] must be zero, got "
-					"0x%4.4" PRIx16 " instead", nfit_struct->flags);
-			}
+			fwts_acpi_reserved_bits_check(fw, "NFIT", "NVDIMM Control Region Flags", nfit_struct->flags, sizeof(nfit_struct->flags), 1, 15, &passed);
 
 		} else if (entry->type == FWTS_ACPI_NFIT_TYPE_DATA_REGION) {
 			fwts_acpi_table_nfit_data_range *nfit_struct = (fwts_acpi_table_nfit_data_range *) entry;
diff --git a/src/acpi/pcct/pcct.c b/src/acpi/pcct/pcct.c
index 424cfc1..c6c18be 100644
--- a/src/acpi/pcct/pcct.c
+++ b/src/acpi/pcct/pcct.c
@@ -52,19 +52,6 @@ static bool subspace_length_equal(fwts_framework *fw, uint8_t type, uint8_t type
 	return true;
 }
 
-static void platform_interrupt_flags(fwts_framework *fw, uint8_t flags, bool *passed)
-{
-	fwts_log_info_verbatim(fw, "    Platform Interrupt Flags:    0x%2.2"   PRIx8, flags);
-
-	if (flags & ~0x3) {
-		*passed = false;
-		fwts_failed(fw, LOG_LEVEL_HIGH,
-			"PCCTBadSubtypePlatformbInterruptlags",
-			"PCCT Subspace Platform Interrupt Flags's bit [7:2] be zero, got "
-			"0x%2.2" PRIx8 " instead", flags);
-	}
-}
-
 static void gas_messages(fwts_framework *fw, uint8_t type, fwts_acpi_gas *gas, bool *passed)
 {
 	fwts_log_info_verbatim(fw, "      Address Space ID           0x%2.2"   PRIx8, gas->address_space_id);
@@ -148,7 +135,7 @@ static void generic_comm_test(fwts_framework *fw, fwts_acpi_table_pcct_subspace_
 static void hw_reduced_comm_test_type1(fwts_framework *fw, fwts_acpi_table_pcct_subspace_type_1 *entry, bool *passed)
 {
 	fwts_log_info_verbatim(fw, "    Platform Interrupt:          0x%8.8"   PRIx32, entry->platform_interrupt);
-	platform_interrupt_flags(fw, entry->platform_interrupt_flags, passed);
+	fwts_log_info_verbatim(fw, "    Platform Interrupt Flags:    0x%2.2"   PRIx8, entry->platform_interrupt_flags);
 	fwts_log_info_verbatim(fw, "    Reserved:                    0x%2.2"   PRIx8, entry->reserved);
 	fwts_log_info_verbatim(fw, "    Base Address:                0x%16.16" PRIx64, entry->base_address);
 	memory_length(fw, entry->header.type, entry->length, 8, passed);
@@ -159,12 +146,14 @@ static void hw_reduced_comm_test_type1(fwts_framework *fw, fwts_acpi_table_pcct_
 	fwts_log_info_verbatim(fw, "    Nominal Latency:             0x%8.8"   PRIx32, entry->nominal_latency);
 	fwts_log_info_verbatim(fw, "    Max Periodic Access Rate:    0x%8.8"   PRIx32, entry->max_periodic_access_rate);
 	fwts_log_info_verbatim(fw, "    Min Request Turnaround Time: 0x%8.8"   PRIx32, entry->min_request_turnaround_time);
+
+	fwts_acpi_reserved_bits_check(fw, "PCCT", "Platform Interrupt Flags", entry->platform_interrupt_flags, sizeof(uint8_t), 2, 7, passed);
 }
 
 static void hw_reduced_comm_test_type2(fwts_framework *fw, fwts_acpi_table_pcct_subspace_type_2 *entry, bool *passed)
 {
 	fwts_log_info_verbatim(fw, "    Platform Interrupt:          0x%8.8"   PRIx32, entry->platform_interrupt);
-	platform_interrupt_flags(fw, entry->platform_interrupt_flags, passed);
+	fwts_log_info_verbatim(fw, "    Platform Interrupt Flags:    0x%2.2"   PRIx8, entry->platform_interrupt_flags);
 	fwts_log_info_verbatim(fw, "    Reserved:                    0x%2.2"   PRIx8, entry->reserved);
 	fwts_log_info_verbatim(fw, "    Base Address:                0x%16.16" PRIx64, entry->base_address);
 	memory_length(fw, entry->header.type, entry->length, 8, passed);
@@ -179,12 +168,14 @@ static void hw_reduced_comm_test_type2(fwts_framework *fw, fwts_acpi_table_pcct_
 	gas_messages(fw, entry->header.type, &entry->platform_ack_register, passed);
 	fwts_log_info_verbatim(fw, "    Platform Ack Preserve:       0x%16.16" PRIx64, entry->platform_ack_preserve);
 	fwts_log_info_verbatim(fw, "    Platform Ack Write:          0x%16.16" PRIx64, entry->platform_ack_write);
+
+	fwts_acpi_reserved_bits_check(fw, "PCCT", "Platform Interrupt Flags", entry->platform_interrupt_flags, sizeof(uint8_t), 2, 7, passed);
 }
 
 static void extended_pcc_test(fwts_framework *fw, fwts_acpi_table_pcct_subspace_type_3_4 *entry, bool *passed)
 {
 	fwts_log_info_verbatim(fw, "    Platform Interrupt:          0x%8.8"   PRIx32, entry->platform_interrupt);
-	platform_interrupt_flags(fw, entry->platform_interrupt_flags, passed);
+	fwts_log_info_verbatim(fw, "    Platform Interrupt Flags:    0x%2.2"   PRIx8, entry->platform_interrupt_flags);
 	fwts_log_info_verbatim(fw, "    Reserved:                    0x%2.2"   PRIx8, entry->reserved1);
 	fwts_log_info_verbatim(fw, "    Base Address:                0x%16.16" PRIx64, entry->base_address);
 	memory_length(fw, entry->header.type, entry->length, 16, passed);
@@ -210,6 +201,8 @@ static void extended_pcc_test(fwts_framework *fw, fwts_acpi_table_pcct_subspace_
 	fwts_log_info_verbatim(fw, "    Error Status Register:");
 	gas_messages(fw, entry->header.type, &entry->error_status_register, passed);
 	fwts_log_info_verbatim(fw, "    Error Status Mask:           0x%16.16" PRIx64, entry->error_status_mask);
+
+	fwts_acpi_reserved_bits_check(fw, "PCCT", "Platform Interrupt Flags", entry->platform_interrupt_flags, sizeof(uint8_t), 2, 7, passed);
 }
 
 static int pcct_test1(fwts_framework *fw)
@@ -224,14 +217,7 @@ static int pcct_test1(fwts_framework *fw)
 	fwts_log_info_verbatim(fw, "  Reserved:  0x%16.16"   PRIx64, pcct->reserved);
 	fwts_log_nl(fw);
 
-	if ((pcct->flags & ~0x01) != 0) {
-		passed = false;
-		fwts_failed(fw, LOG_LEVEL_HIGH,
-			"PCCTBadFlags",
-			"PCCT flags field's bit 1..31 be zero, got "
-			"0x%8.8" PRIx32 " instead", pcct->flags);
-	}
-
+	fwts_acpi_reserved_bits_check(fw, "PCCT", "Flags", pcct->flags, sizeof(pcct->flags), 1, 31, &passed);
 	fwts_acpi_reserved_zero_check(fw, "PCCT", "Reserved", pcct->reserved, sizeof(pcct->reserved), &passed);
 
 	offset = sizeof(fwts_acpi_table_pcct);
diff --git a/src/acpi/pmtt/pmtt.c b/src/acpi/pmtt/pmtt.c
index 915b0c6..f7cdd61 100644
--- a/src/acpi/pmtt/pmtt.c
+++ b/src/acpi/pmtt/pmtt.c
@@ -49,14 +49,7 @@ static void pmtt_subtable_header_test(fwts_framework *fw, fwts_acpi_table_pmtt_h
 	fwts_log_info_verbatim(fw, "    Reserved:                       0x%4.4" PRIx16, entry->reserved2);
 
 	fwts_acpi_reserved_zero_check(fw, "PMTT", "Reserved1", entry->reserved1, sizeof(entry->reserved1), passed);
-
-	if (entry->flags & ~0x0F) {
-		*passed = false;
-		fwts_failed(fw, LOG_LEVEL_HIGH,
-			"PMTTBadFlags",
-			"PMTT Flags's Bits[15..4] must be zero, got "
-			"0x%4.4" PRIx16 " instead", entry->flags);
-	}
+	fwts_acpi_reserved_bits_check(fw, "PMTT", "Flags", entry->flags, sizeof(entry->flags), 4, 15, passed);
 
 	if ((entry->flags & 0x0C) == 0x0C) {
 		*passed = false;
diff --git a/src/acpi/pptt/pptt.c b/src/acpi/pptt/pptt.c
index c1d3cc0..50b7491 100644
--- a/src/acpi/pptt/pptt.c
+++ b/src/acpi/pptt/pptt.c
@@ -65,14 +65,7 @@ static void pptt_processor_test(fwts_framework *fw, const fwts_acpi_table_pptt_p
 	}
 
 	fwts_acpi_reserved_zero_check(fw, "PPTT", "Reserved", entry->reserved, sizeof(entry->reserved), passed);
-
-	if (entry->flags & ~0x03) {
-		*passed = false;
-		fwts_failed(fw, LOG_LEVEL_HIGH,
-			"PPTTBadFlags",
-			"PPTT Flags's Bits[31..2] must be zero, got "
-			"0x%8.8" PRIx32 " instead", entry->flags);
-	}
+	fwts_acpi_reserved_bits_check(fw, "PPTT", "Flags", entry->flags, sizeof(entry->flags), 2, 31, passed);
 }
 
 static void pptt_cache_test(fwts_framework *fw, const fwts_acpi_table_pptt_cache *entry, bool *passed)
@@ -91,14 +84,7 @@ static void pptt_cache_test(fwts_framework *fw, const fwts_acpi_table_pptt_cache
 	fwts_log_info_verbatim(fw, "    Line size:                      0x%4.4" PRIx16, entry->line_size);
 
 	fwts_acpi_reserved_zero_check(fw, "PPTT", "Reserved", entry->reserved, sizeof(entry->reserved), passed);
-
-	if (entry->flags & ~0x7f) {
-		*passed = false;
-		fwts_failed(fw, LOG_LEVEL_HIGH,
-			"PPTTBadFlags",
-			"PPTT Flags's Bits[31..7] must be zero, got "
-			"0x%8.8" PRIx32 " instead", entry->flags);
-	}
+	fwts_acpi_reserved_bits_check(fw, "PPTT", "Flags", entry->flags, sizeof(entry->flags), 7, 31, passed);
 
 	if (entry->attributes & ~0x1f) {
 		*passed = false;
diff --git a/src/acpi/spcr/spcr.c b/src/acpi/spcr/spcr.c
index 4f91ed6..7ac39d3 100644
--- a/src/acpi/spcr/spcr.c
+++ b/src/acpi/spcr/spcr.c
@@ -290,15 +290,7 @@ static int spcr_test1(fwts_framework *fw)
 		}
 	}
 
-	if (spcr->pci_flags & 0xfffe) {
-		passed = false;
-		fwts_failed(fw, LOG_LEVEL_HIGH,
-			"SPCRPciFlags",
-			"SPCR PCI flags reserved bits 1-31 are %" PRIx32
-			", expecting 0",
-			spcr->pci_flags);
-	}
-
+	fwts_acpi_reserved_bits_check(fw, "SPCR", "PCI Flags", spcr->pci_flags, sizeof(spcr->pci_flags), 1, 31, &passed);
 	fwts_acpi_reserved_zero_check(fw, "SPCR", "Reserved3", spcr->reserved3, sizeof(spcr->reserved3), &passed);
 
 	if (passed)
diff --git a/src/acpi/srat/srat.c b/src/acpi/srat/srat.c
index 50df660..d7c9007 100644
--- a/src/acpi/srat/srat.c
+++ b/src/acpi/srat/srat.c
@@ -85,14 +85,7 @@ static void srat_check_local_apic_sapic_affinity(
 	fwts_log_info_verbatim(fw, "  Clock Domain              0x%8.8" PRIx32, affinity->clock_domain);
 	fwts_log_nl(fw);
 
-	if (affinity->flags & ~0x1UL) {
-		fwts_failed(fw, LOG_LEVEL_MEDIUM,
-			"SRATLocalApicSapicAffinityFlags",
-			"SRAT Local APIC/SPAIC Affinity Flags field reserved bits 1..31 should be zero, got "
-			"0x%" PRIx32,
-			affinity->flags);
-		*passed = false;
-	}
+	fwts_acpi_reserved_bits_check(fw, "SRAT", "Local APIC/SPAIC Affinity Flags", affinity->flags, sizeof(affinity->flags), 1, 31, passed);
 
 	/*
 	 * Not clear of bits 0..7 of Proximity Domain are reserved or not
@@ -151,14 +144,8 @@ static void srat_check_memory_affinity(
 	fwts_log_info_verbatim(fw, "  Reserved:                 0x%16.16" PRIx64, affinity->reserved3);
 	fwts_log_nl(fw);
 
-	if (affinity->flags & ~0x7UL) {
-		fwts_failed(fw, LOG_LEVEL_MEDIUM,
-			"SRATMemoryAffinityFlags",
-			"SRAT Memory Affinity Flags field reserved bits 3..31 should be zero, got "
-			"0x%" PRIx32,
-			affinity->flags);
-		*passed = false;
-	}
+	fwts_acpi_reserved_bits_check(fw, "SRAT", "Memory Affinity Flags", affinity->flags, sizeof(affinity->flags), 3, 31, passed);
+
 done:
 	*length -= sizeof(fwts_acpi_table_memory_affinity);
 	*data += sizeof(fwts_acpi_table_memory_affinity);
@@ -214,14 +201,8 @@ static void srat_check_local_x2apic_affinity(
 		*passed = false;
 	}
 
-	if (affinity->flags & ~0x1UL) {
-		fwts_failed(fw, LOG_LEVEL_MEDIUM,
-			"SRATLocalx2apicAffinityFlags",
-			"SRAT Local x2APIC Affinity Flags field reserved bits 1..31 should be zero, got "
-			"0x%" PRIx32,
-			affinity->flags);
-		*passed = false;
-	}
+	fwts_acpi_reserved_bits_check(fw, "SRAT", "Local x2APIC Affinity Flags", affinity->flags, sizeof(affinity->flags), 1, 31, passed);
+
 	/*
 	 *  Clock domain probably needs deeper sanity checking, for now
 	 *  skip this.
@@ -270,14 +251,8 @@ static void srat_check_gicc_affinity(
 	fwts_log_info_verbatim(fw, "  Clock Domain              0x%8.8" PRIx32, affinity->clock_domain);
 	fwts_log_nl(fw);
 
-	if (affinity->flags & ~0x1UL) {
-		fwts_failed(fw, LOG_LEVEL_MEDIUM,
-			"SRATGICCAffinityFlags",
-			"SRAT GICC Affinity Flags field reserved bits 1..31 should be zero, got "
-			"0x%" PRIx32,
-			affinity->flags);
-		*passed = false;
-	}
+	fwts_acpi_reserved_bits_check(fw, "SRAT", "GICC Affinity Flags", affinity->flags, sizeof(affinity->flags), 1, 31, passed);
+
 	/*
 	 *  Clock domain probably needs deeper sanity checking, for now
 	 *  skip this.
diff --git a/src/acpi/waet/waet.c b/src/acpi/waet/waet.c
index ae8cf4d..e6a42dc 100644
--- a/src/acpi/waet/waet.c
+++ b/src/acpi/waet/waet.c
@@ -71,14 +71,8 @@ static int waet_test1(fwts_framework *fw)
 	fwts_log_info_verbatim(fw, "    Bit [1] PM Timer Good:  %1" PRIu32, (waet->flags >> 1) & 1);
 	fwts_log_nl(fw);
 
-	if (waet->flags & ~3) {
-		passed = false;
-		fwts_failed(fw, LOG_LEVEL_HIGH,
-			"WAETFlagReservedNotZero",
-			"WAET Emulated Device Flags was 0x%" PRIx32
-			" and so some of reserved bits [31:2] are not zero "
-			" as expected.", waet->flags);
-	}
+	fwts_acpi_reserved_bits_check(fw, "WAET", "Emulated Device Flags", waet->flags, sizeof(waet->flags), 2, 31, &passed);
+
 done:
 	if (passed)
 		fwts_passed(fw, "No issues found in WAET table.");
diff --git a/src/acpi/wdat/wdat.c b/src/acpi/wdat/wdat.c
index b2de651..3046e56 100644
--- a/src/acpi/wdat/wdat.c
+++ b/src/acpi/wdat/wdat.c
@@ -116,14 +116,7 @@ static int wdat_test1(fwts_framework *fw)
 	 * this does sanity check that somebody has not set these
 	 * bits accidentally.  This is a LOW issue.
 	 */
-	if (wdat->watchdog_flags & ~0x81) {
-		passed = false;
-		fwts_failed(fw, LOG_LEVEL_LOW,
-			"WDATWatchdogFlagsUndefinedSet",
-			"WDAT Watchdog Flags bits [6:1] are not all 0. These bits "
-			"are not defined in the specification and should be "
-			"set to 0. Watchdog flags are: 0x%" PRIx8, wdat->watchdog_flags);
-	}
+	fwts_acpi_reserved_bits_check(fw, "WDAT", "Watchdog Flags", wdat->watchdog_flags, sizeof(wdat->watchdog_flags), 1, 6, &passed);
 
 	total_length = sizeof(fwts_acpi_table_wdat) +
 		(wdat->number_of_entries * sizeof(fwts_acpi_table_wdat_instr_entries));
diff --git a/src/acpi/wsmt/wsmt.c b/src/acpi/wsmt/wsmt.c
index ad23fba..9405adc 100644
--- a/src/acpi/wsmt/wsmt.c
+++ b/src/acpi/wsmt/wsmt.c
@@ -53,14 +53,7 @@ static int wsmt_test1(fwts_framework *fw)
 	fwts_log_info_verbatim(fw, "WSMT Windows SMM Security Mitigations Table:");
 	fwts_log_info_verbatim(fw, "  Protection Flags:      0x%8.8" PRIx32, wsmt->protection_flags);
 
-	if (wsmt->protection_flags & ~0x7) {
-		passed = false;
-		fwts_failed(fw, LOG_LEVEL_MEDIUM,
-			"WSMTFlagsReserved",
-			"WSMT Protection Flags reserved bits "
-			"[3:31] must be zero, instead got 0x%" PRIx32,
-			wsmt->protection_flags);
-	}
+	fwts_acpi_reserved_bits_check(fw, "WSMT", "Protection Flags", wsmt->protection_flags, sizeof(wsmt->protection_flags), 3, 31, &passed);
 
 	if ((wsmt->protection_flags & 0x2) && !(wsmt->protection_flags & 0x1)) {
 		passed = false;
diff --git a/src/acpi/xenv/xenv.c b/src/acpi/xenv/xenv.c
index 09f8158..74bd428 100644
--- a/src/acpi/xenv/xenv.c
+++ b/src/acpi/xenv/xenv.c
@@ -71,14 +71,7 @@ static int xenv_test1(fwts_framework *fw)
 	fwts_log_info_verbatim(fw, "  Evtchn Intr:                     0x%8.8"   PRIx32, xenv->evtchn_intr);
 	fwts_log_info_verbatim(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);
-	}
+	fwts_acpi_reserved_bits_check(fw, "XENV", "Evtchn Intr Flags", xenv->evtchn_intr_flags, sizeof(xenv->evtchn_intr_flags), 2, 7, &passed);
 
 	if (passed)
 		fwts_passed(fw, "No issues found in XENV table.");
-- 
2.7.4




More information about the fwts-devel mailing list