Page MenuHomeFreeBSD

D38495.id116952.diff
No OneTemporary

D38495.id116952.diff

diff --git a/sys/arm/arm/nexus.c b/sys/arm/arm/nexus.c
--- a/sys/arm/arm/nexus.c
+++ b/sys/arm/arm/nexus.c
@@ -45,20 +45,20 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
+#include <sys/interrupt.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>
-#include <machine/bus.h>
#include <sys/rman.h>
-#include <sys/interrupt.h>
-#include <machine/vmparam.h>
-#include <machine/pcb.h>
#include <vm/vm.h>
#include <vm/pmap.h>
-#include <machine/resource.h>
+#include <machine/bus.h>
+#include <machine/pcb.h>
#include <machine/intr.h>
+#include <machine/resource.h>
+#include <machine/vmparam.h>
#include <arm/arm/nexusvar.h>
@@ -79,37 +79,31 @@
static struct rman mem_rman;
static struct rman irq_rman;
-static int nexus_probe(device_t);
-static int nexus_attach(device_t);
-static int nexus_print_child(device_t, device_t);
-static device_t nexus_add_child(device_t, u_int, const char *, int);
-static struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
- rman_res_t, rman_res_t, rman_res_t, u_int);
-static int nexus_activate_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_adjust_resource(device_t, device_t, int, struct resource *,
- rman_res_t, rman_res_t);
-static bus_space_tag_t nexus_get_bus_tag(device_t, device_t);
-static bus_dma_tag_t nexus_get_dma_tag(device_t dev, device_t child);
+static device_probe_t nexus_probe;
+static device_attach_t nexus_attach;
+
+static bus_add_child_t nexus_add_child;
+static bus_print_child_t nexus_print_child;
+
+static bus_activate_resource_t nexus_activate_resource;
+static bus_adjust_resource_t nexus_adjust_resource;
+static bus_alloc_resource_t nexus_alloc_resource;
+static bus_deactivate_resource_t nexus_deactivate_resource;
+static bus_release_resource_t nexus_release_resource;
+
#ifdef SMP
-static int nexus_bind_intr(device_t, device_t, struct resource *, int);
+static bus_bind_intr_t nexus_bind_intr;
#endif
-static int nexus_config_intr(device_t dev, int irq, enum intr_trigger trig,
- enum intr_polarity pol);
-static int nexus_describe_intr(device_t dev, device_t child,
- struct resource *irq, void *cookie, const char *descr);
-static int nexus_deactivate_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_release_resource(device_t, device_t, int, int,
- struct resource *);
-
-static int nexus_setup_intr(device_t dev, device_t child, struct resource *res,
- int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep);
-static int nexus_teardown_intr(device_t, device_t, struct resource *, void *);
+static bus_config_intr_t nexus_config_intr;
+static bus_describe_intr_t nexus_describe_intr;
+static bus_setup_intr_t nexus_setup_intr;
+static bus_teardown_intr_t nexus_teardown_intr;
+
+static bus_get_bus_tag_t nexus_get_bus_tag;
+static bus_get_dma_tag_t nexus_get_dma_tag;
#ifdef FDT
-static int nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent,
- int icells, pcell_t *intr);
+static ofw_bus_map_intr_t nexus_ofw_map_intr;
#endif
/*
@@ -123,35 +117,32 @@
/* Device interface */
DEVMETHOD(device_probe, nexus_probe),
DEVMETHOD(device_attach, nexus_attach),
+
/* Bus interface */
- DEVMETHOD(bus_print_child, nexus_print_child),
DEVMETHOD(bus_add_child, nexus_add_child),
- DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
- DEVMETHOD(bus_activate_resource, nexus_activate_resource),
+ DEVMETHOD(bus_print_child, nexus_print_child),
+ DEVMETHOD(bus_activate_resource, nexus_activate_resource),
DEVMETHOD(bus_adjust_resource, nexus_adjust_resource),
- DEVMETHOD(bus_config_intr, nexus_config_intr),
- DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
+ DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
+ DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
DEVMETHOD(bus_release_resource, nexus_release_resource),
+#ifdef SMP
+ DEVMETHOD(bus_bind_intr, nexus_bind_intr),
+#endif
+ DEVMETHOD(bus_config_intr, nexus_config_intr),
+ DEVMETHOD(bus_describe_intr, nexus_describe_intr),
DEVMETHOD(bus_setup_intr, nexus_setup_intr),
DEVMETHOD(bus_teardown_intr, nexus_teardown_intr),
DEVMETHOD(bus_get_bus_tag, nexus_get_bus_tag),
DEVMETHOD(bus_get_dma_tag, nexus_get_dma_tag),
- DEVMETHOD(bus_describe_intr, nexus_describe_intr),
-#ifdef SMP
- DEVMETHOD(bus_bind_intr, nexus_bind_intr),
-#endif
#ifdef FDT
+ /* ofw_bus interface */
DEVMETHOD(ofw_bus_map_intr, nexus_ofw_map_intr),
#endif
- { 0, 0 }
-};
-
-static driver_t nexus_driver = {
- "nexus",
- nexus_methods,
- 1 /* no softc */
+ DEVMETHOD_END
};
+DEFINE_CLASS_0(nexus, nexus_driver, nexus_methods, 1 /* no softc */);
EARLY_DRIVER_MODULE(nexus, root, nexus_driver, 0, 0,
BUS_PASS_BUS + BUS_PASS_ORDER_EARLY);
@@ -218,7 +209,6 @@
child = device_add_child_ordered(bus, order, name, unit);
- /* should we free this in nexus_child_detached? */
device_set_ivars(child, ndev);
return (child);
@@ -227,7 +217,6 @@
/*
* Allocate a resource on behalf of child. NB: child is usually going to be a
* child of one of our descendants, not a direct child of nexus0.
- * (Exceptions include footbridge.)
*/
static struct resource *
nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
@@ -309,9 +298,9 @@
{
#ifdef FDT
- return(fdtbus_bs_tag);
+ return (fdtbus_bs_tag);
#else
- return((void *)1);
+ return ((void *)1);
#endif
}
@@ -319,7 +308,7 @@
nexus_get_dma_tag(device_t dev, device_t child)
{
- return nexus_dma_tag;
+ return (nexus_dma_tag);
}
void
@@ -348,7 +337,7 @@
if ((rman_get_flags(res) & RF_SHAREABLE) == 0)
flags |= INTR_EXCL;
- return(intr_setup_irq(child, res, filt, intr, arg, flags, cookiep));
+ return (intr_setup_irq(child, res, filt, intr, arg, flags, cookiep));
}
static int
diff --git a/sys/arm64/arm64/nexus.c b/sys/arm64/arm64/nexus.c
--- a/sys/arm64/arm64/nexus.c
+++ b/sys/arm64/arm64/nexus.c
@@ -46,21 +46,21 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
+#include <sys/interrupt.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>
-#include <machine/bus.h>
#include <sys/rman.h>
-#include <sys/interrupt.h>
-#include <machine/machdep.h>
-#include <machine/vmparam.h>
-#include <machine/pcb.h>
#include <vm/vm.h>
#include <vm/pmap.h>
-#include <machine/resource.h>
+#include <machine/bus.h>
#include <machine/intr.h>
+#include <machine/machdep.h>
+#include <machine/pcb.h>
+#include <machine/resource.h>
+#include <machine/vmparam.h>
#ifdef FDT
#include <dev/ofw/ofw_bus_subr.h>
@@ -71,7 +71,6 @@
#include <contrib/dev/acpica/include/acpi.h>
#include <dev/acpica/acpivar.h>
#include "acpi_bus_if.h"
-#include "pcib_if.h"
#endif
extern struct bus_space memmap_bus;
@@ -90,67 +89,61 @@
static int nexus_attach(device_t);
#ifdef FDT
-static device_probe_t nexus_fdt_probe;
-static device_attach_t nexus_fdt_attach;
+static device_probe_t nexus_fdt_probe;
+static device_attach_t nexus_fdt_attach;
#endif
#ifdef DEV_ACPI
-static device_probe_t nexus_acpi_probe;
-static device_attach_t nexus_acpi_attach;
+static device_probe_t nexus_acpi_probe;
+static device_attach_t nexus_acpi_attach;
#endif
-static int nexus_print_child(device_t, device_t);
-static device_t nexus_add_child(device_t, u_int, const char *, int);
-static struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
- rman_res_t, rman_res_t, rman_res_t, u_int);
-static int nexus_activate_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_adjust_resource(device_t, device_t, int, struct resource *,
- rman_res_t, rman_res_t);
-static int nexus_map_resource(device_t, device_t, int, struct resource *,
- struct resource_map_request *, struct resource_map *);
-static int nexus_config_intr(device_t dev, int irq, enum intr_trigger trig,
- enum intr_polarity pol);
-static struct resource_list *nexus_get_reslist(device_t, device_t);
-static int nexus_set_resource(device_t, device_t, int, int,
- rman_res_t, rman_res_t);
-static int nexus_deactivate_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_release_resource(device_t, device_t, int, int,
- struct resource *);
-
-static int nexus_setup_intr(device_t dev, device_t child, struct resource *res,
- int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep);
-static int nexus_teardown_intr(device_t, device_t, struct resource *, void *);
-static bus_space_tag_t nexus_get_bus_tag(device_t, device_t);
+static bus_add_child_t nexus_add_child;
+static bus_print_child_t nexus_print_child;
+
+static bus_activate_resource_t nexus_activate_resource;
+static bus_adjust_resource_t nexus_adjust_resource;
+static bus_alloc_resource_t nexus_alloc_resource;
+static bus_deactivate_resource_t nexus_deactivate_resource;
+static bus_get_resource_list_t nexus_get_reslist;
+static bus_map_resource_t nexus_map_resource;
+static bus_release_resource_t nexus_release_resource;
+static bus_set_resource_t nexus_set_resource;
+
#ifdef SMP
-static int nexus_bind_intr(device_t, device_t, struct resource *, int);
+static bus_bind_intr_t nexus_bind_intr;
#endif
+static bus_config_intr_t nexus_config_intr;
+static bus_describe_intr_t nexus_describe_intr;
+static bus_setup_intr_t nexus_setup_intr;
+static bus_teardown_intr_t nexus_teardown_intr;
+
+static bus_get_bus_tag_t nexus_get_bus_tag;
#ifdef FDT
-static int nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent,
- int icells, pcell_t *intr);
+static ofw_bus_map_intr_t nexus_ofw_map_intr;
#endif
static device_method_t nexus_methods[] = {
/* Bus interface */
- DEVMETHOD(bus_print_child, nexus_print_child),
DEVMETHOD(bus_add_child, nexus_add_child),
- DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
- DEVMETHOD(bus_activate_resource, nexus_activate_resource),
+ DEVMETHOD(bus_print_child, nexus_print_child),
+ DEVMETHOD(bus_activate_resource, nexus_activate_resource),
DEVMETHOD(bus_adjust_resource, nexus_adjust_resource),
- DEVMETHOD(bus_map_resource, nexus_map_resource),
- DEVMETHOD(bus_config_intr, nexus_config_intr),
+ DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
+ DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
DEVMETHOD(bus_get_resource_list, nexus_get_reslist),
- DEVMETHOD(bus_set_resource, nexus_set_resource),
- DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
+ DEVMETHOD(bus_map_resource, nexus_map_resource),
DEVMETHOD(bus_release_resource, nexus_release_resource),
- DEVMETHOD(bus_setup_intr, nexus_setup_intr),
- DEVMETHOD(bus_teardown_intr, nexus_teardown_intr),
- DEVMETHOD(bus_get_bus_tag, nexus_get_bus_tag),
+ DEVMETHOD(bus_set_resource, nexus_set_resource),
#ifdef SMP
DEVMETHOD(bus_bind_intr, nexus_bind_intr),
#endif
- { 0, 0 }
+ DEVMETHOD(bus_config_intr, nexus_config_intr),
+ DEVMETHOD(bus_setup_intr, nexus_setup_intr),
+ DEVMETHOD(bus_teardown_intr, nexus_teardown_intr),
+ DEVMETHOD(bus_get_bus_tag, nexus_get_bus_tag),
+
+ DEVMETHOD_END
};
static driver_t nexus_driver = {
@@ -216,7 +209,6 @@
/*
* Allocate a resource on behalf of child. NB: child is usually going to be a
* child of one of our descendants, not a direct child of nexus0.
- * (Exceptions include footbridge.)
*/
static struct resource *
nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
@@ -236,10 +228,10 @@
*/
if (RMAN_IS_DEFAULT_RANGE(start, end) && (count == 1)) {
if (device_get_parent(child) != bus || ndev == NULL)
- return(NULL);
+ return (NULL);
rle = resource_list_find(&ndev->nx_resources, type, *rid);
if (rle == NULL)
- return(NULL);
+ return (NULL);
start = rle->start;
end = rle->end;
count = rle->count;
@@ -362,7 +354,7 @@
nexus_get_bus_tag(device_t bus __unused, device_t child __unused)
{
- return(&memmap_bus);
+ return (&memmap_bus);
}
static int
@@ -420,7 +412,7 @@
/* XXX this should return a success/failure indicator */
resource_list_add(rl, type, rid, start, start + count - 1, count);
- return(0);
+ return (0);
}
static int
diff --git a/sys/powerpc/powerpc/nexus.c b/sys/powerpc/powerpc/nexus.c
--- a/sys/powerpc/powerpc/nexus.c
+++ b/sys/powerpc/powerpc/nexus.c
@@ -32,62 +32,62 @@
* from: FreeBSD: src/sys/i386/i386/nexus.c,v 1.43 2001/02/09
*/
+/*
+ * This code implements a `root nexus' for Power ISA Architecture
+ * machines. The function of the root nexus is to serve as an
+ * attachment point for both processors and buses, and to manage
+ * resources which are common to all of them. In particular,
+ * this code implements the core resource managers for interrupt
+ * requests and I/O memory address space.
+ */
+
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/endian.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
-#include <sys/kdb.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>
-#include <sys/pcpu.h>
#include <sys/rman.h>
-#include <sys/smp.h>
#include <vm/vm.h>
#include <vm/pmap.h>
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-#include <dev/ofw/openfirm.h>
-
#include <machine/bus.h>
+#include <machine/endian.h>
#include <machine/intr_machdep.h>
#include <machine/resource.h>
-/*
- * The nexus handles root-level resource allocation requests and interrupt
- * mapping. All direct subdevices of nexus are attached by DEVICE_IDENTIFY().
- */
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+#include <dev/ofw/openfirm.h>
static struct rman intr_rman;
static struct rman mem_rman;
-static device_probe_t nexus_probe;
-static device_attach_t nexus_attach;
-static bus_setup_intr_t nexus_setup_intr;
-static bus_teardown_intr_t nexus_teardown_intr;
-static bus_alloc_resource_t nexus_alloc_resource;
-static bus_activate_resource_t nexus_activate_resource;
+static device_probe_t nexus_probe;
+static device_attach_t nexus_attach;
+
+static bus_activate_resource_t nexus_activate_resource;
+static bus_adjust_resource_t nexus_adjust_resource;
+static bus_alloc_resource_t nexus_alloc_resource;
static bus_deactivate_resource_t nexus_deactivate_resource;
-static bus_adjust_resource_t nexus_adjust_resource;
-static bus_release_resource_t nexus_release_resource;
-static int nexus_map_resource(device_t bus, device_t child, int type,
- struct resource *r,
- struct resource_map_request *argsp,
- struct resource_map *map);
-static int nexus_unmap_resource(device_t bus, device_t child, int type,
- struct resource *r, struct resource_map *map);
-
-static bus_space_tag_t nexus_get_bus_tag(device_t, device_t);
+static bus_map_resource_t nexus_map_resource;
+static bus_release_resource_t nexus_release_resource;
+static bus_unmap_resource_t nexus_unmap_resource;
+
#ifdef SMP
-static bus_bind_intr_t nexus_bind_intr;
+static bus_bind_intr_t nexus_bind_intr;
#endif
-static bus_config_intr_t nexus_config_intr;
-static ofw_bus_map_intr_t nexus_ofw_map_intr;
+static bus_config_intr_t nexus_config_intr;
+static bus_setup_intr_t nexus_setup_intr;
+static bus_teardown_intr_t nexus_teardown_intr;
+
+static bus_get_bus_tag_t nexus_get_bus_tag;
+
+static ofw_bus_map_intr_t nexus_ofw_map_intr;
static device_method_t nexus_methods[] = {
/* Device interface */
@@ -96,19 +96,19 @@
/* Bus interface */
DEVMETHOD(bus_add_child, bus_generic_add_child),
- DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
- DEVMETHOD(bus_activate_resource, nexus_activate_resource),
- DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
DEVMETHOD(bus_adjust_resource, nexus_adjust_resource),
- DEVMETHOD(bus_release_resource, nexus_release_resource),
+ DEVMETHOD(bus_activate_resource, nexus_activate_resource),
+ DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
+ DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
DEVMETHOD(bus_map_resource, nexus_map_resource),
+ DEVMETHOD(bus_release_resource, nexus_release_resource),
DEVMETHOD(bus_unmap_resource, nexus_unmap_resource),
- DEVMETHOD(bus_setup_intr, nexus_setup_intr),
- DEVMETHOD(bus_teardown_intr, nexus_teardown_intr),
#ifdef SMP
DEVMETHOD(bus_bind_intr, nexus_bind_intr),
#endif
DEVMETHOD(bus_config_intr, nexus_config_intr),
+ DEVMETHOD(bus_setup_intr, nexus_setup_intr),
+ DEVMETHOD(bus_teardown_intr, nexus_teardown_intr),
DEVMETHOD(bus_get_bus_tag, nexus_get_bus_tag),
/* ofw_bus interface */
@@ -222,7 +222,7 @@
{
return (powerpc_config_intr(irq, trig, pol));
-}
+}
static int
nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent, int icells,
diff --git a/sys/riscv/riscv/nexus.c b/sys/riscv/riscv/nexus.c
--- a/sys/riscv/riscv/nexus.c
+++ b/sys/riscv/riscv/nexus.c
@@ -76,36 +76,28 @@
static struct rman mem_rman;
static struct rman irq_rman;
-static device_probe_t nexus_fdt_probe;
-static int nexus_attach(device_t);
-
-static int nexus_print_child(device_t, device_t);
-static device_t nexus_add_child(device_t, u_int, const char *, int);
-static struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
- rman_res_t, rman_res_t, rman_res_t, u_int);
-static int nexus_activate_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_adjust_resource(device_t, device_t, int, struct resource *,
- rman_res_t, rman_res_t);
-static int nexus_map_resource(device_t, device_t, int, struct resource *,
- struct resource_map_request *, struct resource_map *);
-static int nexus_config_intr(device_t dev, int irq, enum intr_trigger trig,
- enum intr_polarity pol);
-static struct resource_list *nexus_get_reslist(device_t, device_t);
-static int nexus_set_resource(device_t, device_t, int, int,
- rman_res_t, rman_res_t);
-static int nexus_deactivate_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_release_resource(device_t, device_t, int, int,
- struct resource *);
-
-static int nexus_setup_intr(device_t dev, device_t child, struct resource *res,
- int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep);
-static int nexus_teardown_intr(device_t, device_t, struct resource *, void *);
-static bus_space_tag_t nexus_get_bus_tag(device_t, device_t);
-
-static int nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent,
- int icells, pcell_t *intr);
+static device_probe_t nexus_fdt_probe;
+static device_attach_t nexus_attach;
+
+static bus_add_child_t nexus_add_child;
+static bus_print_child_t nexus_print_child;
+
+static bus_activate_resource_t nexus_activate_resource;
+static bus_adjust_resource_t nexus_adjust_resource;
+static bus_alloc_resource_t nexus_alloc_resource;
+static bus_deactivate_resource_t nexus_deactivate_resource;
+static bus_get_resource_list_t nexus_get_reslist;
+static bus_map_resource_t nexus_map_resource;
+static bus_set_resource_t nexus_set_resource;
+static bus_release_resource_t nexus_release_resource;
+
+static bus_config_intr_t nexus_config_intr;
+static bus_setup_intr_t nexus_setup_intr;
+static bus_teardown_intr_t nexus_teardown_intr;
+
+static bus_get_bus_tag_t nexus_get_bus_tag;
+
+static ofw_bus_map_intr_t nexus_ofw_map_intr;
static device_method_t nexus_methods[] = {
/* Device interface */
@@ -116,29 +108,28 @@
DEVMETHOD(ofw_bus_map_intr, nexus_ofw_map_intr),
/* Bus interface */
- DEVMETHOD(bus_print_child, nexus_print_child),
DEVMETHOD(bus_add_child, nexus_add_child),
- DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
- DEVMETHOD(bus_activate_resource, nexus_activate_resource),
+ DEVMETHOD(bus_print_child, nexus_print_child),
+ DEVMETHOD(bus_activate_resource, nexus_activate_resource),
DEVMETHOD(bus_adjust_resource, nexus_adjust_resource),
- DEVMETHOD(bus_map_resource, nexus_map_resource),
- DEVMETHOD(bus_config_intr, nexus_config_intr),
+ DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
+ DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
DEVMETHOD(bus_get_resource_list, nexus_get_reslist),
+ DEVMETHOD(bus_map_resource, nexus_map_resource),
DEVMETHOD(bus_set_resource, nexus_set_resource),
- DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
DEVMETHOD(bus_release_resource, nexus_release_resource),
+ DEVMETHOD(bus_config_intr, nexus_config_intr),
DEVMETHOD(bus_setup_intr, nexus_setup_intr),
DEVMETHOD(bus_teardown_intr, nexus_teardown_intr),
DEVMETHOD(bus_get_bus_tag, nexus_get_bus_tag),
- { 0, 0 }
-};
-static driver_t nexus_fdt_driver = {
- "nexus",
- nexus_methods,
- 1 /* no softc */
+ DEVMETHOD_END
};
+DEFINE_CLASS_0(nexus, nexus_fdt_driver, nexus_methods, 1 /* no softc */);
+EARLY_DRIVER_MODULE(nexus_fdt, root, nexus_fdt_driver, 0, 0,
+ BUS_PASS_BUS + BUS_PASS_ORDER_FIRST);
+
static int
nexus_fdt_probe(device_t dev)
{
@@ -203,7 +194,6 @@
child = device_add_child_ordered(bus, order, name, unit);
- /* should we free this in nexus_child_detached? */
device_set_ivars(child, ndev);
return (child);
@@ -212,7 +202,6 @@
/*
* Allocate a resource on behalf of child. NB: child is usually going to be a
* child of one of our descendants, not a direct child of nexus0.
- * (Exceptions include footbridge.)
*/
static struct resource *
nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
@@ -232,10 +221,10 @@
*/
if (RMAN_IS_DEFAULT_RANGE(start, end) && (count == 1)) {
if (device_get_parent(child) != bus || ndev == NULL)
- return(NULL);
+ return (NULL);
rle = resource_list_find(&ndev->nx_resources, type, *rid);
if (rle == NULL)
- return(NULL);
+ return (NULL);
start = rle->start;
end = rle->end;
count = rle->count;
@@ -301,7 +290,7 @@
if (rman_get_flags(res) & RF_ACTIVE) {
error = bus_deactivate_resource(child, type, rid, res);
- if (error)
+ if (error != 0)
return (error);
}
return (rman_release_resource(res));
@@ -326,7 +315,7 @@
/* We depend here on rman_activate_resource() being idempotent. */
error = rman_activate_resource(res);
- if (error)
+ if (error != 0)
return (error);
error = intr_setup_irq(child, res, filt, intr, arg, flags, cookiep);
@@ -403,7 +392,7 @@
/* XXX this should return a success/failure indicator */
resource_list_add(rl, type, rid, start, start + count - 1, count);
- return(0);
+ return (0);
}
static int
@@ -474,9 +463,6 @@
return (0);
}
-EARLY_DRIVER_MODULE(nexus_fdt, root, nexus_fdt_driver, 0, 0,
- BUS_PASS_BUS + BUS_PASS_ORDER_FIRST);
-
static int
nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent, int icells,
pcell_t *intr)
diff --git a/sys/x86/x86/nexus.c b/sys/x86/x86/nexus.c
--- a/sys/x86/x86/nexus.c
+++ b/sys/x86/x86/nexus.c
@@ -52,16 +52,13 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
+#include <sys/interrupt.h>
#include <sys/kernel.h>
#include <sys/linker.h>
#include <sys/malloc.h>
#include <sys/module.h>
-#include <machine/bus.h>
-#include <machine/intr_machdep.h>
#include <sys/rman.h>
-#include <sys/interrupt.h>
-#include <machine/md_var.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
@@ -69,10 +66,13 @@
#include <vm/vm_dumpset.h>
#include <vm/pmap.h>
+#include <machine/bus.h>
+#include <machine/intr_machdep.h>
+#include <machine/md_var.h>
#include <machine/metadata.h>
#include <machine/nexusvar.h>
-#include <machine/resource.h>
#include <machine/pc/bios.h>
+#include <machine/resource.h>
#ifdef DEV_APIC
#include "pcib_if.h"
@@ -82,7 +82,6 @@
#include <isa/isavar.h>
#include <isa/isareg.h>
#endif
-#include <sys/rtprio.h>
#define ELF_KERN_STR ("elf"__XSTRING(__ELF_WORD_SIZE)" kernel")
@@ -92,56 +91,42 @@
struct rman irq_rman, drq_rman, port_rman, mem_rman;
-static int nexus_probe(device_t);
-static int nexus_attach(device_t);
-static int nexus_print_all_resources(device_t dev);
-static int nexus_print_child(device_t, device_t);
-static device_t nexus_add_child(device_t bus, u_int order, const char *name,
- int unit);
-static struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
- rman_res_t, rman_res_t, rman_res_t,
- u_int);
-static int nexus_adjust_resource(device_t, device_t, int, struct resource *,
- rman_res_t, rman_res_t);
+static int nexus_print_all_resources(device_t dev);
+
+static device_probe_t nexus_probe;
+static device_attach_t nexus_attach;
+
+static bus_add_child_t nexus_add_child;
+static bus_print_child_t nexus_print_child;
+
+static bus_activate_resource_t nexus_activate_resource;
+static bus_adjust_resource_t nexus_adjust_resource;
+static bus_alloc_resource_t nexus_alloc_resource;
+static bus_deactivate_resource_t nexus_deactivate_resource;
+static bus_delete_resource_t nexus_delete_resource;
+static bus_get_resource_t nexus_get_resource;
+static bus_get_resource_list_t nexus_get_reslist;
+static bus_map_resource_t nexus_map_resource;
+static bus_release_resource_t nexus_release_resource;
+static bus_set_resource_t nexus_set_resource;
+static bus_unmap_resource_t nexus_unmap_resource;
+
#ifdef SMP
-static int nexus_bind_intr(device_t, device_t, struct resource *, int);
+static bus_bind_intr_t nexus_bind_intr;
#endif
-static int nexus_config_intr(device_t, int, enum intr_trigger,
- enum intr_polarity);
-static int nexus_describe_intr(device_t dev, device_t child,
- struct resource *irq, void *cookie,
- const char *descr);
-static int nexus_activate_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_deactivate_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_map_resource(device_t bus, device_t child, int type,
- struct resource *r,
- struct resource_map_request *argsp,
- struct resource_map *map);
-static int nexus_unmap_resource(device_t bus, device_t child, int type,
- struct resource *r, struct resource_map *map);
-static int nexus_release_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_setup_intr(device_t, device_t, struct resource *, int flags,
- driver_filter_t filter, void (*)(void *), void *,
- void **);
-static int nexus_teardown_intr(device_t, device_t, struct resource *,
- void *);
-static int nexus_suspend_intr(device_t, device_t, struct resource *);
-static int nexus_resume_intr(device_t, device_t, struct resource *);
-static struct resource_list *nexus_get_reslist(device_t dev, device_t child);
-static int nexus_set_resource(device_t, device_t, int, int,
- rman_res_t, rman_res_t);
-static int nexus_get_resource(device_t, device_t, int, int,
- rman_res_t *, rman_res_t *);
-static void nexus_delete_resource(device_t, device_t, int, int);
+static bus_config_intr_t nexus_config_intr;
+static bus_describe_intr_t nexus_describe_intr;
+static bus_resume_intr_t nexus_resume_intr;
+static bus_setup_intr_t nexus_setup_intr;
+static bus_suspend_intr_t nexus_suspend_intr;
+static bus_teardown_intr_t nexus_teardown_intr;
+
#if defined(DEV_APIC) && defined(DEV_PCI)
-static int nexus_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, int *irqs);
-static int nexus_release_msi(device_t pcib, device_t dev, int count, int *irqs);
-static int nexus_alloc_msix(device_t pcib, device_t dev, int *irq);
-static int nexus_release_msix(device_t pcib, device_t dev, int irq);
-static int nexus_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, uint32_t *data);
+static pcib_alloc_msi_t nexus_alloc_msi;
+static pcib_release_msi_t nexus_release_msi;
+static pcib_alloc_msix_t nexus_alloc_msix;
+static pcib_release_msix_t nexus_release_msix;
+static pcib_map_msi_t nexus_map_msi;
#endif
static device_method_t nexus_methods[] = {
@@ -156,26 +141,26 @@
/* Bus interface */
DEVMETHOD(bus_print_child, nexus_print_child),
DEVMETHOD(bus_add_child, nexus_add_child),
- DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
- DEVMETHOD(bus_adjust_resource, nexus_adjust_resource),
- DEVMETHOD(bus_release_resource, nexus_release_resource),
DEVMETHOD(bus_activate_resource, nexus_activate_resource),
+ DEVMETHOD(bus_adjust_resource, nexus_adjust_resource),
+ DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
+ DEVMETHOD(bus_get_resource, nexus_get_resource),
+ DEVMETHOD(bus_get_resource_list, nexus_get_reslist),
+ DEVMETHOD(bus_delete_resource, nexus_delete_resource),
DEVMETHOD(bus_map_resource, nexus_map_resource),
+ DEVMETHOD(bus_release_resource, nexus_release_resource),
+ DEVMETHOD(bus_set_resource, nexus_set_resource),
DEVMETHOD(bus_unmap_resource, nexus_unmap_resource),
- DEVMETHOD(bus_setup_intr, nexus_setup_intr),
- DEVMETHOD(bus_teardown_intr, nexus_teardown_intr),
- DEVMETHOD(bus_suspend_intr, nexus_suspend_intr),
- DEVMETHOD(bus_resume_intr, nexus_resume_intr),
#ifdef SMP
DEVMETHOD(bus_bind_intr, nexus_bind_intr),
#endif
DEVMETHOD(bus_config_intr, nexus_config_intr),
DEVMETHOD(bus_describe_intr, nexus_describe_intr),
- DEVMETHOD(bus_get_resource_list, nexus_get_reslist),
- DEVMETHOD(bus_set_resource, nexus_set_resource),
- DEVMETHOD(bus_get_resource, nexus_get_resource),
- DEVMETHOD(bus_delete_resource, nexus_delete_resource),
+ DEVMETHOD(bus_resume_intr, nexus_resume_intr),
+ DEVMETHOD(bus_setup_intr, nexus_setup_intr),
+ DEVMETHOD(bus_suspend_intr, nexus_suspend_intr),
+ DEVMETHOD(bus_teardown_intr, nexus_teardown_intr),
/* pcib interface */
#if defined(DEV_APIC) && defined(DEV_PCI)
@@ -185,7 +170,7 @@
DEVMETHOD(pcib_release_msix, nexus_release_msix),
DEVMETHOD(pcib_map_msi, nexus_map_msi),
#endif
- { 0, 0 }
+ DEVMETHOD_END
};
DEFINE_CLASS_0(nexus, nexus_driver, nexus_methods, 1);
@@ -291,7 +276,7 @@
if (BUS_ADD_CHILD(dev, 10, "legacy", 0) == NULL)
panic("legacy: could not attach");
bus_generic_attach(dev);
- return 0;
+ return (0);
}
static int
@@ -308,7 +293,7 @@
retval += resource_list_print_type(rl, "iomem", SYS_RES_MEMORY, "%#jx");
retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%jd");
- return retval;
+ return (retval);
}
static int
@@ -333,7 +318,7 @@
ndev = malloc(sizeof(struct nexus_device), M_NEXUSDEV, M_NOWAIT|M_ZERO);
if (!ndev)
- return(0);
+ return (0);
resource_list_init(&ndev->nx_resources);
child = device_add_child_ordered(bus, order, name, unit);
@@ -341,7 +326,7 @@
/* should we free this in nexus_child_detached? */
device_set_ivars(child, ndev);
- return(child);
+ return (child);
}
static struct rman *
@@ -364,7 +349,6 @@
/*
* Allocate a resource on behalf of child. NB: child is usually going to be a
* child of one of our descendants, not a direct child of nexus0.
- * (Exceptions include npx.)
*/
static struct resource *
nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
@@ -385,10 +369,10 @@
*/
if (RMAN_IS_DEFAULT_RANGE(start, end) && (count == 1)) {
if (device_get_parent(child) != bus || ndev == NULL)
- return(NULL);
+ return (NULL);
rle = resource_list_find(&ndev->nx_resources, type, *rid);
if (rle == NULL)
- return(NULL);
+ return (NULL);
start = rle->start;
end = rle->end;
count = rle->count;
@@ -401,17 +385,17 @@
rv = rman_reserve_resource(rm, start, end, count, flags, child);
if (rv == NULL)
- return 0;
+ return (0);
rman_set_rid(rv, *rid);
if (needactivate) {
if (bus_activate_resource(child, type, *rid, rv)) {
rman_release_resource(rv);
- return 0;
+ return (0);
}
}
- return rv;
+ return (rv);
}
static int
@@ -553,11 +537,12 @@
nexus_release_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
+ int error;
if (rman_get_flags(r) & RF_ACTIVE) {
- int error = bus_deactivate_resource(child, type, rid, r);
- if (error)
- return error;
+ error = bus_deactivate_resource(child, type, rid, r);
+ if (error != 0)
+ return (error);
}
return (rman_release_resource(r));
}
@@ -587,7 +572,7 @@
* We depend here on rman_activate_resource() being idempotent.
*/
error = rman_activate_resource(irq);
- if (error)
+ if (error != 0)
return (error);
if (bus_get_domain(child, &domain) != 0)
domain = 0;
@@ -663,7 +648,7 @@
/* XXX this should return a success/failure indicator */
resource_list_add(rl, type, rid, start, start + count - 1, count);
- return(0);
+ return (0);
}
static int
@@ -676,12 +661,12 @@
rle = resource_list_find(rl, type, rid);
if (!rle)
- return(ENOENT);
+ return (ENOENT);
if (startp)
*startp = rle->start;
if (countp)
*countp = rle->count;
- return(0);
+ return (0);
}
static void
@@ -773,7 +758,7 @@
/* Retrieve the system memory map from the loader. */
kmdp = preload_search_by_type("elf kernel");
if (kmdp == NULL)
- kmdp = preload_search_by_type(ELF_KERN_STR);
+ kmdp = preload_search_by_type(ELF_KERN_STR);
smapbase = (struct bios_smap *)preload_search_info(kmdp,
MODINFO_METADATA | MODINFOMD_SMAP);
if (smapbase != NULL) {
@@ -836,15 +821,11 @@
DEVMETHOD(device_identify, ram_identify),
DEVMETHOD(device_probe, ram_probe),
DEVMETHOD(device_attach, ram_attach),
- { 0, 0 }
-};
-static driver_t ram_driver = {
- "ram",
- ram_methods,
- 1, /* no softc */
+ DEVMETHOD_END
};
+DEFINE_CLASS_0(ram, ram_driver, ram_methods, 1 /* no softc */);
DRIVER_MODULE(ram, nexus, ram_driver, 0, 0);
#ifdef DEV_ISA
@@ -866,13 +847,13 @@
if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, sysresource_ids)) <= 0) {
device_quiet(dev);
}
- return(result);
+ return (result);
}
static int
sysresource_attach(device_t dev)
{
- return(0);
+ return (0);
}
static device_method_t sysresource_methods[] = {
@@ -883,15 +864,12 @@
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
- { 0, 0 }
-};
-static driver_t sysresource_driver = {
- "sysresource",
- sysresource_methods,
- 1, /* no softc */
+ DEVMETHOD_END
};
+DEFINE_CLASS_0(sysresource, sysresource_driver, sysresource_methods,
+ 1 /* no softc */);
DRIVER_MODULE(sysresource, isa, sysresource_driver, 0, 0);
ISA_PNP_INFO(sysresource_ids);
#endif /* DEV_ISA */

File Metadata

Mime Type
text/plain
Expires
Mon, May 25, 11:24 PM (17 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33518886
Default Alt Text
D38495.id116952.diff (33 KB)

Event Timeline