- Add the 'cmp' and 'core' pseudo-busses which are used to group CPU cores

to the exclusion lists as the CPU nodes aren't handled as regular devices
  either. Also add the pseudo-devices found in Sun Fire V1280.
- Allow nexus_attach() and nexus_alloc_resource() to be used by drivers
  derived from nexus(4) for subordinate busses.
- Don't add the zero-sized memory resources of glue devices to the resource
  lists.
This commit is contained in:
Marius Strobl 2010-02-13 18:51:49 +00:00
parent ac144cadbc
commit 527eebfeeb
2 changed files with 46 additions and 54 deletions

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2001 by Thomas Moestl <tmm@FreeBSD.org>. * Copyright (c) 2010 Marius Strobl <marius@FreeBSD.org>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -11,48 +11,24 @@
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* *
* $FreeBSD$ * $FreeBSD$
*/ */
#ifndef _MACHINE_NEXUSVAR_H_ #ifndef _MACHINE_NEXUSVAR_H_
#define _MACHINE_NEXUSVAR_H_ #define _MACHINE_NEXUSVAR_H_
enum nexus_ivars { DECLARE_CLASS(nexus_driver);
NEXUS_IVAR_NODE,
NEXUS_IVAR_NAME,
NEXUS_IVAR_DEVICE_TYPE,
NEXUS_IVAR_MODEL,
NEXUS_IVAR_REG,
NEXUS_IVAR_NREG,
NEXUS_IVAR_INTERRUPTS,
NEXUS_IVAR_NINTERRUPTS,
NEXUS_IVAR_DMATAG,
};
#define NEXUS_ACCESSOR(var, ivar, type) \
__BUS_ACCESSOR(nexus, var, NEXUS, ivar, type)
NEXUS_ACCESSOR(node, NODE, phandle_t)
NEXUS_ACCESSOR(name, NAME, char *)
NEXUS_ACCESSOR(device_type, DEVICE_TYPE, char *)
NEXUS_ACCESSOR(model, MODEL, char *)
NEXUS_ACCESSOR(reg, REG, struct upa_regs *)
NEXUS_ACCESSOR(nreg, NREG, int)
NEXUS_ACCESSOR(interrupts, INTERRUPTS, u_int *)
NEXUS_ACCESSOR(ninterrupts, NINTERRUPTS, int)
NEXUS_ACCESSOR(dmatag, DMATAG, bus_dma_tag_t)
#undef NEXUS_ACCESSOR
#endif /* _MACHINE_NEXUSVAR_H_ */ #endif /* _MACHINE_NEXUSVAR_H_ */

View File

@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h> #include <machine/bus.h>
#include <machine/bus_common.h> #include <machine/bus_common.h>
#include <machine/intr_machdep.h> #include <machine/intr_machdep.h>
#include <machine/nexusvar.h>
#include <machine/ofw_nexus.h> #include <machine/ofw_nexus.h>
#include <machine/resource.h> #include <machine/resource.h>
#include <machine/ver.h> #include <machine/ver.h>
@ -154,17 +155,22 @@ static const char *const nexus_excl_name[] = {
"aliases", "aliases",
"associations", "associations",
"chosen", "chosen",
"cmp",
"counter-timer", /* No separate device; handled by psycho/sbus */ "counter-timer", /* No separate device; handled by psycho/sbus */
"failsafe",
"memory", "memory",
"openprom", "openprom",
"options", "options",
"packages", "packages",
"rsc", "rsc",
"sgcn",
"todsg",
"virtual-memory", "virtual-memory",
NULL NULL
}; };
static const char *const nexus_excl_type[] = { static const char *const nexus_excl_type[] = {
"core",
"cpu", "cpu",
NULL NULL
}; };
@ -206,20 +212,24 @@ nexus_attach(device_t dev)
device_t cdev; device_t cdev;
phandle_t node; phandle_t node;
node = OF_peer(0); if (strcmp(device_get_name(device_get_parent(dev)), "root") == 0) {
if (node == -1) node = OF_peer(0);
panic("%s: OF_peer failed.", __func__); if (node == -1)
panic("%s: OF_peer failed.", __func__);
sc = device_get_softc(dev); sc = device_get_softc(dev);
sc->sc_intr_rman.rm_type = RMAN_ARRAY; sc->sc_intr_rman.rm_type = RMAN_ARRAY;
sc->sc_intr_rman.rm_descr = "Interrupts"; sc->sc_intr_rman.rm_descr = "Interrupts";
sc->sc_mem_rman.rm_type = RMAN_ARRAY; sc->sc_mem_rman.rm_type = RMAN_ARRAY;
sc->sc_mem_rman.rm_descr = "Device Memory"; sc->sc_mem_rman.rm_descr = "Device Memory";
if (rman_init(&sc->sc_intr_rman) != 0 || if (rman_init(&sc->sc_intr_rman) != 0 ||
rman_init(&sc->sc_mem_rman) != 0 || rman_init(&sc->sc_mem_rman) != 0 ||
rman_manage_region(&sc->sc_intr_rman, 0, IV_MAX - 1) != 0 || rman_manage_region(&sc->sc_intr_rman, 0,
rman_manage_region(&sc->sc_mem_rman, 0ULL, ~0ULL) != 0) IV_MAX - 1) != 0 ||
panic("%s: failed to set up rmans.", __func__); rman_manage_region(&sc->sc_mem_rman, 0ULL, ~0ULL) != 0)
panic("%s: failed to set up rmans.", __func__);
} else
node = ofw_bus_get_node(dev);
/* /*
* Allow devices to identify. * Allow devices to identify.
@ -347,12 +357,16 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
struct rman *rm; struct rman *rm;
struct resource *rv; struct resource *rv;
struct resource_list_entry *rle; struct resource_list_entry *rle;
device_t nexus;
int isdefault, needactivate, passthrough; int isdefault, needactivate, passthrough;
isdefault = (start == 0UL && end == ~0UL); isdefault = (start == 0UL && end == ~0UL);
needactivate = flags & RF_ACTIVE; needactivate = flags & RF_ACTIVE;
passthrough = (device_get_parent(child) != bus); passthrough = (device_get_parent(child) != bus);
sc = device_get_softc(bus); nexus = bus;
while (strcmp(device_get_name(device_get_parent(nexus)), "root") != 0)
nexus = device_get_parent(nexus);
sc = device_get_softc(nexus);
rle = NULL; rle = NULL;
if (!passthrough) { if (!passthrough) {
@ -498,8 +512,10 @@ nexus_setup_dinfo(device_t dev, phandle_t node)
for (i = 0; i < nreg; i++) { for (i = 0; i < nreg; i++) {
phys = NEXUS_REG_PHYS(&reg[i]); phys = NEXUS_REG_PHYS(&reg[i]);
size = NEXUS_REG_SIZE(&reg[i]); size = NEXUS_REG_SIZE(&reg[i]);
resource_list_add(&ndi->ndi_rl, SYS_RES_MEMORY, i, phys, /* Skip the dummy reg property of glue devices like ssm(4). */
phys + size - 1, size); if (size != 0)
resource_list_add(&ndi->ndi_rl, SYS_RES_MEMORY, i,
phys, phys + size - 1, size);
} }
free(reg, M_OFWPROP); free(reg, M_OFWPROP);