From bcbfe4183af2cd4bc7995332be631accabb4f87a Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 4 May 1999 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1999-05-04 --- alphapc/audio.h | 16 ++++++++++++++ alphapc/devfloppy.c | 1 + alphapc/dma.c | 43 +++++++++++++++++++++++++++--------- alphapc/fdc37c93x.c | 54 +++++++++++++++++++++++++++++++++++++++++++++ alphapc/main.c | 2 ++ carrera/audio.h | 2 +- pc/audio.h | 1 + port/devaudio.c | 2 +- 8 files changed, 109 insertions(+), 12 deletions(-) create mode 100644 alphapc/audio.h diff --git a/alphapc/audio.h b/alphapc/audio.h new file mode 100644 index 0000000000000000000000000000000000000000..bcf4c4171235bda65068f6b46ba325ed2ef587b4 --- /dev/null +++ b/alphapc/audio.h @@ -0,0 +1,16 @@ +enum +{ + Bufsize = 16*1024, /* 92 ms each */ + Nbuf = 16, /* 1.5 seconds total */ + Dma = 1, + IrqAUDIO = 5, + SBswab = 0, +}; + +#define seteisadma(a, b) dmainit(a, Bufsize); +#define CACHELINESZ 128 +#define UNCACHED(type, v) (type*)((ulong)(v)) +#define dcflush(a, b) + +#define Int0vec VectorPIC +#define setvec(v, f, a) intrenable(v, f, a, BUSUNKNOWN) diff --git a/alphapc/devfloppy.c b/alphapc/devfloppy.c index 57410a2546cb11d147a19d81fff3992246d65a89..92eb6ae6878cb1a9db1e29bdedb0e4c551aac726 100644 --- a/alphapc/devfloppy.c +++ b/alphapc/devfloppy.c @@ -842,6 +842,7 @@ floppyxfer(FDrive *dp, int cmd, void *a, long off, long n) */ 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 9e515ed5edbfc6d78b46cf7934cd84b1e43ad986..f43993705a4c709a72f10274fecc288b8166cacd 100644 --- a/alphapc/dma.c +++ b/alphapc/dma.c @@ -107,6 +107,36 @@ outb(dp->mc, 0); return 0; } +static void +dmastatus(DMA *dp, int chan) +{ + 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("addr %uX len %uX stat %uX\n", a, l, s); +} + +void +xdmastatus(int chan) +{ + DMA *dp; + + dp = &dma[(chan>>2)&1]; + chan = chan & 3; + + dmastatus(dp, chan); +} + /* * setup a dma transfer. if the destination is not in kernel * memory, allocate a page for the transfer. @@ -174,11 +204,12 @@ dmasetup(int chan, void *va, long len, int isread) #ifdef tryPCI outb(0x400|dp->page[chan], pa>>24); #endif /* tryPCI */ + outb(dp->cbp, 0); /* set count & address to their first byte */ outb(dp->count[chan], (len>>dp->shift)-1); /* set count */ outb(dp->count[chan], ((len>>dp->shift)-1)>>8); outb(dp->sbm, chan); /* enable the channel */ iunlock(dp); -//print("pa%lux+", pa); +dmastatus(dp, chan); return len; } @@ -210,6 +241,7 @@ dmaend(int chan) dp = &dma[(chan>>2)&1]; chan = chan & 3; +dmastatus(dp, chan); /* * disable the channel */ @@ -217,15 +249,6 @@ dmaend(int chan) outb(dp->sbm, 4|chan); iunlock(dp); -{ int i; -outb(dp->cbp, 0); -i = inb(dp->addr[chan]); -i |= inb(dp->addr[chan])<<8; -i |= inb(dp->page[chan])<<16; -i |= inb(0x400|dp->page[chan])<<24; -//print("X%uX+", i); -} - xp = &dp->x[chan]; if(xp->len == 0 || !xp->isread) return; diff --git a/alphapc/fdc37c93x.c b/alphapc/fdc37c93x.c index b2cf0a9f1fd9cc8b1a68112eb3b2f072cbd101a9..2d802ba1edf51668f82cbc06110e0d40027e4b2f 100644 --- a/alphapc/fdc37c93x.c +++ b/alphapc/fdc37c93x.c @@ -5,3 +5,57 @@ #include "fns.h" #include "io.h" +/* + * SMC FDC37C93x Plug and Play Compatible Ultra I/O Controller. + */ +enum { /* I/O Ports */ + Config = 0x370, /* could also be 0x3F0 */ + + Index = 0, + Data = 1, +}; + +static int fddregs[] = { + 0x30, + 0x60, 0x61, + 0x70, + 0x74, + 0xF0, + 0xF1, + 0xF2, + 0xF4, + 0xF5, + 0, +}; + +void +fdc37c93xdump(void) +{ + int config, i, x; + + config = Config; + + outb(config, 0x55); + outb(config, 0x55); + + outb(config+Index, 0x20); + x = inb(config+Data); + print("fdc37c93x: Device ID 0x%2.2uX\n", x); + + outb(config+Index, 0x07); + outb(config+Data, 0); + for(i = 0; fddregs[i]; 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, 0xAA); +} diff --git a/alphapc/main.c b/alphapc/main.c index 4b3d5347e1e6854c4250dd9184e99f29ccb7b34c..c84aacafb7cf091d1cd5b89e15ace03ea59e1125 100644 --- a/alphapc/main.c +++ b/alphapc/main.c @@ -274,6 +274,7 @@ char *confname[] = { "ether0", "scsi0", + "audio0", }; @@ -281,6 +282,7 @@ char *confval[] = { "type=21140", "type=aic7xxx", + "type=sb16", }; int nconf = nelem(confname); diff --git a/carrera/audio.h b/carrera/audio.h index 3b2ad2a054db81e8d44753a90201810c156ff3cb..9fe66bca19d7cbc627882f2900e135a566609323 100644 --- a/carrera/audio.h +++ b/carrera/audio.h @@ -3,7 +3,7 @@ enum Bufsize = 16*1024, /* 92 ms each */ Nbuf = 16, /* 1.5 seconds total */ Dma = 6, - Irq = 7, + IrqAUDIO = 7, SBswab = 1, diff --git a/pc/audio.h b/pc/audio.h index 6bf521cc8f73b3a5f8a3f8ebe11848fd67b376a2..06406427a447f161db338e78a14b90016cf8c30c 100644 --- a/pc/audio.h +++ b/pc/audio.h @@ -3,6 +3,7 @@ enum Bufsize = 16*1024, /* 92 ms each */ Nbuf = 16, /* 1.5 seconds total */ Dma = 6, + IrqAUDIO = 7, SBswab = 0, }; diff --git a/port/devaudio.c b/port/devaudio.c index c09f88140b0e4deeb0ba0c9bf254af7f0be8c4ff..acc0c34bea76508e70b3949223357ca99bdf9f62 100644 --- a/port/devaudio.c +++ b/port/devaudio.c @@ -711,7 +711,7 @@ audioinit(void) sbconf.port = 0x220; sbconf.dma = Dma; - sbconf.irq = 7; + sbconf.irq = IrqAUDIO; if(isaconfig("audio", 0, &sbconf) == 0) return; if(cistrcmp(sbconf.type, "sb16") != 0 && cistrcmp(sbconf.type, "ess1688") != 0)