X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=lib_ppc%2Fcache.c;h=338b08bd77005f0b477ad594ce1c37d588943bf2;hb=202d94875c98b7b573f136c4f353609758ed9733;hp=27e1a823c6175eb6fe45feef1e0c3736da23a6e6;hpb=8d79953d03e6c5b24215609997dafe4daa623cd6;p=oweals%2Fu-boot.git diff --git a/lib_ppc/cache.c b/lib_ppc/cache.c index 27e1a823c6..338b08bd77 100644 --- a/lib_ppc/cache.c +++ b/lib_ppc/cache.c @@ -23,28 +23,31 @@ #include #include +#include -void flush_cache (ulong start_addr, ulong size) +void flush_cache(ulong start_addr, ulong size) { #ifndef CONFIG_5xx - ulong addr, end_addr = start_addr + size; + ulong addr, start, end; - if (CFG_CACHELINE_SIZE) { - addr = start_addr & (CFG_CACHELINE_SIZE - 1); - for (addr = start_addr; - addr < end_addr; - addr += CFG_CACHELINE_SIZE) { - asm ("dcbst 0,%0": :"r" (addr)); - } - asm ("sync"); /* Wait for all dcbst to complete on bus */ + start = start_addr & ~(CONFIG_SYS_CACHELINE_SIZE - 1); + end = start_addr + size - 1; - for (addr = start_addr; - addr < end_addr; - addr += CFG_CACHELINE_SIZE) { - asm ("icbi 0,%0": :"r" (addr)); - } + for (addr = start; (addr <= end) && (addr >= start); + addr += CONFIG_SYS_CACHELINE_SIZE) { + asm volatile("dcbst 0,%0" : : "r" (addr) : "memory"); + WATCHDOG_RESET(); } - asm ("sync"); /* Always flush prefetch queue in any case */ - asm ("isync"); + /* wait for all dcbst to complete on bus */ + asm volatile("sync" : : : "memory"); + + for (addr = start; (addr <= end) && (addr >= start); + addr += CONFIG_SYS_CACHELINE_SIZE) { + asm volatile("icbi 0,%0" : : "r" (addr) : "memory"); + WATCHDOG_RESET(); + } + asm volatile("sync" : : : "memory"); + /* flush prefetch queue */ + asm volatile("isync" : : : "memory"); #endif }