summaryrefslogtreecommitdiffstats
path: root/sys/sparc64
diff options
context:
space:
mode:
authornwhitehorn <nwhitehorn@FreeBSD.org>2008-12-15 15:31:10 +0000
committernwhitehorn <nwhitehorn@FreeBSD.org>2008-12-15 15:31:10 +0000
commitf0e837432d62958c713c7e6ebbb2adc52c8fd696 (patch)
treeca68e24ea5167314369eefd8755cc6038f9ec07e /sys/sparc64
parent907438a3fe46be01afa5020f515481b240da1a08 (diff)
downloadFreeBSD-src-f0e837432d62958c713c7e6ebbb2adc52c8fd696.zip
FreeBSD-src-f0e837432d62958c713c7e6ebbb2adc52c8fd696.tar.gz
Adapt parts of the sparc64 Open Firmware bus enumeration code (in particular,
the code for parsing interrupt maps) to PowerPC and reflect their new MI status by moving them to the shared dev/ofw directory. This commit also modifies the OFW PCI enumeration procedure on PowerPC to allow the bus to find non-firmware-enumerated devices that Apple likes to add, and adds some useful Open Firmware properties (compat and name) to the pnpinfo string of children on OFW SBus, EBus, PCI, and MacIO links. Because of the change to PCI enumeration on PowerPC, X has started working again on PPC machines with Grackle hostbridges. Reviewed by: marius Obtained from: sparc64
Diffstat (limited to 'sys/sparc64')
-rw-r--r--sys/sparc64/ebus/ebus.c2
-rw-r--r--sys/sparc64/include/ofw_bus.h53
-rw-r--r--sys/sparc64/isa/ofw_isa.c2
-rw-r--r--sys/sparc64/pci/apb.c1
-rw-r--r--sys/sparc64/pci/ofw_pci.h2
-rw-r--r--sys/sparc64/pci/ofw_pcib.c1
-rw-r--r--sys/sparc64/pci/ofw_pcib_subr.c1
-rw-r--r--sys/sparc64/pci/ofw_pcibus.c19
-rw-r--r--sys/sparc64/pci/psycho.c1
-rw-r--r--sys/sparc64/pci/schizo.c1
-rw-r--r--sys/sparc64/sbus/sbus.c1
-rw-r--r--sys/sparc64/sparc64/ofw_bus.c198
-rw-r--r--sys/sparc64/sparc64/ofw_machdep.c1
13 files changed, 22 insertions, 261 deletions
diff --git a/sys/sparc64/ebus/ebus.c b/sys/sparc64/ebus/ebus.c
index bcc92a2..9baa7a8 100644
--- a/sys/sparc64/ebus/ebus.c
+++ b/sys/sparc64/ebus/ebus.c
@@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus_subr.h>
#include <dev/ofw/openfirm.h>
-#include <machine/ofw_bus.h>
#include <machine/resource.h>
#include <dev/pci/pcireg.h>
@@ -118,6 +117,7 @@ static device_method_t ebus_methods[] = {
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD(bus_release_resource, ebus_release_resource),
DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
+ DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str),
/* ofw_bus interface */
DEVMETHOD(ofw_bus_get_devinfo, ebus_get_devinfo),
diff --git a/sys/sparc64/include/ofw_bus.h b/sys/sparc64/include/ofw_bus.h
deleted file mode 100644
index 1e9004e..0000000
--- a/sys/sparc64/include/ofw_bus.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * Copyright (c) 2001 - 2003 by Thomas Moestl <tmm@FreeBSD.org>.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_OFW_BUS_H_
-#define _MACHINE_OFW_BUS_H_
-
-#define ORIP_NOINT -1
-#define ORIR_NOTFOUND 0xffffffff
-
-/*
- * Other than in Open Firmware calls, the size of a bus cell seems to be
- * always the same.
- */
-typedef u_int32_t pcell_t;
-
-struct ofw_bus_iinfo {
- u_int8_t *opi_imap;
- u_int8_t *opi_imapmsk;
- int opi_imapsz;
- pcell_t opi_addrc;
-};
-
-void ofw_bus_setup_iinfo(phandle_t, struct ofw_bus_iinfo *, int);
-int ofw_bus_lookup_imap(phandle_t, struct ofw_bus_iinfo *, void *, int,
- void *, int, void *, int, void *);
-int ofw_bus_search_intrmap(void *, int, void *, int, void *, int, void *,
- void *, void *, int);
-
-#endif /* !_MACHINE_OFW_BUS_H_ */
diff --git a/sys/sparc64/isa/ofw_isa.c b/sys/sparc64/isa/ofw_isa.c
index e1d7537..de90869 100644
--- a/sys/sparc64/isa/ofw_isa.c
+++ b/sys/sparc64/isa/ofw_isa.c
@@ -41,10 +41,10 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus_subr.h>
#include <machine/bus.h>
#include <machine/resource.h>
-#include <machine/ofw_bus.h>
#include <sparc64/pci/ofw_pci.h>
#include <sparc64/isa/ofw_isa.h>
diff --git a/sys/sparc64/pci/apb.c b/sys/sparc64/pci/apb.c
index d908c17..ba0698c 100644
--- a/sys/sparc64/pci/apb.c
+++ b/sys/sparc64/pci/apb.c
@@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
-#include <machine/ofw_bus.h>
#include <machine/resource.h>
#include <dev/pci/pcireg.h>
diff --git a/sys/sparc64/pci/ofw_pci.h b/sys/sparc64/pci/ofw_pci.h
index 252f474..19c2fbe 100644
--- a/sys/sparc64/pci/ofw_pci.h
+++ b/sys/sparc64/pci/ofw_pci.h
@@ -34,7 +34,7 @@
#ifndef _SPARC64_PCI_OFW_PCI_H_
#define _SPARC64_PCI_OFW_PCI_H_
-#include <machine/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
typedef uint32_t ofw_pci_intr_t;
diff --git a/sys/sparc64/pci/ofw_pcib.c b/sys/sparc64/pci/ofw_pcib.c
index 966d77f..8a5b991 100644
--- a/sys/sparc64/pci/ofw_pcib.c
+++ b/sys/sparc64/pci/ofw_pcib.c
@@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
-#include <machine/ofw_bus.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
diff --git a/sys/sparc64/pci/ofw_pcib_subr.c b/sys/sparc64/pci/ofw_pcib_subr.c
index 9996b7e..6dd0990 100644
--- a/sys/sparc64/pci/ofw_pcib_subr.c
+++ b/sys/sparc64/pci/ofw_pcib_subr.c
@@ -37,7 +37,6 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
-#include <machine/ofw_bus.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
diff --git a/sys/sparc64/pci/ofw_pcibus.c b/sys/sparc64/pci/ofw_pcibus.c
index 7918370..65a498a 100644
--- a/sys/sparc64/pci/ofw_pcibus.c
+++ b/sys/sparc64/pci/ofw_pcibus.c
@@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$");
#include <sys/pciio.h>
#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
#include <dev/ofw/ofw_pci.h>
#include <dev/ofw/openfirm.h>
@@ -69,6 +68,8 @@ static device_probe_t ofw_pcibus_probe;
static device_attach_t ofw_pcibus_attach;
static pci_assign_interrupt_t ofw_pcibus_assign_interrupt;
static ofw_bus_get_devinfo_t ofw_pcibus_get_devinfo;
+static int ofw_pcibus_child_pnpinfo_str_method(device_t cbdev, device_t child,
+ char *buf, size_t buflen);
static device_method_t ofw_pcibus_methods[] = {
/* Device interface */
@@ -76,6 +77,7 @@ static device_method_t ofw_pcibus_methods[] = {
DEVMETHOD(device_attach, ofw_pcibus_attach),
/* Bus interface */
+ DEVMETHOD(bus_child_pnpinfo_str, ofw_pcibus_child_pnpinfo_str_method),
/* PCI interface */
DEVMETHOD(pci_assign_interrupt, ofw_pcibus_assign_interrupt),
@@ -302,3 +304,18 @@ ofw_pcibus_get_devinfo(device_t bus, device_t dev)
dinfo = device_get_ivars(dev);
return (&dinfo->opd_obdinfo);
}
+
+static int
+ofw_pcibus_child_pnpinfo_str_method(device_t cbdev, device_t child, char *buf,
+ size_t buflen)
+{
+ pci_child_pnpinfo_str_method(cbdev, child, buf, buflen);
+
+ if (ofw_bus_get_node(child) != -1) {
+ strlcat(buf, " ", buflen); /* Separate info */
+ ofw_bus_gen_child_pnpinfo_str(cbdev, child, buf, buflen);
+ }
+
+ return (0);
+}
+
diff --git a/sys/sparc64/pci/psycho.c b/sys/sparc64/pci/psycho.c
index d961191..505eec4 100644
--- a/sys/sparc64/pci/psycho.c
+++ b/sys/sparc64/pci/psycho.c
@@ -64,7 +64,6 @@ __FBSDID("$FreeBSD$");
#include <machine/bus_private.h>
#include <machine/iommureg.h>
#include <machine/iommuvar.h>
-#include <machine/ofw_bus.h>
#include <machine/resource.h>
#include <machine/ver.h>
diff --git a/sys/sparc64/pci/schizo.c b/sys/sparc64/pci/schizo.c
index 8f01f9c..45bee8d 100644
--- a/sys/sparc64/pci/schizo.c
+++ b/sys/sparc64/pci/schizo.c
@@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$");
#include <machine/fsr.h>
#include <machine/iommureg.h>
#include <machine/iommuvar.h>
-#include <machine/ofw_bus.h>
#include <machine/resource.h>
#include <dev/pci/pcireg.h>
diff --git a/sys/sparc64/sbus/sbus.c b/sys/sparc64/sbus/sbus.c
index a97fd10..d6b8393 100644
--- a/sys/sparc64/sbus/sbus.c
+++ b/sys/sparc64/sbus/sbus.c
@@ -226,6 +226,7 @@ static device_method_t sbus_methods[] = {
DEVMETHOD(bus_get_resource_list, sbus_get_resource_list),
DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
DEVMETHOD(bus_get_dma_tag, sbus_get_dma_tag),
+ DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str),
/* ofw_bus interface */
DEVMETHOD(ofw_bus_get_devinfo, sbus_get_devinfo),
diff --git a/sys/sparc64/sparc64/ofw_bus.c b/sys/sparc64/sparc64/ofw_bus.c
deleted file mode 100644
index f7458dc..0000000
--- a/sys/sparc64/sparc64/ofw_bus.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/*-
- * Copyright (C) 1996 Wolfgang Solfrank.
- * Copyright (C) 1996 TooLs GmbH.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
- */
-/*-
- * Copyright (c) 2001 - 2003 by Thomas Moestl <tmm@FreeBSD.org>.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * 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.
- *
- * from: $NetBSD: ofw_machdep.c,v 1.16 2001/07/20 00:07:14 eeh Exp $
- *
- * $FreeBSD$
- */
-
-/*
- * Open Firmware bus support code that is (hopefully) independent from the
- * used hardware.
- * Maybe this should go into dev/ofw/; there may however be sparc specific
- * bits left.
- */
-
-#include <sys/param.h>
-#include <sys/malloc.h>
-#include <sys/systm.h>
-
-#include <dev/ofw/openfirm.h>
-
-#include <machine/ofw_bus.h>
-
-static int
-ofw_bus_searchprop(phandle_t node, char *propname, void *buf, int buflen)
-{
- int rv;
-
- for (; node != 0; node = OF_parent(node)) {
- if ((rv = OF_getprop(node, propname, buf, buflen)) != -1)
- return (rv);
- }
- return (-1);
-}
-
-void
-ofw_bus_setup_iinfo(phandle_t node, struct ofw_bus_iinfo *ii, int intrsz)
-{
- pcell_t addrc;
- int msksz;
-
- if (OF_getprop(node, "#address-cells", &addrc, sizeof(addrc)) == -1)
- addrc = 2;
- ii->opi_addrc = addrc * sizeof(pcell_t);
-
- ii->opi_imapsz = OF_getprop_alloc(node, "interrupt-map", 1,
- (void **)&ii->opi_imap);
- if (ii->opi_imapsz > 0) {
- msksz = OF_getprop_alloc(node, "interrupt-map-mask", 1,
- (void **)&ii->opi_imapmsk);
- /*
- * Failure to get the mask is ignored; a full mask is used then.
- * Barf on bad mask sizes, however.
- */
- if (msksz != -1 && msksz != ii->opi_addrc + intrsz) {
- panic("ofw_bus_setup_iinfo: bad interrupt-map-mask "
- "property!");
- }
- }
-
-}
-
-int
-ofw_bus_lookup_imap(phandle_t node, struct ofw_bus_iinfo *ii, void *reg,
- int regsz, void *pintr, int pintrsz, void *mintr, int mintrsz,
- void *maskbuf)
-{
- int rv;
-
- if (ii->opi_imapsz <= 0)
- return (0);
- KASSERT(regsz >= ii->opi_addrc,
- ("ofw_bus_lookup_imap: register size too small: %d < %d",
- regsz, ii->opi_addrc));
- rv = OF_getprop(node, "reg", reg, regsz);
- if (rv < regsz)
- panic("ofw_bus_lookup_imap: could not get reg property");
- return (ofw_bus_search_intrmap(pintr, pintrsz, reg, ii->opi_addrc,
- ii->opi_imap, ii->opi_imapsz, ii->opi_imapmsk, maskbuf, mintr,
- mintrsz));
-}
-
-/*
- * Map an interrupt using the firmware reg, interrupt-map and
- * interrupt-map-mask properties.
- * The interrupt property to be mapped must be of size intrsz, and pointed to
- * by intr. The regs property of the node for which the mapping is done must
- * be passed as regs. This property is an array of register specifications;
- * the size of the address part of such a specification must be passed as
- * physsz. Only the first element of the property is used.
- * imap and imapsz hold the interrupt mask and it's size.
- * imapmsk is a pointer to the interrupt-map-mask property, which must have
- * a size of physsz + intrsz; it may be NULL, in which case a full mask is
- * assumed.
- * maskbuf must point to a buffer of length physsz + intrsz.
- * The interrupt is returned in result, which must point to a buffer of length
- * rintrsz (which gives the expected size of the mapped interrupt).
- * Returns 1 if a mapping was found, 0 otherwise.
- */
-int
-ofw_bus_search_intrmap(void *intr, int intrsz, void *regs, int physsz,
- void *imap, int imapsz, void *imapmsk, void *maskbuf, void *result,
- int rintrsz)
-{
- phandle_t parent;
- u_int8_t *ref = maskbuf;
- u_int8_t *uiintr = intr;
- u_int8_t *uiregs = regs;
- u_int8_t *uiimapmsk = imapmsk;
- u_int8_t *mptr;
- pcell_t pintrsz;
- int i, rsz, tsz;
-
- rsz = -1;
- if (imapmsk != NULL) {
- for (i = 0; i < physsz; i++)
- ref[i] = uiregs[i] & uiimapmsk[i];
- for (i = 0; i < intrsz; i++)
- ref[physsz + i] = uiintr[i] & uiimapmsk[physsz + i];
- } else {
- bcopy(regs, ref, physsz);
- bcopy(intr, ref + physsz, intrsz);
- }
-
- mptr = imap;
- i = imapsz;
- tsz = physsz + intrsz + sizeof(phandle_t) + rintrsz;
- while (i > 0) {
- KASSERT(i >= tsz, ("ofw_bus_search_intrmap: truncated map"));
- bcopy(mptr + physsz + intrsz, &parent, sizeof(parent));
- if (ofw_bus_searchprop(parent, "#interrupt-cells",
- &pintrsz, sizeof(pintrsz)) == -1)
- pintrsz = 1; /* default */
- pintrsz *= sizeof(pcell_t);
- if (pintrsz != rintrsz)
- panic("ofw_bus_search_intrmap: expected interrupt cell "
- "size incorrect: %d != %d", rintrsz, pintrsz);
- if (bcmp(ref, mptr, physsz + intrsz) == 0) {
- bcopy(mptr + physsz + intrsz + sizeof(parent),
- result, rintrsz);
- return (1);
- }
- mptr += tsz;
- i -= tsz;
- }
- return (0);
-}
diff --git a/sys/sparc64/sparc64/ofw_machdep.c b/sys/sparc64/sparc64/ofw_machdep.c
index 7efc807..bcacea7 100644
--- a/sys/sparc64/sparc64/ofw_machdep.c
+++ b/sys/sparc64/sparc64/ofw_machdep.c
@@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
#include <machine/idprom.h>
-#include <machine/ofw_bus.h>
#include <machine/ofw_machdep.h>
void
OpenPOWER on IntegriCloud