From e372b812a0296ddae2247976467f4b1fa29730ad Mon Sep 17 00:00:00 2001 From: isiora Date: Tue, 27 Feb 2018 00:23:45 +0000 Subject: Added L2 related code. git-svn-id: https://svn.code.sf.net/p/chibios/svn2/trunk@11581 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- os/hal/ports/SAMA/SAMA5D2x/sama_cache.c | 18 ++++++++++++++++-- os/hal/ports/SAMA/SAMA5D2x/sama_cache.h | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'os/hal/ports') diff --git a/os/hal/ports/SAMA/SAMA5D2x/sama_cache.c b/os/hal/ports/SAMA/SAMA5D2x/sama_cache.c index 64f1f32d2..5c01ba359 100644 --- a/os/hal/ports/SAMA/SAMA5D2x/sama_cache.c +++ b/os/hal/ports/SAMA/SAMA5D2x/sama_cache.c @@ -26,7 +26,6 @@ /** * @brief Invalidate D-Cache Region - * @TODO: Extend to L2C * * @param[in] start Pointer to beginning of memory region. * @param[in] length Length of the memory location. @@ -41,11 +40,18 @@ void cacheInvalidateRegion(void *start, uint32_t length) { for (mva = start_addr & ~L1_CACHE_BYTES; mva < end_addr; mva += L1_CACHE_BYTES) { L1C_InvalidateDCacheMVA((uint32_t *)mva); } +#if defined(ARM_ENABLE_L2CC) +#if ARM_ENABLE_L2CC + /* Invalidate L2 Cache */ + for (mva = start_addr & ~L2_CACHE_BYTES; mva < end_addr; mva += L2_CACHE_BYTES) { + L2C_InvPa((uint32_t *)mva); + } +#endif +#endif } /** * @brief Clean D-Cache Region - * @TODO: Extend to L2C * * @param[in] start Pointer to beginning of memory region. * @param[in] length Length of the memory location. @@ -60,6 +66,14 @@ void cacheCleanRegion(void *start, uint32_t length) { for (mva = start_addr & ~L1_CACHE_BYTES; mva < end_addr; mva += L1_CACHE_BYTES) { L1C_CleanDCacheMVA((uint32_t *)mva); } +#if defined(ARM_ENABLE_L2CC) +#if ARM_ENABLE_L2CC + /* Invalidate L2 Cache */ + for (mva = start_addr & ~L2_CACHE_BYTES; mva < end_addr; mva += L2_CACHE_BYTES) { + L2C_CleanPa((uint32_t *)mva); + } +#endif +#endif } /** @} */ diff --git a/os/hal/ports/SAMA/SAMA5D2x/sama_cache.h b/os/hal/ports/SAMA/SAMA5D2x/sama_cache.h index fc7bcedac..1608a023c 100644 --- a/os/hal/ports/SAMA/SAMA5D2x/sama_cache.h +++ b/os/hal/ports/SAMA/SAMA5D2x/sama_cache.h @@ -28,6 +28,7 @@ /* Driver constants. */ /*===========================================================================*/ #define L1_CACHE_BYTES 32u +#define L2_CACHE_BYTES 32u #ifdef __cplusplus extern "C" { -- cgit v1.2.3