Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86/x86 Towards bifurcating XEN and native interrup...



details:   https://anonhg.NetBSD.org/src/rev/6d1d6ac31d80
branches:  trunk
changeset: 446910:6d1d6ac31d80
user:      cherry <cherry%NetBSD.org@localhost>
date:      Mon Dec 24 22:05:45 2018 +0000

description:
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

diffstat:

 sys/arch/x86/x86/intr.c        |  145 +----------------------------------------
 sys/arch/x86/x86/mp.c          |  140 +++++++++++++++++++++++++++++++++++++++-
 sys/arch/x86/x86/x86_machdep.c |   31 ++++++++-
 3 files changed, 169 insertions(+), 147 deletions(-)

diffs (truncated from 407 to 300 lines):

diff -r 9c1e3d885e56 -r 6d1d6ac31d80 sys/arch/x86/x86/intr.c
--- a/sys/arch/x86/x86/intr.c   Mon Dec 24 22:02:32 2018 +0000
+++ b/sys/arch/x86/x86/intr.c   Mon Dec 24 22:05:45 2018 +0000
@@ -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 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 @@
 }
 
 /*
- * 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 @@
 #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)
 /*
diff -r 9c1e3d885e56 -r 6d1d6ac31d80 sys/arch/x86/x86/mp.c
--- a/sys/arch/x86/x86/mp.c     Mon Dec 24 22:02:32 2018 +0000
+++ b/sys/arch/x86/x86/mp.c     Mon Dec 24 22:05:45 2018 +0000
@@ -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 @@
 #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 @@
        }
 }
 #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)
+{



Home | Main Index | Thread Index | Old Index