From 74ab48995e17b4cb643c5c9e68da760c440a7a0e Mon Sep 17 00:00:00 2001 From: dimok789 Date: Mon, 25 Apr 2016 19:26:34 +0200 Subject: [PATCH] fixed bug in the flush and invalidate cache function --- src/utils/utils.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/utils/utils.c b/src/utils/utils.c index b2e1b13..3d3d032 100644 --- a/src/utils/utils.c +++ b/src/utils/utils.c @@ -3,13 +3,12 @@ void FlushRange(unsigned int startAddr, unsigned int size) { register unsigned int addr = startAddr & ~0x1F; - register unsigned int len = ((startAddr & 0x1F) + size) >> 5; + register unsigned int end_addr = startAddr + size; - while(len) + while(addr < end_addr) { asm volatile("dcbf 0, %0" : : "r"(addr)); addr += 0x20; - --len; } asm volatile("sync; eieio"); } @@ -18,12 +17,11 @@ void FlushRange(unsigned int startAddr, unsigned int size) void InvalidateRange(unsigned int startAddr, unsigned int size) { register unsigned int addr = startAddr & ~0x1F; - register unsigned int len = ((startAddr & 0x1F) + size) >> 5; + register unsigned int end_addr = startAddr + size; - while(len) + while(addr < end_addr) { asm volatile("dcbi 0, %0" : : "r"(addr)); addr += 0x20; - --len; } }