diff options
author | rgrimes <rgrimes@FreeBSD.org> | 1995-05-30 08:16:23 +0000 |
---|---|---|
committer | rgrimes <rgrimes@FreeBSD.org> | 1995-05-30 08:16:23 +0000 |
commit | c86f0c7a71e7ade3e38b325c186a9cf374e0411e (patch) | |
tree | 176f04f674860c7cfae9ac5d2ff4d4e1d73cb2b7 /sys/i386/isa/gpib.c | |
parent | 423ba8f9bc23d93bfc244aca9b12563b1c9de90d (diff) | |
download | FreeBSD-src-c86f0c7a71e7ade3e38b325c186a9cf374e0411e.zip FreeBSD-src-c86f0c7a71e7ade3e38b325c186a9cf374e0411e.tar.gz |
Remove trailing whitespace.
Diffstat (limited to 'sys/i386/isa/gpib.c')
-rw-r--r-- | sys/i386/isa/gpib.c | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/sys/i386/isa/gpib.c b/sys/i386/isa/gpib.c index 34e83bb..5d1d1a2 100644 --- a/sys/i386/isa/gpib.c +++ b/sys/i386/isa/gpib.c @@ -2,10 +2,10 @@ /* * GPIB driver for FreeBSD. * Version 0.1 (No interrupts, no DMA) - * Supports National Instruments AT-GPIB and AT-GPIB/TNT boards. + * Supports National Instruments AT-GPIB and AT-GPIB/TNT boards. * (AT-GPIB not tested, but it should work) - * - * Written by Fred Cawthorne (fcawth@delphi.umd.edu) + * + * Written by Fred Cawthorne (fcawth@delphi.umd.edu) * Some sections were based partly on the lpt driver. * (some remnants may remain) * @@ -22,7 +22,7 @@ #include "gp.h" -#if NGP > 0 +#if NGP > 0 #include "param.h" #include "buf.h" @@ -44,9 +44,9 @@ #define MIN(a,b) ((a < b) ? a : b) -#define GPIBPRI (PZERO+8)|PCATCH +#define GPIBPRI (PZERO+8)|PCATCH #define SLEEP_MAX 1000 -#define SLEEP_MIN 4 +#define SLEEP_MIN 4 int initgpib(void); void closegpib(void); @@ -73,7 +73,7 @@ struct isa_driver gpdriver = {gpprobe, gpattach, "gp"}; #define BUFSIZE 1024 #define ATTACHED 0x08 #define OPEN 0x04 -#define INIT 0x02 +#define INIT 0x02 static struct gpib_softc { @@ -81,7 +81,7 @@ static struct gpib_softc { int sc_count; /* bytes queued in sc_inbuf */ int sc_type; /* Type of gpib controller */ u_char sc_flags; /* flags (open and internal) */ - char sc_unit; /* gpib device number */ + char sc_unit; /* gpib device number */ char *sc_inbuf; /* buffer for data */ } gpib_sc; static int oldcount; @@ -112,7 +112,7 @@ else if ((inb(KSR)&0xF7)==0x14) sc->sc_type=1; /* * gpattach() - * Attach device and print the type of card to the screen. + * Attach device and print the type of card to the screen. */ int gpattach(isdp) @@ -121,13 +121,13 @@ gpattach(isdp) struct gpib_softc *sc = &gpib_sc; sc->sc_unit = isdp->id_unit; - if (sc->sc_type==3) - printf ("gp%d: type AT-GPIB/TNT\n",sc->sc_unit); + if (sc->sc_type==3) + printf ("gp%d: type AT-GPIB/TNT\n",sc->sc_unit); if (sc->sc_type==2) - printf ("gp%d: type AT-GPIB chip NAT4882B\n",sc->sc_unit); + printf ("gp%d: type AT-GPIB chip NAT4882B\n",sc->sc_unit); if (sc->sc_type==1) - printf ("gp%d: type AT-GPIB chip NAT4882A\n",sc->sc_unit); - sc->sc_flags |=ATTACHED; + printf ("gp%d: type AT-GPIB chip NAT4882A\n",sc->sc_unit); + sc->sc_flags |=ATTACHED; return (1); } @@ -149,7 +149,7 @@ gpopen(dev, flag) u_char sta, unit; int status; int counter; - + unit= minor(dev); /* minor number out of limits ? */ @@ -170,8 +170,8 @@ gpopen(dev, flag) sc->sc_inbuf = malloc(BUFSIZE, M_DEVBUF, M_WAITOK); if (sc->sc_inbuf == 0) return(ENOMEM); - - if (initgpib()) return(EBUSY); + + if (initgpib()) return(EBUSY); sc->sc_flags |= OPEN; sc->sc_count = 0; oldcount=0; @@ -215,13 +215,13 @@ enableremote(unit); /* * gpclose() - * Close gpib device. + * Close gpib device. */ int gpclose(dev, flag) dev_t dev; int flag; - + { struct gpib_softc *sc = &gpib_sc; unsigned char unit; @@ -241,7 +241,7 @@ if (unit!=0) { /*Here we need to send the last character with EOS*/ while ((inb(ISR3)&0x04)&&status==EWOULDBLOCK); /*Fifo is not empty*/ outb(CMDR,0x08); /*Issue STOP to TURBO488*/ - + /*Wait for DONE and STOP*/ if (status==EWOULDBLOCK) do { status=tsleep((caddr_t)&gpib_sc,GPIBPRI,"gpibpoll",1); @@ -256,7 +256,7 @@ if (unit!=0) { /*Here we need to send the last character with EOS*/ /*Send last byte with EOI set*/ /*Send second to last byte if there are 2 bytes left*/ -if (status==EWOULDBLOCK) { +if (status==EWOULDBLOCK) { do if (!(inb(ISR1)&2)) status=tsleep((caddr_t)&gpib_sc, GPIBPRI,"gpibpoll",1); @@ -265,19 +265,19 @@ if (oldcount==2){ outb(CDOR,oldbytes[0]); /*Send second to last byte*/ while (!(inb(ISR1)&2)&&(status==EWOULDBLOCK)); status=tsleep((caddr_t)&gpib_sc, GPIBPRI,"gpibpoll",1); - } + } outb(AUXMR,seoi); /*Set EOI for the last byte*/ outb(AUXMR,0x5E); /*Clear SYNC*/ if (oldcount==1) outb(CDOR,oldbytes[0]); - else + else if (oldcount==2) outb(CDOR,oldbytes[1]); else { outb (CDOR,13); /*Send a CR.. we've got trouble*/ printf("gpib: Warning: gpclose called with nothing left in buffer\n"); - } + } } do @@ -330,8 +330,8 @@ gpwrite(dev, uio) while ((gpib_sc.sc_count = MIN(BUFSIZE-1, uio->uio_resid)) > 0) { /* If there were >1 bytes left over, send them */ if (oldcount==2) - sendrawgpibfifo(minor(dev),oldbytes,2); - + sendrawgpibfifo(minor(dev),oldbytes,2); + /*If there was 1 character left, put it at the beginning of the new buffer*/ if (oldcount==1){ @@ -339,7 +339,7 @@ gpwrite(dev, uio) gpib_sc.sc_cp = gpib_sc.sc_inbuf; /* get from user-space */ uiomove(gpib_sc.sc_inbuf+1, gpib_sc.sc_count, uio); - gpib_sc.sc_count++; + gpib_sc.sc_count++; } else { gpib_sc.sc_cp = gpib_sc.sc_inbuf; @@ -348,7 +348,7 @@ gpwrite(dev, uio) } /*NOTE we always leave one byte in case this is the last write - so close can send EOI with the last byte There may be 2 bytes + so close can send EOI with the last byte There may be 2 bytes since we are doing 16 bit transfers.(note the -1 in the count below)*/ /*If count<=2 we'll either pick it up on the next write or on close*/ if (gpib_sc.sc_count>2) { @@ -357,12 +357,12 @@ gpwrite(dev, uio) if (err) return(1); oldcount=gpib_sc.sc_count-count; /*Set # of remaining bytes*/ - gpib_sc.sc_count-=count; + gpib_sc.sc_count-=count; gpib_sc.sc_cp+=count; /*point char pointer to remaining bytes*/ } else oldcount=gpib_sc.sc_count; oldbytes[0]=gpib_sc.sc_cp[0]; - if (oldcount==2) + if (oldcount==2) oldbytes[1]=gpib_sc.sc_cp[1]; } return(0); @@ -384,7 +384,7 @@ gpioctl(dev_t dev, int cmd, struct gpibdata *gd) break; case GPIBREAD: result=readgpibfifo(gd->address,gd->data,*(gd->count)); - *(gd->count)=result; + *(gd->count)=result; error=0; break; case GPIBINIT: @@ -490,11 +490,11 @@ int initgpib() { outb(EOSR,10); /*set EOS message to newline*/ /*should I make the default to interpret END as EOS?*/ - /*It isn't now. The following changes this*/ + /*It isn't now. The following changes this*/ outb(AUXMR,0x80); /*No special EOS handling*/ /*outb(AUXMR,0x88) */ /* Transmit END with EOS*/ /*outb(AUXMR,0x84) */ /* Set END on EOS received*/ - /*outb(AUXMR,0x8C) */ /* Do both of the above*/ + /*outb(AUXMR,0x8C) */ /* Do both of the above*/ /* outb(AUXMR,hldi); */ /*Perform RFD Holdoff for all data in*/ @@ -502,7 +502,7 @@ int initgpib() { outb(AUXMR,pon); outb(AUXMR,sic_rsc); - tsleep((caddr_t)&gpib_sc,GPIBPRI,"gpibpoll",1); + tsleep((caddr_t)&gpib_sc,GPIBPRI,"gpibpoll",1); outb(AUXMR,sic_rsc_off); @@ -519,12 +519,12 @@ void closegpib() { /*GPIB ROUTINES: These will also make little sense unless you have a data sheet. - Note that the routines with an "m" in the beginning are for + Note that the routines with an "m" in the beginning are for accessing multiple devices in one call*/ /*This is one thing I could not figure out how to do correctly. - I tried to use the auxilary command to enable remote, but it + I tried to use the auxilary command to enable remote, but it never worked. Here, I bypass everything and write to the BSR to enable the remote line. NOTE that these lines are effectively "OR'ed" with the actual lines, so writing a 1 to the bit in the BSR @@ -559,9 +559,9 @@ status=EWOULDBLOCK; while (!(inb(ISR2)&0x08)&&status==EWOULDBLOCK); /*Wait to send next cmd*/ } -/*This does not release the REM line on the gpib port, because if it did, - all the remote devices would go to local mode. This only sends the - gotolocal message to one device. Currently, REM is always held true +/*This does not release the REM line on the gpib port, because if it did, + all the remote devices would go to local mode. This only sends the + gotolocal message to one device. Currently, REM is always held true after enableremote is called, and is reset only on a close of the gpib device */ @@ -573,7 +573,7 @@ void gotolocal(unsigned char device) status=tsleep((caddr_t)&gpib_sc,GPIBPRI,"gpibpoll",2); } while (!(inb(ISR2)&0x08)&&status==EWOULDBLOCK); /*Wait to send next cmd*/ - + outb(CDOR,(device&31)+32); if (status==EWOULDBLOCK) do { @@ -852,7 +852,7 @@ do{ if (!(status&2)&&!counter2) done=tsleep((caddr_t)&gpib_sc, GPIBPRI,"gpibpoll",1); } while (!(status&2)&&(done==EWOULDBLOCK)); - if (done!=EWOULDBLOCK) return(done); + if (done!=EWOULDBLOCK) return(done); if ((data[counter+1]==0)||(count+1)==0){ @@ -873,7 +873,7 @@ return(counter-1); } /*Send data through the TURBO488 FIFOS to a device that is already - addressed to listen. This is used by the write call when someone is + addressed to listen. This is used by the write call when someone is writing to a printer or plotter, etc... */ /*The last byte of each write is held off until either the next write or close, so it can be sent with EOI set*/ @@ -901,7 +901,7 @@ status=EWOULDBLOCK; if (sleeptime<SLEEP_MAX) sleeptime=sleeptime*2; } while (!(inb(ISR3)&0x08)&&(status==EWOULDBLOCK)); /*Fifo is full*/ - + if((count>1)&&(inb(ISR3)&0x08)){ outw(FIFOB,*(unsigned*)(data+counter)); /* printf ("gpib: sent:%c,%c\n",data[counter],data[counter+1]);*/ @@ -911,7 +911,7 @@ status=EWOULDBLOCK; } } while ((count>1)&&(status==EWOULDBLOCK)); -/*The write routine and close routine must check if there is 1 +/*The write routine and close routine must check if there is 1 byte left and handle it accordingly*/ @@ -933,7 +933,7 @@ int sendgpibfifo(unsigned char device,char *data,int count) int counter; int fifopos; int sleeptime; - + outb(IMR2,0x30); /*we have to enable DMA (0x30) for turbo488 to work*/ outb(CNT0,0); outb(CNT1,0); @@ -950,7 +950,7 @@ status=EWOULDBLOCK; status=tsleep((caddr_t)&gpib_sc,GPIBPRI,"gpibpoll",1); while (!(inb(ISR2)&8)&&status==EWOULDBLOCK); outb (CDOR,64); /*Address controller (me) to talk*/ - + if (!(inb(ISR2)&8)&&status==EWOULDBLOCK) do status=tsleep((caddr_t)&gpib_sc,GPIBPRI,"gpibpoll",1); while (!(inb(ISR2)&8)&&status==EWOULDBLOCK); @@ -978,7 +978,7 @@ status=EWOULDBLOCK; if (sleeptime<SLEEP_MAX) sleeptime=sleeptime*2; } while (!(inb(ISR3)&0x08)&&(status==EWOULDBLOCK)); /*Fifo is full*/ - + if((count>1)&&(inb(ISR3)&0x08)){ /*if(count==2) outb(CFG,15+0x40); *//*send eoi when done*/ outw(FIFOB,*(unsigned*)(data+counter)); @@ -1011,7 +1011,7 @@ status=EWOULDBLOCK; while ((inb(ISR3)&0x04)&&status==EWOULDBLOCK); /*Fifo is not empty*/ outb(CMDR,0x08); /*Issue STOP to TURBO488*/ - + /*Wait for DONE and STOP*/ if (status==EWOULDBLOCK) do { status=tsleep((caddr_t)&gpib_sc,GPIBPRI,"gpibpoll",1); @@ -1061,7 +1061,7 @@ while (!(inb(ISR1)&2)&&(status==EWOULDBLOCK)); if (!(inb(ISR2)&8)&&status==EWOULDBLOCK) do status=tsleep((caddr_t)&gpib_sc,GPIBPRI,"gpibpoll",1); while (!(inb(ISR2)&8)&&status==EWOULDBLOCK); - + outb(AUXMR,0x5E); /*Clear SYNC*/ outb (CDOR,95);/*untalk*/ @@ -1097,7 +1097,7 @@ int readgpibfifo(unsigned char device,char *data,int count) -status=EWOULDBLOCK; +status=EWOULDBLOCK; do status=tsleep((caddr_t)&gpib_sc,GPIBPRI,"gpibpoll",1); while (!(inb(ISR2)&8)&&status==EWOULDBLOCK); @@ -1129,7 +1129,7 @@ do status2=inb(STS2); inword=inw(FIFOB); *(unsigned*)(data+counter)=inword; - /* printf ("Read:%c,%c\n",data[counter],data[counter+1]);*/ + /* printf ("Read:%c,%c\n",data[counter],data[counter+1]);*/ counter+=2; } else { @@ -1149,7 +1149,7 @@ do } while(!(inb(ISR3)&0x11)&&status==EWOULDBLOCK); /*wait for DONE and STOP*/ outb(AUXMR,0x55); - + outb(IMR2,0x00); /*we have to enable DMA (0x30) for turbo488 to work*/ outb(CMDR,0x20); /*soft reset turbo488*/ outb(CMDR,0x10); /*reset fifos*/ @@ -1168,7 +1168,7 @@ do do status=tsleep((caddr_t)&gpib_sc,GPIBPRI,"gpibpoll",1); while (!(inb(ISR2)&8)&&status==EWOULDBLOCK); - + outb(AUXMR,0x5E); /*Clear SYNC*/ outb (CDOR,95);/*untalk*/ do @@ -1209,7 +1209,7 @@ char spoll(unsigned char device) if (!(inb(ISR2)&8)&&status==EWOULDBLOCK) do status=tsleep((caddr_t)&gpib_sc,GPIBPRI,"gpibpoll",1); while (!(inb(ISR2)&8)&&status==EWOULDBLOCK); - + /*wait for bus to be synced*/ if (!(inb(ISR0)&1)&&status==EWOULDBLOCK) do status=tsleep((caddr_t)&gpib_sc,GPIBPRI,"gpibpoll",1); @@ -1239,7 +1239,7 @@ char spoll(unsigned char device) if (!(inb(ISR2)&8)&&status==EWOULDBLOCK) do status=tsleep((caddr_t)&gpib_sc,GPIBPRI,"gpibpoll",1); while (!(inb(ISR2)&8)&&status==EWOULDBLOCK); - + outb(CDOR,95); /*untalk*/ if (!(inb(ISR2)&8)&&status==EWOULDBLOCK) do |