diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2019-07-17 10:24:50 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2019-07-17 10:24:50 +0200 |
commit | 19a883ce7a8b0d1f57a1df68947af2bfa7ea5576 (patch) | |
tree | 2fa24248e0399ffb1a1b49ae3b9400d542cf118b /sys/src/9/zynq | |
parent | a4688b03228dfdebcde34570b2a7b5c79db31c79 (diff) |
usbehci: introduce dmaflush() function to handle portable cache invalidation for device drivers
Diffstat (limited to 'sys/src/9/zynq')
-rw-r--r-- | sys/src/9/zynq/fns.h | 1 | ||||
-rw-r--r-- | sys/src/9/zynq/main.c | 19 | ||||
-rw-r--r-- | sys/src/9/zynq/usbehci.h | 1 | ||||
-rw-r--r-- | sys/src/9/zynq/usbehcizynq.c | 26 |
4 files changed, 21 insertions, 26 deletions
diff --git a/sys/src/9/zynq/fns.h b/sys/src/9/zynq/fns.h index 11ae795de..0855b1ea6 100644 --- a/sys/src/9/zynq/fns.h +++ b/sys/src/9/zynq/fns.h @@ -68,6 +68,7 @@ void clinvdse(void *, void *); void invaldln(void *); void cleandln(void *); void clinvdln(void *); +void dmaflush(int, void*, ulong); void* ucalloc(ulong); void clean2pa(uintptr, uintptr); void inval2pa(uintptr, uintptr); diff --git a/sys/src/9/zynq/main.c b/sys/src/9/zynq/main.c index 443cbabe6..042c06e45 100644 --- a/sys/src/9/zynq/main.c +++ b/sys/src/9/zynq/main.c @@ -133,6 +133,25 @@ inval2pa(uintptr start, uintptr end) l2[0x770/4] = pa; } +void +dmaflush(int clean, void *data, ulong len) +{ + uintptr va, pa; + + va = (uintptr)data & ~31; + pa = PADDR(va); + len = ROUND(len, 32); + if(clean){ + /* flush cache before write */ + cleandse((uchar*)va, (uchar*)va+len); + clean2pa(pa, pa+len); + } else { + /* invalidate cache before read */ + invaldse((uchar*)va, (uchar*)va+len); + inval2pa(pa, pa+len); + } +} + static void options(void) { diff --git a/sys/src/9/zynq/usbehci.h b/sys/src/9/zynq/usbehci.h index 6b8b32fd0..eeee6180c 100644 --- a/sys/src/9/zynq/usbehci.h +++ b/sys/src/9/zynq/usbehci.h @@ -130,7 +130,6 @@ struct Ctlr void* (*tdalloc)(ulong,int,ulong); void* (*dmaalloc)(ulong); void (*dmafree)(void*); - void (*dmaflush)(int,void*,ulong len); int nframes; /* 1024, 512, or 256 frames in the list */ ulong* frames; /* periodic frame list (hw) */ diff --git a/sys/src/9/zynq/usbehcizynq.c b/sys/src/9/zynq/usbehcizynq.c index c93dbe0f0..cb1562a43 100644 --- a/sys/src/9/zynq/usbehcizynq.c +++ b/sys/src/9/zynq/usbehcizynq.c @@ -61,10 +61,6 @@ ehcireset(Ctlr *ctlr) iunlock(ctlr); } -enum { - Cls = 64, -}; - /* descriptors need to be allocated in uncached memory */ static void* tdalloc(ulong size, int, ulong) @@ -75,7 +71,7 @@ tdalloc(ulong size, int, ulong) static void* dmaalloc(ulong len) { - return mallocalign(ROUND(len, Cls), Cls, 0, 0); + return mallocalign(ROUND(len, BLOCKALIGN), BLOCKALIGN, 0, 0); } static void dmafree(void *data) @@ -83,25 +79,6 @@ dmafree(void *data) free(data); } -static void -dmaflush(int clean, void *data, ulong len) -{ - uintptr va, pa; - - va = (uintptr)data & ~(Cls-1); - pa = PADDR(va); - len = ROUND(len, Cls); - if(clean){ - /* flush cache before write */ - cleandse((uchar*)va, (uchar*)va+len); - clean2pa(pa, pa+len); - } else { - /* invalidate cache before read */ - invaldse((uchar*)va, (uchar*)va+len); - inval2pa(pa, pa+len); - } -} - static int (*ehciportstatus)(Hci*,int); static int @@ -152,7 +129,6 @@ reset(Hci *hp) ctlr->tdalloc = tdalloc; ctlr->dmaalloc = dmaalloc; ctlr->dmafree = dmafree; - ctlr->dmaflush = dmaflush; ehcireset(ctlr); ctlr->r[USBMODE] |= USBHOST; |