- 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.
*
* 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
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _MACHINE_NEXUSVAR_H_
#define _MACHINE_NEXUSVAR_H_
#define _MACHINE_NEXUSVAR_H_
enum nexus_ivars {
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
DECLARE_CLASS(nexus_driver);
#endif /* _MACHINE_NEXUSVAR_H_ */

View File

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