Deleted Added
full compact
ibfoo.c (178250) ibfoo.c (199104)
1/*-
2 * Copyright (c) 2005 Poul-Henning Kamp <phk@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * High-level driver for �PD7210 based GPIB cards.
27 *
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2005 Poul-Henning Kamp <phk@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * High-level driver for �PD7210 based GPIB cards.
27 *
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/ieee488/ibfoo.c 178250 2008-04-16 16:47:14Z kris $");
31__FBSDID("$FreeBSD: head/sys/dev/ieee488/ibfoo.c 199104 2009-11-09 20:29:10Z rdivacky $");
32
33# define IBDEBUG
34# undef IBDEBUG
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/conf.h>
39#include <sys/malloc.h>

--- 352 unchanged lines hidden (view full) ---

392dma_idata(struct upd7210 *u, u_char *data, int len)
393{
394 int j;
395 struct ibfoo *ib;
396
397 KASSERT(u->dmachan >= 0, ("Bogus dmachan %d", u->dmachan));
398 ib = u->ibfoo;
399 ib->mode = DMA_IDATA;
32
33# define IBDEBUG
34# undef IBDEBUG
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/conf.h>
39#include <sys/malloc.h>

--- 352 unchanged lines hidden (view full) ---

392dma_idata(struct upd7210 *u, u_char *data, int len)
393{
394 int j;
395 struct ibfoo *ib;
396
397 KASSERT(u->dmachan >= 0, ("Bogus dmachan %d", u->dmachan));
398 ib = u->ibfoo;
399 ib->mode = DMA_IDATA;
400 mtx_lock(&Giant);
401 isa_dmastart(ISADMA_READ, data, len, u->dmachan);
400 isa_dmastart(ISADMA_READ, data, len, u->dmachan);
402 mtx_unlock(&Giant);
403 mtx_lock(&u->mutex);
404 upd7210_wr(u, IMR1, IXR1_ENDRX);
405 upd7210_wr(u, IMR2, IMR2_DMAI);
406 gpib_ib_wait_xfer(u, ib);
407 mtx_unlock(&u->mutex);
401 mtx_lock(&u->mutex);
402 upd7210_wr(u, IMR1, IXR1_ENDRX);
403 upd7210_wr(u, IMR2, IMR2_DMAI);
404 gpib_ib_wait_xfer(u, ib);
405 mtx_unlock(&u->mutex);
408 mtx_lock(&Giant);
409 j = isa_dmastatus(u->dmachan);
410 isa_dmadone(ISADMA_READ, data, len, u->dmachan);
406 j = isa_dmastatus(u->dmachan);
407 isa_dmadone(ISADMA_READ, data, len, u->dmachan);
411 mtx_unlock(&Giant);
412 return (len - j);
413}
414
415static int
416ib_send_msg(struct ibfoo *ib, int msg)
417{
418 u_char buf[10];
419 int i, j;

--- 365 unchanged lines hidden (view full) ---

785 if (u->busy) {
786 mtx_unlock(&u->mutex);
787 return (EBUSY);
788 }
789 u->busy = 1;
790 mtx_unlock(&u->mutex);
791
792 if (u->dmachan >= 0) {
408 return (len - j);
409}
410
411static int
412ib_send_msg(struct ibfoo *ib, int msg)
413{
414 u_char buf[10];
415 int i, j;

--- 365 unchanged lines hidden (view full) ---

781 if (u->busy) {
782 mtx_unlock(&u->mutex);
783 return (EBUSY);
784 }
785 u->busy = 1;
786 mtx_unlock(&u->mutex);
787
788 if (u->dmachan >= 0) {
793 mtx_lock(&Giant);
794 error = isa_dma_acquire(u->dmachan);
795 if (!error) {
796 error = isa_dma_init(u->dmachan, PAGE_SIZE, M_WAITOK);
797 if (error)
798 isa_dma_release(u->dmachan);
799 }
789 error = isa_dma_acquire(u->dmachan);
790 if (!error) {
791 error = isa_dma_init(u->dmachan, PAGE_SIZE, M_WAITOK);
792 if (error)
793 isa_dma_release(u->dmachan);
794 }
800 mtx_unlock(&Giant);
801 }
802
803 if (error) {
804 mtx_lock(&u->mutex);
805 u->busy = 0;
806 mtx_unlock(&u->mutex);
807 return (error);
808 }

--- 41 unchanged lines hidden (view full) ---

850 /* XXX: assert pointer consistency */
851
852 u->ibfoo = NULL;
853 /* XXX: free handles */
854 dev->si_drv2 = NULL;
855 free(ib, M_IBFOO);
856
857 if (u->dmachan >= 0) {
795 }
796
797 if (error) {
798 mtx_lock(&u->mutex);
799 u->busy = 0;
800 mtx_unlock(&u->mutex);
801 return (error);
802 }

--- 41 unchanged lines hidden (view full) ---

844 /* XXX: assert pointer consistency */
845
846 u->ibfoo = NULL;
847 /* XXX: free handles */
848 dev->si_drv2 = NULL;
849 free(ib, M_IBFOO);
850
851 if (u->dmachan >= 0) {
858 mtx_lock(&Giant);
859 isa_dma_release(u->dmachan);
852 isa_dma_release(u->dmachan);
860 mtx_unlock(&Giant);
861 }
862 mtx_lock(&u->mutex);
863 u->busy = 0;
864 ibdebug = 0;
865 upd7210_wr(u, IMR1, 0x00);
866 upd7210_wr(u, IMR2, 0x00);
867 upd7210_wr(u, AUXMR, AUXMR_CRST);
868 DELAY(10000);

--- 137 unchanged lines hidden ---
853 }
854 mtx_lock(&u->mutex);
855 u->busy = 0;
856 ibdebug = 0;
857 upd7210_wr(u, IMR1, 0x00);
858 upd7210_wr(u, IMR2, 0x00);
859 upd7210_wr(u, AUXMR, AUXMR_CRST);
860 DELAY(10000);

--- 137 unchanged lines hidden ---