cache_hal_esp32.c 969 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "hal/cache_ll.h"
  7. #include "hal/cache_hal.h"
  8. static uint32_t s_cache_status[2];
  9. void cache_hal_suspend(cache_type_t type)
  10. {
  11. s_cache_status[0] = cache_ll_l1_get_enabled_bus(0);
  12. cache_ll_l1_disable_cache(0);
  13. #if !CONFIG_FREERTOS_UNICORE
  14. s_cache_status[1] = cache_ll_l1_get_enabled_bus(1);
  15. cache_ll_l1_disable_cache(1);
  16. #endif
  17. }
  18. void cache_hal_resume(cache_type_t type)
  19. {
  20. cache_ll_l1_enable_cache(0);
  21. cache_ll_l1_enable_bus(0, s_cache_status[0]);
  22. #if !CONFIG_FREERTOS_UNICORE
  23. cache_ll_l1_enable_cache(1);
  24. cache_ll_l1_enable_bus(1, s_cache_status[1]);
  25. #endif
  26. }
  27. bool cache_hal_is_cache_enabled(cache_type_t type)
  28. {
  29. bool result = cache_ll_l1_is_cache_enabled(0, CACHE_TYPE_ALL);
  30. #if !CONFIG_FREERTOS_UNICORE
  31. result = result && cache_ll_l1_is_cache_enabled(1, CACHE_TYPE_ALL);
  32. #endif
  33. return result;
  34. }