mpu_hal.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2020 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #include <stdlib.h>
  14. #include <stdint.h>
  15. #include "esp_err.h"
  16. #include "hal/mpu_hal.h"
  17. #include "hal/mpu_ll.h"
  18. #include "hal/mpu_types.h"
  19. #include "soc/soc_caps.h"
  20. void mpu_hal_set_region_access(int id, mpu_access_t access)
  21. {
  22. uint32_t addr = mpu_ll_id_to_addr(id);
  23. switch (access)
  24. {
  25. #if SOC_MPU_REGION_RO_SUPPORTED
  26. case MPU_REGION_RO:
  27. mpu_ll_set_region_ro(addr);
  28. break;
  29. #endif
  30. #if SOC_MPU_REGION_WO_SUPPORTED
  31. case MPU_REGION_WO:
  32. mpu_ll_set_region_wo(addr);
  33. break;
  34. #endif
  35. case MPU_REGION_RW:
  36. mpu_ll_set_region_rw(addr);
  37. break;
  38. case MPU_REGION_X:
  39. mpu_ll_set_region_x(addr);
  40. break;
  41. case MPU_REGION_RWX:
  42. mpu_ll_set_region_rwx(addr);
  43. break;
  44. case MPU_REGION_ILLEGAL:
  45. mpu_ll_set_region_illegal(addr);
  46. break;
  47. default:
  48. break;
  49. }
  50. }