diff mbox series

acpi: madt: add more interrupt controller structure types defined in ACPI 6.5

Message ID 20230901092018.29227-1-ivan.hu@canonical.com
State Accepted
Headers show
Series acpi: madt: add more interrupt controller structure types defined in ACPI 6.5 | expand

Commit Message

Ivan Hu Sept. 1, 2023, 9:20 a.m. UTC
BugLink: https://bugs.launchpad.net/fwts/+bug/2027660

Add more types for Loongarch which are defined in ACPI 6.5,
Core Programmable Interrupt Controller (CORE PIC)
Legacy I/O Programmable Interrupt Controller (LIO PIC)
HyperTransport Programmable Interrupt Controller (HT PIC)
Extend I/O Programmable Interrupt Controller (EIO PIC)
MSI Programmable Interrupt Controller (MSI PIC)
Bridge I/O Programmable Interrupt Controller (BIO PIC)
Low Pin Count Programmable Interrupt Controller (LPC PIC)

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/acpi/madt/madt.c        | 79 +++++++++++++++++++++++++++++++++++--
 src/lib/include/fwts_acpi.h |  9 +++++
 2 files changed, 84 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/src/acpi/madt/madt.c b/src/acpi/madt/madt.c
index 05f93ed8..52a8449f 100644
--- a/src/acpi/madt/madt.c
+++ b/src/acpi/madt/madt.c
@@ -245,10 +245,7 @@  static struct acpi_madt_subtable_lengths spec_info[] = {
 		.num_types = 24,
 		.lengths = { 8, 12, 10, 8, 6, 12, 16, SUBTABLE_VARIABLE,
 			     16, 16, 12, 82, 24, 24, 16, 20, 16,
-			     SUBTABLE_VARIABLE, SUBTABLE_VARIABLE,
-			     SUBTABLE_VARIABLE, SUBTABLE_VARIABLE,
-			     SUBTABLE_VARIABLE, SUBTABLE_VARIABLE,
-			     SUBTABLE_VARIABLE }
+			     15, 23, 21, 13, 19, 17, 15 }
 	},
 	{ /* terminator */
 		.major_version = 0,
@@ -574,6 +571,13 @@  static const char *madt_sub_names[] = {
 	/* 0x0e */ "GICR Redistributor",
 	/* 0x0f */ "GIC Interrupt Translation Service (ITS)",
 	/* 0x10 */ "Multiprocessor Wakeup",
+	/* 0x11 */ "CORE PIC",
+	/* 0x12 */ "LIO PIC",
+	/* 0x13 */ "HT PIC",
+	/* 0x14 */ "EIO PIC",
+	/* 0x16 */ "MSI PIC",
+	/* 0x17 */ "BIO PIC",
+	/* 0x18 */ "LPC PIC",
 	/* 0x11 - 0x7f */ "Reserved. OSPM skips structures of the reserved type.",
 	/* 0x80 - 0xff */ "Reserved for OEM use",
 	NULL
@@ -1446,6 +1450,60 @@  static int madt_mp_wakup(fwts_framework *fw,
 	return (hdr->length - sizeof(fwts_acpi_madt_sub_table_header));
 }
 
+static int madt_core_pic(fwts_framework *fw,
+			     fwts_acpi_madt_sub_table_header *hdr,
+			     uint8_t *data)
+{
+
+	fwts_acpi_madt_core_pic *core_pic = (fwts_acpi_madt_core_pic *)data;
+
+	if (core_pic->version > 1)
+		fwts_failed(fw, LOG_LEVEL_LOW,
+			    "SPECMADTPicVersion",
+			    "MADT %s version should not over 1, "
+			    "but instead have 0x%" PRIx32 ".",
+			    madt_sub_names[hdr->type], core_pic->version);
+	else
+		fwts_passed(fw,
+			    "MADT %s version is properly set.",
+			    madt_sub_names[hdr->type]);
+
+	if (core_pic->flag & 0xfffffffe)
+		fwts_failed(fw, LOG_LEVEL_MEDIUM,
+			    "SPECMADTPicFlag",
+			    "MADT %s flags, bits 1..31 are reserved "
+			    "and should be zero, but are set as: %" PRIx32 ".",
+			    madt_sub_names[hdr->type], core_pic->flag);
+	else
+		fwts_passed(fw,
+			    "MADT %s flags, bits 1..31 are reserved "
+			    "and set to zero.",
+			    madt_sub_names[hdr->type]);
+
+	return (hdr->length - sizeof(fwts_acpi_madt_sub_table_header));
+}
+
+static int madt_general_pic(fwts_framework *fw,
+			     fwts_acpi_madt_sub_table_header *hdr,
+			     uint8_t *data)
+{
+
+	uint8_t *version = (uint8_t *)data;
+
+	if (*version > 1)
+		fwts_failed(fw, LOG_LEVEL_LOW,
+			    "SPECMADTPicVersion",
+			    "MADT %s version should not over 1, "
+			    "but instead have 0x%" PRIx32 ".",
+			    madt_sub_names[hdr->type], *version);
+	else
+		fwts_passed(fw,
+			    "MADT %s version is properly set.",
+			    madt_sub_names[hdr->type]);
+
+	return (hdr->length - sizeof(fwts_acpi_madt_sub_table_header));
+}
+
 static void madt_ioapic_sapic_compare(fwts_framework *fw,
 				     int num_ioapics,
 				     int num_iosapics)
@@ -1672,6 +1730,19 @@  static int madt_subtables(fwts_framework *fw)
 			skip = madt_mp_wakup(fw, hdr, data);
 			break;
 
+		case FWTS_MADT_CORE_PIC:
+			skip = madt_core_pic(fw, hdr, data);
+			break;
+			
+		case FWTS_MADT_LIO_PIC:
+		case FWTS_MADT_HT_PIC:
+		case FWTS_MADT_EIO_PIC:
+		case FWTS_MADT_MSI_PIC:
+		case FWTS_MADT_BIO_PIC:
+		case FWTS_MADT_LPC_PIC:
+			skip = madt_general_pic(fw, hdr, data);
+			break;
+
 		case FWTS_MADT_RESERVED:
 			fwts_failed(fw, LOG_LEVEL_MEDIUM,
 				    "SPECMADTSubReservedID",
diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h
index 249460b7..481277e5 100644
--- a/src/lib/include/fwts_acpi.h
+++ b/src/lib/include/fwts_acpi.h
@@ -691,6 +691,15 @@  typedef struct {
 	uint64_t	mail_box_address;
 } __attribute__ ((packed)) fwts_acpi_madt_mp_wakeup;
 
+/* New in ACPI 6.5 Core Programmable Interrupt Controller (CORE PIC) Structure, 5.2.12.20 */
+/* Type 17, FWTS_MADT_CORE_PIC */
+typedef struct {
+	uint8_t		version;
+	uint32_t	acpi_processor_id;
+	uint32_t	physical_processor_id;
+	uint32_t	flag;
+} __attribute__ ((packed)) fwts_acpi_madt_core_pic;
+
 /*
  * ACPI TCPA (Trusted Computing Platform Alliance Capabilities Table)
  *   http://www.kuro5hin.org/story/2002/10/27/16622/530,