arm_mpu.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (c) 2017 Linaro Limited.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef ZEPHYR_INCLUDE_ARCH_ARM_AARCH32_MPU_ARM_MPU_H_
  7. #define ZEPHYR_INCLUDE_ARCH_ARM_AARCH32_MPU_ARM_MPU_H_
  8. #if defined(CONFIG_CPU_CORTEX_M0PLUS) || \
  9. defined(CONFIG_CPU_CORTEX_M3) || \
  10. defined(CONFIG_CPU_CORTEX_M4) || \
  11. defined(CONFIG_CPU_CORTEX_M7) || \
  12. defined(CONFIG_CPU_CORTEX_R)
  13. #include <arch/arm/aarch32/mpu/arm_mpu_v7m.h>
  14. #elif defined(CONFIG_CPU_CORTEX_M23) || \
  15. defined(CONFIG_CPU_CORTEX_M33) || \
  16. defined(CONFIG_CPU_CORTEX_M55)
  17. #include <arch/arm/aarch32/mpu/arm_mpu_v8m.h>
  18. #else
  19. #error "Unsupported ARM CPU"
  20. #endif
  21. #ifndef _ASMLANGUAGE
  22. /* Region definition data structure */
  23. struct arm_mpu_region {
  24. /* Region Base Address */
  25. uint32_t base;
  26. /* Region Name */
  27. const char *name;
  28. #if defined(CONFIG_CPU_CORTEX_R)
  29. /* Region Size */
  30. uint32_t size;
  31. #endif
  32. /* Region Attributes */
  33. arm_mpu_region_attr_t attr;
  34. };
  35. /* MPU configuration data structure */
  36. struct arm_mpu_config {
  37. /* Number of regions */
  38. uint32_t num_regions;
  39. /* Regions */
  40. const struct arm_mpu_region *mpu_regions;
  41. };
  42. #if defined(CONFIG_CPU_CORTEX_R)
  43. #define MPU_REGION_ENTRY(_name, _base, _size, _attr) \
  44. {\
  45. .name = _name, \
  46. .base = _base, \
  47. .size = _size, \
  48. .attr = _attr, \
  49. }
  50. #else
  51. #define MPU_REGION_ENTRY(_name, _base, _attr) \
  52. {\
  53. .name = _name, \
  54. .base = _base, \
  55. .attr = _attr, \
  56. }
  57. #endif
  58. /* Reference to the MPU configuration.
  59. *
  60. * This struct is defined and populated for each SoC (in the SoC definition),
  61. * and holds the build-time configuration information for the fixed MPU
  62. * regions enabled during kernel initialization. Dynamic MPU regions (e.g.
  63. * for Thread Stack, Stack Guards, etc.) are programmed during runtime, thus,
  64. * not kept here.
  65. */
  66. extern const struct arm_mpu_config mpu_config;
  67. #endif /* _ASMLANGUAGE */
  68. #endif /* ZEPHYR_INCLUDE_ARCH_ARM_AARCH32_MPU_ARM_MPU_H_ */