|
|
| version 1.8, 2004/05/13 23:49:19 | version 1.9, 2004/05/19 22:52:49 |
|---|---|
| Line 112 | Line 112 |
| #define IO_SIZE 0x04 | #define IO_SIZE 0x04 |
| #define MEM_SIZE 0x8000 | #define MEM_SIZE 0x8000 |
| #define DGM_UNITMASK 0x30000 | |
| #define DGM_UNIT(unit) ((unit) << 16) | |
| struct dgm_softc; | struct dgm_softc; |
| /* digiboard port structure */ | /* digiboard port structure */ |
| Line 261 dgmmodhandler(module_t mod, int event, v | Line 264 dgmmodhandler(module_t mod, int event, v |
| switch (event) { | switch (event) { |
| case MOD_LOAD: | case MOD_LOAD: |
| cdevsw_add(&dgm_cdevsw); | |
| break; | break; |
| case MOD_UNLOAD: | case MOD_UNLOAD: |
| cdevsw_remove(&dgm_cdevsw); | |
| break; | break; |
| } | } |
| Line 421 dgmprobe(device_t dev) | Line 421 dgmprobe(device_t dev) |
| struct dgm_softc *sc = device_get_softc(dev); | struct dgm_softc *sc = device_get_softc(dev); |
| int i, v; | int i, v; |
| /* | |
| * Assign unit number. Due to bits we use in the minor number for | |
| * the various tty types, only 4 units are supported. | |
| */ | |
| sc->unit = device_get_unit(dev); | sc->unit = device_get_unit(dev); |
| if (sc->unit > 3) { | |
| device_printf(dev, "Too many units, only 4 supported\n"); | |
| return(ENXIO); | |
| } | |
| /* Check that we've got a valid i/o address */ | /* Check that we've got a valid i/o address */ |
| if ((sc->port = bus_get_resource_start(dev, SYS_RES_IOPORT, 0)) == 0) | if ((sc->port = bus_get_resource_start(dev, SYS_RES_IOPORT, 0)) == 0) |
| Line 775 dgmattach(device_t dev) | Line 783 dgmattach(device_t dev) |
| else | else |
| shrinkmem = 0; | shrinkmem = 0; |
| cdevsw_add(&dgm_cdevsw, DGM_UNITMASK, DGM_UNIT(sc->unit)); | |
| for (i = 0; i < sc->numports; i++, bc++) { | for (i = 0; i < sc->numports; i++, bc++) { |
| DPRINT3(DB_INFO, "dgm%d: Set up port %d\n", sc->unit, i); | DPRINT3(DB_INFO, "dgm%d: Set up port %d\n", sc->unit, i); |
| port = &sc->ports[i]; | port = &sc->ports[i]; |
| Line 887 dgmdetach(device_t dev) | Line 896 dgmdetach(device_t dev) |
| DPRINT2(DB_INFO, "dgm%d: detach\n", sc->unit); | DPRINT2(DB_INFO, "dgm%d: detach\n", sc->unit); |
| for (i = 0; i < sc->numports; i++) { | /* |
| destroy_dev(makedev(CDEV_MAJOR, sc->unit * 65536 + i)); | * The cdevsw_remove() call will destroy all associated devices |
| destroy_dev(makedev(CDEV_MAJOR, sc->unit * 65536 + i + 64)); | * and dereference any ad-hoc-created devices, but does not |
| destroy_dev(makedev(CDEV_MAJOR, sc->unit * 65536 + i + 128)); | * dereference devices created via make_dev(). |
| destroy_dev(makedev(CDEV_MAJOR, sc->unit * 65536 + i + 262144)); | */ |
| destroy_dev(makedev(CDEV_MAJOR, sc->unit * 65536 + i + 262208)); | cdevsw_remove(&dgm_cdevsw, DGM_UNITMASK, DGM_UNIT(sc->unit)); |
| destroy_dev(makedev(CDEV_MAJOR, sc->unit * 65536 + i + 262272)); | |
| } | |
| untimeout(dgmpoll, (void *)(int)sc->unit, sc->toh); | untimeout(dgmpoll, (void *)(int)sc->unit, sc->toh); |
| callout_handle_init(&sc->toh); | callout_handle_init(&sc->toh); |