1 /*
2  * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <sys/param.h>
8 #include <inttypes.h>
9 #include "sdkconfig.h"
10 #include "rom/cache.h"
11 #include "esp_private/esp_cache_esp32_private.h"
12 
13 
14 static cache_driver_t s_cache_drv = {
15     Cache_Flush,
16     NULL,
17 };
18 
19 
cache_register_writeback(cache_driver_t * func)20 void cache_register_writeback(cache_driver_t *func)
21 {
22     s_cache_drv.cache_writeback_psram = func->cache_writeback_psram;
23 }
24 
25 
cache_sync(void)26 void cache_sync(void)
27 {
28     if (s_cache_drv.cache_writeback_psram) {
29         s_cache_drv.cache_writeback_psram();
30     }
31 
32     s_cache_drv.cache_flush(0);
33 #if !CONFIG_FREERTOS_UNICORE
34     s_cache_drv.cache_flush(1);
35 #endif // !CONFIG_FREERTOS_UNICORE
36 }
37