diff mbox series

[1/2] acpi: phat: modify the dumping vendor data format

Message ID 20230728044653.50389-1-ivan.hu@canonical.com
State Accepted
Headers show
Series [1/2] acpi: phat: modify the dumping vendor data format | expand

Commit Message

ivanhu July 28, 2023, 4:46 a.m. UTC
BugLingk: https://bugs.launchpad.net/fwts/+bug/2028907

Currently vendor dumping one byte each time.

Firmware Health Data Record (Type 1):
    Type: 0x0001
    Record Length: 0x004a
    Revision: 0x00
    Reserved: 0x0000
    AmHealthy: 0x00
    Device Signature: 18D5DD11-BA12-4924-A75A-46D251ECB593
    Device-specific Data Offset: 0x00000042
    Device Path: \_SB.PCI0.GFX0.XYZ
    Vendor Data: 0x12
    Vendor Data: 0x34
    Vendor Data: 0x56
    Vendor Data: 0x78
    Vendor Data: 0x90
    Vendor Data: 0xab
    Vendor Data: 0xcd
    Vendor Data: 0xef

modify as below,

 Firmware Health Data Record (Type 1):
    Type: 0x0001
    Record Length: 0x004a
    Revision: 0x00
    Reserved: 0x0000
    AmHealthy: 0x00
    Device Signature: 18D5DD11-BA12-4924-A75A-46D251ECB593
    Device-specific Data Offset: 0x00000042
    Device Path: \_SB.PCI0.GFX0.XYZ
    Vendor Data:
      12 34 56 78 90 AB CD EF

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/acpi/phat/phat.c | 35 ++++++++++++++---------------------
 1 file changed, 14 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/src/acpi/phat/phat.c b/src/acpi/phat/phat.c
index 9a72e732..57499c34 100644
--- a/src/acpi/phat/phat.c
+++ b/src/acpi/phat/phat.c
@@ -103,31 +103,24 @@  static void phat_health_test(
 
 	offset = offset + sizeof(fwts_acpi_table_phat_health) + (fwts_uefi_str16len(device_path) + 1) * 2;
 
-	if (entry->data_offset != 0) {
-		uint16_t i;
-
-		for (i = entry->data_offset; i < entry->header.length; i++) {
-			uint8_t *vendor_data = (uint8_t *)entry + i;
-
-			/* stop if data is outside the table */
-			offset += sizeof(uint8_t);
-			if (fwts_acpi_structure_range(fw, "PHAT", table->length, offset)) {
-				*passed = false;
-				break;
-			}
+	fwts_acpi_reserved_zero("PHAT", "Reserved", entry->reserved, passed);
 
-			fwts_log_info_simp_int(fw, "    Vendor Data:                    ", *vendor_data);
+	if (entry->data_offset != 0) {
+		if (fwts_acpi_structure_range(fw, "PHAT", table->length, offset))
+			*passed = false;
+		else if (entry->data_offset > entry->header.length) {
+			fwts_failed(fw, LOG_LEVEL_CRITICAL,
+				"PHATOutOfRangeOffset",
+				"PHAT Type 1's Data Offset is out of range");
+			*passed = false;
+		}
+		else {
+			fwts_log_info_verbatim(fw, "    Vendor Data:");
+			fwts_hexdump_data_prefix_all(fw, (uint8_t *)entry + entry->data_offset,
+					"      ", entry->header.length - entry->data_offset);
 		}
 	}
 
-	fwts_acpi_reserved_zero("PHAT", "Reserved", entry->reserved, passed);
-
-	if (entry->data_offset > entry->header.length) {
-		fwts_failed(fw, LOG_LEVEL_CRITICAL,
-			"PHATOutOfRangeOffset",
-			"PHAT Type 1's Data Offset is out of range");
-		*passed = false;
-	}
 }
 
 static int phat_test1(fwts_framework *fw)