From owner-p4-projects@FreeBSD.ORG Wed Jun 9 09:20:34 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BA58316A4D9; Wed, 9 Jun 2004 09:20:33 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 60D2816A4D8 for ; Wed, 9 Jun 2004 09:20:33 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 41B7143D39 for ; Wed, 9 Jun 2004 09:20:33 +0000 (GMT) (envelope-from jmallett@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i599KXMw063822 for ; Wed, 9 Jun 2004 09:20:33 GMT (envelope-from jmallett@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i599KWxP063818 for perforce@freebsd.org; Wed, 9 Jun 2004 09:20:32 GMT (envelope-from jmallett@freebsd.org) Date: Wed, 9 Jun 2004 09:20:32 GMT Message-Id: <200406090920.i599KWxP063818@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jmallett@freebsd.org using -f From: Juli Mallett To: Perforce Change Reviews Subject: PERFORCE change 54461 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jun 2004 09:20:34 -0000 http://perforce.freebsd.org/chv.cgi?CH=54461 Change 54461 by jmallett@jmallett_oingo on 2004/06/09 09:20:22 Do evil GIO64 things which aren't really evil. Gotta do hints stuff to be able to look up children rather than this crap done to check for products ala NetBSD. Affected files ... .. //depot/projects/mips/sys/mips/sgimips/gio/gio.c#2 edit Differences ... ==== //depot/projects/mips/sys/mips/sgimips/gio/gio.c#2 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $P4: //depot/projects/mips/sys/mips/sgimips/gio/gio.c#1 $ + * $P4: //depot/projects/mips/sys/mips/sgimips/gio/gio.c#2 $ */ #include @@ -34,9 +34,11 @@ #include #include #include +#include #include #include +#include static devclass_t gio_devclass; @@ -44,12 +46,11 @@ * Device methods */ static int gio_probe(device_t); -static int gio_attach(device_t); static device_method_t gio_methods[] = { /* Device interface */ DEVMETHOD(device_probe, gio_probe), - DEVMETHOD(device_attach, gio_attach), + DEVMETHOD(device_attach, bus_generic_attach), DEVMETHOD(device_detach, bus_generic_detach), DEVMETHOD(device_shutdown, bus_generic_shutdown), @@ -64,27 +65,72 @@ "gio", gio_methods, 1 }; +static struct gio_device { + const char *gd_name; + uint32_t gd_product; +} gio_devices[] = { + { NULL, 0x00000000 } +}; + +static struct gio_ivar gio_slots[] = { + { NULL, 0x1f000000 }, + { NULL, 0x1f400000 }, + { NULL, 0x1f600000 }, + { NULL, 0x00000000 } +}; + +static int +gio_configure(device_t gio, struct gio_ivar *iv) +{ + struct gio_device *gd; + uint32_t product; + device_t dev; + + product = bus_space_read_4(iv->gi_tag, iv->gi_handle, 0); + for (gd = gio_devices; gd->gd_name != NULL; gd++) { + if (gd->gd_product == product) { + dev = device_add_child(gio, gd->gd_name, -1); + if (dev != NULL) { + device_set_ivars(dev, iv); + return (0); + } + } + } + return (ENOENT); +} + static int gio_probe(device_t dev) { + struct gio_ivar *iv; + int count; + int error; + + count = 0; + switch (mach_type) { case MACH_SGI_IP22: + device_set_desc(dev, "GIO64 Bus"); + for (iv = gio_slots; iv->gi_handle != 0; iv++) { + if (iv->gi_tag != NULL) + continue; + count++; + iv->gi_tag = device_space_tag; + error = gio_configure(dev, iv); + if (error != 0) { + iv->gi_tag = NULL; + count--; + } + } + if (count == 0) + device_printf(dev, "no children found\n"); + device_add_child(dev, "hpc", 0); + device_add_child(dev, "hpc", 1); + device_add_child(dev, "hpc", 2); return (0); default: return (ENOENT); } } -#define GIO_READ_4(port, r) \ - (*(volatile uint32_t *)(MIPS_PHYS_TO_KSEG1(port) | r)) - -#define GIO_WRITE_4(port, r, v) \ - ((*(volatile uint32_t *)(MIPS_PHYS_TO_KSEG1(port) | r)) = (v)) - -static int -gio_attach(device_t dev) -{ - return (0); -} - DRIVER_MODULE(gio, imc, gio_driver, gio_devclass, 0, 0);