mpu_ll.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 <stdint.h>
  14. #include "soc/soc_caps.h"
  15. #include "xt_instr_macros.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. static inline uint32_t mpu_ll_id_to_addr(unsigned id)
  20. {
  21. // vpn - id
  22. // 0x00000000 = 0
  23. // 0x20000000 = 1
  24. // 0x40000000 = 2
  25. // 0x60000000 = 3
  26. // 0x80000000 = 4
  27. // 0xa0000000 = 5
  28. // 0xc0000000 = 6
  29. // 0xe0000000 = 7
  30. return id * SOC_MPU_MIN_REGION_SIZE;
  31. }
  32. static inline void mpu_ll_set_region_rw(uint32_t addr)
  33. {
  34. WDTLB(0x0, addr); // cached, no allocate
  35. }
  36. static inline void mpu_ll_set_region_rwx(uint32_t addr)
  37. {
  38. WDTLB(0x2, addr); // bypass cache
  39. }
  40. static inline void mpu_ll_set_region_x(uint32_t addr)
  41. {
  42. WITLB(0x3, addr); // cached
  43. }
  44. static inline void mpu_ll_set_region_illegal(uint32_t addr)
  45. {
  46. WITLB(0xF, addr);
  47. WDTLB(0xF, addr);
  48. }
  49. #ifdef __cplusplus
  50. }
  51. #endif