armv7: add a helper function for dcache ops by MVA

This adds a helper function for dcache ops by MVA which will perform
the specified operation on a given memory range. This will make it
more trivial to add other data cache maintenance routines.

Change-Id: I01d746d5fd2f4138257ca9cab9e9d738e73f8633
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: http://review.coreboot.org/2870
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins)
This commit is contained in:
David Hendricks 2013-03-19 17:57:59 -07:00
parent a54efdcf8c
commit 758abdd75b
1 changed files with 24 additions and 4 deletions

View File

@ -77,7 +77,8 @@ void icache_invalidate_all(void)
enum dcache_op {
OP_DCCISW,
OP_DCISW
OP_DCISW,
OP_DCCIMVAC,
};
/*
@ -169,13 +170,32 @@ static unsigned int line_bytes(void)
return size;
}
void dcache_clean_invalidate_by_mva(unsigned long addr, unsigned long len)
/*
* Do a dcache operation by modified virtual address. This is useful for
* maintaining coherency in drivers which do DMA transfers and only need to
* perform cache maintenance on a particular memory range rather than the
* entire cache.
*/
static void dcache_op_mva(unsigned long addr,
unsigned long len, enum dcache_op op)
{
unsigned long line, i;
line = line_bytes();
for (i = addr & ~(line - 1); i < addr + len - 1; i += line)
dccimvac(addr);
for (i = addr & ~(line - 1); i < addr + len - 1; i += line) {
switch(op) {
case OP_DCCIMVAC:
dccimvac(addr);
break;
default:
break;
}
}
}
void dcache_clean_invalidate_by_mva(unsigned long addr, unsigned long len)
{
dcache_op_mva(addr, len, OP_DCCIMVAC);
}
void armv7_invalidate_caches(void)