summaryrefslogtreecommitdiffstats
path: root/sys/powerpc/booke
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2012-07-02 21:11:01 +0000
committermarcel <marcel@FreeBSD.org>2012-07-02 21:11:01 +0000
commitce5683d3c56907d0392e960e5a6793755c4a0c8f (patch)
tree40db40f0ac0d8faacf2b59926114031b09376521 /sys/powerpc/booke
parent53224f018aac13056c11af9d1233317b1754149c (diff)
downloadFreeBSD-src-ce5683d3c56907d0392e960e5a6793755c4a0c8f.zip
FreeBSD-src-ce5683d3c56907d0392e960e5a6793755c4a0c8f.tar.gz
Implement cpu_flush_dcache(). This allows us to optimize __syncicache()
for the common case in chich D-caches are coherent by virtue of busdma.
Diffstat (limited to 'sys/powerpc/booke')
-rw-r--r--sys/powerpc/booke/machdep.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/sys/powerpc/booke/machdep.c b/sys/powerpc/booke/machdep.c
index 47ce206..ad49831 100644
--- a/sys/powerpc/booke/machdep.c
+++ b/sys/powerpc/booke/machdep.c
@@ -473,7 +473,24 @@ cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t sz)
void
cpu_flush_dcache(void *ptr, size_t len)
{
- /* TBD */
+ register_t addr, off;
+
+ /*
+ * Align the address to a cacheline and adjust the length
+ * accordingly. Then round the length to a multiple of the
+ * cacheline for easy looping.
+ */
+ addr = (uintptr_t)ptr;
+ off = addr & (cacheline_size - 1);
+ addr -= off;
+ len = (len + off + cacheline_size - 1) & ~(cacheline_size - 1);
+
+ while (len > 0) {
+ __asm __volatile ("dcbf 0,%0" :: "r"(addr));
+ __asm __volatile ("sync");
+ addr += cacheline_size;
+ len -= cacheline_size;
+ }
}
void
OpenPOWER on IntegriCloud