## diffname bitsy/sa1110dma.c 2000/1103 ## diff -e /dev/null /n/emeliedump/2000/1103/sys/src/9/bitsy/sa1110dma.c 0a #include "u.h" #include "../port/lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "io.h" #include "../port/error.h" /* * DMA helper routines */ enum { NDMA = 6, /* Number of DMA channels */ DMAREGS = 0xb0000000, /* DMA registers, physical */ }; enum { /* Device Address Register, DDAR */ RW = 0, E = 1, BS = 2, DW = 3, DS = 4, /* bits 4 - 7 */ DA = 8 /* bits 8 - 31 */ }; enum { /* Device Control & Status Register, DCSR */ RUN = 0, IE = 1, ERROR = 2, DONEA = 3, STRTA = 4, DONEB = 5, STRTB = 6, BIU = 7 }; struct { Lock; Rendez r; int channels; } dma; struct dmaregs { ulong ddar; ulong dcsr_set; ulong dcsr_clr; ulong dcsr_rd; ulong dstrtA; ulong dxcntA; ulong dstrtB; ulong dxcntB; } *dmaregs; void dmainit(void) { /* map the lcd regs into the kernel's virtual space */ dmaregs = (struct dmaregs*)mapspecial(DMAREGS, NDMA*sizeof(struct dmaregs));; } int dmaalloc(int rd, int bigendian, int burstsize, int datumsize, int device, void *port) { int i; lock(&dma); for (i = 0; i < NDMA; i++) { if (dma.channels & (1 << i)) continue; dma.channels |= 1 << i; unlock(&dma); dmaregs[i].ddar = (rd?1:0)<dcsr_rd) & (1<dcsr_rd; if (debug > 1) iprint("dma: interrupt channel %d, status 0x%lux\n", i, dcsr); if (dcsr & 1<dcsr_clr |= donebit; . 181d 179c ulong dcsr, donebit; . 162,168c dmawait(int chan) { while (dma.chan[chan].active.ref) sleep(&dma.chan[chan].r, _dmaidle, (void*)chan); . 155,158c static int _dmaidle(void* chan) { return dma.chan[(int)chan].active.ref == 0; . 153c return dma.chan[chan].active.ref == 0; } . 141,150d 136c incref(&dma.chan[chan].active); dmaregs[chan].dcsr_set = 1< 1) print("dma: dmastart 0x%lux\n", status); if (dma.chan[chan].active.ref >= 2) { if (debug > 1) print("\n"); . 111,115d 107c dma.chan[i].allocated = 0; . 98a dmaregs[i].dcsr_clr = 0xff; . 96a dmaregs[i].ddar = ddar; if (debug) print("dma: dmaalloc: 0x%lux\n", ddar); . 90c ddar = . 88c dma.chan[i].allocated++; . 86c if (dma.chan[i].allocated) . 83d 81a ulong ddar; . 73a if (debug) print("dma: dmaalloc registers 0x%ux mapped at 0x%p\n", DMAREGS, dmaregs); . 44c int allocated; Ref active; . ## diffname bitsy/sa1110dma.c 2000/1116 ## diff -e /n/emeliedump/2000/1115/sys/src/9/bitsy/sa1110dma.c /n/emeliedump/2000/1116/sys/src/9/bitsy/sa1110dma.c 191,192c return; } iprint("spurious DMA interrupt, channel %d, status 0x%lux\n", i, dcsr); iunlock(&dma.chan[i]); . 185,189c regs->dcsr_clr = donebit; /* try the other bit as well */ donebit ^= 1<dcsr_clr = donebit; } iunlock(&dma.chan[i]); if (dma.chan[i].intr) { dcsr &= 1< 1) iprint("dma: dmastart 0x%lux\n", status); . 120a ilock(&dma.chan[chan]); . 119c ulong status, n; . 45d 43a Lock; . ## diffname bitsy/sa1110dma.c 2000/1117 ## diff -e /n/emeliedump/2000/1116/sys/src/9/bitsy/sa1110dma.c /n/emeliedump/2000/1117/sys/src/9/bitsy/sa1110dma.c 208d 201,202c (*dma.chan[i].intr)(dma.chan[i].param, dcsr & (1< 1) print("dmaidle: 0x%lux\n", status); return (status & (1<dcsr_clr = ERROR; iprint("DMA error, channel %d, status 0x%lux\n", i, dcsr); if (dma.chan[i].intr) { (*dma.chan[i].intr)(dma.chan[i].param, 0); . 197c regs->dcsr_clr = 1<