X-Git-Url: https://gitweb.dragonflybsd.org/~lentferj/dragonfly.git/blobdiff_plain/20f72c61d541fd28235fd6f4c847d0388b7a3880..21ce0dfafb495e9c50966d5c9205985a50f69597:/sys/dev/misc/gpib/gpib.c diff --git a/sys/dev/misc/gpib/gpib.c b/sys/dev/misc/gpib/gpib.c index 2587c21096..ba8e77c3de 100644 --- a/sys/dev/misc/gpib/gpib.c +++ b/sys/dev/misc/gpib/gpib.c @@ -17,7 +17,7 @@ * all derivative works or modified versions. * * $FreeBSD: src/sys/i386/isa/gpib.c,v 1.29 2000/01/29 16:17:32 peter Exp $ - * $DragonFly: src/sys/dev/misc/gpib/gpib.c,v 1.10 2005/12/11 01:54:08 swildner Exp $ + * $DragonFly: src/sys/dev/misc/gpib/gpib.c,v 1.16 2008/08/02 01:14:42 dillon Exp $ * */ /*Please read the README file for usage information*/ @@ -25,11 +25,12 @@ #include #include #include +#include #include #include #include "gpibreg.h" #include "gpib.h" -#include +#include #define GPIBPRI PCATCH #define SLEEP_MAX 1000 @@ -64,23 +65,12 @@ static d_write_t gpwrite; static d_ioctl_t gpioctl; #define CDEV_MAJOR 44 -static struct cdevsw gp_cdevsw = { - /* name */ "gp", - /* maj */ CDEV_MAJOR, - /* flags */ 0, - /* port */ NULL, - /* clone */ NULL, - - /* open */ gpopen, - /* close */ gpclose, - /* read */ noread, - /* write */ gpwrite, - /* ioctl */ gpioctl, - /* poll */ nopoll, - /* mmap */ nommap, - /* strategy */ nostrategy, - /* dump */ nodump, - /* psize */ nopsize +static struct dev_ops gp_ops = { + { "gp", CDEV_MAJOR, 0 }, + .d_open = gpopen, + .d_close = gpclose, + .d_write = gpwrite, + .d_ioctl = gpioctl, }; #define BUFSIZE 1024 @@ -129,15 +119,15 @@ gpattach(struct isa_device *isdp) sc->sc_unit = isdp->id_unit; if (sc->sc_type==3) - printf ("gp%d: type AT-GPIB/TNT\n",sc->sc_unit); + kprintf ("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); + kprintf ("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); + kprintf ("gp%d: type AT-GPIB chip NAT4882A\n",sc->sc_unit); sc->sc_flags |=ATTACHED; - cdevsw_add(&gp_cdevsw, -1, sc->sc_unit); - make_dev(&gp_cdevsw, sc->sc_unit, 0, 0, 0600, "gp"); + dev_ops_add(&gp_ops, -1, sc->sc_unit); + make_dev(&gp_ops, sc->sc_unit, 0, 0, 0600, "gp"); return (1); } @@ -149,8 +139,9 @@ gpattach(struct isa_device *isdp) * i.e. even if gpib5 is open, we can't open another minor device */ static int -gpopen(dev_t dev, int flags, int fmt, struct thread *td) +gpopen(struct dev_open_args *ap) { + cdev_t dev = ap->a_head.a_dev; struct gpib_softc *sc = &gpib_sc; u_char unit; int status; @@ -171,10 +162,7 @@ gpopen(dev_t dev, int flags, int fmt, struct thread *td) return(EBUSY); } - /* Have memory for buffer? */ - sc->sc_inbuf = malloc(BUFSIZE, M_DEVBUF, M_WAITOK); - if (sc->sc_inbuf == 0) - return(ENOMEM); + sc->sc_inbuf = kmalloc(BUFSIZE, M_DEVBUF, M_WAITOK); if (initgpib()) return(EBUSY); sc->sc_flags |= OPEN; @@ -223,8 +211,9 @@ enableremote(unit); * Close gpib device. */ static int -gpclose(dev_t dev, int flags, int fmt, struct thread *td) +gpclose(struct dev_close_args *ap) { + cdev_t dev = ap->a_head.a_dev; struct gpib_softc *sc = &gpib_sc; unsigned char unit; unsigned char status; @@ -278,7 +267,7 @@ 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"); + kprintf("gpib: Warning: gpclose called with nothing left in buffer\n"); } } @@ -311,7 +300,7 @@ while (!(inb(ISR1)&2)&&(status==EWOULDBLOCK)); } closegpib(); sc->sc_flags = ATTACHED; - free(sc->sc_inbuf, M_DEVBUF); + kfree(sc->sc_inbuf, M_DEVBUF); sc->sc_inbuf = 0; /* Sanity */ return(0); } @@ -322,8 +311,10 @@ while (!(inb(ISR1)&2)&&(status==EWOULDBLOCK)); * by minor(dev). */ static int -gpwrite(dev_t dev, struct uio *uio, int ioflag) +gpwrite(struct dev_write_args *ap) { + cdev_t dev = ap->a_head.a_dev; + struct uio *uio = ap->a_uio; int err,count; /* main loop */ @@ -372,13 +363,13 @@ gpwrite(dev_t dev, struct uio *uio, int ioflag) write to using a minor device = its GPIB address */ static int -gpioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) +gpioctl(struct dev_ioctl_args *ap) { - struct gpibdata *gd = (struct gpibdata *)data; + struct gpibdata *gd = (struct gpibdata *)ap->a_data; int error,result; error = 0; - switch (cmd) { + switch (ap->a_cmd) { case GPIBWRITE: sendgpibfifo(gd->address,gd->data,*(gd->count)); error=0; @@ -435,29 +426,29 @@ gpioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct thread *td) /*Just in case you want a dump of the registers...*/ static void showregs() { - printf ("NAT4882:\n"); - printf ("ISR1=%X\t",inb(ISR1)); - printf ("ISR2=%X\t",inb(ISR2)); - printf ("SPSR=%X\t",inb(SPSR)); - printf ("KSR =%X\t",inb(KSR)); - printf ("ADSR=%X\t",inb(ADSR)); - printf ("CPTR=%X\t",inb(CPTR)); - printf ("SASR=%X\t",inb(SASR)); - printf ("ADR0=%X\t",inb(ADR0)); - printf ("ISR0=%X\t",inb(ISR0)); - printf ("ADR1=%X\t",inb(ADR1)); - printf ("BSR =%X\n",inb(BSR)); - - printf ("Turbo488\n"); - printf ("STS1=%X ",inb(STS1)); - printf ("STS2=%X ",inb(STS2)); - printf ("ISR3=%X ",inb(ISR3)); - printf ("CNT0=%X ",inb(CNT0)); - printf ("CNT1=%X ",inb(CNT1)); - printf ("CNT2=%X ",inb(CNT2)); - printf ("CNT3=%X ",inb(CNT3)); - printf ("IMR3=%X ",inb(IMR3)); - printf ("TIMER=%X\n",inb(TIMER)); + kprintf ("NAT4882:\n"); + kprintf ("ISR1=%X\t",inb(ISR1)); + kprintf ("ISR2=%X\t",inb(ISR2)); + kprintf ("SPSR=%X\t",inb(SPSR)); + kprintf ("KSR =%X\t",inb(KSR)); + kprintf ("ADSR=%X\t",inb(ADSR)); + kprintf ("CPTR=%X\t",inb(CPTR)); + kprintf ("SASR=%X\t",inb(SASR)); + kprintf ("ADR0=%X\t",inb(ADR0)); + kprintf ("ISR0=%X\t",inb(ISR0)); + kprintf ("ADR1=%X\t",inb(ADR1)); + kprintf ("BSR =%X\n",inb(BSR)); + + kprintf ("Turbo488\n"); + kprintf ("STS1=%X ",inb(STS1)); + kprintf ("STS2=%X ",inb(STS2)); + kprintf ("ISR3=%X ",inb(ISR3)); + kprintf ("CNT0=%X ",inb(CNT0)); + kprintf ("CNT1=%X ",inb(CNT1)); + kprintf ("CNT2=%X ",inb(CNT2)); + kprintf ("CNT3=%X ",inb(CNT3)); + kprintf ("IMR3=%X ",inb(IMR3)); + kprintf ("TIMER=%X\n",inb(TIMER)); } @@ -789,7 +780,7 @@ status=EWOULDBLOCK; if((count>1)&&(inb(ISR3)&0x08)){ outw(FIFOB,*(unsigned*)(data+counter)); - /* printf ("gpib: sent:%c,%c\n",data[counter],data[counter+1]);*/ + /* kprintf ("gpib: sent:%c,%c\n",data[counter],data[counter+1]);*/ counter+=2; count-=2; @@ -1011,7 +1002,7 @@ do status2=inb(STS2); inword=inw(FIFOB); *(unsigned*)(data+counter)=inword; - /* printf ("Read:%c,%c\n",data[counter],data[counter+1]);*/ + /* kprintf ("Read:%c,%c\n",data[counter],data[counter+1]);*/ counter+=2; } else {