int mcd_attach(struct mcd_softc *sc) { int unit; unit = device_get_unit(sc->dev); MCD_LOCK(sc); sc->data.flags |= MCDINIT; mcd_soft_reset(sc); bioq_init(&sc->data.head); #ifdef NOTYET /* wire controller for interrupts and dma */ mcd_configure(sc); #endif MCD_UNLOCK(sc); /* name filled in probe */ sc->mcd_dev_t = make_dev(&mcd_cdevsw, 8 * unit, UID_ROOT, GID_OPERATOR, 0640, "mcd%d", unit); sc->mcd_dev_t->si_drv1 = (void *)sc; callout_init_mtx(&sc->timer, &sc->mtx, 0); return (0); }
void mcdattach(struct device *parent, struct device *self, void *aux) { struct mcd_softc *sc = (void *)self; struct isa_attach_args *ia = aux; bus_space_tag_t iot = ia->ia_iot; bus_space_handle_t ioh; struct mcd_mbox mbx; /* Map i/o space */ if (bus_space_map(iot, ia->ia_io[0].ir_addr, MCD_NPORT, 0, &ioh)) { printf(": can't map i/o space\n"); return; } mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE); sc->sc_iot = iot; sc->sc_ioh = ioh; sc->probe = 0; sc->debug = 0; if (!mcd_find(iot, ioh, sc)) { printf(": mcd_find failed\n"); return; } bufq_alloc(&sc->buf_queue, "disksort", BUFQ_SORT_RAWBLOCK); callout_init(&sc->sc_pintr_ch, 0); /* * Initialize and attach the disk structure. */ disk_init(&sc->sc_dk, device_xname(&sc->sc_dev), &mcddkdriver); disk_attach(&sc->sc_dk); printf(": model %s\n", sc->type != 0 ? sc->type : "unknown"); (void) mcd_setlock(sc, MCD_LK_UNLOCK); mbx.cmd.opcode = MCD_CMDCONFIGDRIVE; mbx.cmd.length = sizeof(mbx.cmd.data.config) - 1; mbx.cmd.data.config.subcommand = MCD_CF_IRQENABLE; mbx.cmd.data.config.data1 = 0x01; mbx.res.length = 0; (void) mcd_send(sc, &mbx, 0); mcd_soft_reset(sc); sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq, IST_EDGE, IPL_BIO, mcdintr, sc); }
int mcd_hard_reset(struct mcd_softc *sc) { struct mcd_mbox mbx; mcd_soft_reset(sc); mbx.cmd.opcode = MCD_CMDRESET; mbx.cmd.length = 0; mbx.res.length = 0; return mcd_send(sc, &mbx, 0); }
static int mcd_setflags(struct mcd_softc *sc) { /* check flags */ if ( (sc->data.status & (MCDDSKCHNG|MCDDOOROPEN)) || !(sc->data.status & MCDDSKIN)) { MCD_TRACE("setflags: sensed DSKCHNG or DOOROPEN or !DSKIN\n"); mcd_soft_reset(sc); return (-1); } if (sc->data.status & MCDAUDIOBSY) sc->data.audio_status = CD_AS_PLAY_IN_PROGRESS; else if (sc->data.audio_status == CD_AS_PLAY_IN_PROGRESS) sc->data.audio_status = CD_AS_PLAY_COMPLETED; return (0); }