xil_mpu.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 2014 - 2017 Xilinx, Inc. All rights reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the "Software"), to deal
  7. * in the Software without restriction, including without limitation the rights
  8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. * copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. * THE SOFTWARE.
  22. *
  23. *
  24. *
  25. ******************************************************************************/
  26. /*****************************************************************************/
  27. /**
  28. * @file xil_mmu.h
  29. *
  30. * @addtogroup r5_mpu_apis Cortex R5 Processor MPU specific APIs
  31. *
  32. * MPU functions provides access to MPU operations such as enable MPU, disable
  33. * MPU and set attribute for section of memory.
  34. * Boot code invokes Init_MPU function to configure the MPU. A total of 10 MPU
  35. * regions are allocated with another 6 being free for users. Overview of the
  36. * memory attributes for different MPU regions is as given below,
  37. *
  38. *| | Memory Range | Attributes of MPURegion |
  39. *|-----------------------|-------------------------|-----------------------------|
  40. *| DDR | 0x00000000 - 0x7FFFFFFF | Normal write-back Cacheable |
  41. *| PL | 0x80000000 - 0xBFFFFFFF | Strongly Ordered |
  42. *| QSPI | 0xC0000000 - 0xDFFFFFFF | Device Memory |
  43. *| PCIe | 0xE0000000 - 0xEFFFFFFF | Device Memory |
  44. *| STM_CORESIGHT | 0xF8000000 - 0xF8FFFFFF | Device Memory |
  45. *| RPU_R5_GIC | 0xF9000000 - 0xF90FFFFF | Device memory |
  46. *| FPS | 0xFD000000 - 0xFDFFFFFF | Device Memory |
  47. *| LPS | 0xFE000000 - 0xFFFFFFFF | Device Memory |
  48. *| OCM | 0xFFFC0000 - 0xFFFFFFFF | Normal write-back Cacheable |
  49. *
  50. *
  51. * @note
  52. * For a system where DDR is less than 2GB, region after DDR and before PL is
  53. * marked as undefined in translation table. Memory range 0xFE000000-0xFEFFFFFF is
  54. * allocated for upper LPS slaves, where as memory region 0xFF000000-0xFFFFFFFF is
  55. * allocated for lower LPS slaves.
  56. *
  57. * @{
  58. * <pre>
  59. * MODIFICATION HISTORY:
  60. *
  61. * Ver Who Date Changes
  62. * ----- ---- -------- ---------------------------------------------------
  63. * 5.00 pkp 02/10/14 Initial version
  64. * 6.4 asa 08/16/17 Added many APIs for MPU access to make MPU usage
  65. * user-friendly. The APIs added are: Xil_UpdateMPUConfig,
  66. * Xil_GetMPUConfig, Xil_GetNumOfFreeRegions,
  67. * Xil_GetNextMPURegion, Xil_DisableMPURegionByRegNum,
  68. * Xil_GetMPUFreeRegMask, Xil_SetMPURegionByRegNum, and
  69. * Xil_InitializeExistingMPURegConfig.
  70. * Added a new array of structure of type XMpuConfig to
  71. * represent the MPU configuration table.
  72. * </pre>
  73. *
  74. *
  75. *
  76. ******************************************************************************/
  77. #ifndef XIL_MPU_H
  78. #define XIL_MPU_H
  79. #ifdef __cplusplus
  80. extern "C" {
  81. #endif /* __cplusplus */
  82. #include "xil_types.h"
  83. /***************************** Include Files *********************************/
  84. /***************** Macros (Inline Functions) Definitions *********************/
  85. #define MPU_REG_DISABLED 0U
  86. #define MPU_REG_ENABLED 1U
  87. #define MAX_POSSIBLE_MPU_REGS 16U
  88. /**************************** Type Definitions *******************************/
  89. struct XMpuConfig{
  90. u32 RegionStatus; /* Enabled or disabled */
  91. INTPTR BaseAddress;/* MPU region base address */
  92. u64 Size; /* MPU region size address */
  93. u32 Attribute; /* MPU region size attribute */
  94. };
  95. typedef struct XMpuConfig XMpu_Config[MAX_POSSIBLE_MPU_REGS];
  96. extern XMpu_Config Mpu_Config;
  97. /************************** Constant Definitions *****************************/
  98. /************************** Variable Definitions *****************************/
  99. /************************** Function Prototypes ******************************/
  100. void Xil_SetTlbAttributes(INTPTR Addr, u32 attrib);
  101. void Xil_EnableMPU(void);
  102. void Xil_DisableMPU(void);
  103. u32 Xil_SetMPURegion(INTPTR addr, u64 size, u32 attrib);
  104. u32 Xil_UpdateMPUConfig(u32 reg_num, INTPTR address, u32 size, u32 attrib);
  105. void Xil_GetMPUConfig (XMpu_Config mpuconfig);
  106. u32 Xil_GetNumOfFreeRegions (void);
  107. u32 Xil_GetNextMPURegion(void);
  108. u32 Xil_DisableMPURegionByRegNum (u32 reg_num);
  109. u16 Xil_GetMPUFreeRegMask (void);
  110. u32 Xil_SetMPURegionByRegNum (u32 reg_num, INTPTR addr, u64 size, u32 attrib);
  111. void* Xil_MemMap(UINTPTR Physaddr, size_t size, u32 flags);
  112. #ifdef __cplusplus
  113. }
  114. #endif /* __cplusplus */
  115. #endif /* XIL_MPU_H */
  116. /**
  117. * @} End of "addtogroup r5_mpu_apis".
  118. */