Module Name: src
Committed By: cherry
Date: Mon Dec 24 22:05:45 UTC 2018
Modified Files:
src/sys/arch/x86/x86: intr.c mp.c x86_machdep.c
Log Message:
Towards bifurcating XEN and native interrupt related functions,
this is a preliminary cleanup sweep.
Move functions related to MP bus probe and scanning to x86/mp.c
Move generic platform pic search function to x86/x86_machdep.c
To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/sys/arch/x86/x86/intr.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/x86/mp.c
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/x86/x86/x86_machdep.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/x86/intr.c
diff -u src/sys/arch/x86/x86/intr.c:1.139 src/sys/arch/x86/x86/intr.c:1.140
--- src/sys/arch/x86/x86/intr.c:1.139 Mon Dec 24 14:55:41 2018
+++ src/sys/arch/x86/x86/intr.c Mon Dec 24 22:05:45 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: intr.c,v 1.139 2018/12/24 14:55:41 cherry Exp $ */
+/* $NetBSD: intr.c,v 1.140 2018/12/24 22:05:45 cherry Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.139 2018/12/24 14:55:41 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.140 2018/12/24 22:05:45 cherry Exp $");
#include "opt_intrdebug.h"
#include "opt_multiprocessor.h"
@@ -220,13 +220,6 @@ static SIMPLEQ_HEAD(, intrsource) io_int
static kmutex_t intr_distribute_lock;
-#if NIOAPIC > 0 || NACPICA > 0
-static int intr_scan_bus(int, int, intr_handle_t *);
-#if NPCI > 0
-static int intr_find_pcibridge(int, pcitag_t *, pci_chipset_tag_t *);
-#endif
-#endif
-
#if !defined(XEN)
static int intr_allocate_slot_cpu(struct cpu_info *, struct pic *, int, int *,
struct intrsource *);
@@ -374,123 +367,6 @@ intr_calculatemasks(struct cpu_info *ci)
}
/*
- * List to keep track of PCI buses that are probed but not known
- * to the firmware. Used to
- *
- * XXX should maintain one list, not an array and a linked list.
- */
-#if (NPCI > 0) && ((NIOAPIC > 0) || NACPICA > 0)
-struct intr_extra_bus {
- int bus;
- pcitag_t *pci_bridge_tag;
- pci_chipset_tag_t pci_chipset_tag;
- LIST_ENTRY(intr_extra_bus) list;
-};
-
-LIST_HEAD(, intr_extra_bus) intr_extra_buses =
- LIST_HEAD_INITIALIZER(intr_extra_buses);
-
-
-void
-intr_add_pcibus(struct pcibus_attach_args *pba)
-{
- struct intr_extra_bus *iebp;
-
- iebp = kmem_alloc(sizeof(*iebp), KM_SLEEP);
- iebp->bus = pba->pba_bus;
- iebp->pci_chipset_tag = pba->pba_pc;
- iebp->pci_bridge_tag = pba->pba_bridgetag;
- LIST_INSERT_HEAD(&intr_extra_buses, iebp, list);
-}
-
-static int
-intr_find_pcibridge(int bus, pcitag_t *pci_bridge_tag,
- pci_chipset_tag_t *pc)
-{
- struct intr_extra_bus *iebp;
- struct mp_bus *mpb;
-
- if (bus < 0)
- return ENOENT;
-
- if (bus < mp_nbus) {
- mpb = &mp_busses[bus];
- if (mpb->mb_pci_bridge_tag == NULL)
- return ENOENT;
- *pci_bridge_tag = *mpb->mb_pci_bridge_tag;
- *pc = mpb->mb_pci_chipset_tag;
- return 0;
- }
-
- LIST_FOREACH(iebp, &intr_extra_buses, list) {
- if (iebp->bus == bus) {
- if (iebp->pci_bridge_tag == NULL)
- return ENOENT;
- *pci_bridge_tag = *iebp->pci_bridge_tag;
- *pc = iebp->pci_chipset_tag;
- return 0;
- }
- }
- return ENOENT;
-}
-#endif
-
-#if NIOAPIC > 0 || NACPICA > 0
-/*
- * 'pin' argument pci bus_pin encoding of a device/pin combination.
- */
-int
-intr_find_mpmapping(int bus, int pin, intr_handle_t *handle)
-{
-
-#if NPCI > 0
- while (intr_scan_bus(bus, pin, handle) != 0) {
- int dev, func;
- pcitag_t pci_bridge_tag;
- pci_chipset_tag_t pc;
-
- if (intr_find_pcibridge(bus, &pci_bridge_tag, &pc) != 0)
- return ENOENT;
- dev = pin >> 2;
- pin = pin & 3;
- pin = PPB_INTERRUPT_SWIZZLE(pin + 1, dev) - 1;
- pci_decompose_tag(pc, pci_bridge_tag, &bus, &dev, &func);
- pin |= (dev << 2);
- }
- return 0;
-#else
- return intr_scan_bus(bus, pin, handle);
-#endif
-}
-
-static int
-intr_scan_bus(int bus, int pin, intr_handle_t *handle)
-{
- struct mp_intr_map *mip, *intrs;
-
- if (bus < 0 || bus >= mp_nbus)
- return ENOENT;
-
- intrs = mp_busses[bus].mb_intrs;
- if (intrs == NULL)
- return ENOENT;
-
- for (mip = intrs; mip != NULL; mip = mip->next) {
- if (mip->bus_pin == pin) {
-#if NACPICA > 0
- if (mip->linkdev != NULL)
- if (mpacpi_findintr_linkdev(mip) != 0)
- continue;
-#endif
- *handle = mip->ioapic_ih;
- return 0;
- }
- }
- return ENOENT;
-}
-#endif
-
-/*
* Create an interrupt id such as "ioapic0 pin 9". This interrupt id is used
* by MI code and intrctl(8).
*/
@@ -852,23 +728,6 @@ intr_biglock_wrapper(void *vp)
#endif /* MULTIPROCESSOR */
#endif /* XEN */
-#if defined(DOM0OPS) || !defined(XEN)
-struct pic *
-intr_findpic(int num)
-{
-#if NIOAPIC > 0
- struct ioapic_softc *pic;
-
- pic = ioapic_find_bybase(num);
- if (pic != NULL)
- return &pic->sc_pic;
-#endif
- if (num < NUM_LEGACY_IRQS)
- return &i8259_pic;
-
- return NULL;
-}
-#endif
#if !defined(XEN)
/*
Index: src/sys/arch/x86/x86/mp.c
diff -u src/sys/arch/x86/x86/mp.c:1.3 src/sys/arch/x86/x86/mp.c:1.4
--- src/sys/arch/x86/x86/mp.c:1.3 Fri Jul 1 18:21:31 2011
+++ src/sys/arch/x86/x86/mp.c Mon Dec 24 22:05:45 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: mp.c,v 1.3 2011/07/01 18:21:31 dyoung Exp $ */
+/* $NetBSD: mp.c,v 1.4 2018/12/24 22:05:45 cherry Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,9 +36,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mp.c,v 1.3 2011/07/01 18:21:31 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mp.c,v 1.4 2018/12/24 22:05:45 cherry Exp $");
#include "opt_multiprocessor.h"
+#include "opt_acpi.h"
+
+#include "acpica.h"
+#include "ioapic.h"
#include "pchb.h"
#include <sys/param.h>
@@ -59,6 +63,21 @@ __KERNEL_RCSID(0, "$NetBSD: mp.c,v 1.3 2
#include "pci.h"
#include "locators.h"
+#if NIOAPIC > 0 || NACPICA > 0
+#include <machine/mpacpi.h>
+#endif
+
+#if NPCI > 0
+#include <dev/pci/ppbreg.h>
+#endif
+
+#if NIOAPIC > 0 || NACPICA > 0
+static int intr_scan_bus(int, int, intr_handle_t *);
+#if NPCI > 0
+static int intr_find_pcibridge(int, pcitag_t *, pci_chipset_tag_t *);
+#endif
+#endif
+
#if NPCI > 0
int
mp_pci_scan(device_t self, struct pcibus_attach_args *pba,
@@ -97,3 +116,120 @@ mp_pci_childdetached(device_t self, devi
}
}
#endif
+
+/*
+ * List to keep track of PCI buses that are probed but not known
+ * to the firmware. Used to
+ *
+ * XXX should maintain one list, not an array and a linked list.
+ */
+#if (NPCI > 0) && ((NIOAPIC > 0) || NACPICA > 0)
+struct intr_extra_bus {
+ int bus;
+ pcitag_t *pci_bridge_tag;
+ pci_chipset_tag_t pci_chipset_tag;
+ LIST_ENTRY(intr_extra_bus) list;
+};
+
+LIST_HEAD(, intr_extra_bus) intr_extra_buses =
+ LIST_HEAD_INITIALIZER(intr_extra_buses);
+
+
+void
+intr_add_pcibus(struct pcibus_attach_args *pba)
+{
+ struct intr_extra_bus *iebp;
+
+ iebp = kmem_alloc(sizeof(*iebp), KM_SLEEP);
+ iebp->bus = pba->pba_bus;
+ iebp->pci_chipset_tag = pba->pba_pc;
+ iebp->pci_bridge_tag = pba->pba_bridgetag;
+ LIST_INSERT_HEAD(&intr_extra_buses, iebp, list);
+}
+
+static int
+intr_find_pcibridge(int bus, pcitag_t *pci_bridge_tag,
+ pci_chipset_tag_t *pc)
+{
+ struct intr_extra_bus *iebp;
+ struct mp_bus *mpb;
+
+ if (bus < 0)
+ return ENOENT;
+
+ if (bus < mp_nbus) {
+ mpb = &mp_busses[bus];
+ if (mpb->mb_pci_bridge_tag == NULL)
+ return ENOENT;
+ *pci_bridge_tag = *mpb->mb_pci_bridge_tag;
+ *pc = mpb->mb_pci_chipset_tag;
+ return 0;
+ }
+
+ LIST_FOREACH(iebp, &intr_extra_buses, list) {
+ if (iebp->bus == bus) {
+ if (iebp->pci_bridge_tag == NULL)
+ return ENOENT;
+ *pci_bridge_tag = *iebp->pci_bridge_tag;
+ *pc = iebp->pci_chipset_tag;
+ return 0;
+ }
+ }
+ return ENOENT;
+}
+#endif
+
+#if NIOAPIC > 0 || NACPICA > 0
+/*
+ * 'pin' argument pci bus_pin encoding of a device/pin combination.
+ */
+int
+intr_find_mpmapping(int bus, int pin, intr_handle_t *handle)
+{
+
+#if NPCI > 0
+ while (intr_scan_bus(bus, pin, handle) != 0) {
+ int dev, func;
+ pcitag_t pci_bridge_tag;
+ pci_chipset_tag_t pc;
+
+ if (intr_find_pcibridge(bus, &pci_bridge_tag, &pc) != 0)
+ return ENOENT;
+ dev = pin >> 2;
+ pin = pin & 3;
+ pin = PPB_INTERRUPT_SWIZZLE(pin + 1, dev) - 1;
+ pci_decompose_tag(pc, pci_bridge_tag, &bus, &dev, &func);
+ pin |= (dev << 2);
+ }
+ return 0;
+#else
+ return intr_scan_bus(bus, pin, handle);
+#endif
+}
+
+static int
+intr_scan_bus(int bus, int pin, intr_handle_t *handle)
+{
+ struct mp_intr_map *mip, *intrs;
+
+ if (bus < 0 || bus >= mp_nbus)
+ return ENOENT;
+
+ intrs = mp_busses[bus].mb_intrs;
+ if (intrs == NULL)
+ return ENOENT;
+
+ for (mip = intrs; mip != NULL; mip = mip->next) {
+ if (mip->bus_pin == pin) {
+#if NACPICA > 0
+ if (mip->linkdev != NULL)
+ if (mpacpi_findintr_linkdev(mip) != 0)
+ continue;
+#endif
+ *handle = mip->ioapic_ih;
+ return 0;
+ }
+ }
+ return ENOENT;
+}
+#endif
Index: src/sys/arch/x86/x86/x86_machdep.c
diff -u src/sys/arch/x86/x86/x86_machdep.c:1.120 src/sys/arch/x86/x86/x86_machdep.c:1.121
--- src/sys/arch/x86/x86/x86_machdep.c:1.120 Wed Sep 19 16:23:05 2018
+++ src/sys/arch/x86/x86/x86_machdep.c Mon Dec 24 22:05:45 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: x86_machdep.c,v 1.120 2018/09/19 16:23:05 maxv Exp $ */
+/* $NetBSD: x86_machdep.c,v 1.121 2018/12/24 22:05:45 cherry Exp $ */
/*-
* Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.120 2018/09/19 16:23:05 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.121 2018/12/24 22:05:45 cherry Exp $");
#include "opt_modular.h"
#include "opt_physmem.h"
@@ -74,10 +74,17 @@ __KERNEL_RCSID(0, "$NetBSD: x86_machdep.
#include "tsc.h"
#include "acpica.h"
+#include "ioapic.h"
+#include "lapic.h"
+
#if NACPICA > 0
#include <dev/acpi/acpivar.h>
#endif
+#if NIOAPIC > 0 || NACPICA > 0
+#include <machine/i82093var.h>
+#endif
+
#include "opt_md.h"
#if defined(MEMORY_DISK_HOOKS) && defined(MEMORY_DISK_DYNAMIC)
#include <dev/md.h>
@@ -1298,3 +1305,23 @@ SYSCTL_SETUP(sysctl_machdep_setup, "sysc
CPU_BIOSEXTMEM);
#endif
}
+
+/* Here for want of a better place */
+#if defined(DOM0OPS) || !defined(XEN)
+struct pic *
+intr_findpic(int num)
+{
+#if NIOAPIC > 0
+ struct ioapic_softc *pic;
+
+ pic = ioapic_find_bybase(num);
+ if (pic != NULL)
+ return &pic->sc_pic;
+#endif
+ if (num < NUM_LEGACY_IRQS)
+ return &i8259_pic;
+
+ return NULL;
+}
+#endif
+