mpu_hal.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include <stdlib.h>
  7. #include <stdint.h>
  8. #include "esp_err.h"
  9. #include "hal/mpu_hal.h"
  10. #include "hal/mpu_ll.h"
  11. #include "hal/mpu_types.h"
  12. #include "soc/soc_caps.h"
  13. void mpu_hal_set_region_access(int id, mpu_access_t access)
  14. {
  15. uint32_t addr = mpu_ll_id_to_addr(id);
  16. switch (access)
  17. {
  18. #if SOC_MPU_REGION_RO_SUPPORTED
  19. case MPU_REGION_RO:
  20. mpu_ll_set_region_ro(addr);
  21. break;
  22. #endif
  23. #if SOC_MPU_REGION_WO_SUPPORTED
  24. case MPU_REGION_WO:
  25. mpu_ll_set_region_wo(addr);
  26. break;
  27. #endif
  28. case MPU_REGION_RW:
  29. mpu_ll_set_region_rw(addr);
  30. break;
  31. case MPU_REGION_X:
  32. mpu_ll_set_region_x(addr);
  33. break;
  34. case MPU_REGION_RWX:
  35. mpu_ll_set_region_rwx(addr);
  36. break;
  37. case MPU_REGION_ILLEGAL:
  38. mpu_ll_set_region_illegal(addr);
  39. break;
  40. default:
  41. break;
  42. }
  43. }