- addr = (struct dmcdevice *)ui->ui_addr;
- addr->bsel2 |= DMC_IEO;
- base = sc->sc_ubinfo & 0x3ffff;
- printd(" base 0x%x\n", base);
- dmcload(sc, DMC_BASEI, base, (base>>2)&DMC_XMEM);
- dmcload(sc, DMC_CNTLI, 0, 0);
- base = sc->sc_ifuba.ifu_r.ifrw_info & 0x3ffff;
- dmcload(sc, DMC_READ, base, ((base>>2)&DMC_XMEM)|DMCMTU);
- printd(" first read queued, addr 0x%x\n", base);
+ sc->sc_flag &= ~DMC_ONLINE;
+ sc->sc_flag |= DMC_RUNNING;
+ /*
+ * Limit packets enqueued until we see if we're on the air.
+ */
+ ifp->if_snd.ifq_maxlen = 3;
+
+ /* initialize buffer pool */
+ /* receives */
+ ifrw = &sc->sc_ifr[0];
+ for (rp = &sc->sc_rbufs[0]; rp < &sc->sc_rbufs[NRCV]; rp++) {
+ rp->ubinfo = UBAI_ADDR(ifrw->ifrw_info);
+ rp->cc = DMCMTU + sizeof (struct dmc_header);
+ rp->flags = DBUF_OURS|DBUF_RCV;
+ ifrw++;
+ }
+ /* transmits */
+ ifxp = &sc->sc_ifw[0];
+ for (rp = &sc->sc_xbufs[0]; rp < &sc->sc_xbufs[NXMT]; rp++) {
+ rp->ubinfo = UBAI_ADDR(ifxp->ifw_info);
+ rp->cc = 0;
+ rp->flags = DBUF_OURS|DBUF_XMIT;
+ ifxp++;
+ }
+
+ /* set up command queues */
+ sc->sc_qfreeh = sc->sc_qfreet
+ = sc->sc_qhead = sc->sc_qtail = sc->sc_qactive =
+ (struct dmc_command *)0;
+ /* set up free command buffer list */
+ for (qp = &sc->sc_cmdbuf[0]; qp < &sc->sc_cmdbuf[NCMDS]; qp++) {
+ QUEUE_AT_HEAD(qp, sc->sc_qfreeh, sc->sc_qfreet);
+ }
+
+ /* base in */
+ base = UBAI_ADDR(sc->sc_ubinfo);
+ dmcload(sc, DMC_BASEI, (u_short)base, (base>>2) & DMC_XMEM);
+ /* specify half duplex operation, flags tell if primary */
+ /* or secondary station */
+ if (ui->ui_flags == 0)
+ /* use DDCMP mode in full duplex */
+ dmcload(sc, DMC_CNTLI, 0, 0);
+ else if (ui->ui_flags == 1)
+ /* use MAINTENENCE mode */
+ dmcload(sc, DMC_CNTLI, 0, DMC_MAINT );
+ else if (ui->ui_flags == 2)
+ /* use DDCMP half duplex as primary station */
+ dmcload(sc, DMC_CNTLI, 0, DMC_HDPLX);
+ else if (ui->ui_flags == 3)
+ /* use DDCMP half duplex as secondary station */
+ dmcload(sc, DMC_CNTLI, 0, DMC_HDPLX | DMC_SEC);
+
+ /* enable operation done interrupts */
+ while ((addr->bsel2 & DMC_IEO) == 0)
+ addr->bsel2 |= DMC_IEO;
+ s = spl5();
+ /* queue first NRCV buffers for DMC to fill */
+ for (rp = &sc->sc_rbufs[0]; rp < &sc->sc_rbufs[NRCV]; rp++) {
+ rp->flags |= DBUF_DMCS;
+ dmcload(sc, DMC_READ, rp->ubinfo,
+ (((rp->ubinfo>>2)&DMC_XMEM) | rp->cc));
+ sc->sc_iused++;
+ }
+ splx(s);