Lines Matching defs:ib

117 typedef int ibhandler_t(struct ibfoo *ib);
181 struct ibfoo *ib;
183 ib = u->ibfoo;
186 switch (ib->mode) {
190 if (ib->buflen == 0)
192 upd7210_wr(u, CDOR, *ib->buf);
193 ib->buf++;
194 ib->buflen--;
199 *ib->buf = upd7210_rd(u, DIR);
200 ib->buf++;
201 ib->buflen--;
202 if (ib->buflen == 0 || (u->rreg[ISR1] & IXR1_ENDRX))
208 if (ib->buflen == 0)
210 if (ib->buflen == 1 && ib->doeoi)
212 upd7210_wr(u, CDOR, *ib->buf);
213 ib->buf++;
214 ib->buflen--;
223 while (ib->buflen != 0 && (isr_3 & 0x04 /* NEF */) != 0) {
224 *ib->buf = bus_read_1(u->reg_res[0], fifob);
225 ib->buf++;
226 ib->buflen--;
231 ib->buflen == 0)
242 if (ib->buflen == 0)
245 while (ib->buflen != 0 && (isr_3 & 0x08 /* NFF */) != 0) {
246 bus_write_1(u->reg_res[0], fifob, *ib->buf);
247 ib->buf++;
248 ib->buflen--;
254 if (ib->buflen == 0)
267 ib->mode = BUSY;
268 wakeup(&ib->buflen);
276 struct ibfoo *ib;
281 ib = u->ibfoo;
283 if (ib->mode == DMA_IDATA && isa_dmatc(u->dmachan)) {
287 ib->mode = BUSY;
288 wakeup(&ib->buflen);
290 if (ib->mode > BUSY) {
299 if (ib->mode != IDLE && timevalisset(&ib->deadline)) {
301 if (timevalcmp(&ib->deadline, &tv, <)) {
302 ib_had_timeout(ib->ap);
309 ib->mode = BUSY;
310 wakeup(&ib->buflen);
313 if (ib->mode != IDLE)
314 callout_reset(&ib->callout, hz / 5, gpib_ib_timeout, arg);
319 gpib_ib_wait_xfer(struct upd7210 *u, struct ibfoo *ib)
324 while (ib->mode > BUSY) {
325 i = msleep(&ib->buflen, &u->mutex,
328 ib_set_errno(ib->ap, i);
332 ib_set_error(ib->ap, EABO); /* XXX ? */
337 ib->ap->__retval |= END;
338 ib->ap->__ibsta |= END;
341 ib->ap->__retval |= SRQI;
342 ib->ap->__ibsta |= SRQI;
344 ib->mode = BUSY;
345 ib->buf = NULL;
377 struct ibfoo *ib;
381 ib = u->ibfoo;
382 LIST_FOREACH(h, &ib->handles, list) {
395 struct ibfoo *ib;
397 ib = u->ibfoo;
399 if (ib->rdh != NULL || ib->wrh != NULL) {
401 ib->rdh = NULL;
402 ib->wrh = NULL;
405 ib->buf = cmd;
406 ib->buflen = len;
409 ib->mode = FIFO_CMD;
420 ib->mode = PIO_CMD;
425 gpib_ib_wait_xfer(u, ib);
431 return (len - ib->buflen);
437 struct ibfoo *ib;
439 ib = u->ibfoo;
444 ib->buf = data;
445 ib->buflen = len;
448 ib->mode = FIFO_ODATA;
450 if (ib->doeoi)
461 ib->mode = PIO_ODATA;
465 gpib_ib_wait_xfer(u, ib);
471 return (len - ib->buflen);
477 struct ibfoo *ib;
479 ib = u->ibfoo;
482 ib->buf = data;
483 ib->buflen = len;
486 ib->mode = FIFO_IDATA;
497 ib->mode = PIO_IDATA;
501 gpib_ib_wait_xfer(u, ib);
507 return (len - ib->buflen);
514 struct ibfoo *ib;
517 ib = u->ibfoo;
518 ib->mode = DMA_IDATA;
523 gpib_ib_wait_xfer(u, ib);
531 ib_send_msg(struct ibfoo *ib, int msg)
539 buf[i++] = LAD | ib->h->pad;
540 if (ib->h->sad)
541 buf[i++] = LAD | TAD | ib->h->sad;
544 j = pio_cmd(ib->u, buf, i);
546 ib_set_error(ib->ap, EABO); /* XXX ? */
551 ibask(struct ibfoo *ib)
554 ibdebug = ib->ap->option;
562 ibclr(struct ibfoo *ib)
565 return (ib_send_msg(ib, SDC));
573 ibdev(struct ibfoo *ib)
578 h->handle = alloc_unr(ib->unrhdr);
580 h->pad = ib->ap->pad;
581 h->sad = ib->ap->sad;
582 h->timeout = timeouts[ib->ap->tmo];
583 h->eot = ib->ap->eot;
584 h->eos = ib->ap->eos;
585 mtx_lock(&ib->u->mutex);
586 LIST_INSERT_HEAD(&ib->handles, h, list);
587 mtx_unlock(&ib->u->mutex);
588 ib->ap->__retval = h->handle;
595 ibdma(struct ibfoo *ib)
598 if (ib->u->dmachan < 0 && ib->ap->v)
599 return (ib_set_error(ib->ap, EARG));
600 ib->h->dma = ib->ap->v;
605 ibeos(struct ibfoo *ib)
608 ib->ap->__iberr = ib->h->eos;
609 ib->h->eos = ib->ap->eos;
610 if (ib->rdh == ib->h)
611 config_eos(ib->u, ib->h);
616 ibeot(struct ibfoo *ib)
619 ib->h->eot = ib->ap->eot;
632 ibloc(struct ibfoo *ib)
635 if (ib->h->kind == H_BOARD)
637 return (ib_send_msg(ib, GTL));
641 ibonl(struct ibfoo *ib)
644 if (ib->ap->v)
646 mtx_lock(&ib->u->mutex);
647 LIST_REMOVE(ib->h, list);
648 mtx_unlock(&ib->u->mutex);
649 free(ib->h, M_IBFOO);
650 ib->h = NULL;
655 ibpad(struct ibfoo *ib)
658 ib->h->pad = ib->ap->pad;
667 ibrd(struct ibfoo *ib)
673 if (ib->h->kind == H_BOARD)
675 bl = ib->ap->cnt;
680 if (ib->rdh != ib->h) {
685 buf[i++] = TAD | ib->h->pad;
686 if (ib->h->sad)
687 buf[i++] = ib->h->sad;
688 i = pio_cmd(ib->u, buf, i);
689 config_eos(ib->u, ib->h);
690 ib->rdh = ib->h;
691 ib->wrh = NULL;
693 upd7210_goto_standby(ib->u);
694 dp = ib->ap->buffer;
695 bc = ib->ap->cnt;
697 while (bc > 0 && ib->ap->__iberr == 0) {
699 if (ib->h->dma)
700 i = dma_idata(ib->u, bp, j);
702 i = pio_idata(ib->u, bp, j);
706 ib->ap->__ibcnt += i;
712 upd7210_take_ctrl_async(ib->u);
726 ibsad(struct ibfoo *ib)
729 ib->h->sad = ib->ap->sad;
736 ibsic(struct ibfoo *ib)
739 upd7210_wr(ib->u, AUXMR, AUXMR_SIFC);
741 upd7210_wr(ib->u, AUXMR, AUXMR_CIFC);
750 ibtmo(struct ibfoo *ib)
753 ib->h->timeout = timeouts[ib->ap->tmo];
760 ibtrg(struct ibfoo *ib)
763 return (ib_send_msg(ib, GET));
769 ibwrt(struct ibfoo *ib)
774 if (ib->h->kind == H_BOARD)
776 bp = malloc(ib->ap->cnt, M_IBFOO, M_WAITOK);
778 i = copyin(ib->ap->buffer, bp, ib->ap->cnt);
783 if (ib->wrh != ib->h) {
787 buf[i++] = LAD | ib->h->pad;
788 if (ib->h->sad)
789 buf[i++] = LAD | TAD | ib->h->sad;
791 i = pio_cmd(ib->u, buf, i);
792 ib->rdh = NULL;
793 ib->wrh = ib->h;
794 config_eos(ib->u, ib->h);
796 upd7210_goto_standby(ib->u);
797 ib->doeoi = ib->h->eot;
798 i = pio_odata(ib->u, bp, ib->ap->cnt);
799 upd7210_take_ctrl_async(ib->u);
800 ib->ap->__ibcnt = i;
894 struct ibfoo *ib;
923 ib = malloc(sizeof *ib, M_IBFOO, M_WAITOK | M_ZERO);
924 LIST_INIT(&ib->handles);
925 callout_init(&ib->callout, CALLOUT_MPSAFE);
926 ib->unrhdr = new_unrhdr(0, INT_MAX, NULL);
927 dev->si_drv2 = ib;
928 ib->u = u;
929 u->ibfoo = ib;
965 struct ibfoo *ib;
968 ib = dev->si_drv2;
974 free(ib, M_IBFOO);
1002 struct ibfoo *ib;
1007 ib = u->ibfoo;
1078 error = msleep(ib, &u->mutex,
1096 ib->ap = ap;
1097 ib->h = h;
1098 ib->mode = BUSY;
1099 ib->deadline = deadline;
1100 callout_reset(&ib->callout, hz / 5, gpib_ib_timeout, u);
1102 error = ih->func(ib);
1105 ib->mode = IDLE;
1106 ib->ap = NULL;
1107 ib->h = NULL;
1109 callout_stop(&ib->callout);
1113 wakeup(ib);