Merge branch 'feat/cache_preload' into 'master'

cache: preload hal api

Closes IDF-7800

See merge request espressif/esp-idf!46106
This commit is contained in:
Armando (Dou Yiwen)
2026-03-11 01:06:50 +00:00
22 changed files with 1090 additions and 44 deletions
+49 -1
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -33,6 +33,14 @@ extern "C" {
#define CACHE_LL_L1_ACCESS_EVENT_MASK (0x1f)
/**
* @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.
@@ -184,6 +192,46 @@ static inline void cache_ll_unfreeze_cache(uint32_t cache_level, cache_type_t ty
Cache_Freeze_Disable();
}
/**
* @brief Set the preload strategy (L1 unified)
*/
__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_id;
(void)type;
if (cache_level == CACHE_LL_LEVEL_EXT_MEM || cache_level == CACHE_LL_LEVEL_ALL) {
CACHE.l1_cache_ctrl.l1_icache_undef_op = strategy;
}
}
/**
* @brief Preload cache (L1 unified)
*
* Starts preload and does not wait. Use cache_ll_preload_wait_done() to wait for completion.
*/
__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;
(void)type;
HAL_ASSERT(cache_level == CACHE_LL_LEVEL_EXT_MEM);
Cache_Start_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;
(void)type;
HAL_ASSERT(cache_level == CACHE_LL_LEVEL_EXT_MEM);
while (Cache_Preload_Done() == 0) {
}
}
/**
* @brief Get Cache line size, in bytes
*