feat(cache): support cache preload hal api

This commit is contained in:
armando
2026-03-10 15:03:05 +08:00
parent 638a47b704
commit a699805d39
22 changed files with 1090 additions and 44 deletions
+54 -1
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -33,6 +33,15 @@ extern "C" {
#define CACHE_LL_LEVEL_NUMS 1 //Number of cache levels
#define CACHE_LL_L1_ICACHE_AUTOLOAD (1<<0)
/**
* @brief Preload strategy
*/
typedef enum {
CACHE_LL_PRELOAD_UNTIL_FETCH_DONE = 0,
CACHE_LL_PRELOAD_AFTER_FETCH = 1,
CACHE_LL_PRELOAD_ARBITRARY = 2,
} cache_ll_preload_strategy_t;
/**
* @brief Check if Cache auto preload is enabled or not.
*
@@ -166,6 +175,50 @@ static inline void cache_ll_unfreeze_cache(uint32_t cache_level, cache_type_t ty
Cache_Freeze_ICache_Disable();
}
/**
* @brief Set the preload strategy (no-op)
*/
__attribute__((always_inline))
static inline void cache_ll_preload_set_strategy(uint32_t cache_level, cache_type_t type, uint32_t cache_id, cache_ll_preload_strategy_t strategy)
{
(void)cache_level;
(void)type;
(void)cache_id;
(void)strategy;
}
/**
* @brief Preload cache (L1 ICache only)
*
* Starts preload and does not wait. Use cache_ll_preload_wait_done() to wait for completion.
* DATA type is no-op.
*/
__attribute__((always_inline))
static inline void cache_ll_preload(uint32_t cache_level, cache_type_t type, uint32_t cache_id, uint32_t vaddr, uint32_t size, bool ascending)
{
(void)cache_id;
HAL_ASSERT(cache_level == CACHE_LL_LEVEL_EXT_MEM);
if (type == CACHE_TYPE_DATA) {
return;
}
Cache_Start_ICache_Preload(vaddr, size, ascending ? 0 : 1);
}
/**
* @brief Wait until cache preload is done (L1 only)
*/
__attribute__((always_inline))
static inline void cache_ll_preload_wait_done(uint32_t cache_level, cache_type_t type, uint32_t cache_id)
{
(void)cache_id;
HAL_ASSERT(cache_level == CACHE_LL_LEVEL_EXT_MEM);
if (type == CACHE_TYPE_DATA) {
return;
}
while (Cache_ICache_Preload_Done() == 0) {
}
}
/**
* @brief Get Cache line size, in bytes
*