diff options
| author | Mitsuru IWASAKI <iwasaki@FreeBSD.org> | 2006-04-15 12:31:34 +0000 |
|---|---|---|
| committer | Mitsuru IWASAKI <iwasaki@FreeBSD.org> | 2006-04-15 12:31:34 +0000 |
| commit | 858a52f46425ce4e1b69b7c2462aab2b77b2acf9 (patch) | |
| tree | 57443a0c29eee4bcf962bf261e8f771819778250 /sys/dev/ppc | |
| parent | be9365a9f296c439577ac6a314bf7343c8636703 (diff) | |
Notes
Diffstat (limited to 'sys/dev/ppc')
| -rw-r--r-- | sys/dev/ppc/ppc.c | 42 | ||||
| -rw-r--r-- | sys/dev/ppc/ppcvar.h | 1 |
2 files changed, 43 insertions, 0 deletions
diff --git a/sys/dev/ppc/ppc.c b/sys/dev/ppc/ppc.c index c6bc9cf81479..7e1ed40abc32 100644 --- a/sys/dev/ppc/ppc.c +++ b/sys/dev/ppc/ppc.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include <sys/module.h> #include <sys/bus.h> #include <sys/malloc.h> +#include <sys/kdb.h> #include <vm/vm.h> #include <vm/pmap.h> @@ -72,6 +73,7 @@ static device_method_t ppc_methods[] = { /* device interface */ DEVMETHOD(device_probe, ppc_isa_probe), DEVMETHOD(device_attach, ppc_attach), + DEVMETHOD(device_detach, ppc_detach), /* bus interface */ DEVMETHOD(bus_read_ivar, ppc_read_ivar), @@ -2007,6 +2009,46 @@ ppc_attach(device_t dev) return (0); } +int +ppc_detach(device_t dev) +{ + struct ppc_data *ppc = DEVTOSOFTC(dev); + device_t *children; + int nchildren, i; + + if (ppc->res_irq == 0) { + return (ENXIO); + } + + /* detach & delete all children */ + if (!device_get_children(dev, &children, &nchildren)) { + for (i = 0; i < nchildren; i++) + if (children[i]) + device_delete_child(dev, children[i]); + free(children, M_TEMP); + } + + if (ppc->res_irq != 0) { + bus_teardown_intr(dev, ppc->res_irq, ppc->intr_cookie); + bus_release_resource(dev, SYS_RES_IRQ, ppc->rid_irq, + ppc->res_irq); + } + if (ppc->res_ioport != 0) { + bus_deactivate_resource(dev, SYS_RES_IOPORT, ppc->rid_ioport, + ppc->res_ioport); + bus_release_resource(dev, SYS_RES_IOPORT, ppc->rid_ioport, + ppc->res_ioport); + } + if (ppc->res_drq != 0) { + bus_deactivate_resource(dev, SYS_RES_DRQ, ppc->rid_drq, + ppc->res_drq); + bus_release_resource(dev, SYS_RES_DRQ, ppc->rid_drq, + ppc->res_drq); + } + + return (0); +} + u_char ppc_io(device_t ppcdev, int iop, u_char *addr, int cnt, u_char byte) { diff --git a/sys/dev/ppc/ppcvar.h b/sys/dev/ppc/ppcvar.h index 9bef9080aa7a..98bc0225c598 100644 --- a/sys/dev/ppc/ppcvar.h +++ b/sys/dev/ppc/ppcvar.h @@ -30,6 +30,7 @@ int ppc_probe(device_t dev); int ppc_attach(device_t dev); +int ppc_detach(device_t dev); int ppc_read_ivar(device_t bus, device_t dev, int index, uintptr_t *val); int ppc_read(device_t, char *, int, int); |
