arch: Unify basic cache clearing API
Caching is a very architecture-specific thing, but most architectures have a cache in general. Therefore it can be useful to have a generic architecture-independent API to perform simple cache management tasks from common code. We have already standardized on the dcache_clean/invalidate naming scheme that originally comes from ARM in libpayload, so let's just do the same for coreboot. Unlike libpayload, there are other things than just DMA coherency we may want to achieve with those functions, so actually implement them for real even on architectures with cache-snooping DMA like x86. (In the future, we may find applications like this in libpayload as well and should probably rethink the API there... maybe move the current functionality to a separate dma_map/unmap API instead. But that's beyond scope of this patch.) Change-Id: I2c1723a287f76cd4118ef38a445339840601aeea Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/19788 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Philippe Mathieu-Daudé <philippe.mathieu.daude@gmail.com>
This commit is contained in:
parent
a92851939c
commit
cd6b22f9a0
4 changed files with 107 additions and 0 deletions
|
|
@ -31,6 +31,9 @@
|
|||
#ifndef ARCH_CACHE_H
|
||||
#define ARCH_CACHE_H
|
||||
|
||||
#include <arch/early_variables.h>
|
||||
#include <cpu/x86/cache.h>
|
||||
|
||||
/*
|
||||
* For the purposes of the currently executing CPU loading code that will be
|
||||
* run there aren't any cache coherency operations required. This just provides
|
||||
|
|
@ -38,4 +41,21 @@
|
|||
*/
|
||||
static inline void cache_sync_instructions(void) {}
|
||||
|
||||
/* Executing WBINVD when running out of CAR would not be good, prevent that. */
|
||||
static inline void dcache_clean_invalidate_all(void)
|
||||
{
|
||||
if (!car_active())
|
||||
wbinvd();
|
||||
}
|
||||
static inline void dcache_clean_all(void)
|
||||
{
|
||||
/* x86 doesn't have a "clean without invalidate", fall back to both. */
|
||||
dcache_clean_invalidate_all();
|
||||
}
|
||||
static inline void dcache_invalidate_all(void)
|
||||
{
|
||||
if (!car_active())
|
||||
invd();
|
||||
}
|
||||
|
||||
#endif /* ARCH_CACHE_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue