2 * Copyright (C) 2012 Margarida Gouveia
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
21 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 #include <sys/cdefs.h>
27 __FBSDID("$FreeBSD$");
29 #include <sys/param.h>
30 #include <sys/systm.h>
31 #include <sys/module.h>
34 #include <sys/kernel.h>
35 #include <sys/malloc.h>
38 #include <machine/bus.h>
39 #include <machine/platform.h>
40 #include <machine/intr_machdep.h>
41 #include <machine/resource.h>
43 #include <powerpc/wii/wii_ipcreg.h>
46 * Driver to interface with the Wii's IOS. IOS are small "microkernels" that run
47 * on the Broadway GPU and provide access to system services like USB.
49 static int wiiipc_probe(device_t);
50 static int wiiipc_attach(device_t);
55 static device_method_t wiiipc_methods[] = {
56 /* Device interface */
57 DEVMETHOD(device_probe, wiiipc_probe),
58 DEVMETHOD(device_attach, wiiipc_attach),
63 static driver_t wiiipc_driver = {
66 sizeof(struct wiiipc_softc)
69 static devclass_t wiiipc_devclass;
71 DRIVER_MODULE(wiiipc, wiibus, wiiipc_driver, wiiipc_devclass, 0, 0);
74 wiiipc_probe(device_t dev)
76 device_set_desc(dev, "Nintendo Wii IOS IPC");
78 return (BUS_PROBE_NOWILDCARD);
82 wiiipc_attach(device_t dev)
84 struct wiiipc_softc *sc;
86 sc = device_get_softc(dev);
91 sc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
92 &sc->sc_rrid, RF_ACTIVE);
93 if (sc->sc_rres == NULL) {
94 device_printf(dev, "could not alloc mem resource\n");
97 sc->sc_bt = rman_get_bustag(sc->sc_rres);
98 sc->sc_bh = rman_get_bushandle(sc->sc_rres);