- Dump LAPIC and I/O APIC correctly. trunk
authormsaitoh <msaitoh@NetBSD.org>
Fri, 14 Jun 2019 09:23:42 +0000
branchtrunk
changeset 452001 959aad8a3b7b
parent 452000 e025373e1d58
child 452002 73a5e7e68b89
- Dump LAPIC and I/O APIC correctly. - Don't print redirect target on LAPIC. - Fix DEST_MASK: - DEST_MASK is not 1 bit but 2 bit. - Add missing "\0"s to print decoded name correctly. - Support both LAPIC and I/O APIC correctly in apic_format_redir(). - Improve output of some bits using with snprintb()'s "F\B\1" and ":\V".
sys/arch/x86/include/apicvar.h
sys/arch/x86/x86/apic.c
sys/arch/x86/x86/ioapic.c
sys/arch/x86/x86/lapic.c
--- a/sys/arch/x86/include/apicvar.h	Fri Jun 14 09:12:42 2019 +0000
+++ b/sys/arch/x86/include/apicvar.h	Fri Jun 14 09:23:42 2019 +0000
@@ -1,4 +1,4 @@
-/* 	$NetBSD: apicvar.h,v 1.5 2008/04/28 20:23:40 martin Exp $ */
+/* 	$NetBSD: apicvar.h,v 1.6 2019/06/14 09:23:42 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -44,6 +44,14 @@
 	int apic_vecbase;
 };
 
-void apic_format_redir(const char *, const char *, int, u_int32_t, u_int32_t);
+/*
+ * Dump function for both LAPIC and I/O APIC.
+ * The 3rd argument is APIC_VECTYPE_*.
+ */
+#define APIC_VECTYPE_LAPIC_LVT	1
+#define APIC_VECTYPE_LAPIC_ICR	2
+#define APIC_VECTYPE_IOAPIC	3
+void apic_format_redir(const char *, const char *, int, int, uint32_t,
+    uint32_t);
 
 #endif /* !_X86_APICVAR_H_ */
--- a/sys/arch/x86/x86/apic.c	Fri Jun 14 09:12:42 2019 +0000
+++ b/sys/arch/x86/x86/apic.c	Fri Jun 14 09:23:42 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: apic.c,v 1.9 2019/06/13 07:28:17 msaitoh Exp $ */
+/* $NetBSD: apic.c,v 1.10 2019/06/14 09:23:42 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: apic.c,v 1.9 2019/06/13 07:28:17 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: apic.c,v 1.10 2019/06/14 09:23:42 msaitoh Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -42,31 +42,38 @@
 #include <machine/i82489var.h>
 #include <machine/apicvar.h>
 
-const char redirlofmt[] = "\177\20"
-	"f\0\10vector\0"
-	"f\10\3delmode\0"
-	"b\13logical\0"
-	"b\14pending\0"
-	"b\15actlo\0"
-	"b\16irrpending\0"
-	"b\17level\0"
+#define APICVTFMT "\177\20"						\
+	"f\0\10vector\0"						\
+	"f\10\3delmode\0" "=\0fixed\0" "=\1low\0" "=\2SMI\0" "=\4NMI\0"	\
+			"=\5INIT\0" "=\6startup\0" "=\7ExtINT\0"	\
+	"F\13\1\0" ":\0physical\0" ":\1logical\0"			\
+	"b\14pending\0"							\
+	"F\15\1\0" ":\0acthi\0" ":\1actlo\0"				\
+	"b\16irrpending\0"						\
+	"F\17\1\0" ":\0edge\0" ":\1level\0"				\
 	"b\20masked\0"
-	"f\22\1dest\0" "=\1self" "=\2all" "=\3all-others";
+
+static const char ioapicfmt[] = APICVTFMT
+	"f\22\2dest\0" "=\1self\0" "=\2all\0" "=\3all-others\0";
 
-const char redirhifmt[] = "\177\20"
+static const char lapicfmt[] = APICVTFMT
+	"f\21\2timer\0" "=\0oneshot\0" "=\1periodic\0" "=\2TSC-deadine\0";
+
+static const char redirhifmt[] = "\177\20"
 	"f\30\10target\0";
 
 void
-apic_format_redir(const char *where1, const char *where2, int idx,
+apic_format_redir(const char *where1, const char *where2, int idx, int type,
 		uint32_t redirhi, uint32_t redirlo)
 {
 	char buf[256];
 
-	snprintb(buf, sizeof(buf), redirlofmt, redirlo);
-	printf("%s: %s%d %s",
-	    where1, where2, idx, buf);
+	snprintb(buf, sizeof(buf),
+	    type == APIC_VECTYPE_IOAPIC ? ioapicfmt : lapicfmt, redirlo);
+	printf("%s: %s%d %s", where1, where2, idx, buf);
 
-	if ((redirlo & LAPIC_DEST_MASK) == 0) {
+	if ((type == APIC_VECTYPE_IOAPIC)
+	    && ((redirlo & LAPIC_DEST_MASK) == 0)) {
 		snprintb(buf, sizeof(buf), redirhifmt, redirhi);
 		printf(" %s", buf);
 	}
--- a/sys/arch/x86/x86/ioapic.c	Fri Jun 14 09:12:42 2019 +0000
+++ b/sys/arch/x86/x86/ioapic.c	Fri Jun 14 09:23:42 2019 +0000
@@ -1,4 +1,4 @@
-/* 	$NetBSD: ioapic.c,v 1.60 2019/06/13 07:28:17 msaitoh Exp $	*/
+/* 	$NetBSD: ioapic.c,v 1.61 2019/06/14 09:23:42 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2009 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1.60 2019/06/13 07:28:17 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1.61 2019/06/14 09:23:42 msaitoh Exp $");
 
 #include "opt_ddb.h"
 
@@ -238,8 +238,8 @@
 	uint32_t redirlo = ioapic_read(sc, IOAPIC_REDLO(pin));
 	uint32_t redirhi = ioapic_read(sc, IOAPIC_REDHI(pin));
 
-	apic_format_redir(device_xname(sc->sc_dev), why, pin, redirhi,
-	    redirlo);
+	apic_format_redir(device_xname(sc->sc_dev), why, pin,
+	    APIC_VECTYPE_IOAPIC, redirhi, redirlo);
 }
 
 CFATTACH_DECL_NEW(ioapic, sizeof(struct ioapic_softc),
--- a/sys/arch/x86/x86/lapic.c	Fri Jun 14 09:12:42 2019 +0000
+++ b/sys/arch/x86/x86/lapic.c	Fri Jun 14 09:23:42 2019 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: lapic.c,v 1.74 2019/06/14 05:59:39 msaitoh Exp $	*/
+/*	$NetBSD: lapic.c,v 1.75 2019/06/14 09:23:42 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.74 2019/06/14 05:59:39 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.75 2019/06/14 09:23:42 msaitoh Exp $");
 
 #include "acpica.h"
 #include "ioapic.h"
@@ -422,10 +422,10 @@
 
 #ifdef MULTIPROCESSOR
 	if (mp_verbose) {
-		apic_format_redir(device_xname(ci->ci_dev), "prelint", 0, 0,
-		    lapic_readreg(LAPIC_LVT_LINT0));
-		apic_format_redir(device_xname(ci->ci_dev), "prelint", 1, 0,
-		    lapic_readreg(LAPIC_LVT_LINT1));
+		apic_format_redir(device_xname(ci->ci_dev), "prelint", 0,
+		    APIC_VECTYPE_LAPIC_LVT, 0, lapic_readreg(LAPIC_LVT_LINT0));
+		apic_format_redir(device_xname(ci->ci_dev), "prelint", 1,
+		    APIC_VECTYPE_LAPIC_LVT, 0, lapic_readreg(LAPIC_LVT_LINT1));
 	}
 #endif
 
@@ -956,9 +956,9 @@
 	struct cpu_info *ci = curcpu();
 
 #define APIC_LVT_PRINT(ci, where, idx, lvtreg)				\
-	apic_format_redir(device_xname(ci->ci_dev), where, (idx), 0,	\
-	    lapic_readreg(lvtreg))
-	
+	apic_format_redir(device_xname(ci->ci_dev), where, (idx),	\
+	    APIC_VECTYPE_LAPIC_LVT, 0, lapic_readreg(lvtreg))
+
 	APIC_LVT_PRINT(ci, "cmci", 0, LAPIC_LVT_CMCI);
 	APIC_LVT_PRINT(ci, "timer", 0, LAPIC_LVT_TIMER);
 	APIC_LVT_PRINT(ci, "thermal", 0, LAPIC_LVT_THERM);