summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2004-08-12 17:41:33 +0000
committermarius <marius@FreeBSD.org>2004-08-12 17:41:33 +0000
commitf8c9f3a5e2940ba4fac814bea5bf4f4728dcd87b (patch)
treee750b2d26d6511903970a6a2a5d73da06845d58b
parent482740a238b6b7d0f1c649d1d3391e801547f668 (diff)
downloadFreeBSD-src-f8c9f3a5e2940ba4fac814bea5bf4f4728dcd87b.zip
FreeBSD-src-f8c9f3a5e2940ba4fac814bea5bf4f4728dcd87b.tar.gz
- Introduce an ofw_bus kobj-interface for retrieving the OFW node and a
subset ("compatible", "device_type", "model" and "name") of the standard properties in drivers for devices on Open Firmware supported busses. The standard properties "reg", "interrupts" und "address" are not covered by this interface because they are only of interest in the respective bridge code. There's a remaining standard property "status" which is unclear how to support properly but which also isn't used in FreeBSD at present. This ofw_bus kobj-interface allows to replace the various (ebus_get_node(), ofw_pci_get_node(), etc.) and partially inconsistent (central_get_type() vs. sbus_get_device_type(), etc.) existing IVAR ones with a common one. This in turn allows to simplify and remove code-duplication in drivers for devices that can hang off of more than one OFW supported bus. - Convert the sparc64 Central, EBus, FHC, PCI and SBus bus drivers and the drivers for their children to use the ofw_bus kobj-interface. The IVAR- interfaces of the Central, EBus and FHC are entirely replaced by this. The PCI bus driver used its own kobj-interface and now also uses the ofw_bus one. The IVARs special to the SBus, e.g. for retrieving the burst size, remain. Beware: this causes an ABI-breakage for modules of drivers which used the IVAR-interfaces, i.e. esp(4), hme(4), isp(4) and uart(4), which need to be recompiled. The style-inconsistencies introduced in some of the bus drivers will be fixed by tmm@ in a generic clean-up of the respective drivers later (he requested to add the changes in the "new" style). - Convert the powerpc MacIO bus driver and the drivers for its children to use the ofw_bus kobj-interface. This invloves removing the IVARs related to the "reg" property which were unused and a leftover from the NetBSD origini of the code. There's no ABI-breakage caused by this because none of these driver are currently built as modules. There are other powerpc bus drivers which can be converted to the ofw_bus kobj-interface, e.g. the PCI bus driver, which should be done together with converting powerpc to use the OFW PCI code from sparc64. - Make the SBus and FHC front-end of zs(4) and the sparc64 eeprom(4) take advantage of the ofw_bus kobj-interface and simplify them a bit. Reviewed by: grehan, tmm Approved by: re (scottl) Discussed with: tmm Tested with: Sun AX1105, AXe, Ultra 2, Ultra 60; PPC cross-build on i386
-rw-r--r--sys/conf/files.powerpc1
-rw-r--r--sys/conf/files.sparc643
-rw-r--r--sys/conf/kmod.mk1
-rw-r--r--sys/dev/esp/esp_sbus.c9
-rw-r--r--sys/dev/hme/if_hme_sbus.c7
-rw-r--r--sys/dev/isp/isp_sbus.c11
-rw-r--r--sys/dev/ofw/ofw_bus.h73
-rw-r--r--sys/dev/ofw/ofw_bus_if.m110
-rw-r--r--sys/dev/pcf/envctrl.c8
-rw-r--r--sys/dev/pcf/pcf_ebus.c15
-rw-r--r--sys/dev/puc/puc_ebus.c8
-rw-r--r--sys/dev/puc/puc_sbus.c8
-rw-r--r--sys/dev/sab/sab.c21
-rw-r--r--sys/dev/uart/uart_bus_ebus.c10
-rw-r--r--sys/dev/zs/zs_macio.c14
-rw-r--r--sys/dev/zs/zs_sbus.c73
-rw-r--r--sys/modules/esp/Makefile2
-rw-r--r--sys/modules/hme/Makefile4
-rw-r--r--sys/modules/isp/Makefile2
-rw-r--r--sys/modules/uart/Makefile5
-rw-r--r--sys/powerpc/powermac/ata_macio.c5
-rw-r--r--sys/powerpc/powermac/hrowpic.c4
-rw-r--r--sys/powerpc/powermac/macio.c122
-rw-r--r--sys/powerpc/powermac/maciovar.h31
-rw-r--r--sys/powerpc/powermac/openpic_macio.c4
-rw-r--r--sys/sparc64/central/central.c110
-rw-r--r--sys/sparc64/central/centralvar.h47
-rw-r--r--sys/sparc64/ebus/ebus.c120
-rw-r--r--sys/sparc64/ebus/ebusvar.h56
-rw-r--r--sys/sparc64/fhc/fhc.c93
-rw-r--r--sys/sparc64/fhc/fhc_central.c15
-rw-r--r--sys/sparc64/fhc/fhc_nexus.c10
-rw-r--r--sys/sparc64/fhc/fhcvar.h22
-rw-r--r--sys/sparc64/include/eeprom.h3
-rw-r--r--sys/sparc64/isa/isa.c3
-rw-r--r--sys/sparc64/pci/apb.c5
-rw-r--r--sys/sparc64/pci/ofw_pci.h7
-rw-r--r--sys/sparc64/pci/ofw_pci_if.m17
-rw-r--r--sys/sparc64/pci/ofw_pcib.c7
-rw-r--r--sys/sparc64/pci/ofw_pcib_subr.c7
-rw-r--r--sys/sparc64/pci/ofw_pcib_subr.h2
-rw-r--r--sys/sparc64/pci/ofw_pcibus.c76
-rw-r--r--sys/sparc64/pci/psycho.c11
-rw-r--r--sys/sparc64/sbus/sbus.c92
-rw-r--r--sys/sparc64/sbus/sbusvar.h8
-rw-r--r--sys/sparc64/sparc64/eeprom.c25
-rw-r--r--sys/sparc64/sparc64/eeprom_ebus.c23
-rw-r--r--sys/sparc64/sparc64/eeprom_fhc.c136
-rw-r--r--sys/sparc64/sparc64/eeprom_sbus.c26
-rw-r--r--sys/sparc64/sparc64/ofw_machdep.c4
50 files changed, 738 insertions, 738 deletions
diff --git a/sys/conf/files.powerpc b/sys/conf/files.powerpc
index ab91b50..8581a98 100644
--- a/sys/conf/files.powerpc
+++ b/sys/conf/files.powerpc
@@ -72,6 +72,7 @@ crypto/blowfish/bf_enc.c optional ipsec ipsec_esp
crypto/des/des_enc.c optional ipsec ipsec_esp
dev/ofw/openfirm.c standard
+dev/ofw/ofw_bus_if.m standard
dev/ofw/ofw_console.c standard
dev/ofw/ofw_disk.c optional ofwd
diff --git a/sys/conf/files.sparc64 b/sys/conf/files.sparc64
index 148483e..ad33b63 100644
--- a/sys/conf/files.sparc64
+++ b/sys/conf/files.sparc64
@@ -18,6 +18,7 @@ dev/fb/creator.c optional creator sc
dev/fb/fb.c optional sc
dev/fb/splash.c optional splash
dev/kbd/kbd.c optional sc
+dev/ofw/ofw_bus_if.m standard
dev/ofw/ofw_console.c optional ofw_console
dev/ofw/openfirm.c standard
dev/ofw/openfirmio.c standard
@@ -78,7 +79,7 @@ sparc64/sparc64/elf_machdep.c standard
sparc64/sparc64/exception.S standard no-obj
sparc64/sparc64/eeprom.c optional eeprom
sparc64/sparc64/eeprom_ebus.c optional eeprom ebus
-sparc64/sparc64/eeprom_fhc.c optional eeprom fhc
+sparc64/sparc64/eeprom_sbus.c optional eeprom fhc
sparc64/sparc64/eeprom_sbus.c optional eeprom sbus
sparc64/sparc64/gdb_machdep.c optional gdb
sparc64/sparc64/identcpu.c standard
diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk
index 39cca2c..6ac4035 100644
--- a/sys/conf/kmod.mk
+++ b/sys/conf/kmod.mk
@@ -294,6 +294,7 @@ MFILES?= kern/bus_if.m kern/device_if.m dev/iicbus/iicbb_if.m \
dev/iicbus/iicbus_if.m isa/isa_if.m \
libkern/iconv_converter_if.m \
dev/acpica/acpi_if.m dev/eisa/eisa_if.m dev/mii/miibus_if.m \
+ dev/ofw/ofw_bus_if.m \
dev/pccard/card_if.m dev/pccard/power_if.m dev/pci/pci_if.m \
dev/pci/pcib_if.m dev/ppbus/ppbus_if.m dev/smbus/smbus_if.m \
dev/usb/usb_if.m dev/sound/pcm/ac97_if.m dev/sound/pcm/channel_if.m \
diff --git a/sys/dev/esp/esp_sbus.c b/sys/dev/esp/esp_sbus.c
index ec1e037..eb32f1d 100644
--- a/sys/dev/esp/esp_sbus.c
+++ b/sys/dev/esp/esp_sbus.c
@@ -76,8 +76,9 @@ __FBSDID("$FreeBSD$");
#include <sys/lock.h>
#include <sys/mutex.h>
-#include <machine/bus.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
+#include <machine/bus.h>
#include <machine/ofw_machdep.h>
#include <machine/resource.h>
#include <sys/rman.h>
@@ -168,9 +169,9 @@ static struct ncr53c9x_glue esp_sbus_glue = {
static int
esp_sbus_probe(device_t dev)
{
- char *name;
+ const char *name;
- name = sbus_get_name(dev);
+ name = ofw_bus_get_name(dev);
if (strcmp("SUNW,fas", name) == 0) {
device_set_desc(dev, "Sun FAS366 Fast-Wide SCSI");
return (-10);
@@ -189,7 +190,7 @@ esp_sbus_attach(device_t dev)
int burst;
esc->sc_dev = dev;
- node = sbus_get_node(dev);
+ node = ofw_bus_get_node(dev);
if (OF_getprop(node, "initiator-id", &sc->sc_id,
sizeof(sc->sc_id)) == -1)
sc->sc_id = 7;;
diff --git a/sys/dev/hme/if_hme_sbus.c b/sys/dev/hme/if_hme_sbus.c
index f2eac6d..06c0d8a 100644
--- a/sys/dev/hme/if_hme_sbus.c
+++ b/sys/dev/hme/if_hme_sbus.c
@@ -51,8 +51,9 @@ __FBSDID("$FreeBSD$");
#include <sys/resource.h>
#include <sys/socket.h>
+#include <dev/ofw/ofw_bus.h>
+
#include <machine/bus.h>
-#include <dev/ofw/openfirm.h>
#include <machine/ofw_machdep.h>
#include <machine/resource.h>
@@ -131,9 +132,9 @@ MODULE_DEPEND(hme, ether, 1, 1, 1);
static int
hme_sbus_probe(device_t dev)
{
- char *name;
+ const char *name;
- name = sbus_get_name(dev);
+ name = ofw_bus_get_name(dev);
if (strcmp(name, "SUNW,qfe") == 0 ||
strcmp(name, "SUNW,hme") == 0) {
device_set_desc(dev, "Sun HME 10/100 Ethernet");
diff --git a/sys/dev/isp/isp_sbus.c b/sys/dev/isp/isp_sbus.c
index a1f912d..5f87f3d 100644
--- a/sys/dev/isp/isp_sbus.c
+++ b/sys/dev/isp/isp_sbus.c
@@ -35,11 +35,12 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/resource.h>
+
+#include <dev/ofw/ofw_bus.h>
+
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.h>
-#include <dev/ofw/openfirm.h>
-#include <machine/ofw_machdep.h>
#include <sparc64/sbus/sbusvar.h>
#include <dev/isp/isp_freebsd.h>
@@ -110,7 +111,7 @@ static int
isp_sbus_probe(device_t dev)
{
int found = 0;
- char *name = sbus_get_name(dev);
+ const char *name = ofw_bus_get_name(dev);
if (strcmp(name, "SUNW,isp") == 0 ||
strcmp(name, "QLGC,isp") == 0 ||
strcmp(name, "ptisp") == 0 ||
@@ -240,8 +241,8 @@ isp_sbus_attach(device_t dev)
* would fail in trying to download (via poking)
* FW. We give up on them.
*/
- if (strcmp("PTI,ptisp", sbus_get_name(dev)) == 0 ||
- strcmp("ptisp", sbus_get_name(dev)) == 0) {
+ if (strcmp("PTI,ptisp", ofw_bus_get_name(dev)) == 0 ||
+ strcmp("ptisp", ofw_bus_get_name(dev)) == 0) {
isp->isp_confopts |= ISP_CFG_NORELOAD;
}
diff --git a/sys/dev/ofw/ofw_bus.h b/sys/dev/ofw/ofw_bus.h
new file mode 100644
index 0000000..3f4fbae
--- /dev/null
+++ b/sys/dev/ofw/ofw_bus.h
@@ -0,0 +1,73 @@
+/*-
+ * Copyright (c) 2001, 2003 by Thomas Moestl <tmm@FreeBSD.org>
+ * Copyright (c) 2004 by Marius Strobl <marius@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 _DEV_OFW_OFW_BUS_H_
+#define _DEV_OFW_OFW_BUS_H_
+
+#include <sys/bus.h>
+
+#include <dev/ofw/openfirm.h>
+
+#include "ofw_bus_if.h"
+
+static __inline const char *
+ofw_bus_get_compat(device_t dev)
+{
+
+ return (OFW_BUS_GET_COMPAT(device_get_parent(dev), dev));
+}
+
+static __inline const char *
+ofw_bus_get_model(device_t dev)
+{
+
+ return (OFW_BUS_GET_MODEL(device_get_parent(dev), dev));
+}
+
+static __inline const char *
+ofw_bus_get_name(device_t dev)
+{
+
+ return (OFW_BUS_GET_NAME(device_get_parent(dev), dev));
+}
+
+static __inline phandle_t
+ofw_bus_get_node(device_t dev)
+{
+
+ return (OFW_BUS_GET_NODE(device_get_parent(dev), dev));
+}
+
+static __inline const char *
+ofw_bus_get_type(device_t dev)
+{
+
+ return (OFW_BUS_GET_TYPE(device_get_parent(dev), dev));
+}
+
+#endif /* !_DEV_OFW_OFW_BUS_H_ */
diff --git a/sys/dev/ofw/ofw_bus_if.m b/sys/dev/ofw/ofw_bus_if.m
new file mode 100644
index 0000000..87e4fcc
--- /dev/null
+++ b/sys/dev/ofw/ofw_bus_if.m
@@ -0,0 +1,110 @@
+# Copyright (c) 2001, 2003 by Thomas Moestl <tmm@FreeBSD.org>
+# Copyright (c) 2004 by Marius Strobl <marius@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$
+
+#include <sys/bus.h>
+#include <machine/bus.h>
+
+#include <dev/ofw/openfirm.h>
+
+INTERFACE ofw_bus;
+
+CODE {
+ static ofw_bus_get_compat_t ofw_bus_default_get_compat;
+ static ofw_bus_get_model_t ofw_bus_default_get_model;
+ static ofw_bus_get_name_t ofw_bus_default_get_name;
+ static ofw_bus_get_node_t ofw_bus_default_get_node;
+ static ofw_bus_get_type_t ofw_bus_default_get_type;
+
+ static const char *
+ ofw_bus_default_get_compat(device_t bus, device_t dev)
+ {
+
+ return (NULL);
+ }
+
+ static const char *
+ ofw_bus_default_get_model(device_t bus, device_t dev)
+ {
+
+ return (NULL);
+ }
+
+ static const char *
+ ofw_bus_default_get_name(device_t bus, device_t dev)
+ {
+
+ return (NULL);
+ }
+
+ static phandle_t
+ ofw_bus_default_get_node(device_t bus, device_t dev)
+ {
+
+ return (0);
+ }
+
+ static const char *
+ ofw_bus_default_get_type(device_t bus, device_t dev)
+ {
+
+ return (NULL);
+ }
+};
+
+# Get the alternate firmware name for the device dev on the bus. The default
+# method will return NULL, which means the device doesn't have such a property.
+METHOD const char * get_compat {
+ device_t bus;
+ device_t dev;
+} DEFAULT ofw_bus_default_get_compat;
+
+# Get the firmware model name for the device dev on the bus. The default method
+# will return NULL, which means the device doesn't have such a property.
+METHOD const char * get_model {
+ device_t bus;
+ device_t dev;
+} DEFAULT ofw_bus_default_get_model;
+
+# Get the firmware name for the device dev on the bus. The default method will
+# return NULL, which means the device doesn't have such a property.
+METHOD const char * get_name {
+ device_t bus;
+ device_t dev;
+} DEFAULT ofw_bus_default_get_name;
+
+# Get the firmware node for the device dev on the bus. The default method will
+# return 0, which signals that there is no such node.
+METHOD phandle_t get_node {
+ device_t bus;
+ device_t dev;
+} DEFAULT ofw_bus_default_get_node;
+
+# Get the firmware device type for the device dev on the bus. The default
+# method will return NULL, which means the device doesn't have such a property.
+METHOD const char * get_type {
+ device_t bus;
+ device_t dev;
+} DEFAULT ofw_bus_default_get_type;
diff --git a/sys/dev/pcf/envctrl.c b/sys/dev/pcf/envctrl.c
index 74d87c7..7b5f064 100644
--- a/sys/dev/pcf/envctrl.c
+++ b/sys/dev/pcf/envctrl.c
@@ -46,15 +46,13 @@ __FBSDID("$FreeBSD$");
#include <sys/resource.h>
#include <sys/uio.h>
+#include <dev/ofw/ofw_bus.h>
+
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.h>
-#include <dev/ofw/openfirm.h>
-
-#include <sparc64/ebus/ebusvar.h>
-
#include <dev/iicbus/iiconf.h>
#include <dev/pcf/pcfvar.h>
#include "iicbus_if.h"
@@ -95,7 +93,7 @@ static int
envctrl_probe(device_t dev)
{
- if (strcmp("SUNW,envctrl", ebus_get_name(dev)) == 0) {
+ if (strcmp("SUNW,envctrl", ofw_bus_get_name(dev)) == 0) {
device_set_desc(dev, "EBus SUNW,envctrl");
return (0);
}
diff --git a/sys/dev/pcf/pcf_ebus.c b/sys/dev/pcf/pcf_ebus.c
index 13b8110..b23c8dd 100644
--- a/sys/dev/pcf/pcf_ebus.c
+++ b/sys/dev/pcf/pcf_ebus.c
@@ -70,15 +70,14 @@ __FBSDID("$FreeBSD$");
#include <sys/module.h>
#include <sys/resource.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/openfirm.h>
+
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.h>
-#include <dev/ofw/openfirm.h>
-
-#include <sparc64/ebus/ebusvar.h>
-
#include <dev/iicbus/iiconf.h>
#include <dev/pcf/pcfvar.h>
#include "iicbus_if.h"
@@ -117,15 +116,15 @@ static driver_t pcf_ebus_driver = {
static int
pcf_ebus_probe(device_t dev)
{
- char *compat;
+ const char *compat;
/*
* We must not attach to this i2c device if this is a system with
* a boot-bus controller. Additionally testing the compatibility
* property will hopefully take care of this.
*/
- if (strcmp("i2c", ebus_get_name(dev)) == 0) {
- compat = ebus_get_compat(dev);
+ if (strcmp("i2c", ofw_bus_get_name(dev)) == 0) {
+ compat = ofw_bus_get_compat(dev);
if (compat != NULL && strcmp("i2cpcf,8584", compat) == 0) {
device_set_desc(dev, "PCF8584 I2C bus controller");
return (0);
@@ -146,7 +145,7 @@ pcf_ebus_attach(device_t dev)
bzero(sc, sizeof(struct pcf_softc));
/* get OFW node of the pcf */
- if ((node = ebus_get_node(dev)) <= 0) {
+ if ((node = ofw_bus_get_node(dev)) <= 0) {
device_printf(dev, "cannot get OFW node\n");
goto error;
}
diff --git a/sys/dev/puc/puc_ebus.c b/sys/dev/puc/puc_ebus.c
index ce0184a..c7ddeb4 100644
--- a/sys/dev/puc/puc_ebus.c
+++ b/sys/dev/puc/puc_ebus.c
@@ -35,13 +35,13 @@ __FBSDID("$FreeBSD$");
#include <sys/module.h>
#include <sys/bus.h>
#include <sys/conf.h>
+
+#include <dev/ofw/ofw_bus.h>
+
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>
-#include <dev/ofw/openfirm.h>
-#include <sparc64/ebus/ebusvar.h>
-
#define PUC_ENTRAILS 1
#include <dev/puc/pucvar.h>
@@ -50,7 +50,7 @@ puc_ebus_probe(device_t dev)
{
const char *nm;
- nm = ebus_get_name(dev);
+ nm = ofw_bus_get_name(dev);
if (!strcmp(nm, "se")) {
device_set_desc(dev, "Siemens SAB 82532 dual channel SCC");
return (0);
diff --git a/sys/dev/puc/puc_sbus.c b/sys/dev/puc/puc_sbus.c
index efc55c4..47a2fb4 100644
--- a/sys/dev/puc/puc_sbus.c
+++ b/sys/dev/puc/puc_sbus.c
@@ -35,13 +35,13 @@ __FBSDID("$FreeBSD$");
#include <sys/module.h>
#include <sys/bus.h>
#include <sys/conf.h>
+
+#include <dev/ofw/ofw_bus.h>
+
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>
-#include <dev/ofw/openfirm.h>
-#include <sparc64/sbus/sbusvar.h>
-
#define PUC_ENTRAILS 1
#include <dev/puc/pucvar.h>
@@ -50,7 +50,7 @@ puc_sbus_probe(device_t dev)
{
const char *nm;
- nm = sbus_get_name(dev);
+ nm = ofw_bus_get_name(dev);
if (!strcmp(nm, "zs")) {
device_set_desc(dev, "Zilog Z8530 dual channel SCC");
return (0);
diff --git a/sys/dev/sab/sab.c b/sys/dev/sab/sab.c
index eb9a4f3..0b39f0d 100644
--- a/sys/dev/sab/sab.c
+++ b/sys/dev/sab/sab.c
@@ -57,16 +57,18 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h>
#include <sys/module.h>
#include <sys/proc.h>
+
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/openfirm.h>
+
#include <machine/bus.h>
#include <machine/resource.h>
+
#include <sys/rman.h>
#include <sys/serial.h>
#include <sys/syslog.h>
#include <sys/tty.h>
-#include <dev/ofw/openfirm.h>
-#include <sparc64/ebus/ebusvar.h>
-
#include <dev/sab/sab82532reg.h>
#define SAB_READ(sc, r) \
@@ -249,9 +251,10 @@ sab_probe(device_t dev)
bus_space_tag_t tag;
uint8_t r;
int rid;
+ const char *name;
- if (strcmp(ebus_get_name(dev), "se") != 0 &&
- strcmp(ebus_get_name(dev), "serial") != 0)
+ name = ofw_bus_get_name(dev);
+ if (strcmp(name, "se") != 0 && strcmp(name, "serial") != 0)
return (ENXIO);
rid = 0;
res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid,
@@ -1191,25 +1194,25 @@ sabtty_cnputc(struct sabtty_softc *sc, int c)
static int
sabtty_console(device_t dev, char *mode, int len)
{
- device_t parent;
phandle_t chosen;
phandle_t options;
+ phandle_t parent;
ihandle_t stdin;
ihandle_t stdout;
char output[32];
char input[32];
char name[32];
- parent = device_get_parent(dev);
chosen = OF_finddevice("/chosen");
options = OF_finddevice("/options");
+ parent = ofw_bus_get_node(device_get_parent(dev));
if (OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1 ||
OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1 ||
OF_getprop(options, "input-device", input, sizeof(input)) == -1 ||
OF_getprop(options, "output-device", output, sizeof(output)) == -1)
return (0);
- if (ebus_get_node(parent) != OF_instance_to_package(stdin) ||
- ebus_get_node(parent) != OF_instance_to_package(stdout))
+ if (parent != OF_instance_to_package(stdin) ||
+ parent != OF_instance_to_package(stdout))
return (0);
if ((strcmp(input, device_get_desc(dev)) == 0 &&
strcmp(output, device_get_desc(dev)) == 0) ||
diff --git a/sys/dev/uart/uart_bus_ebus.c b/sys/dev/uart/uart_bus_ebus.c
index e643025..15e8bcb 100644
--- a/sys/dev/uart/uart_bus_ebus.c
+++ b/sys/dev/uart/uart_bus_ebus.c
@@ -32,13 +32,13 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/module.h>
+
+#include <dev/ofw/ofw_bus.h>
+
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>
-#include <dev/ofw/openfirm.h>
-#include <sparc64/ebus/ebusvar.h>
-
#include <dev/uart/uart.h>
#include <dev/uart/uart_bus.h>
#include <dev/uart/uart_cpu.h>
@@ -69,8 +69,8 @@ uart_ebus_probe(device_t dev)
sc = device_get_softc(dev);
sc->sc_class = NULL;
- nm = ebus_get_name(dev);
- cmpt = ebus_get_compat(dev);
+ nm = ofw_bus_get_name(dev);
+ cmpt = ofw_bus_get_compat(dev);
if (!strcmp(nm, "su") || !strcmp(nm, "su_pnp") || (cmpt != NULL &&
(!strcmp(cmpt, "su") || !strcmp(cmpt, "su16550")))) {
sc->sc_class = &uart_ns8250_class;
diff --git a/sys/dev/zs/zs_macio.c b/sys/dev/zs/zs_macio.c
index 182fe77..3879a9e 100644
--- a/sys/dev/zs/zs_macio.c
+++ b/sys/dev/zs/zs_macio.c
@@ -37,8 +37,8 @@ __FBSDID("$FreeBSD$");
#include <machine/resource.h>
#include <sys/rman.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
-#include <powerpc/powermac/maciovar.h>
#include <dev/zs/z8530reg.h>
#include <dev/zs/z8530var.h>
@@ -132,7 +132,7 @@ static int
zs_macio_probe(device_t dev)
{
- if (strcmp(macio_get_name(dev), "escc") != 0 ||
+ if (strcmp(ofw_bus_get_name(dev), "escc") != 0 ||
device_get_unit(dev) != 0)
return (ENXIO);
return (zs_probe(dev));
@@ -142,10 +142,8 @@ static int
zs_macio_attach(device_t dev)
{
struct zs_macio_softc *sc;
- struct macio_reg *reg;
sc = device_get_softc(dev);
- reg = macio_get_regs(dev);
sc->sc_memres = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
&sc->sc_memrid, RF_ACTIVE);
@@ -265,16 +263,15 @@ zstty_set_speed(struct zstty_softc *sc, int ospeed)
int
zstty_console(device_t dev, char *mode, int len)
{
- device_t parent;
- phandle_t chosen, options;
+ phandle_t chosen, options, parent;
ihandle_t stdin, stdout;
phandle_t stdinp, stdoutp;
char input[32], output[32];
const char *desc;
- parent = device_get_parent(dev);
chosen = OF_finddevice("/chosen");
options = OF_finddevice("/options");
+ parent = ofw_bus_get_node(device_get_parent(dev));
if (OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1 ||
OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1 ||
OF_getprop(options, "input-device", input, sizeof(input)) == -1 ||
@@ -285,8 +282,7 @@ zstty_console(device_t dev, char *mode, int len)
stdinp = OF_parent(OF_instance_to_package(stdin));
stdoutp = OF_parent(OF_instance_to_package(stdout));
desc = device_get_desc(dev);
- if (macio_get_node(parent) == stdinp &&
- macio_get_node(parent) == stdoutp &&
+ if (parent == stdinp && parent == stdoutp &&
input[3] == desc[3] && output[3] == desc[3]) {
if (mode != NULL)
strlcpy(mode, "57600,8,n,1,-", len);
diff --git a/sys/dev/zs/zs_sbus.c b/sys/dev/zs/zs_sbus.c
index 796d076..40b7ea4 100644
--- a/sys/dev/zs/zs_sbus.c
+++ b/sys/dev/zs/zs_sbus.c
@@ -34,16 +34,15 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/module.h>
+
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/openfirm.h>
+
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.h>
-#include <dev/ofw/openfirm.h>
-
#include <sparc64/fhc/fhcreg.h>
-#include <sparc64/fhc/fhcvar.h>
-
-#include <sparc64/sbus/sbusvar.h>
#include <dev/zs/z8530reg.h>
#include <dev/zs/z8530var.h>
@@ -59,12 +58,6 @@ __FBSDID("$FreeBSD$");
#define ZS_SBUS_DEF_SPEED (9600)
-enum zs_device_ivars {
- ZS_IVAR_NODE
-};
-
-__BUS_ACCESSOR(zs, node, ZS, NODE, phandle_t)
-
struct zs_sbus_softc {
struct zs_softc sc_zs;
struct resource *sc_irqres;
@@ -74,15 +67,10 @@ struct zs_sbus_softc {
int sc_memrid;
};
-static int zs_fhc_probe(device_t dev);
static int zs_fhc_attach(device_t dev);
-static int zs_fhc_read_ivar(device_t dev, device_t child, int which,
- uintptr_t *result);
static int zs_sbus_probe(device_t dev);
static int zs_sbus_attach(device_t dev);
-static int zs_sbus_read_ivar(device_t dev, device_t child, int which,
- uintptr_t *result);
static int zs_sbus_detach(device_t dev);
@@ -92,12 +80,11 @@ static int zstty_sbus_probe(device_t dev);
static int zstty_keyboard(device_t dev);
static device_method_t zs_fhc_methods[] = {
- DEVMETHOD(device_probe, zs_fhc_probe),
+ DEVMETHOD(device_probe, zs_sbus_probe),
DEVMETHOD(device_attach, zs_fhc_attach),
DEVMETHOD(device_detach, zs_sbus_detach),
DEVMETHOD(bus_print_child, bus_generic_print_child),
- DEVMETHOD(bus_read_ivar, zs_fhc_read_ivar),
{ 0, 0 }
};
@@ -108,7 +95,6 @@ static device_method_t zs_sbus_methods[] = {
DEVMETHOD(device_detach, zs_sbus_detach),
DEVMETHOD(bus_print_child, bus_generic_print_child),
- DEVMETHOD(bus_read_ivar, zs_sbus_read_ivar),
{ 0, 0 }
};
@@ -169,20 +155,10 @@ static uint8_t zs_sbus_init_reg[16] = {
};
static int
-zs_fhc_probe(device_t dev)
-{
-
- if (strcmp(fhc_get_name(dev), "zs") != 0 ||
- device_get_unit(dev) != 0)
- return (ENXIO);
- return (zs_probe(dev));
-}
-
-static int
zs_sbus_probe(device_t dev)
{
- if (strcmp(sbus_get_name(dev), "zs") != 0 ||
+ if (strcmp(ofw_bus_get_name(dev), "zs") != 0 ||
device_get_unit(dev) != 0)
return (ENXIO);
return (zs_probe(dev));
@@ -260,34 +236,6 @@ zs_sbus_detach(device_t dev)
}
static int
-zs_fhc_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
-{
-
- switch (which) {
- case ZS_IVAR_NODE:
- *result = fhc_get_node(dev);
- break;
- default:
- return (ENOENT);
- }
- return (0);
-}
-
-static int
-zs_sbus_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
-{
-
- switch (which) {
- case ZS_IVAR_NODE:
- *result = sbus_get_node(dev);
- break;
- default:
- return (ENOENT);
- }
- return (0);
-}
-
-static int
zstty_sbus_probe(device_t dev)
{
@@ -349,6 +297,7 @@ zstty_console(device_t dev, char *mode, int len)
{
phandle_t chosen;
phandle_t options;
+ phandle_t parent;
ihandle_t stdin;
ihandle_t stdout;
char output[32];
@@ -357,13 +306,14 @@ zstty_console(device_t dev, char *mode, int len)
chosen = OF_finddevice("/chosen");
options = OF_finddevice("/options");
+ parent = ofw_bus_get_node(device_get_parent(dev));
if (OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1 ||
OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1 ||
OF_getprop(options, "input-device", input, sizeof(input)) == -1 ||
OF_getprop(options, "output-device", output, sizeof(output)) == -1)
return (0);
- if (zs_get_node(dev) != OF_instance_to_package(stdin) ||
- zs_get_node(dev) != OF_instance_to_package(stdout))
+ if (parent != OF_instance_to_package(stdin) ||
+ parent != OF_instance_to_package(stdout))
return (0);
if ((strcmp(input, device_get_desc(dev)) == 0 &&
strcmp(output, device_get_desc(dev)) == 0) ||
@@ -382,5 +332,6 @@ static int
zstty_keyboard(device_t dev)
{
- return (OF_getproplen(zs_get_node(dev), "keyboard") == 0);
+ return (OF_getproplen(ofw_bus_get_node(device_get_parent(dev)),
+ "keyboard") == 0);
}
diff --git a/sys/modules/esp/Makefile b/sys/modules/esp/Makefile
index 40bbc44..2b747fd 100644
--- a/sys/modules/esp/Makefile
+++ b/sys/modules/esp/Makefile
@@ -9,7 +9,7 @@ SRCS+= opt_ddb.h opt_cam.h
SRCS+= device_if.h bus_if.h
.if ${MACHINE_ARCH} == "sparc64"
-SRCS+= esp_sbus.c lsi64854.c
+SRCS+= esp_sbus.c lsi64854.c ofw_bus_if.h
.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/hme/Makefile b/sys/modules/hme/Makefile
index 4660231..f99b0f7 100644
--- a/sys/modules/hme/Makefile
+++ b/sys/modules/hme/Makefile
@@ -3,7 +3,7 @@
.PATH: ${.CURDIR}/../../dev/hme
KMOD= if_hme
-SRCS= if_hme.c if_hme_pci.c if_hme_sbus.c device_if.h bus_if.h pci_if.h
-SRCS+= miibus_if.h
+SRCS= if_hme.c if_hme_pci.c if_hme_sbus.c device_if.h bus_if.h ofw_bus_if.h
+SRCS+= pci_if.h miibus_if.h
.include <bsd.kmod.mk>
diff --git a/sys/modules/isp/Makefile b/sys/modules/isp/Makefile
index a71998d..b3ddc39 100644
--- a/sys/modules/isp/Makefile
+++ b/sys/modules/isp/Makefile
@@ -8,7 +8,7 @@ SRCS= bus_if.h device_if.h pci_if.h \
isp.c isp_target.c isp_freebsd.c isp_pci.c
.if ${MACHINE_ARCH} == sparc64
-SRCS+= isp_sbus.c
+SRCS+= isp_sbus.c ofw_bus_if.h
.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/uart/Makefile b/sys/modules/uart/Makefile
index 43dd5d8..9214a73 100644
--- a/sys/modules/uart/Makefile
+++ b/sys/modules/uart/Makefile
@@ -4,6 +4,7 @@
.if ${MACHINE_ARCH} == "sparc64"
uart_bus_ebus= uart_bus_ebus.c
+ofw_bus_if= ofw_bus_if.h
.endif
KMOD= uart
@@ -11,7 +12,7 @@ SRCS= uart_bus_acpi.c ${uart_bus_ebus} uart_bus_isa.c uart_bus_pccard.c \
uart_bus_pci.c uart_bus_puc.c uart_core.c uart_cpu_${MACHINE}.c \
uart_dbg.c uart_dev_i8251.c uart_dev_ns8250.c uart_dev_sab82532.c \
uart_dev_z8530.c uart_if.c uart_subr.c uart_tty.c
-SRCS+= bus_if.h device_if.h isa_if.h pci_if.h uart_if.h power_if.h card_if.h \
- pccarddevs.h
+SRCS+= bus_if.h card_if.h device_if.h isa_if.h ${ofw_bus_if} pci_if.h \
+ power_if.h uart_if.h pccarddevs.h
.include <bsd.kmod.mk>
diff --git a/sys/powerpc/powermac/ata_macio.c b/sys/powerpc/powermac/ata_macio.c
index 127defe..5fb2865 100644
--- a/sys/powerpc/powermac/ata_macio.c
+++ b/sys/powerpc/powermac/ata_macio.c
@@ -47,8 +47,7 @@
#include <sys/ata.h>
#include <dev/ata/ata-all.h>
-#include <dev/ofw/openfirm.h>
-#include <powerpc/powermac/maciovar.h>
+#include <dev/ofw/ofw_bus.h>
/*
* Offset to control registers from base
@@ -99,7 +98,7 @@ ata_macio_setmode(struct ata_device *atadev, int mode)
static int
ata_macio_probe(device_t dev)
{
- char *type = macio_get_devtype(dev);
+ const char *type = ofw_bus_get_type(dev);
struct ata_channel *ch;
struct resource *mem;
int rid, i;
diff --git a/sys/powerpc/powermac/hrowpic.c b/sys/powerpc/powermac/hrowpic.c
index 6b8caff..0c1fd4b 100644
--- a/sys/powerpc/powermac/hrowpic.c
+++ b/sys/powerpc/powermac/hrowpic.c
@@ -46,6 +46,7 @@
#include <sys/conf.h>
#include <sys/kernel.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
@@ -61,7 +62,6 @@
#include <sys/rman.h>
-#include <powerpc/powermac/maciovar.h>
#include <powerpc/powermac/hrowpicvar.h>
#include "pic_if.h"
@@ -434,7 +434,7 @@ DRIVER_MODULE(hrowpicmacio, macio, hrowpic_macio_driver,
static int
hrowpic_macio_probe(device_t dev)
{
- char *type = macio_get_devtype(dev);
+ const char *type = ofw_bus_get_type(dev);
/*
* OpenPIC cells have a type of "open-pic", so this
diff --git a/sys/powerpc/powermac/macio.c b/sys/powerpc/powermac/macio.c
index 300cbe7..1bf007d 100644
--- a/sys/powerpc/powermac/macio.c
+++ b/sys/powerpc/powermac/macio.c
@@ -47,6 +47,7 @@
#include <machine/resource.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <powerpc/powermac/maciovar.h>
@@ -70,8 +71,6 @@ static int macio_probe(device_t);
static int macio_attach(device_t);
static int macio_print_child(device_t dev, device_t child);
static void macio_probe_nomatch(device_t, device_t);
-static int macio_read_ivar(device_t, device_t, int, uintptr_t *);
-static int macio_write_ivar(device_t, device_t, int, uintptr_t);
static struct resource *macio_alloc_resource(device_t, device_t, int, int *,
u_long, u_long, u_long, u_int);
static int macio_activate_resource(device_t, device_t, int, int,
@@ -81,6 +80,11 @@ static int macio_deactivate_resource(device_t, device_t, int, int,
static int macio_release_resource(device_t, device_t, int, int,
struct resource *);
static struct resource_list *macio_get_resource_list (device_t, device_t);
+static ofw_bus_get_compat_t macio_get_compat;
+static ofw_bus_get_model_t macio_get_model;
+static ofw_bus_get_name_t macio_get_name;
+static ofw_bus_get_node_t macio_get_node;
+static ofw_bus_get_type_t macio_get_type;
/*
* Bus interface definition
@@ -97,8 +101,6 @@ static device_method_t macio_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, macio_print_child),
DEVMETHOD(bus_probe_nomatch, macio_probe_nomatch),
- DEVMETHOD(bus_read_ivar, macio_read_ivar),
- DEVMETHOD(bus_write_ivar, macio_write_ivar),
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
@@ -108,6 +110,13 @@ static device_method_t macio_methods[] = {
DEVMETHOD(bus_deactivate_resource, macio_deactivate_resource),
DEVMETHOD(bus_get_resource_list, macio_get_resource_list),
+ /* ofw_bus interface */
+ DEVMETHOD(ofw_bus_get_compat, macio_get_compat),
+ DEVMETHOD(ofw_bus_get_model, macio_get_model),
+ DEVMETHOD(ofw_bus_get_name, macio_get_name),
+ DEVMETHOD(ofw_bus_get_node, macio_get_node),
+ DEVMETHOD(ofw_bus_get_type, macio_get_type),
+
{ 0, 0 }
};
@@ -206,9 +215,6 @@ macio_add_reg(phandle_t devnode, struct macio_devinfo *dinfo)
if (nreg == -1)
return;
- dinfo->mdi_nregs = nreg;
- dinfo->mdi_regs = reg;
-
for (i = 0; i < nreg; i++) {
resource_list_add(&dinfo->mdi_resources, SYS_RES_MEMORY, i,
reg[i].mr_base, reg[i].mr_base + reg[i].mr_size,
@@ -250,7 +256,7 @@ macio_attach(device_t dev)
phandle_t subchild;
device_t cdev;
u_int reg[3];
- char *name, *type;
+ char *name;
int quirks;
sc = device_get_softc(dev);
@@ -281,12 +287,10 @@ macio_attach(device_t dev)
*/
for (child = OF_child(root); child != 0; child = OF_peer(child)) {
OF_getprop_alloc(child, "name", 1, (void **)&name);
- OF_getprop_alloc(child, "device_type", 1, (void **)&type);
quirks = macio_get_quirks(name);
if ((quirks & MACIO_QUIRK_IGNORE) != 0) {
free(name, M_OFWPROP);
- free(type, M_OFWPROP);
continue;
}
@@ -297,7 +301,12 @@ macio_attach(device_t dev)
resource_list_init(&dinfo->mdi_resources);
dinfo->mdi_node = child;
dinfo->mdi_name = name;
- dinfo->mdi_device_type = type;
+ OF_getprop_alloc(child, "compatible", 1,
+ (void **)&dinfo->mdi_compat);
+ OF_getprop_alloc(child, "device_type", 1,
+ (void **)&dinfo->mdi_type);
+ OF_getprop_alloc(child, "model", 1,
+ (void **)&dinfo->mdi_model);
dinfo->mdi_ninterrupts = 0;
macio_add_intr(child, dinfo);
macio_add_reg(child, dinfo);
@@ -313,7 +322,6 @@ macio_attach(device_t dev)
device_set_ivars(cdev, dinfo);
} else {
free(name, M_OFWPROP);
- free(type, M_OFWPROP);
}
}
@@ -347,13 +355,15 @@ macio_probe_nomatch(device_t dev, device_t child)
{
struct macio_devinfo *dinfo;
struct resource_list *rl;
+ const char *type;
if (bootverbose) {
dinfo = device_get_ivars(child);
rl = &dinfo->mdi_resources;
- device_printf(dev, "<%s, %s>", macio_get_devtype(child),
- macio_get_name(child));
+ if ((type = ofw_bus_get_type(child)) == NULL)
+ type = "(unknown)";
+ device_printf(dev, "<%s, %s>", type, ofw_bus_get_name(child));
resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#lx");
resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
printf(" (no driver attached)\n");
@@ -361,45 +371,6 @@ macio_probe_nomatch(device_t dev, device_t child)
}
-static int
-macio_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
-{
- struct macio_devinfo *dinfo;
-
- if ((dinfo = device_get_ivars(child)) == 0)
- return (ENOENT);
-
- switch (which) {
- case MACIO_IVAR_NODE:
- *result = dinfo->mdi_node;
- break;
- case MACIO_IVAR_NAME:
- *result = (uintptr_t)dinfo->mdi_name;
- break;
- case MACIO_IVAR_DEVTYPE:
- *result = (uintptr_t)dinfo->mdi_device_type;
- break;
- case MACIO_IVAR_NREGS:
- *result = dinfo->mdi_nregs;
- break;
- case MACIO_IVAR_REGS:
- *result = (uintptr_t)dinfo->mdi_regs;
- break;
- default:
- return (ENOENT);
- }
-
- return (0);
-}
-
-
-static int
-macio_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
-{
- return (EINVAL);
-}
-
-
static struct resource *
macio_alloc_resource(device_t bus, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags)
@@ -572,3 +543,48 @@ macio_get_resource_list (device_t dev, device_t child)
return (rl);
}
+
+const char *
+macio_get_compat(device_t bus, device_t dev)
+{
+ struct macio_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->mdi_compat);
+}
+
+const char *
+macio_get_model(device_t bus, device_t dev)
+{
+ struct macio_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->mdi_model);
+}
+
+const char *
+macio_get_name(device_t bus, device_t dev)
+{
+ struct macio_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->mdi_name);
+}
+
+static phandle_t
+macio_get_node(device_t bus, device_t dev)
+{
+ struct macio_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->mdi_node);
+}
+
+const char *
+macio_get_type(device_t bus, device_t dev)
+{
+ struct macio_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->mdi_type);
+}
diff --git a/sys/powerpc/powermac/maciovar.h b/sys/powerpc/powermac/maciovar.h
index d28f946..2de15e2 100644
--- a/sys/powerpc/powermac/maciovar.h
+++ b/sys/powerpc/powermac/maciovar.h
@@ -31,29 +31,6 @@
#define _MACIO_MACIOVAR_H_
/*
- * Accessors for macio devices
- */
-
-enum macio_ivars {
- MACIO_IVAR_NODE,
- MACIO_IVAR_NAME,
- MACIO_IVAR_DEVTYPE,
- MACIO_IVAR_NREGS,
- MACIO_IVAR_REGS,
-};
-
-#define MACIO_ACCESSOR(var, ivar, type) \
- __BUS_ACCESSOR(macio, var, MACIO, ivar, type)
-
-MACIO_ACCESSOR(node, NODE, phandle_t)
-MACIO_ACCESSOR(name, NAME, char *)
-MACIO_ACCESSOR(devtype, DEVTYPE, char *)
-MACIO_ACCESSOR(nregs, NREGS, u_int)
-MACIO_ACCESSOR(regs, REGS, struct macio_reg *)
-
-#undef MACIO_ACCESSOR
-
-/*
* The addr space size
* XXX it would be better if this could be determined by querying the
* PCI device, but there isn't an access method for this
@@ -72,14 +49,14 @@ struct macio_reg {
* Per macio device structure.
*/
struct macio_devinfo {
+ char *mdi_compat;
+ char *mdi_model;
+ char *mdi_name;
phandle_t mdi_node;
- char *mdi_name;
- char *mdi_device_type;
+ char *mdi_type;
int mdi_interrupts[5];
int mdi_ninterrupts;
int mdi_base;
- int mdi_nregs;
- struct macio_reg *mdi_regs;
struct resource_list mdi_resources;
};
diff --git a/sys/powerpc/powermac/openpic_macio.c b/sys/powerpc/powermac/openpic_macio.c
index 0f8b0e2..fac08d8 100644
--- a/sys/powerpc/powermac/openpic_macio.c
+++ b/sys/powerpc/powermac/openpic_macio.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <sys/conf.h>
#include <sys/kernel.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
@@ -61,7 +62,6 @@ __FBSDID("$FreeBSD$");
#include <sys/rman.h>
#include <machine/openpicvar.h>
-#include <powerpc/powermac/maciovar.h>
#include "pic_if.h"
@@ -186,7 +186,7 @@ DRIVER_MODULE(openpicmacio, macio, openpic_macio_driver,
static int
openpic_macio_probe(device_t dev)
{
- char *type = macio_get_devtype(dev);
+ const char *type = ofw_bus_get_type(dev);
if (strcmp(type, "open-pic") != 0)
return (ENXIO);
diff --git a/sys/sparc64/central/central.c b/sys/sparc64/central/central.c
index b886d0c..d26f9af 100644
--- a/sys/sparc64/central/central.c
+++ b/sys/sparc64/central/central.c
@@ -33,6 +33,7 @@
#include <sys/malloc.h>
#include <sys/module.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
@@ -42,11 +43,12 @@
#include <sys/rman.h>
-#include <sparc64/central/centralvar.h>
#include <sparc64/sbus/ofw_sbus.h>
#include <sparc64/sbus/sbusreg.h>
struct central_devinfo {
+ char *cdi_compat;
+ char *cdi_model;
char *cdi_name;
char *cdi_type;
phandle_t cdi_node;
@@ -62,10 +64,13 @@ static int central_probe(device_t dev);
static int central_attach(device_t dev);
static void central_probe_nomatch(device_t dev, device_t child);
-static int central_read_ivar(device_t, device_t, int, uintptr_t *);
-static int central_write_ivar(device_t, device_t, int, uintptr_t);
static struct resource *central_alloc_resource(device_t, device_t, int, int *,
u_long, u_long, u_long, u_int);
+static ofw_bus_get_compat_t central_get_compat;
+static ofw_bus_get_model_t central_get_model;
+static ofw_bus_get_name_t central_get_name;
+static ofw_bus_get_node_t central_get_node;
+static ofw_bus_get_type_t central_get_type;
static device_method_t central_methods[] = {
/* Device interface. */
@@ -75,8 +80,6 @@ static device_method_t central_methods[] = {
/* Bus interface. */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_probe_nomatch, central_probe_nomatch),
- DEVMETHOD(bus_read_ivar, central_read_ivar),
- DEVMETHOD(bus_write_ivar, central_write_ivar),
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
DEVMETHOD(bus_alloc_resource, central_alloc_resource),
@@ -84,6 +87,13 @@ static device_method_t central_methods[] = {
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
+ /* ofw_bus interface */
+ DEVMETHOD(ofw_bus_get_compat, central_get_compat),
+ DEVMETHOD(ofw_bus_get_model, central_get_model),
+ DEVMETHOD(ofw_bus_get_name, central_get_name),
+ DEVMETHOD(ofw_bus_get_node, central_get_node),
+ DEVMETHOD(ofw_bus_get_type, central_get_type),
+
{ NULL, NULL }
};
@@ -138,8 +148,12 @@ central_attach(device_t dev)
M_WAITOK | M_ZERO);
cdi->cdi_name = name;
cdi->cdi_node = child;
+ OF_getprop_alloc(child, "compatible", 1,
+ (void **)&cdi->cdi_compat);
OF_getprop_alloc(child, "device_type", 1,
(void **)&cdi->cdi_type);
+ OF_getprop_alloc(child, "model", 1,
+ (void **)&cdi->cdi_model);
device_set_ivars(cdev, cdi);
} else
free(name, M_OFWPROP);
@@ -158,47 +172,6 @@ central_probe_nomatch(device_t dev, device_t child)
cdi->cdi_name, cdi->cdi_type != NULL ? cdi->cdi_type : "unknown");
}
-static int
-central_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
-{
- struct central_devinfo *cdi;
-
- if ((cdi = device_get_ivars(child)) == 0)
- return (ENOENT);
- switch (which) {
- case CENTRAL_IVAR_NAME:
- *result = (uintptr_t)cdi->cdi_name;
- break;
- case CENTRAL_IVAR_NODE:
- *result = cdi->cdi_node;
- break;
- case CENTRAL_IVAR_TYPE:
- *result = (uintptr_t)cdi->cdi_type;
- break;
- default:
- return (ENOENT);
- }
- return (0);
-}
-
-static int
-central_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
-{
- struct central_devinfo *cdi;
-
- if ((cdi = device_get_ivars(child)) == 0)
- return (ENOENT);
- switch (which) {
- case CENTRAL_IVAR_NAME:
- case CENTRAL_IVAR_NODE:
- case CENTRAL_IVAR_TYPE:
- return (EINVAL);
- default:
- return (ENOENT);
- }
- return (0);
-}
-
static struct resource *
central_alloc_resource(device_t bus, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags)
@@ -231,3 +204,48 @@ central_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
return (res);
}
+
+static const char *
+central_get_compat(device_t bus, device_t dev)
+{
+ struct central_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->cdi_compat);
+}
+
+static const char *
+central_get_model(device_t bus, device_t dev)
+{
+ struct central_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->cdi_model);
+}
+
+static const char *
+central_get_name(device_t bus, device_t dev)
+{
+ struct central_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->cdi_name);
+}
+
+static phandle_t
+central_get_node(device_t bus, device_t dev)
+{
+ struct central_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->cdi_node);
+}
+
+static const char *
+central_get_type(device_t bus, device_t dev)
+{
+ struct central_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->cdi_type);
+}
diff --git a/sys/sparc64/central/centralvar.h b/sys/sparc64/central/centralvar.h
deleted file mode 100644
index a3b03c6..0000000
--- a/sys/sparc64/central/centralvar.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * Copyright (c) 2003 Jake Burkholder.
- * 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 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 _SPARC64_CENTRAL_CENTRALVAR_H_
-#define _SPARC64_CENTRAL_CENTRALVAR_H_
-
-enum central_device_ivars {
- CENTRAL_IVAR_NAME,
- CENTRAL_IVAR_NODE,
- CENTRAL_IVAR_TYPE
-};
-
-#define CENTRAL_ACCESSOR(var, ivar, type) \
- __BUS_ACCESSOR(central, var, CENTRAL, ivar, type)
-
-CENTRAL_ACCESSOR(name, NAME, char *)
-CENTRAL_ACCESSOR(node, NODE, phandle_t)
-CENTRAL_ACCESSOR(type, TYPE, char *)
-
-#undef CENTRAL_ACCESSOR
-
-#endif
diff --git a/sys/sparc64/ebus/ebus.c b/sys/sparc64/ebus/ebus.c
index 10b98bc..bf12a26 100644
--- a/sys/sparc64/ebus/ebus.c
+++ b/sys/sparc64/ebus/ebus.c
@@ -57,6 +57,7 @@
#include <sys/rman.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <machine/ofw_bus.h>
@@ -72,11 +73,12 @@
* ones.
*/
#include <sparc64/isa/ofw_isa.h>
-#include <sparc64/ebus/ebusvar.h>
struct ebus_devinfo {
+ char *edi_compat; /* PROM compatible */
+ char *edi_model; /* PROM model */
char *edi_name; /* PROM name */
- char *edi_compat;
+ char *edi_type; /* PROM device_type */
phandle_t edi_node; /* PROM node */
struct resource_list edi_rl;
@@ -104,11 +106,14 @@ static device_probe_t ebus_probe;
static device_attach_t ebus_attach;
static bus_print_child_t ebus_print_child;
static bus_probe_nomatch_t ebus_probe_nomatch;
-static bus_read_ivar_t ebus_read_ivar;
-static bus_write_ivar_t ebus_write_ivar;
static bus_alloc_resource_t ebus_alloc_resource;
static bus_release_resource_t ebus_release_resource;
static bus_get_resource_list_t ebus_get_resource_list;
+static ofw_bus_get_compat_t ebus_get_compat;
+static ofw_bus_get_model_t ebus_get_model;
+static ofw_bus_get_name_t ebus_get_name;
+static ofw_bus_get_node_t ebus_get_node;
+static ofw_bus_get_type_t ebus_get_type;
static struct ebus_devinfo *ebus_setup_dinfo(device_t, struct ebus_softc *,
phandle_t, char *);
@@ -123,8 +128,6 @@ static device_method_t ebus_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, ebus_print_child),
DEVMETHOD(bus_probe_nomatch, ebus_probe_nomatch),
- DEVMETHOD(bus_read_ivar, ebus_read_ivar),
- DEVMETHOD(bus_write_ivar, ebus_write_ivar),
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
DEVMETHOD(bus_alloc_resource, ebus_alloc_resource),
@@ -134,6 +137,13 @@ static device_method_t ebus_methods[] = {
DEVMETHOD(bus_release_resource, ebus_release_resource),
DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
+ /* ofw_bus interface */
+ DEVMETHOD(ofw_bus_get_compat, ebus_get_compat),
+ DEVMETHOD(ofw_bus_get_model, ebus_get_model),
+ DEVMETHOD(ofw_bus_get_name, ebus_get_name),
+ DEVMETHOD(ofw_bus_get_node, ebus_get_node),
+ DEVMETHOD(ofw_bus_get_type, ebus_get_type),
+
{ 0, 0 }
};
@@ -153,7 +163,7 @@ ebus_probe(device_t dev)
char name[10];
phandle_t node;
- if ((node = ofw_pci_get_node(dev)) == 0)
+ if ((node = ofw_bus_get_node(dev)) == 0)
return (ENXIO);
OF_getprop(node, "name", &name, sizeof(name));
@@ -184,7 +194,7 @@ ebus_attach(device_t dev)
int i, rnum, rid;
sc = device_get_softc(dev);
- sc->sc_node = node = ofw_pci_get_node(dev);
+ sc->sc_node = node = ofw_bus_get_node(dev);
sc->sc_nrange = OF_getprop_alloc(node, "ranges",
sizeof(*sc->sc_range), (void **)&sc->sc_range);
@@ -281,47 +291,6 @@ ebus_probe_nomatch(device_t dev, device_t child)
printf(" (no driver attached)\n");
}
-static int
-ebus_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
-{
- struct ebus_devinfo *dinfo;
-
- if ((dinfo = device_get_ivars(child)) == NULL)
- return (ENOENT);
- switch (which) {
- case EBUS_IVAR_COMPAT:
- *result = (uintptr_t)dinfo->edi_compat;
- break;
- case EBUS_IVAR_NAME:
- *result = (uintptr_t)dinfo->edi_name;
- break;
- case EBUS_IVAR_NODE:
- *result = dinfo->edi_node;
- break;
- default:
- return (ENOENT);
- }
- return 0;
-}
-
-static int
-ebus_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
-{
- struct ebus_devinfo *dinfo;
-
- if ((dinfo = device_get_ivars(child)) == NULL)
- return (ENOENT);
- switch (which) {
- case EBUS_IVAR_COMPAT:
- case EBUS_IVAR_NAME:
- case EBUS_IVAR_NODE:
- return (EINVAL);
- default:
- return (ENOENT);
- }
- return 0;
-}
-
static struct resource *
ebus_alloc_resource(device_t bus, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags)
@@ -452,6 +421,8 @@ ebus_setup_dinfo(device_t dev, struct ebus_softc *sc, phandle_t node,
edi->edi_node = node;
OF_getprop_alloc(node, "compatible", 1, (void **)&edi->edi_compat);
+ OF_getprop_alloc(node, "device_type", 1, (void **)&edi->edi_type);
+ OF_getprop_alloc(node, "model", 1, (void **)&edi->edi_model);
nreg = OF_getprop_alloc(node, "reg", sizeof(*reg), (void **)&reg);
if (nreg == -1) {
ebus_destroy_dinfo(edi);
@@ -492,6 +463,12 @@ static void
ebus_destroy_dinfo(struct ebus_devinfo *edi)
{
+ if (edi->edi_compat != NULL)
+ free(edi->edi_compat, M_OFWPROP);
+ if (edi->edi_type != NULL)
+ free(edi->edi_type, M_OFWPROP);
+ if (edi->edi_model != NULL)
+ free(edi->edi_model, M_OFWPROP);
resource_list_free(&edi->edi_rl);
free(edi, M_DEVBUF);
}
@@ -508,3 +485,48 @@ ebus_print_res(struct ebus_devinfo *edi)
"%ld");
return (retval);
}
+
+static const char *
+ebus_get_compat(device_t bus, device_t dev)
+{
+ struct ebus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->edi_compat);
+}
+
+static const char *
+ebus_get_model(device_t bus, device_t dev)
+{
+ struct ebus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->edi_model);
+}
+
+static const char *
+ebus_get_name(device_t bus, device_t dev)
+{
+ struct ebus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->edi_name);
+}
+
+static phandle_t
+ebus_get_node(device_t bus, device_t dev)
+{
+ struct ebus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->edi_node);
+}
+
+static const char *
+ebus_get_type(device_t bus, device_t dev)
+{
+ struct ebus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->edi_type);
+}
diff --git a/sys/sparc64/ebus/ebusvar.h b/sys/sparc64/ebus/ebusvar.h
deleted file mode 100644
index c8fd7c6..0000000
--- a/sys/sparc64/ebus/ebusvar.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 1999, 2000 Matthew R. Green
- * 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. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * 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 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: ebusvar.h,v 1.5 2001/07/20 00:07:13 eeh Exp
- * and
- * from: FreeBSD: src/sys/dev/pci/pcivar.h,v 1.51 2001/02/27
- *
- * $FreeBSD$
- */
-
-#ifndef _SPARC64_EBUS_EBUSVAR_H_
-#define _SPARC64_EBUS_EBUSVAR_H_
-
-enum ebus_device_ivars {
- EBUS_IVAR_COMPAT,
- EBUS_IVAR_NAME,
- EBUS_IVAR_NODE,
-};
-
-/*
- * Simplified accessors for ebus devices
- */
-#define EBUS_ACCESSOR(var, ivar, type) \
- __BUS_ACCESSOR(ebus, var, EBUS, ivar, type)
-
-EBUS_ACCESSOR(compat, COMPAT, char *)
-EBUS_ACCESSOR(name, NAME, char *)
-EBUS_ACCESSOR(node, NODE, phandle_t)
-
-#undef EBUS_ACCESSOR
-
-#endif /* !_SPARC64_EBUS_EBUSVAR_H_ */
diff --git a/sys/sparc64/fhc/fhc.c b/sys/sparc64/fhc/fhc.c
index def8904..69e7aab 100644
--- a/sys/sparc64/fhc/fhc.c
+++ b/sys/sparc64/fhc/fhc.c
@@ -33,6 +33,7 @@
#include <sys/malloc.h>
#include <sys/pcpu.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
@@ -56,6 +57,8 @@ struct fhc_clr {
};
struct fhc_devinfo {
+ char *fdi_compat;
+ char *fdi_model;
char *fdi_name;
char *fdi_type;
phandle_t fdi_node;
@@ -127,8 +130,12 @@ fhc_attach(device_t dev)
M_WAITOK | M_ZERO);
fdi->fdi_name = name;
fdi->fdi_node = child;
+ OF_getprop_alloc(child, "compatible", 1,
+ (void **)&fdi->fdi_compat);
OF_getprop_alloc(child, "device_type", 1,
(void **)&fdi->fdi_type);
+ OF_getprop_alloc(child, "model", 1,
+ (void **)&fdi->fdi_model);
resource_list_init(&fdi->fdi_rl);
nreg = OF_getprop_alloc(child, "reg", sizeof(*reg),
(void **)&reg);
@@ -177,47 +184,6 @@ fhc_probe_nomatch(device_t dev, device_t child)
}
int
-fhc_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
-{
- struct fhc_devinfo *fdi;
-
- if ((fdi = device_get_ivars(child)) == 0)
- return (ENOENT);
- switch (which) {
- case FHC_IVAR_NAME:
- *result = (uintptr_t)fdi->fdi_name;
- break;
- case FHC_IVAR_NODE:
- *result = fdi->fdi_node;
- break;
- case FHC_IVAR_TYPE:
- *result = (uintptr_t)fdi->fdi_type;
- break;
- default:
- return (ENOENT);
- }
- return (0);
-}
-
-int
-fhc_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
-{
- struct fhc_devinfo *fdi;
-
- if ((fdi = device_get_ivars(child)) == 0)
- return (ENOENT);
- switch (which) {
- case FHC_IVAR_NAME:
- case FHC_IVAR_NODE:
- case FHC_IVAR_TYPE:
- return (EINVAL);
- default:
- return (ENOENT);
- }
- return (0);
-}
-
-int
fhc_setup_intr(device_t bus, device_t child, struct resource *r, int flags,
driver_intr_t *func, void *arg, void **cookiep)
{
@@ -372,3 +338,48 @@ fhc_release_resource(device_t bus, device_t child, int type, int rid,
rle->res = NULL;
return (error);
}
+
+const char *
+fhc_get_compat(device_t bus, device_t dev)
+{
+ struct fhc_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->fdi_compat);
+}
+
+const char *
+fhc_get_model(device_t bus, device_t dev)
+{
+ struct fhc_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->fdi_model);
+}
+
+const char *
+fhc_get_name(device_t bus, device_t dev)
+{
+ struct fhc_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->fdi_name);
+}
+
+phandle_t
+fhc_get_node(device_t bus, device_t dev)
+{
+ struct fhc_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->fdi_node);
+}
+
+const char *
+fhc_get_type(device_t bus, device_t dev)
+{
+ struct fhc_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->fdi_type);
+}
diff --git a/sys/sparc64/fhc/fhc_central.c b/sys/sparc64/fhc/fhc_central.c
index ce35c0d..50dc669 100644
--- a/sys/sparc64/fhc/fhc_central.c
+++ b/sys/sparc64/fhc/fhc_central.c
@@ -33,6 +33,7 @@
#include <sys/malloc.h>
#include <sys/module.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
@@ -40,7 +41,6 @@
#include <sys/rman.h>
-#include <sparc64/central/centralvar.h>
#include <sparc64/fhc/fhcreg.h>
#include <sparc64/fhc/fhcvar.h>
#include <sparc64/sbus/ofw_sbus.h>
@@ -56,8 +56,6 @@ static device_method_t fhc_central_methods[] = {
/* Bus interface. */
DEVMETHOD(bus_print_child, fhc_print_child),
DEVMETHOD(bus_probe_nomatch, fhc_probe_nomatch),
- DEVMETHOD(bus_read_ivar, fhc_read_ivar),
- DEVMETHOD(bus_write_ivar, fhc_write_ivar),
DEVMETHOD(bus_setup_intr, fhc_setup_intr),
DEVMETHOD(bus_teardown_intr, fhc_teardown_intr),
DEVMETHOD(bus_alloc_resource, fhc_alloc_resource),
@@ -65,6 +63,13 @@ static device_method_t fhc_central_methods[] = {
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
+ /* ofw_bus interface */
+ DEVMETHOD(ofw_bus_get_compat, fhc_get_compat),
+ DEVMETHOD(ofw_bus_get_model, fhc_get_model),
+ DEVMETHOD(ofw_bus_get_name, fhc_get_name),
+ DEVMETHOD(ofw_bus_get_node, fhc_get_node),
+ DEVMETHOD(ofw_bus_get_type, fhc_get_type),
+
{ NULL, NULL }
};
@@ -82,7 +87,7 @@ static int
fhc_central_probe(device_t dev)
{
- if (strcmp(central_get_name(dev), "fhc") == 0) {
+ if (strcmp(ofw_bus_get_name(dev), "fhc") == 0) {
device_set_desc(dev, "fhc");
return (fhc_probe(dev));
}
@@ -103,7 +108,7 @@ fhc_central_attach(device_t dev)
int i;
sc = device_get_softc(dev);
- node = central_get_node(dev);
+ node = ofw_bus_get_node(dev);
sc->sc_node = node;
sc->sc_flags |= FHC_CENTRAL;
diff --git a/sys/sparc64/fhc/fhc_nexus.c b/sys/sparc64/fhc/fhc_nexus.c
index f5d0951..4943329 100644
--- a/sys/sparc64/fhc/fhc_nexus.c
+++ b/sys/sparc64/fhc/fhc_nexus.c
@@ -33,6 +33,7 @@
#include <sys/malloc.h>
#include <sys/module.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
@@ -56,8 +57,6 @@ static device_method_t fhc_nexus_methods[] = {
/* Bus interface. */
DEVMETHOD(bus_print_child, fhc_print_child),
DEVMETHOD(bus_probe_nomatch, fhc_probe_nomatch),
- DEVMETHOD(bus_read_ivar, fhc_read_ivar),
- DEVMETHOD(bus_write_ivar, fhc_write_ivar),
DEVMETHOD(bus_setup_intr, fhc_setup_intr),
DEVMETHOD(bus_teardown_intr, fhc_teardown_intr),
DEVMETHOD(bus_alloc_resource, fhc_alloc_resource),
@@ -65,6 +64,13 @@ static device_method_t fhc_nexus_methods[] = {
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
+ /* ofw_bus interface */
+ DEVMETHOD(ofw_bus_get_compat, fhc_get_compat),
+ DEVMETHOD(ofw_bus_get_model, fhc_get_model),
+ DEVMETHOD(ofw_bus_get_name, fhc_get_name),
+ DEVMETHOD(ofw_bus_get_node, fhc_get_node),
+ DEVMETHOD(ofw_bus_get_type, fhc_get_type),
+
{ NULL, NULL }
};
diff --git a/sys/sparc64/fhc/fhcvar.h b/sys/sparc64/fhc/fhcvar.h
index ad4a72d..5566565 100644
--- a/sys/sparc64/fhc/fhcvar.h
+++ b/sys/sparc64/fhc/fhcvar.h
@@ -29,12 +29,6 @@
#ifndef _SPARC64_FHC_FHCVAR_H_
#define _SPARC64_FHC_FHCVAR_H_
-enum fhc_device_ivars {
- FHC_IVAR_NAME,
- FHC_IVAR_NODE,
- FHC_IVAR_TYPE
-};
-
#define FHC_CENTRAL (1<<0)
struct fhc_softc {
@@ -54,22 +48,16 @@ int fhc_attach(device_t dev);
int fhc_print_child(device_t dev, device_t child);
void fhc_probe_nomatch(device_t dev, device_t child);
-int fhc_read_ivar(device_t, device_t, int, uintptr_t *);
-int fhc_write_ivar(device_t, device_t, int, uintptr_t);
int fhc_setup_intr(device_t, device_t, struct resource *, int, driver_intr_t *,
void *, void **);
int fhc_teardown_intr(device_t, device_t, struct resource *, void *);
struct resource *fhc_alloc_resource(device_t, device_t, int, int *, u_long,
u_long, u_long, u_int);
int fhc_release_resource(device_t, device_t, int, int, struct resource *);
-
-#define FHC_ACCESSOR(var, ivar, type) \
- __BUS_ACCESSOR(fhc, var, FHC, ivar, type)
-
-FHC_ACCESSOR(name, NAME, char *)
-FHC_ACCESSOR(node, NODE, phandle_t)
-FHC_ACCESSOR(type, TYPE, char *)
-
-#undef FHC_ACCESSOR
+ofw_bus_get_compat_t fhc_get_compat;
+ofw_bus_get_model_t fhc_get_model;
+ofw_bus_get_name_t fhc_get_name;
+ofw_bus_get_node_t fhc_get_node;
+ofw_bus_get_type_t fhc_get_type;
#endif
diff --git a/sys/sparc64/include/eeprom.h b/sys/sparc64/include/eeprom.h
index 8e49419..57a7ff5 100644
--- a/sys/sparc64/include/eeprom.h
+++ b/sys/sparc64/include/eeprom.h
@@ -59,6 +59,7 @@ struct eeprom_softc {
extern devclass_t eeprom_devclass;
-int eeprom_attach(device_t, phandle_t, bus_space_tag_t, bus_space_handle_t);
+int eeprom_probe(device_t);
+int eeprom_attach(device_t, bus_space_tag_t, bus_space_handle_t);
#endif /* _MACHINE_EEPROM_H_ */
diff --git a/sys/sparc64/isa/isa.c b/sys/sparc64/isa/isa.c
index a8b440a..cfe9e87 100644
--- a/sys/sparc64/isa/isa.c
+++ b/sys/sparc64/isa/isa.c
@@ -41,6 +41,7 @@
#include <isa/isavar.h>
#include <isa/isa_common.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <machine/resource.h>
@@ -111,7 +112,7 @@ isa_init(device_t dev)
/* The parent of the bus must be a PCI-ISA bridge. */
bridge = device_get_parent(dev);
- isab_node = ofw_pci_get_node(bridge);
+ isab_node = ofw_bus_get_node(bridge);
nbr = OF_getprop_alloc(isab_node, "ranges", sizeof(*br), (void **)&br);
if (nbr <= 0)
panic("isa_init: cannot get bridge range property");
diff --git a/sys/sparc64/pci/apb.c b/sys/sparc64/pci/apb.c
index be43974..4fc8fd2 100644
--- a/sys/sparc64/pci/apb.c
+++ b/sys/sparc64/pci/apb.c
@@ -48,6 +48,7 @@
#include <sys/module.h>
#include <sys/bus.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
@@ -101,8 +102,10 @@ static device_method_t apb_methods[] = {
DEVMETHOD(pcib_write_config, pcib_write_config),
DEVMETHOD(pcib_route_interrupt, ofw_pcib_gen_route_interrupt),
+ /* ofw_bus interface */
+ DEVMETHOD(ofw_bus_get_node, ofw_pcib_gen_get_node),
+
/* ofw_pci interface */
- DEVMETHOD(ofw_pci_get_node, ofw_pcib_gen_get_node),
DEVMETHOD(ofw_pci_adjust_busrange, ofw_pcib_gen_adjust_busrange),
{ 0, 0 }
diff --git a/sys/sparc64/pci/ofw_pci.h b/sys/sparc64/pci/ofw_pci.h
index d1b6623..d5fdf12 100644
--- a/sys/sparc64/pci/ofw_pci.h
+++ b/sys/sparc64/pci/ofw_pci.h
@@ -48,11 +48,4 @@ typedef u_int32_t ofw_pci_intr_t;
u_int8_t ofw_pci_alloc_busno(phandle_t);
-static __inline phandle_t
-ofw_pci_get_node(device_t dev)
-{
-
- return (OFW_PCI_GET_NODE(device_get_parent(dev), dev));
-}
-
#endif /* ! _SPARC64_PCI_OFW_PCI_H_ */
diff --git a/sys/sparc64/pci/ofw_pci_if.m b/sys/sparc64/pci/ofw_pci_if.m
index adbb8cf..ef203b6 100644
--- a/sys/sparc64/pci/ofw_pci_if.m
+++ b/sys/sparc64/pci/ofw_pci_if.m
@@ -35,7 +35,6 @@ INTERFACE ofw_pci;
CODE {
static ofw_pci_intr_pending_t ofw_pci_default_intr_pending;
static ofw_pci_get_bus_handle_t ofw_pci_default_get_bus_handle;
- static ofw_pci_get_node_t ofw_pci_default_get_node;
static ofw_pci_adjust_busrange_t ofw_pci_default_adjust_busrange;
static int
@@ -54,13 +53,6 @@ CODE {
childhdl, tag));
}
- static phandle_t
- ofw_pci_default_get_node(device_t bus, device_t dev)
- {
-
- return (0);
- }
-
static void
ofw_pci_default_adjust_busrange(device_t dev, u_int busno)
{
@@ -85,15 +77,6 @@ METHOD bus_space_handle_t get_bus_handle {
bus_space_tag_t *tag;
} DEFAULT ofw_pci_default_get_bus_handle;
-# Get the firmware node for the device dev on the bus. The default method will
-# return 0, which signals that there is no such node.
-# This could be an ivar, but isn't to avoid numbering conflicts with standard
-# pci/pcib ones.
-METHOD phandle_t get_node {
- device_t bus;
- device_t dev;
-} DEFAULT ofw_pci_default_get_node;
-
# Make sure that all PCI bridges up in the hierarchy contain this bus in their
# subordinate bus range. This is required because we reenumerate all PCI
# buses.
diff --git a/sys/sparc64/pci/ofw_pcib.c b/sys/sparc64/pci/ofw_pcib.c
index 66ef81f..bf2f1d7 100644
--- a/sys/sparc64/pci/ofw_pcib.c
+++ b/sys/sparc64/pci/ofw_pcib.c
@@ -40,6 +40,7 @@
#include <sys/bus.h>
#include <sys/module.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
@@ -82,8 +83,10 @@ static device_method_t ofw_pcib_methods[] = {
DEVMETHOD(pcib_write_config, pcib_write_config),
DEVMETHOD(pcib_route_interrupt, ofw_pcib_gen_route_interrupt),
+ /* ofw_bus interface */
+ DEVMETHOD(ofw_bus_get_node, ofw_pcib_gen_get_node),
+
/* ofw_pci interface */
- DEVMETHOD(ofw_pci_get_node, ofw_pcib_gen_get_node),
DEVMETHOD(ofw_pci_adjust_busrange, ofw_pcib_gen_adjust_busrange),
{ 0, 0 }
@@ -102,7 +105,7 @@ ofw_pcib_probe(device_t dev)
{
if ((pci_get_class(dev) == PCIC_BRIDGE) &&
(pci_get_subclass(dev) == PCIS_BRIDGE_PCI) &&
- ofw_pci_get_node(dev) != 0) {
+ ofw_bus_get_node(dev) != 0) {
device_set_desc(dev, "OFW PCI-PCI bridge");
return (0);
}
diff --git a/sys/sparc64/pci/ofw_pcib_subr.c b/sys/sparc64/pci/ofw_pcib_subr.c
index daf7e0b..b297d34 100644
--- a/sys/sparc64/pci/ofw_pcib_subr.c
+++ b/sys/sparc64/pci/ofw_pcib_subr.c
@@ -31,8 +31,9 @@
#include <sys/systm.h>
#include <sys/bus.h>
-#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_pci.h>
+#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
#include <machine/ofw_bus.h>
@@ -53,7 +54,7 @@ ofw_pcib_gen_setup(device_t bridge)
u_int secbus;
sc->ops_pcib_sc.dev = bridge;
- sc->ops_node = ofw_pci_get_node(bridge);
+ sc->ops_node = ofw_bus_get_node(bridge);
KASSERT(sc->ops_node != 0,
("ofw_pcib_gen_setup: no ofw pci parent bus!"));
@@ -81,7 +82,7 @@ ofw_pcib_gen_route_interrupt(device_t bridge, device_t dev, int intpin)
struct ofw_bus_iinfo *ii = &sc->ops_iinfo;
struct ofw_pci_register reg;
device_t pbridge = device_get_parent(device_get_parent(bridge));
- phandle_t node = ofw_pci_get_node(dev);
+ phandle_t node = ofw_bus_get_node(dev);
ofw_pci_intr_t pintr, mintr;
u_int8_t maskbuf[sizeof(reg) + sizeof(pintr)];
diff --git a/sys/sparc64/pci/ofw_pcib_subr.h b/sys/sparc64/pci/ofw_pcib_subr.h
index f925cbe..8c17e2c 100644
--- a/sys/sparc64/pci/ofw_pcib_subr.h
+++ b/sys/sparc64/pci/ofw_pcib_subr.h
@@ -41,7 +41,7 @@ struct ofw_pcib_gen_softc {
void ofw_pcib_gen_setup(device_t);
pcib_route_interrupt_t ofw_pcib_gen_route_interrupt;
-ofw_pci_get_node_t ofw_pcib_gen_get_node;
+ofw_bus_get_node_t ofw_pcib_gen_get_node;
ofw_pci_adjust_busrange_t ofw_pcib_gen_adjust_busrange;
#endif /* !_SPARC64_PCI_OFW_PCI_SUBR_H */
diff --git a/sys/sparc64/pci/ofw_pcibus.c b/sys/sparc64/pci/ofw_pcibus.c
index 597b656..85369d1 100644
--- a/sys/sparc64/pci/ofw_pcibus.c
+++ b/sys/sparc64/pci/ofw_pcibus.c
@@ -30,6 +30,7 @@
*/
#include "opt_ofw_pci.h"
+
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/kernel.h>
@@ -37,8 +38,9 @@
#include <sys/module.h>
#include <sys/pciio.h>
-#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_pci.h>
+#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
#include <machine/bus_common.h>
@@ -62,7 +64,11 @@ static void ofw_pcibus_setup_device(device_t, u_int, u_int, u_int);
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_pci_get_node_t ofw_pcibus_get_node;
+static ofw_bus_get_compat_t ofw_pcibus_get_compat;
+static ofw_bus_get_model_t ofw_pcibus_get_model;
+static ofw_bus_get_name_t ofw_pcibus_get_name;
+static ofw_bus_get_node_t ofw_pcibus_get_node;
+static ofw_bus_get_type_t ofw_pcibus_get_type;
static device_method_t ofw_pcibus_methods[] = {
/* Device interface */
@@ -103,14 +109,22 @@ static device_method_t ofw_pcibus_methods[] = {
DEVMETHOD(pci_set_powerstate, pci_set_powerstate_method),
DEVMETHOD(pci_assign_interrupt, ofw_pcibus_assign_interrupt),
- /* OFW PCI interface */
- DEVMETHOD(ofw_pci_get_node, ofw_pcibus_get_node),
+ /* ofw_bus interface */
+ DEVMETHOD(ofw_bus_get_compat, ofw_pcibus_get_compat),
+ DEVMETHOD(ofw_bus_get_model, ofw_pcibus_get_model),
+ DEVMETHOD(ofw_bus_get_name, ofw_pcibus_get_name),
+ DEVMETHOD(ofw_bus_get_node, ofw_pcibus_get_node),
+ DEVMETHOD(ofw_bus_get_type, ofw_pcibus_get_type),
{ 0, 0 }
};
struct ofw_pcibus_devinfo {
struct pci_devinfo opd_dinfo;
+ char *opd_compat;
+ char *opd_model;
+ char *opd_name;
+ char *opd_type;
phandle_t opd_node;
};
@@ -132,7 +146,7 @@ static int
ofw_pcibus_probe(device_t dev)
{
- if (ofw_pci_get_node(dev) == 0)
+ if (ofw_bus_get_node(dev) == 0)
return (ENXIO);
device_set_desc(dev, "OFW PCI bus");
@@ -205,7 +219,7 @@ ofw_pcibus_attach(device_t dev)
if (bootverbose)
device_printf(dev, "physical bus=%d\n", busno);
- node = ofw_pci_get_node(dev);
+ node = ofw_bus_get_node(dev);
for (child = OF_child(node); child != 0; child = OF_peer(child)) {
if (OF_getprop(child, "reg", &pcir, sizeof(pcir)) == -1)
panic("ofw_pci_attach: OF_getprop failed");
@@ -216,6 +230,14 @@ ofw_pcibus_attach(device_t dev)
busno, slot, func, sizeof(*dinfo));
if (dinfo != NULL) {
dinfo->opd_node = child;
+ OF_getprop_alloc(child, "compatible", 1,
+ (void **)&dinfo->opd_compat);
+ OF_getprop_alloc(child, "device_type", 1,
+ (void **)&dinfo->opd_type);
+ OF_getprop_alloc(child, "model", 1,
+ (void **)&dinfo->opd_model);
+ OF_getprop_alloc(child, "name", 1,
+ (void **)&dinfo->opd_name);
pci_add_child(dev, (struct pci_devinfo *)dinfo);
}
}
@@ -228,11 +250,10 @@ ofw_pcibus_assign_interrupt(device_t dev, device_t child)
{
struct ofw_pcibus_devinfo *dinfo = device_get_ivars(child);
pcicfgregs *cfg = &dinfo->opd_dinfo.cfg;
- phandle_t node = ofw_pci_get_node(child);
ofw_pci_intr_t intr;
int isz;
- isz = OF_getprop(node, "interrupts", &intr, sizeof(intr));
+ isz = OF_getprop(dinfo->opd_node, "interrupts", &intr, sizeof(intr));
if (isz != sizeof(intr)) {
/* No property; our best guess is the intpin. */
intr = cfg->intpin;
@@ -255,10 +276,47 @@ ofw_pcibus_assign_interrupt(device_t dev, device_t child)
return (PCIB_ROUTE_INTERRUPT(device_get_parent(dev), child, intr));
}
+static const char *
+ofw_pcibus_get_compat(device_t bus, device_t dev)
+{
+ struct ofw_pcibus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->opd_compat);
+}
+
+static const char *
+ofw_pcibus_get_model(device_t bus, device_t dev)
+{
+ struct ofw_pcibus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->opd_model);
+}
+
+static const char *
+ofw_pcibus_get_name(device_t bus, device_t dev)
+{
+ struct ofw_pcibus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->opd_name);
+}
+
static phandle_t
ofw_pcibus_get_node(device_t bus, device_t dev)
{
- struct ofw_pcibus_devinfo *dinfo = device_get_ivars(dev);
+ struct ofw_pcibus_devinfo *dinfo;
+ dinfo = device_get_ivars(dev);
return (dinfo->opd_node);
}
+
+static const char *
+ofw_pcibus_get_type(device_t bus, device_t dev)
+{
+ struct ofw_pcibus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->opd_type);
+}
diff --git a/sys/sparc64/pci/psycho.c b/sys/sparc64/pci/psycho.c
index aa002cc..6b42f01 100644
--- a/sys/sparc64/pci/psycho.c
+++ b/sys/sparc64/pci/psycho.c
@@ -48,8 +48,9 @@
#include <sys/malloc.h>
#include <sys/pcpu.h>
-#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_pci.h>
+#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
#include <machine/bus_private.h>
@@ -113,7 +114,7 @@ static pcib_write_config_t psycho_write_config;
static pcib_route_interrupt_t psycho_route_interrupt;
static ofw_pci_intr_pending_t psycho_intr_pending;
static ofw_pci_get_bus_handle_t psycho_get_bus_handle;
-static ofw_pci_get_node_t psycho_get_node;
+static ofw_bus_get_node_t psycho_get_node;
static ofw_pci_adjust_busrange_t psycho_adjust_busrange;
static device_method_t psycho_methods[] = {
@@ -137,10 +138,12 @@ static device_method_t psycho_methods[] = {
DEVMETHOD(pcib_write_config, psycho_write_config),
DEVMETHOD(pcib_route_interrupt, psycho_route_interrupt),
+ /* ofw_bus interface */
+ DEVMETHOD(ofw_bus_get_node, psycho_get_node),
+
/* ofw_pci interface */
DEVMETHOD(ofw_pci_intr_pending, psycho_intr_pending),
DEVMETHOD(ofw_pci_get_bus_handle, psycho_get_bus_handle),
- DEVMETHOD(ofw_pci_get_node, psycho_get_node),
DEVMETHOD(ofw_pci_adjust_busrange, psycho_adjust_busrange),
{ 0, 0 }
@@ -840,7 +843,7 @@ psycho_route_interrupt(device_t bridge, device_t dev, int pin)
struct psycho_softc *sc = device_get_softc(bridge);
struct ofw_pci_register reg;
bus_addr_t intrmap;
- phandle_t node = ofw_pci_get_node(dev);
+ phandle_t node = ofw_bus_get_node(dev);
ofw_pci_intr_t pintr, mintr;
u_int8_t maskbuf[sizeof(reg) + sizeof(pintr)];
diff --git a/sys/sparc64/sbus/sbus.c b/sys/sparc64/sbus/sbus.c
index 89c7ac9..4ae43d1 100644
--- a/sys/sparc64/sbus/sbus.c
+++ b/sys/sparc64/sbus/sbus.c
@@ -112,6 +112,7 @@
#include <sys/pcpu.h>
#include <sys/reboot.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
@@ -132,7 +133,6 @@
#include <sparc64/sbus/sbusreg.h>
#include <sparc64/sbus/sbusvar.h>
-
#ifdef DEBUG
#define SDB_DVMA 0x1
#define SDB_INTR 0x2
@@ -144,11 +144,12 @@ int sbus_debug = 0;
struct sbus_devinfo {
int sdi_burstsz;
- char *sdi_compat;
+ char *sdi_compat; /* PROM compatible */
+ char *sdi_model; /* PROM model */
char *sdi_name; /* PROM name */
phandle_t sdi_node; /* PROM node */
int sdi_slot;
- char *sdi_type; /* PROM name */
+ char *sdi_type; /* PROM device_type */
struct resource_list sdi_rl;
};
@@ -219,6 +220,11 @@ static int sbus_deactivate_resource(device_t, device_t, int, int,
struct resource *);
static int sbus_release_resource(device_t, device_t, int, int,
struct resource *);
+static ofw_bus_get_compat_t sbus_get_compat;
+static ofw_bus_get_model_t sbus_get_model;
+static ofw_bus_get_name_t sbus_get_name;
+static ofw_bus_get_node_t sbus_get_node;
+static ofw_bus_get_type_t sbus_get_type;
static struct sbus_devinfo * sbus_setup_dinfo(struct sbus_softc *sc,
phandle_t node, char *name);
@@ -246,6 +252,13 @@ static device_method_t sbus_methods[] = {
DEVMETHOD(bus_get_resource_list, sbus_get_resource_list),
DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
+ /* ofw_bus interface */
+ DEVMETHOD(ofw_bus_get_compat, sbus_get_compat),
+ DEVMETHOD(ofw_bus_get_model, sbus_get_model),
+ DEVMETHOD(ofw_bus_get_name, sbus_get_name),
+ DEVMETHOD(ofw_bus_get_node, sbus_get_node),
+ DEVMETHOD(ofw_bus_get_type, sbus_get_type),
+
{ 0, 0 }
};
@@ -460,6 +473,7 @@ sbus_setup_dinfo(struct sbus_softc *sc, phandle_t node, char *name)
sdi->sdi_node = node;
OF_getprop_alloc(node, "compatible", 1, (void **)&sdi->sdi_compat);
OF_getprop_alloc(node, "device_type", 1, (void **)&sdi->sdi_type);
+ OF_getprop_alloc(node, "model", 1, (void **)&sdi->sdi_model);
slot = -1;
nreg = OF_getprop_alloc(node, "reg", sizeof(*reg), (void **)&reg);
if (nreg == -1) {
@@ -524,6 +538,8 @@ sbus_destroy_dinfo(struct sbus_devinfo *dinfo)
resource_list_free(&dinfo->sdi_rl);
if (dinfo->sdi_compat != NULL)
free(dinfo->sdi_compat, M_OFWPROP);
+ if (dinfo->sdi_model != NULL)
+ free(dinfo->sdi_model, M_OFWPROP);
if (dinfo->sdi_type != NULL)
free(dinfo->sdi_type, M_OFWPROP);
free(dinfo, M_DEVBUF);
@@ -548,19 +564,12 @@ sbus_print_child(device_t dev, device_t child)
static void
sbus_probe_nomatch(device_t dev, device_t child)
{
- char *name;
- char *type;
+ const char *type;
- if (BUS_READ_IVAR(dev, child, SBUS_IVAR_NAME,
- (uintptr_t *)&name) != 0 ||
- BUS_READ_IVAR(dev, child, SBUS_IVAR_DEVICE_TYPE,
- (uintptr_t *)&type) != 0)
- return;
-
- if (type == NULL)
+ if ((type = ofw_bus_get_type(child)) == NULL)
type = "(unknown)";
device_printf(dev, "<%s>, type %s (no driver attached)\n",
- name, type);
+ ofw_bus_get_name(child), type);
}
static int
@@ -578,21 +587,9 @@ sbus_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
case SBUS_IVAR_CLOCKFREQ:
*result = sc->sc_clockfreq;
break;
- case SBUS_IVAR_COMPAT:
- *result = (uintptr_t)dinfo->sdi_compat;
- break;
- case SBUS_IVAR_NAME:
- *result = (uintptr_t)dinfo->sdi_name;
- break;
- case SBUS_IVAR_NODE:
- *result = dinfo->sdi_node;
- break;
case SBUS_IVAR_SLOT:
*result = dinfo->sdi_slot;
break;
- case SBUS_IVAR_DEVICE_TYPE:
- *result = (uintptr_t)dinfo->sdi_type;
- break;
default:
return (ENOENT);
}
@@ -890,3 +887,48 @@ sbus_alloc_bustag(struct sbus_softc *sc)
sbt->bst_type = SBUS_BUS_SPACE;
return (sbt);
}
+
+const char *
+sbus_get_compat(device_t bus, device_t dev)
+{
+ struct sbus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->sdi_compat);
+}
+
+const char *
+sbus_get_model(device_t bus, device_t dev)
+{
+ struct sbus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->sdi_model);
+}
+
+const char *
+sbus_get_name(device_t bus, device_t dev)
+{
+ struct sbus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->sdi_name);
+}
+
+static phandle_t
+sbus_get_node(device_t bus, device_t dev)
+{
+ struct sbus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->sdi_node);
+}
+
+const char *
+sbus_get_type(device_t bus, device_t dev)
+{
+ struct sbus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->sdi_type);
+}
diff --git a/sys/sparc64/sbus/sbusvar.h b/sys/sparc64/sbus/sbusvar.h
index 6b5a438..1f4a05d 100644
--- a/sys/sparc64/sbus/sbusvar.h
+++ b/sys/sparc64/sbus/sbusvar.h
@@ -98,11 +98,7 @@
enum sbus_device_ivars {
SBUS_IVAR_BURSTSZ,
SBUS_IVAR_CLOCKFREQ,
- SBUS_IVAR_COMPAT,
- SBUS_IVAR_NAME,
- SBUS_IVAR_NODE,
SBUS_IVAR_SLOT,
- SBUS_IVAR_DEVICE_TYPE,
};
/*
@@ -113,11 +109,7 @@ enum sbus_device_ivars {
SBUS_ACCESSOR(burstsz, BURSTSZ, int)
SBUS_ACCESSOR(clockfreq, CLOCKFREQ, int)
-SBUS_ACCESSOR(compat, COMPAT, char *)
-SBUS_ACCESSOR(name, NAME, char *)
-SBUS_ACCESSOR(node, NODE, phandle_t)
SBUS_ACCESSOR(slot, SLOT, int)
-SBUS_ACCESSOR(device_type, DEVICE_TYPE, char *)
#undef SBUS_ACCESSOR
diff --git a/sys/sparc64/sparc64/eeprom.c b/sys/sparc64/sparc64/eeprom.c
index 266cbdb..5f67a31 100644
--- a/sys/sparc64/sparc64/eeprom.c
+++ b/sys/sparc64/sparc64/eeprom.c
@@ -57,14 +57,14 @@
#include <sys/malloc.h>
#include <sys/resource.h>
+#include <dev/ofw/ofw_bus.h>
+
#include <machine/bus.h>
#include <machine/idprom.h>
#include <machine/resource.h>
#include <sys/rman.h>
-#include <dev/ofw/openfirm.h>
-
#include <machine/eeprom.h>
#include <dev/mk48txx/mk48txxreg.h>
@@ -73,26 +73,34 @@
devclass_t eeprom_devclass;
-
#define IDPROM_OFFSET (8 * 1024 - 40) /* XXX - get nvram size from driver */
int
-eeprom_attach(device_t dev, phandle_t node, bus_space_tag_t bt,
- bus_space_handle_t bh)
+eeprom_probe(device_t dev)
+{
+
+ if (strcmp("eeprom", ofw_bus_get_name(dev)) == 0) {
+ device_set_desc(dev, "EEPROM/clock");
+ return (0);
+ }
+ return (ENXIO);
+}
+
+int
+eeprom_attach(device_t dev, bus_space_tag_t bt, bus_space_handle_t bh)
{
struct timespec ts;
struct idprom *idp;
- char *model;
+ const char *model;
int error, i;
u_int32_t h;
- if (OF_getprop_alloc(node, "model", 1, (void **)&model) == -1)
+ if ((model = ofw_bus_get_model(dev)) == NULL)
panic("eeprom_attach: no model property");
/* Our TOD clock year 0 is 1968 */
if ((error = mk48txx_attach(dev, bt, bh, model, 1968)) != 0) {
device_printf(dev, "Can't attach %s tod clock", model);
- free(model, M_OFWPROP);
return (error);
}
/* XXX: register clock device */
@@ -115,4 +123,3 @@ eeprom_attach(device_t dev, phandle_t node, bus_space_tag_t bt,
return (0);
}
-
diff --git a/sys/sparc64/sparc64/eeprom_ebus.c b/sys/sparc64/sparc64/eeprom_ebus.c
index 7f6e495..645602b 100644
--- a/sys/sparc64/sparc64/eeprom_ebus.c
+++ b/sys/sparc64/sparc64/eeprom_ebus.c
@@ -58,32 +58,29 @@
#include <sys/module.h>
#include <sys/resource.h>
+#include <dev/ofw/ofw_bus.h>
+
#include <machine/bus.h>
#include <machine/idprom.h>
#include <machine/resource.h>
#include <sys/rman.h>
-#include <dev/ofw/openfirm.h>
-
#include <machine/eeprom.h>
#include <dev/mk48txx/mk48txxreg.h>
-#include <sparc64/ebus/ebusvar.h>
-
#include "clock_if.h"
/*
* clock (eeprom) attaches at the sbus or the ebus
*/
-static int eeprom_ebus_probe(device_t);
static int eeprom_ebus_attach(device_t);
static device_method_t eeprom_ebus_methods[] = {
/* Device interface */
- DEVMETHOD(device_probe, eeprom_ebus_probe),
+ DEVMETHOD(device_probe, eeprom_probe),
DEVMETHOD(device_attach, eeprom_ebus_attach),
/* clock interface */
@@ -101,18 +98,6 @@ static driver_t eeprom_ebus_driver = {
DRIVER_MODULE(eeprom, ebus, eeprom_ebus_driver, eeprom_devclass, 0, 0);
-
-static int
-eeprom_ebus_probe(device_t dev)
-{
-
- if (strcmp("eeprom", ebus_get_name(dev)) == 0) {
- device_set_desc(dev, "EBus EEPROM/clock");
- return (0);
- }
- return (ENXIO);
-}
-
/*
* Attach a clock (really `eeprom') to the ebus.
*
@@ -134,7 +119,7 @@ eeprom_ebus_attach(device_t dev)
device_printf(dev, "could not allocate resources\n");
return (ENXIO);
}
- error = eeprom_attach(dev, ebus_get_node(dev), rman_get_bustag(res),
+ error = eeprom_attach(dev, rman_get_bustag(res),
rman_get_bushandle(res));
return (error);
}
diff --git a/sys/sparc64/sparc64/eeprom_fhc.c b/sys/sparc64/sparc64/eeprom_fhc.c
deleted file mode 100644
index b1f320f..0000000
--- a/sys/sparc64/sparc64/eeprom_fhc.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1994 Gordon W. Ross
- * Copyright (c) 1993 Adam Glass
- * Copyright (c) 1996 Paul Kranenburg
- * Copyright (c) 1996
- * The President and Fellows of Harvard College. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Harvard University.
- *
- * 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 Paul Kranenburg.
- * This product includes software developed by Harvard University.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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: @(#)clock.c 8.1 (Berkeley) 6/11/93
- * from: NetBSD: clock.c,v 1.41 2001/07/24 19:29:25 eeh Exp
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/module.h>
-#include <sys/resource.h>
-
-#include <machine/bus.h>
-#include <machine/idprom.h>
-#include <machine/resource.h>
-
-#include <sys/rman.h>
-
-#include <dev/ofw/openfirm.h>
-
-#include <machine/eeprom.h>
-
-#include <dev/mk48txx/mk48txxreg.h>
-
-#include <sparc64/fhc/fhcreg.h>
-#include <sparc64/fhc/fhcvar.h>
-
-#include "clock_if.h"
-
-static int eeprom_fhc_probe(device_t);
-static int eeprom_fhc_attach(device_t);
-
-static device_method_t eeprom_fhc_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, eeprom_fhc_probe),
- DEVMETHOD(device_attach, eeprom_fhc_attach),
-
- /* clock interface */
- DEVMETHOD(clock_gettime, mk48txx_gettime),
- DEVMETHOD(clock_settime, mk48txx_settime),
-
- { 0, 0 }
-};
-
-static driver_t eeprom_fhc_driver = {
- "eeprom",
- eeprom_fhc_methods,
- 0,
-};
-
-DRIVER_MODULE(eeprom, fhc, eeprom_fhc_driver, eeprom_devclass, 0, 0);
-
-static int
-eeprom_fhc_probe(device_t dev)
-{
-
- if (strcmp("eeprom", fhc_get_name(dev)) == 0) {
- device_set_desc(dev, "FHC EEPROM/clock");
- return (0);
- }
- return (ENXIO);
-}
-
-/*
- * Attach a clock (really `eeprom') to the fhc.
- *
- * This is mapped read-only on NetBSD for safety, but this is not possible
- * with the current FreeBSD bus code.
- *
- * the MK48T02 is 2K. the MK48T08 is 8K, and the MK48T59 is supposed to be
- * identical to it.
- */
-static int
-eeprom_fhc_attach(device_t dev)
-{
- struct resource *res;
- int rid, error;
-
- rid = 0;
- res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
- if (res == NULL) {
- device_printf(dev, "could not allocate resources\n");
- return (ENXIO);
- }
- error = eeprom_attach(dev, fhc_get_node(dev), rman_get_bustag(res),
- rman_get_bushandle(res));
- return (error);
-}
diff --git a/sys/sparc64/sparc64/eeprom_sbus.c b/sys/sparc64/sparc64/eeprom_sbus.c
index 3bf0116..9273193 100644
--- a/sys/sparc64/sparc64/eeprom_sbus.c
+++ b/sys/sparc64/sparc64/eeprom_sbus.c
@@ -58,28 +58,25 @@
#include <sys/module.h>
#include <sys/resource.h>
+#include <dev/ofw/ofw_bus.h>
+
#include <machine/bus.h>
#include <machine/idprom.h>
#include <machine/resource.h>
#include <sys/rman.h>
-#include <dev/ofw/openfirm.h>
-
#include <machine/eeprom.h>
#include <dev/mk48txx/mk48txxreg.h>
-#include <sparc64/sbus/sbusvar.h>
-
#include "clock_if.h"
-static int eeprom_sbus_probe(device_t);
static int eeprom_sbus_attach(device_t);
static device_method_t eeprom_sbus_methods[] = {
/* Device interface */
- DEVMETHOD(device_probe, eeprom_sbus_probe),
+ DEVMETHOD(device_probe, eeprom_probe),
DEVMETHOD(device_attach, eeprom_sbus_attach),
/* clock interface */
@@ -95,22 +92,11 @@ static driver_t eeprom_sbus_driver = {
0,
};
+DRIVER_MODULE(eeprom, fhc, eeprom_sbus_driver, eeprom_devclass, 0, 0);
DRIVER_MODULE(eeprom, sbus, eeprom_sbus_driver, eeprom_devclass, 0, 0);
-
-static int
-eeprom_sbus_probe(device_t dev)
-{
-
- if (strcmp("eeprom", sbus_get_name(dev)) == 0) {
- device_set_desc(dev, "SBus EEPROM/clock");
- return (0);
- }
- return (ENXIO);
-}
-
/*
- * Attach a clock (really `eeprom') to the sbus.
+ * Attach a clock (really `eeprom') to fhc or sbus.
*
* This is mapped read-only on NetBSD for safety, but this is not possible
* with the current FreeBSD bus code.
@@ -130,7 +116,7 @@ eeprom_sbus_attach(device_t dev)
device_printf(dev, "could not allocate resources\n");
return (ENXIO);
}
- error = eeprom_attach(dev, sbus_get_node(dev), rman_get_bustag(res),
+ error = eeprom_attach(dev, rman_get_bustag(res),
rman_get_bushandle(res));
return (error);
}
diff --git a/sys/sparc64/sparc64/ofw_machdep.c b/sys/sparc64/sparc64/ofw_machdep.c
index 482fcb5..f4ba52a 100644
--- a/sys/sparc64/sparc64/ofw_machdep.c
+++ b/sys/sparc64/sparc64/ofw_machdep.c
@@ -30,10 +30,12 @@
*/
#include <sys/param.h>
+#include <sys/bus.h>
#include <sys/systm.h>
#include <net/ethernet.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
@@ -63,7 +65,7 @@ OF_getetheraddr2(device_t dev, u_char *addr)
{
phandle_t node;
- node = ofw_pci_get_node(dev);
+ node = ofw_bus_get_node(dev);
if (node <= 0)
return (-1);
return (OF_getprop(node, "local-mac-address", addr, ETHER_ADDR_LEN));
OpenPOWER on IntegriCloud