Skip to content
Snippets Groups Projects
Commit 4c140532 authored by Gregory Nutt's avatar Gregory Nutt
Browse files

SAM4E CMCC: Fix some errors introducted in last check-in

parent fb41a110
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,9 @@
****************************************************************************************/
/* This information is available in the Cache Type Register. How every, it is more
* efficient if we do not to do the decoding on each cache access.
*
* CacheSize = CacheLineSize * NCacheLines * NWays
* CacheAddressRange = CacheLineSize * NCacheLines = CacheSize / NWays
*/
#ifdef CONFIG_ARCH_CHIP_SAM4E
......
......@@ -39,6 +39,7 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdint.h>
#include <assert.h>
......@@ -144,24 +145,31 @@ void sam_cmcc_invalidate(uintptr_t start, uintptr_t end)
{
uintptr_t addr;
uint32_t regval;
uint32_t way
uint32_t index;
size_t size;
int nlines;
ssize_t size;
int index;
int way;
/* Get the aligned addresses and size for the memory region to be
* invalidated.
/* Get the aligned addresses and size (in bytes) for the memory region
* to be invalidated.
*/
start = ALIGN_DOWN(start);
end = ALIGN_up(end);
size = end - start;
end = ALIGN_UP(end);
size = end - start + 1;
/* If this is a large region (as big as the cache), then just invalidate
* the entire cache the easy way.
*
* CacheSize = CacheLineSize * NCacheLines * NWays
* CacheAddressRange = CacheLineSize * NCacheLines = CacheSize / NWays
*
* Example: CacheSize = 2048, CacheLineSize=16, NWays=4:
*
* CacheAddressRange = 2048 / 4 = 512
* NCacheLines = 32
*/
if (size >= (CMCC_CACHE_SIZE / CMCC_CACHE_LINE_SIZE / CMCC_NWAYS)
if (size >= (CMCC_CACHE_SIZE / CMCC_NWAYS))
{
sam_cmcc_invalidateall();
return;
......@@ -189,10 +197,9 @@ void sam_cmcc_invalidate(uintptr_t start, uintptr_t end)
/* Invalidate the address region */
index = (start >> CMCC_SHIFT)
nlines = ((end - start) >> CMCC_SHIFT);
for (addr = start; addr < end; addr += CMCC_CACHE_LINE_SIZE, index++)
for (addr = start, index = (int)(start >> CMCC_SHIFT);
addr <= end;
addr += CMCC_CACHE_LINE_SIZE, index++)
{
regval = CMCC_MAINT1_INDEX(index);
for (way = 0; way < CMCC_NWAYS; way++)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment