Module Name: src
Committed By: msaitoh
Date: Fri Jun 14 09:23:42 UTC 2019
Modified Files:
src/sys/arch/x86/include: apicvar.h
src/sys/arch/x86/x86: apic.c ioapic.c lapic.c
Log Message:
- 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".
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/include/apicvar.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x86/x86/apic.c
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/x86/x86/ioapic.c
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/x86/x86/lapic.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/x86/include/apicvar.h
diff -u src/sys/arch/x86/include/apicvar.h:1.5 src/sys/arch/x86/include/apicvar.h:1.6
--- src/sys/arch/x86/include/apicvar.h:1.5 Mon Apr 28 20:23:40 2008
+++ src/sys/arch/x86/include/apicvar.h Fri Jun 14 09:23:42 2019
@@ -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 @@ struct apic_attach_args {
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_ */
Index: src/sys/arch/x86/x86/apic.c
diff -u src/sys/arch/x86/x86/apic.c:1.9 src/sys/arch/x86/x86/apic.c:1.10
--- src/sys/arch/x86/x86/apic.c:1.9 Thu Jun 13 07:28:17 2019
+++ src/sys/arch/x86/x86/apic.c Fri Jun 14 09:23:42 2019
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: apic.c,v 1.9
#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";
-const char redirhifmt[] = "\177\20"
+static const char ioapicfmt[] = APICVTFMT
+ "f\22\2dest\0" "=\1self\0" "=\2all\0" "=\3all-others\0";
+
+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);
}
Index: src/sys/arch/x86/x86/ioapic.c
diff -u src/sys/arch/x86/x86/ioapic.c:1.60 src/sys/arch/x86/x86/ioapic.c:1.61
--- src/sys/arch/x86/x86/ioapic.c:1.60 Thu Jun 13 07:28:17 2019
+++ src/sys/arch/x86/x86/ioapic.c Fri Jun 14 09:23:42 2019
@@ -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 @@ ioapic_print_redir(struct ioapic_softc *
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),
Index: src/sys/arch/x86/x86/lapic.c
diff -u src/sys/arch/x86/x86/lapic.c:1.74 src/sys/arch/x86/x86/lapic.c:1.75
--- src/sys/arch/x86/x86/lapic.c:1.74 Fri Jun 14 05:59:39 2019
+++ src/sys/arch/x86/x86/lapic.c Fri Jun 14 09:23:42 2019
@@ -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 @@ lapic_set_lvt(void)
#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 @@ lapic_dump(void)
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);