From 6f23ed5519c349c1a77adcf6a47b1dbdbcbb870b Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 6 May 1999 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1999-05-06 --- alphapc/devfloppy.c | 35 ++++++++++++++++++--------- alphapc/dma.c | 58 +++++++++++++++++++++++++++------------------ alphapc/fdc37c93x.c | 31 ++++++++++++++---------- alphapc/sio.c | 18 ++++++++++++++ 4 files changed, 95 insertions(+), 47 deletions(-) create mode 100644 alphapc/sio.c diff --git a/alphapc/devfloppy.c b/alphapc/devfloppy.c index 92eb6ae6878cb1a9db1e29bdedb0e4c551aac726..8b831416746d23238c53aad1614ec43eaea92b73 100644 --- a/alphapc/devfloppy.c +++ b/alphapc/devfloppy.c @@ -39,7 +39,7 @@ enum { }; #define DPRINT if(floppydebug)print -int floppydebug = 1; +int floppydebug = 0; /* * types of drive (from PC equipment byte) @@ -106,7 +106,8 @@ static void floppywait(void); static long floppyxfer(FDrive*, int, void*, long, long); Dirtab floppydir[]={ - "fd0disk", {Qdata + 0}, 0, 0660, +// "fd0disk", {Qdata + 0}, 0, 0660, + "fd0disk", {Qdata + 0}, 0, 0666, "fd0ctl", {Qctl + 0}, 0, 0660, "fd1disk", {Qdata + 1}, 0, 0660, "fd1ctl", {Qctl + 1}, 0, 0660, @@ -535,7 +536,6 @@ floppycmd(void) microdelay(8); /* for machine independence */ } outb(Pfdata, fl.cmd[i]); -microdelay(8); /* for machine independence */ } return 0; } @@ -639,11 +639,7 @@ cmddone(void *) static void floppywait(void) { -vlong t0, t1; -t0 = fastticks(nil); tsleep(&fl.r, cmddone, 0, 5000); -t1 = fastticks(nil); -print("wait %lld ticks\n", t1-t0); if(!cmddone(0)){ floppyintr(0); fl.confused = 1; @@ -687,6 +683,26 @@ floppyrecal(FDrive *dp) return 0; } +static void +dumpreg(void) +{ + int i; + + fl.ncmd = 0; + fl.cmd[fl.ncmd++] = Fdumpreg; + if(floppycmd() < 0) + return; + floppywait(); + if(fl.nstat < 0){ + print("dumpreg bad %d\n", fl.nstat); + fldump(); + return; + } + for(i = 0; i < fl.nstat; i++) + print(" %2.2uX", fl.stat[i]); + print("\n"); +} + static void specify(void) { @@ -794,7 +810,7 @@ floppyxfer(FDrive *dp, int cmd, void *a, long off, long n) /* retry on error (until it gets ridiculous) */ tries = 0; while(waserror()){ - if(tries++ > 2/*0*/) + if(tries++ > 20) nexterror(); DPRINT("floppyxfer: retrying\n"); /*floppyon(dp);*/ @@ -840,9 +856,6 @@ floppyxfer(FDrive *dp, int cmd, void *a, long off, long n) /* * give bus to DMA, floppyintr() will read result */ -delay(10); -print("msr 0x%2.2uX\n", inb(Pmsr)); -xdmastatus(DMAchan); floppywait(); dmaend(DMAchan); poperror(); diff --git a/alphapc/dma.c b/alphapc/dma.c index 5fe63380d1a8bf42da0cb64d2b3507840f3a8656..2ad5ad9c7c57727919251918ab4d1da462d26c26 100644 --- a/alphapc/dma.c +++ b/alphapc/dma.c @@ -3,7 +3,6 @@ #include "mem.h" #include "dat.h" #include "fns.h" -#include "io.h" typedef struct DMAport DMAport; typedef struct DMA DMA; @@ -63,6 +62,25 @@ DMA dma[2] = { 1 }, }; +static void +dmastatus(DMA *dp, int chan, char c) +{ + int a, l, s; + + ilock(dp); + outb(dp->cbp, 0); + a = inb(dp->addr[chan]); + a |= inb(dp->addr[chan])<<8; + a |= inb(dp->page[chan])<<16; + a |= inb(0x400|dp->page[chan])<<24; + outb(dp->cbp, 0); + l = inb(dp->count[chan]); + l |= inb(dp->count[chan])<<8; + s = inb(dp->cmd); + iunlock(dp); + print("%c: addr %uX len %uX stat %uX\n", c, a, l, s); +} + /* * DMA must be in the first 16MB. This gets called early by the * initialisation routines of any devices which require DMA to ensure @@ -73,6 +91,16 @@ dmainit(int chan, int maxtransfer) { DMA *dp; DMAxfer *xp; + static int once; + + if(once == 0){ + outb(dma[0].mc, 0); + outb(dma[1].mc, 0); + outb(dma[0].cmask, 0); + outb(dma[1].cmask, 0); + outb(dma[1].mode, 0xC0); + once = 1; + } if(maxtransfer > 64*1024) maxtransfer = 64*1024; @@ -85,7 +113,7 @@ dmainit(int chan, int maxtransfer) return 1; return 0; } -outb(dp->mc, 0); +//dmastatus(dp, chan, 'I'); xp->bva = xspanalloc(maxtransfer, BY2PG, 64*1024); if(xp->bva == nil) @@ -107,25 +135,6 @@ outb(dp->mc, 0); return 0; } -static void -dmastatus(DMA *dp, int chan, char c) -{ - int a, l, s; - - ilock(dp); - outb(dp->cbp, 0); - a = inb(dp->addr[chan]); - a |= inb(dp->addr[chan])<<8; - a |= inb(dp->page[chan])<<16; - a |= inb(0x400|dp->page[chan])<<24; - outb(dp->cbp, 0); - l = inb(dp->count[chan]); - l |= inb(dp->count[chan])<<8; - s = inb(dp->cmd); - iunlock(dp); - print("%c: addr %uX len %uX stat %uX\n", c, a, l, s); -} - void xdmastatus(int chan) { @@ -159,6 +168,9 @@ dmasetup(int chan, void *va, long len, int isread) chan = chan & 3; //print("va%lux+", va); #define tryPCI +#ifndef PCIWADDR +#define PCIWADDR(va) PADDR(va) +#endif /* PCIWADDR */ #ifdef notdef xp = &dp->x[chan]; @@ -209,7 +221,7 @@ dmasetup(int chan, void *va, long len, int isread) outb(dp->count[chan], ((len>>dp->shift)-1)>>8); outb(dp->sbm, chan); /* enable the channel */ iunlock(dp); -dmastatus(dp, chan, 'S'); +//dmastatus(dp, chan, 'S'); return len; } @@ -241,7 +253,7 @@ dmaend(int chan) dp = &dma[(chan>>2)&1]; chan = chan & 3; -dmastatus(dp, chan, 'E'); +//dmastatus(dp, chan, 'E'); /* * disable the channel */ diff --git a/alphapc/fdc37c93x.c b/alphapc/fdc37c93x.c index 2d802ba1edf51668f82cbc06110e0d40027e4b2f..ce2a63963fbbac5dcb2b078f28a6824607fbd974 100644 --- a/alphapc/fdc37c93x.c +++ b/alphapc/fdc37c93x.c @@ -28,6 +28,8 @@ static int fddregs[] = { 0, }; +#define OUTB(p, d) outb(p, d); microdelay(10); + void fdc37c93xdump(void) { @@ -35,27 +37,30 @@ fdc37c93xdump(void) config = Config; - outb(config, 0x55); - outb(config, 0x55); + OUTB(config, 0x55); + OUTB(config, 0x55); - outb(config+Index, 0x20); + OUTB(config+Index, 0x20); x = inb(config+Data); print("fdc37c93x: Device ID 0x%2.2uX\n", x); + OUTB(config+Index, 0x22); + x = inb(config+Data); + print("fdc37c93x: Power/Control 0x%2.2uX\n", x); - outb(config+Index, 0x07); - outb(config+Data, 0); + OUTB(config+Index, 0x07); + OUTB(config+Data, 0); for(i = 0; fddregs[i]; i++){ - outb(config+Index, fddregs[i]); + OUTB(config+Index, fddregs[i]); x = inb(config+Data); print("FDD%2.2uX: 0x%2.2uX\n", fddregs[i], x); } - outb(config, 0x70); - outb(config, 0x06); - outb(config, 0x74); - outb(config, 0x02); - outb(config, 0x30); - outb(config, 0x01); + OUTB(config+Index, 0x70); + OUTB(config+Data, 0x06); + OUTB(config+Index, 0x74); + OUTB(config+Data, 0x02); + OUTB(config+Index, 0x30); + OUTB(config+Data, 0x01); - outb(config, 0xAA); + OUTB(config, 0xAA); } diff --git a/alphapc/sio.c b/alphapc/sio.c new file mode 100644 index 0000000000000000000000000000000000000000..1b75fabadec9e79c1e9f9734f4b1882045e41b7e --- /dev/null +++ b/alphapc/sio.c @@ -0,0 +1,18 @@ +#include "u.h" +#include "../port/lib.h" +#include "mem.h" +#include "dat.h" +#include "fns.h" +#include "io.h" + +/* + * 82378ZB Saturn-I/O (SIO) PCI-to-ISA Bus Bridge. + */ +static Pcidev* siodev; + +void +siodump(void) +{ + if(siodev == nil && (siodev = pcimatch(nil, 0x8086, 0x0484)) == nil) + return; +}