wm_sasc.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #ifndef __WM_SASC_H_
  2. #define __WM_SASC_H_
  3. #include <core_804.h>
  4. #include "wm_regs.h"
  5. #define HR_SASC_B1_BASE (DEVICE_BASE_ADDR + 0xB000)
  6. #define HR_SASC_FLASH_BASE (DEVICE_BASE_ADDR + 0xB100)
  7. #define HR_SASC_B2_BASE (DEVICE_BASE_ADDR + 0xB200)
  8. #define _R1_Pos(val, rgn) ((val&0x1) << (rgn))
  9. #define _R1_Msk(rgn) (0x1 << (rgn))
  10. #define _R2_Pos(val, rgn) ((val&0x3) << (2*rgn))
  11. #define _R2_Msk(rgn) (0x3 << (2*rgn))
  12. typedef enum {
  13. SASC_UN_SE_USER = 0,
  14. SASC_UN_SE_SUPER,
  15. SASC_SE_USER,
  16. SASC_SE_SUPER
  17. } sasc_car_e;
  18. typedef enum {
  19. SASC_AP_RW = 0,
  20. SASC_AP_RO,
  21. SASC_AP_WO,
  22. SASC_AP_DENYALL
  23. } sasc_ap_e;
  24. typedef enum {
  25. SASC_CD_DA_OF = 0,
  26. SASC_CD_DA,
  27. SASC_CD_OF,
  28. SASC_CD_DENYALL
  29. } sasc_cd_e;
  30. typedef enum {
  31. SASC_REGION_SIZE_4B = 0x5,
  32. SASC_REGION_SIZE_8B,
  33. SASC_REGION_SIZE_16B,
  34. SASC_REGION_SIZE_32B,
  35. SASC_REGION_SIZE_64B,
  36. SASC_REGION_SIZE_128B,
  37. SASC_REGION_SIZE_256B,
  38. SASC_REGION_SIZE_512B,
  39. SASC_REGION_SIZE_1KB,
  40. SASC_REGION_SIZE_2KB,
  41. SASC_REGION_SIZE_4KB,
  42. SASC_REGION_SIZE_8KB,
  43. SASC_REGION_SIZE_16KB,
  44. SASC_REGION_SIZE_32KB,
  45. SASC_REGION_SIZE_64KB,
  46. SASC_REGION_SIZE_128KB,
  47. SASC_REGION_SIZE_256KB,
  48. SASC_REGION_SIZE_512KB,
  49. SASC_REGION_SIZE_1MB,
  50. SASC_REGION_SIZE_2MB,
  51. SASC_REGION_SIZE_4MB,
  52. SASC_REGION_SIZE_8MB
  53. } sasc_region_size_e;
  54. typedef struct {
  55. sasc_car_e car; /* security and user or super */
  56. sasc_ap_e ap; /* super user and normal user access.*/
  57. sasc_cd_e cd; /* instruction fetched excution */
  58. } sasc_region_attr_t;
  59. typedef struct {
  60. __IOM uint32_t CAR;
  61. __IOM uint32_t CR;
  62. __IOM uint32_t AP0;
  63. __IOM uint32_t CD0;
  64. __IOM uint32_t AP1;
  65. __IOM uint32_t CD1;
  66. __IOM uint32_t AP2;
  67. __IOM uint32_t CD2;
  68. __IOM uint32_t REGION[8];
  69. } SASC_Type;
  70. #define SASC_B1 ((SASC_Type *) HR_SASC_B1_BASE)
  71. #define SASC_FLASH ((SASC_Type *) HR_SASC_FLASH_BASE)
  72. #define SASC_B2 ((SASC_Type *) HR_SASC_B2_BASE)
  73. /**
  74. * @defgroup Driver_APIs Driver APIs
  75. * @brief Driver APIs
  76. */
  77. /**
  78. * @addtogroup Driver_APIs
  79. * @{
  80. */
  81. /**
  82. * @defgroup SASC_Driver_APIs SASC Driver APIs
  83. * @brief SASC driver APIs
  84. */
  85. /**
  86. * @addtogroup SASC_Driver_APIs
  87. * @{
  88. */
  89. /**
  90. * @brief This function is used enable region.
  91. *
  92. * @param[in] block sasc type
  93. * @param[in] idx index
  94. *
  95. * @return None
  96. *
  97. * @note None
  98. */
  99. void wm_sasc_enable_region(SASC_Type *block, uint32_t idx);
  100. /**
  101. * @brief This function is used disable region.
  102. *
  103. * @param[in] block sasc type
  104. * @param[in] idx index
  105. *
  106. * @return None
  107. *
  108. * @note None
  109. */
  110. void wm_sasc_disable_region(SASC_Type *block, uint32_t idx);
  111. /**
  112. * @brief This function is used set region protect.
  113. *
  114. * @param[in] base_addr base address
  115. * @param[in] idx index
  116. * @param[in] size size
  117. * @param[in] attr attribute
  118. *
  119. * @return None
  120. *
  121. * @note None
  122. */
  123. void set_region_protect(uint32_t base_addr, uint32_t idx, sasc_region_size_e size, sasc_region_attr_t *attr);
  124. /**
  125. * @}
  126. */
  127. /**
  128. * @}
  129. */
  130. #endif