[coreboot-gerrit] Patch set updated for coreboot: MP Spec: Add debugging capabilities

Martin Roth (martinroth@google.com) gerrit at coreboot.org
Fri Apr 15 19:06:42 CEST 2016


Martin Roth (martinroth at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/5978

-gerrit

commit f101dff64bcf404d2032cb3cd5d848da583a54d7
Author: Mike Loptien <mike.loptien at se-eng.com>
Date:   Wed Jun 11 14:26:10 2014 -0600

    MP Spec: Add debugging capabilities
    
    The MP Table did not have any sort of debug capabilities
    like the ACPI and SMBIOS tables do.  If both BIOS_SPEW or
    BIOS_DEBUG and CONFIG_DEBUG_MP_TABLE are selected, this
    will print out all of the tables that get created by the
    MP Table process.
    
    Change-Id: I13a446043c5094a680eb7461ec4b61427b7a7050
    Signed-off-by: Mike Loptien <mike.loptien at se-eng.com>
---
 src/Kconfig                            |  13 ++
 src/arch/x86/include/arch/smp/mpspec.h |   2 +
 src/arch/x86/mpspec.c                  | 259 ++++++++++++++++++++++++++++++++-
 3 files changed, 266 insertions(+), 8 deletions(-)

diff --git a/src/Kconfig b/src/Kconfig
index 0649bf7..e4264bd 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -866,6 +866,19 @@ config DEBUG_ACPI
 
 # Only visible if debug level is DEBUG (7) or SPEW (8) as it does additional
 # printk(BIOS_DEBUG, ...) calls.
+config DEBUG_MP_TABLE
+	def_bool n
+	prompt "Output verbose MP Table debug messages" if DEFAULT_CONSOLE_LOGLEVEL_7 || DEFAULT_CONSOLE_LOGLEVEL_8
+	depends on HAVE_MP_TABLE
+	help
+	  This option enables additional MP Table related debug messages.
+
+	  Note: This option will slightly increase the size of the coreboot image.
+
+	  If unsure, say N.
+
+# Only visible if debug level is DEBUG (7) or SPEW (8) as it does additional
+# printk(BIOS_DEBUG, ...) calls.
 config REALMODE_DEBUG
 	prompt "Enable debug messages for option ROM execution" if DEFAULT_CONSOLE_LOGLEVEL_7 || DEFAULT_CONSOLE_LOGLEVEL_8
 	bool
diff --git a/src/arch/x86/include/arch/smp/mpspec.h b/src/arch/x86/include/arch/smp/mpspec.h
index 28a3e11..e99729d 100644
--- a/src/arch/x86/include/arch/smp/mpspec.h
+++ b/src/arch/x86/include/arch/smp/mpspec.h
@@ -257,6 +257,8 @@ void smp_write_processor(struct mp_config_table *mc,
 void smp_write_processors(struct mp_config_table *mc);
 void smp_write_ioapic(struct mp_config_table *mc,
 	u8 id, u8 ver, void *apicaddr);
+const char * smp_irqtype_to_str(u8 irqtype);
+char * smp_irqflag_to_str(u16 irqflag, char *str);
 void smp_write_intsrc(struct mp_config_table *mc,
 	u8 irqtype, u16 irqflag, u8 srcbus, u8 srcbusirq,
 	u8 dstapic, u8 dstirq);
diff --git a/src/arch/x86/mpspec.c b/src/arch/x86/mpspec.c
index d91adf8..9e56613 100644
--- a/src/arch/x86/mpspec.c
+++ b/src/arch/x86/mpspec.c
@@ -22,6 +22,9 @@
 #include <arch/cpu.h>
 #include <cpu/x86/lapic.h>
 #include <drivers/generic/ioapic/chip.h>
+#include <lib.h> /* hexdump */
+
+#define IRQFLAG_STRING_SIZE 40
 
 /* Initialize the specified "mc" struct with initial values. */
 void mptable_init(struct mp_config_table *mc, u32 lapic_addr)
@@ -54,6 +57,24 @@ void mptable_init(struct mp_config_table *mc, u32 lapic_addr)
 		mc->mpc_oem[i] = ' ';
 	for (i = MIN(strlen(CONFIG_MAINBOARD_PART_NUMBER), 12); i < 12; i++)
 		mc->mpc_productid[i] = ' ';
+
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE))
+		printk(BIOS_DEBUG, "MP_Tables: Init MP Configuration Table Header:\n"
+			"\tSignature\t\t: %4.4s\n"
+			"\tLength\t\t\t: 0x%x (Only Header, no other entries)\n"
+			"\tMP Specification\t: 0x%x\n"
+			"\tChecksum\t\t: 0x%x (Not calculated yet)\n"
+			"\tOEM ID\t\t\t: %8.8s\n"
+			"\tProduct ID\t\t: %12.12s\n"
+			"\tOEM Table PTR\t\t: 0x%x\n"
+			"\tOEM Table Size\t\t: 0x%x (Not filled in yet)\n"
+			"\tEntry Count\t\t: 0x%x (No entries created yet)\n"
+			"\tMMIO LAPIC Address\t: 0x%x\n"
+			"\tExtended Table Length\t: 0x%x (Not filled in yet)\n"
+			"\tExtended Table Checksum\t: 0x%x (Not calculated yet)\n",
+			mc->mpc_signature, mc->mpc_length, mc->mpc_spec, mc->mpc_checksum,
+			mc->mpc_oem, mc->mpc_productid, mc->mpc_oemptr, mc->mpc_oemsize,
+			mc->mpc_entry_count, mc->mpc_lapic, mc->mpe_length, mc->mpe_checksum);
 }
 
 static unsigned char smp_compute_checksum(void *v, int len)
@@ -90,6 +111,23 @@ static void *smp_write_floating_table_physaddr(uintptr_t addr, uintptr_t mpf_phy
 	mf->mpf_feature4 = 0;
 	mf->mpf_feature5 = 0;
 	mf->mpf_checksum = smp_compute_checksum(mf, mf->mpf_length*16);
+
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE))
+	printk(BIOS_DEBUG, "MP_Tables: Add MP Floating Pointer Structure:\n"
+			"\tSignature\t\t: %4.4s\n"
+			"\tPhysical Pointer\t: 0x%lx\n"
+			"\tLength\t\t\t: %d Paragraph(s) (16-bytes each)\n"
+			"\tMP Specification\t: 0x%x\n"
+			"\tChecksum\t\t: 0x%x\n"
+			"\tFeature1\t\t: 0x%x (Should be 0)\n"
+			"\tFeature2\t\t: '%s'\n"
+			"\tFeature3\t\t: 0x%x\n"
+			"\tFeature4\t\t: 0x%x\n"
+			"\tFeature5\t\t: 0x%x\n",
+			mf->mpf_signature, mpf_physptr, mf->mpf_length, mf->mpf_specification,
+			mf->mpf_checksum, mf->mpf_feature1, virtualwire?"PIC Mode":"Virtual Wire Mode",
+			mf->mpf_feature3, mf->mpf_feature4,	mf->mpf_feature5);
+
 	return v;
 }
 
@@ -97,6 +135,8 @@ void *smp_write_floating_table(unsigned long addr, unsigned int virtualwire)
 {
 	/* 16 byte align the table address */
 	addr = (addr + 0xf) & (~0xf);
+
+	printk(BIOS_DEBUG, "MP_Tables: Start writing the MP_Tables at 0x%lx\n", addr);
 	return smp_write_floating_table_physaddr(addr, addr + SMP_FLOATING_TABLE_LEN, virtualwire);
 }
 
@@ -134,6 +174,9 @@ void smp_write_processor(struct mp_config_table *mc,
 	u8 apicid, u8 apicver, u8 cpuflag,
 	u32 cpufeature, u32 featureflag)
 {
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE))
+		printk(BIOS_DEBUG, "\n\tAdd CPU/LAPIC Entry (Type 0)\n");
+
 	struct mpc_config_processor *mpc;
 	mpc = smp_next_mpc_entry(mc);
 	memset(mpc, '\0', sizeof(*mpc));
@@ -143,6 +186,21 @@ void smp_write_processor(struct mp_config_table *mc,
 	mpc->mpc_cpuflag = cpuflag;
 	mpc->mpc_cpufeature = cpufeature;
 	mpc->mpc_featureflag = featureflag;
+
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE))
+		printk(BIOS_SPEW,
+			"\tID\t\t: 0x%x\n"
+			"\tVersion\t\t: 0x%x\n"
+			"\tFlags\t\t: 0x%x (%s%s)\n"
+			"\tCPU Signature 0x%x:\n"
+			"\t  (Family %d, Model %d, Stepping %d)\n"
+			"\tFeature Flag\t: 0x%x (See CPUID)\n",
+			apicid, apicver, cpuflag,
+			(cpuflag & 0x1) ? "Enabled" : "Disabled",
+			(cpuflag & 0x2) ? ", Bootstrap" : "",
+			cpufeature, (cpufeature >> 8) & 0x0F, (cpufeature  >> 4) & 0x0F,
+			cpufeature & 0x0F, featureflag);
+
 	smp_add_mpc_entry(mc, sizeof(*mpc));
 }
 
@@ -203,12 +261,22 @@ void smp_write_processors(struct mp_config_table *mc)
 static void smp_write_bus(struct mp_config_table *mc,
 	u8 id, const char *bustype)
 {
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE))
+		printk(BIOS_DEBUG, "\n\tAdd Bus Entry (Type 1)\n");
+
 	struct mpc_config_bus *mpc;
 	mpc = smp_next_mpc_entry(mc);
 	memset(mpc, '\0', sizeof(*mpc));
 	mpc->mpc_type = MP_BUS;
 	mpc->mpc_busid = id;
 	memcpy(mpc->mpc_bustype, bustype, sizeof(mpc->mpc_bustype));
+
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE))
+		printk(BIOS_SPEW,
+			"\tBus ID\t\t: 0x%x\n"
+			"\tBus Type\t: %s\n",
+			id, bustype);
+
 	smp_add_mpc_entry(mc, sizeof(*mpc));
 }
 
@@ -220,6 +288,9 @@ static void smp_write_bus(struct mp_config_table *mc,
 void smp_write_ioapic(struct mp_config_table *mc,
 	u8 id, u8 ver, void *apicaddr)
 {
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE))
+	printk(BIOS_DEBUG, "\n\tAdd IOAPIC Entry (Type 2)\n");
+
 	struct mpc_config_ioapic *mpc;
 	mpc = smp_next_mpc_entry(mc);
 	memset(mpc, '\0', sizeof(*mpc));
@@ -228,10 +299,78 @@ void smp_write_ioapic(struct mp_config_table *mc,
 	mpc->mpc_apicver = ver;
 	mpc->mpc_flags = MPC_APIC_USABLE;
 	mpc->mpc_apicaddr = apicaddr;
+
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE))
+		printk(BIOS_SPEW,
+			"\tID\t\t: 0x%x\n"
+			"\tVersion\t\t: 0x%x\n"
+			"\tFlags\t\t: 0x%x (%s)\n"
+			"\tAddress\t\t: %p\n",
+			id, ver, mpc->mpc_flags, mpc->mpc_flags ? "Useable" : "Unusable",
+			apicaddr);
+
 	smp_add_mpc_entry(mc, sizeof(*mpc));
 }
 
 /*
+ * Type 3 and 4 MP entries have identical IRQ Types
+ * where an integer corresponds to a type which is
+ * easier to understand as a string
+ */
+const char * smp_irqtype_to_str(u8 irqtype)
+{
+	const char * str[] = {
+			"Vectored INT",
+			"NMI",
+			"SMI",
+			"ExtINT",
+	};
+
+	if (irqtype < 4)
+		return str[irqtype];
+	else
+		return "Unknown IRQ Type";
+}
+
+/*
+ * Type 3 and 4 MP entries have an irqflag field
+ * that has (Polarity << 2) | (Trigger) data.  This
+ * is much easier to read as a string for each MP
+ * entry that uses them
+ */
+char * smp_irqflag_to_str(u16 irqflag, char *str)
+{
+	int polarity = (irqflag & 0x3);		/* Polarity is bottom 2 bits */
+	int trigger = (irqflag >> 2) & 0x3;	/* Trigger is next 2 bits */
+	const char *divider = " | ";
+
+	/* IRQ Trigger polarity */
+	const char * pol[] = {
+			"Bus Default",
+			"Active High",
+			"Reserved",
+			"Active Low",
+	};
+
+	/* IRQ Trigger mode */
+	const char * trig[] = {
+			"Bus Default",
+			"Edge Triggered",
+			"Reserved",
+			"Level Triggered",
+		};
+
+	/* Create the Polarity|Trigger string */
+	if ((strlen(pol[polarity]) + strlen(divider) + strlen(trig[trigger]) + 1) < IRQFLAG_STRING_SIZE) {
+		strcpy(str, pol[polarity]);
+		strcpy(str + strlen(str), divider);
+		strcpy(str + strlen(str), trig[trigger]);
+	}
+
+	return str;
+}
+
+/*
  * Type 3: I/O Interrupt Table Entries:
  * Entry Type, Int Type, Int Polarity, Int Level,
  * Source Bus ID, Source Bus IRQ, Dest APIC ID, Dest PIN#
@@ -241,6 +380,10 @@ void smp_write_intsrc(struct mp_config_table *mc,
 	u8 srcbus, u8 srcbusirq,
 	u8 dstapic, u8 dstirq)
 {
+
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE))
+		printk(BIOS_DEBUG, "\n\tAdd IO Interrupt Entry (Type 3)\n");
+
 	struct mpc_config_intsrc *mpc;
 	mpc = smp_next_mpc_entry(mc);
 	memset(mpc, '\0', sizeof(*mpc));
@@ -251,12 +394,20 @@ void smp_write_intsrc(struct mp_config_table *mc,
 	mpc->mpc_srcbusirq = srcbusirq;
 	mpc->mpc_dstapic = dstapic;
 	mpc->mpc_dstirq = dstirq;
+
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE)) {
+		char str[IRQFLAG_STRING_SIZE];
+		printk(BIOS_SPEW,"\tIRQ Type\t: 0x%x (%s)\n"
+			"\tIRQ Flags\t: 0x%x (%s)\n"
+			"\tSrc Bus ID\t: 0x%x\n"
+			"\tSrc Bus IRQ\t: 0x%x\n"
+			"\tDest IOAPIC\t: 0x%x\n"
+			"\tDest IOAPIC IRQ\t: 0x%x\n",
+			irqtype, smp_irqtype_to_str(irqtype),
+			irqflag, smp_irqflag_to_str(irqflag, &str[0]),
+			srcbus, srcbusirq, dstapic, dstirq);
+	}
 	smp_add_mpc_entry(mc, sizeof(*mpc));
-#ifdef DEBUG_MPTABLE
-	printk(BIOS_DEBUG, "add intsrc srcbus 0x%x srcbusirq 0x%x, dstapic 0x%x, dstirq 0x%x\n",
-				srcbus, srcbusirq, dstapic, dstirq);
-	hexdump(__func__, mpc, sizeof(*mpc));
-#endif
 }
 
 /*
@@ -339,6 +490,9 @@ void smp_write_lintsrc(struct mp_config_table *mc,
 	u8 srcbusid, u8 srcbusirq,
 	u8 destapic, u8 destapiclint)
 {
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE))
+		printk(BIOS_DEBUG, "\n\tAdd Local Interrupt Entry (Type 4)\n");
+
 	struct mpc_config_lintsrc *mpc;
 	mpc = smp_next_mpc_entry(mc);
 	memset(mpc, '\0', sizeof(*mpc));
@@ -349,6 +503,21 @@ void smp_write_lintsrc(struct mp_config_table *mc,
 	mpc->mpc_srcbusirq = srcbusirq;
 	mpc->mpc_destapic = destapic;
 	mpc->mpc_destapiclint = destapiclint;
+
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE)) {
+		char str[IRQFLAG_STRING_SIZE];
+		printk(BIOS_SPEW,
+			"\tIRQ Type\t: 0x%x (%s)\n"
+			"\tIRQ Flags\t: 0x%x (%s)\n"
+			"\tSrc Bus ID\t: 0x%x\n"
+			"\tSrc Bus IRQ\t: 0x%x\n"
+			"\tDest LAPIC\t: 0x%x\n"
+			"\tDest LAPIC IRQ\t: 0x%x\n",
+			irqtype, smp_irqtype_to_str(irqtype),
+			irqflag, smp_irqflag_to_str(irqflag, &str[0]),
+			srcbusid, srcbusirq, destapic, destapiclint);
+	}
+
 	smp_add_mpc_entry(mc, sizeof(*mpc));
 }
 
@@ -362,6 +531,9 @@ void smp_write_address_space(struct mp_config_table *mc,
 	u32 address_base_low, u32 address_base_high,
 	u32 address_length_low, u32 address_length_high)
 {
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE))
+		printk(BIOS_DEBUG, "\n\tAdd Address Space Mapping Entry (Type 128)\n");
+
 	struct mp_exten_system_address_space *mpe;
 	mpe = smp_next_mpe_entry(mc);
 	memset(mpe, '\0', sizeof(*mpe));
@@ -373,6 +545,18 @@ void smp_write_address_space(struct mp_config_table *mc,
 	mpe->mpe_address_base_high = address_base_high;
 	mpe->mpe_address_length_low  = address_length_low;
 	mpe->mpe_address_length_high = address_length_high;
+
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE))
+		printk(BIOS_SPEW,
+			"\tEntry Length\t: 0x%x\n"
+			"\tBus ID\t\t: 0x%x\n"
+			"\tAddress Type\t: 0x%x\n"
+			"\tAddress Base\t: 0x%x%x\n"
+			"\tAddress Length\t: 0x%x%x\n",
+			mpe->mpe_length, busid, address_type,
+			address_base_high, address_base_low,
+			address_length_high, address_length_low);
+
 	smp_add_mpe_entry(mc, (mpe_t)mpe);
 }
 
@@ -384,6 +568,9 @@ void smp_write_address_space(struct mp_config_table *mc,
 void smp_write_bus_hierarchy(struct mp_config_table *mc,
 	u8 busid, u8 bus_info, u8 parent_busid)
 {
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE))
+		printk(BIOS_DEBUG, "\n\tAdd Bus Hierarchy Entry (Type 129)\n");
+
 	struct mp_exten_bus_hierarchy *mpe;
 	mpe = smp_next_mpe_entry(mc);
 	memset(mpe, '\0', sizeof(*mpe));
@@ -392,6 +579,15 @@ void smp_write_bus_hierarchy(struct mp_config_table *mc,
 	mpe->mpe_busid = busid;
 	mpe->mpe_bus_info = bus_info;
 	mpe->mpe_parent_busid = parent_busid;
+
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE))
+		printk(BIOS_SPEW,
+			"\tEntry Length\t: 0x%x\n"
+			"\tBus ID\t\t: 0x%x\n"
+			"\tBus Info\t: 0x%x\n"
+			"\tParent Bus ID\t: 0x%x\n",
+			mpe->mpe_length, busid, bus_info, parent_busid);
+
 	smp_add_mpe_entry(mc, (mpe_t)mpe);
 }
 
@@ -404,6 +600,9 @@ void smp_write_compatibility_address_space(struct mp_config_table *mc,
 	u8 busid, u8 address_modifier,
 	u32 range_list)
 {
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE))
+		printk(BIOS_DEBUG, "\n\tAdd Compatibility Address Space Entry (Type 130)\n");
+
 	struct mp_exten_compatibility_address_space *mpe;
 	mpe = smp_next_mpe_entry(mc);
 	memset(mpe, '\0', sizeof(*mpe));
@@ -412,6 +611,15 @@ void smp_write_compatibility_address_space(struct mp_config_table *mc,
 	mpe->mpe_busid = busid;
 	mpe->mpe_address_modifier = address_modifier;
 	mpe->mpe_range_list = range_list;
+
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE))
+		printk(BIOS_SPEW,
+			"\tEntry Length\t: 0x%x\n"
+			"\tBus ID\t\t: 0x%x\n"
+			"\tAddress Modifier: 0x%x\n"
+			"\tRange List\t: 0x%x\n",
+			mpe->mpe_length, busid, address_modifier, range_list);
+
 	smp_add_mpe_entry(mc, (mpe_t)mpe);
 }
 
@@ -478,10 +686,45 @@ void mptable_write_buses(struct mp_config_table *mc, int *max_pci_bus, int *isa_
 
 void *mptable_finalize(struct mp_config_table *mc)
 {
-	mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
+	void *last_mpc_entry = smp_next_mpc_entry(mc);
+	void *last_mpe_entry = smp_next_mpe_entry(mc);
+
+	mc->mpe_checksum = smp_compute_checksum(last_mpc_entry, mc->mpe_length);
 	mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
-	printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", mc, smp_next_mpe_entry(mc));
-	return smp_next_mpe_entry(mc);
+	printk(BIOS_INFO, "MP_Tables: Finished writing the MP_Table from");
+	printk(BIOS_INFO, " 0x%p - 0x%p\n", mc, last_mpe_entry);
+
+	if (IS_ENABLED(CONFIG_DEBUG_MP_TABLE)) {
+		printk(BIOS_DEBUG, "MP_Tables: Final MP Configuration Table Header:\n"
+			"\tSignature\t\t: %4.4s\n"
+			"\tLength\t\t\t: 0x%x\n"
+			"\tMP Specification\t: 0x%x\n"
+			"\tChecksum\t\t: 0x%x\n"
+			"\tOEM ID\t\t\t: %8.8s\n"
+			"\tProduct ID\t\t: %12.12s\n"
+			"\tOEM Table PTR\t\t: 0x%x\n"
+			"\tOEM Table Size\t\t: 0x%x\n"
+			"\tEntry Count\t\t: 0x%x\n"
+			"\tMMIO LAPIC Address\t: 0x%x\n"
+			"\tExtended Table Length\t: 0x%x\n"
+			"\tExtended Table Checksum\t: 0x%x\n",
+			mc->mpc_signature, mc->mpc_length, mc->mpc_spec,
+			mc->mpc_checksum, mc->mpc_oem, mc->mpc_productid,
+			mc->mpc_oemptr, mc->mpc_oemsize, mc->mpc_entry_count,
+			mc->mpc_lapic, mc->mpe_length, mc->mpe_checksum);
+
+		printk(BIOS_SPEW, "\nMP_Tables: Hexdump of the MP Configuration Table");
+		printk(BIOS_SPEW, " (0x%x bytes):\n", mc->mpc_length);
+		hexdump(mc, mc->mpc_length);
+
+		if(mc->mpe_length){
+			printk(BIOS_SPEW, "\nMP_Tables: Hexdump of the MP Extended Table");
+			printk(BIOS_SPEW, " (0x%x bytes):\n", mc->mpe_length);
+			hexdump(last_mpc_entry, mc->mpe_length);
+		}
+	}
+
+	return last_mpe_entry;
 }
 
 unsigned long __attribute__((weak)) write_smp_table(unsigned long addr)



More information about the coreboot-gerrit mailing list