hpm_bsec_regs.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /*
  2. * Copyright (c) 2021-2023 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_BSEC_H
  8. #define HPM_BSEC_H
  9. typedef struct {
  10. __RW uint32_t SECURE_STATE; /* 0x0: Secure state */
  11. __RW uint32_t SECURE_STATE_CONFIG; /* 0x4: secure state configuration */
  12. __RW uint32_t VIOLATION_CONFIG; /* 0x8: Security violation config */
  13. __RW uint32_t ESCALATE_CONFIG; /* 0xC: Escalate behavior on security event */
  14. __R uint32_t EVENT; /* 0x10: Event and escalate status */
  15. } BSEC_Type;
  16. /* Bitfield definition for register: SECURE_STATE */
  17. /*
  18. * ALLOW_NSC (RO)
  19. *
  20. * Non-secure state allow
  21. * 0: system is not healthy to enter non-secure state, request to enter non-secure state will cause a fail state
  22. * 1: system is healthy to enter non-secure state
  23. */
  24. #define BSEC_SECURE_STATE_ALLOW_NSC_MASK (0x20000UL)
  25. #define BSEC_SECURE_STATE_ALLOW_NSC_SHIFT (17U)
  26. #define BSEC_SECURE_STATE_ALLOW_NSC_GET(x) (((uint32_t)(x) & BSEC_SECURE_STATE_ALLOW_NSC_MASK) >> BSEC_SECURE_STATE_ALLOW_NSC_SHIFT)
  27. /*
  28. * ALLOW_SEC (RO)
  29. *
  30. * Secure state allow
  31. * 0: system is not healthy to enter secure state, request to enter non-secure state will cause a fail state
  32. * 1: system is healthy to enter secure state
  33. */
  34. #define BSEC_SECURE_STATE_ALLOW_SEC_MASK (0x10000UL)
  35. #define BSEC_SECURE_STATE_ALLOW_SEC_SHIFT (16U)
  36. #define BSEC_SECURE_STATE_ALLOW_SEC_GET(x) (((uint32_t)(x) & BSEC_SECURE_STATE_ALLOW_SEC_MASK) >> BSEC_SECURE_STATE_ALLOW_SEC_SHIFT)
  37. /*
  38. * BATT_FAIL (RW)
  39. *
  40. * BATT secure state one hot indicator
  41. * 0: secure state is not in fail state
  42. * 1: secure state is in fail state
  43. */
  44. #define BSEC_SECURE_STATE_BATT_FAIL_MASK (0x8U)
  45. #define BSEC_SECURE_STATE_BATT_FAIL_SHIFT (3U)
  46. #define BSEC_SECURE_STATE_BATT_FAIL_SET(x) (((uint32_t)(x) << BSEC_SECURE_STATE_BATT_FAIL_SHIFT) & BSEC_SECURE_STATE_BATT_FAIL_MASK)
  47. #define BSEC_SECURE_STATE_BATT_FAIL_GET(x) (((uint32_t)(x) & BSEC_SECURE_STATE_BATT_FAIL_MASK) >> BSEC_SECURE_STATE_BATT_FAIL_SHIFT)
  48. /*
  49. * BATT_NSC (RW)
  50. *
  51. * BATT secure state one hot indicator
  52. * 0: secure state is not in non-secure state
  53. * 1: secure state is in non-secure state
  54. */
  55. #define BSEC_SECURE_STATE_BATT_NSC_MASK (0x4U)
  56. #define BSEC_SECURE_STATE_BATT_NSC_SHIFT (2U)
  57. #define BSEC_SECURE_STATE_BATT_NSC_SET(x) (((uint32_t)(x) << BSEC_SECURE_STATE_BATT_NSC_SHIFT) & BSEC_SECURE_STATE_BATT_NSC_MASK)
  58. #define BSEC_SECURE_STATE_BATT_NSC_GET(x) (((uint32_t)(x) & BSEC_SECURE_STATE_BATT_NSC_MASK) >> BSEC_SECURE_STATE_BATT_NSC_SHIFT)
  59. /*
  60. * BATT_SEC (RW)
  61. *
  62. * BATT secure state one hot indicator
  63. * 0: secure state is not in secure state
  64. * 1: secure state is in secure state
  65. */
  66. #define BSEC_SECURE_STATE_BATT_SEC_MASK (0x2U)
  67. #define BSEC_SECURE_STATE_BATT_SEC_SHIFT (1U)
  68. #define BSEC_SECURE_STATE_BATT_SEC_SET(x) (((uint32_t)(x) << BSEC_SECURE_STATE_BATT_SEC_SHIFT) & BSEC_SECURE_STATE_BATT_SEC_MASK)
  69. #define BSEC_SECURE_STATE_BATT_SEC_GET(x) (((uint32_t)(x) & BSEC_SECURE_STATE_BATT_SEC_MASK) >> BSEC_SECURE_STATE_BATT_SEC_SHIFT)
  70. /*
  71. * BATT_INS (RW)
  72. *
  73. * BATT secure state one hot indicator
  74. * 0: secure state is not in inspect state
  75. * 1: secure state is in inspect state
  76. */
  77. #define BSEC_SECURE_STATE_BATT_INS_MASK (0x1U)
  78. #define BSEC_SECURE_STATE_BATT_INS_SHIFT (0U)
  79. #define BSEC_SECURE_STATE_BATT_INS_SET(x) (((uint32_t)(x) << BSEC_SECURE_STATE_BATT_INS_SHIFT) & BSEC_SECURE_STATE_BATT_INS_MASK)
  80. #define BSEC_SECURE_STATE_BATT_INS_GET(x) (((uint32_t)(x) & BSEC_SECURE_STATE_BATT_INS_MASK) >> BSEC_SECURE_STATE_BATT_INS_SHIFT)
  81. /* Bitfield definition for register: SECURE_STATE_CONFIG */
  82. /*
  83. * LOCK (RW)
  84. *
  85. * Lock bit of allow restart setting, once locked, lock bit itself and configuration register will keep value until next reset
  86. * 0: not locked, register can be modified
  87. * 1: register locked, write access to the register is ignored
  88. */
  89. #define BSEC_SECURE_STATE_CONFIG_LOCK_MASK (0x8U)
  90. #define BSEC_SECURE_STATE_CONFIG_LOCK_SHIFT (3U)
  91. #define BSEC_SECURE_STATE_CONFIG_LOCK_SET(x) (((uint32_t)(x) << BSEC_SECURE_STATE_CONFIG_LOCK_SHIFT) & BSEC_SECURE_STATE_CONFIG_LOCK_MASK)
  92. #define BSEC_SECURE_STATE_CONFIG_LOCK_GET(x) (((uint32_t)(x) & BSEC_SECURE_STATE_CONFIG_LOCK_MASK) >> BSEC_SECURE_STATE_CONFIG_LOCK_SHIFT)
  93. /*
  94. * ALLOW_RESTART (RW)
  95. *
  96. * allow secure state restart from fail state
  97. * 0: restart is not allowed, only hardware reset can recover secure state
  98. * 1: software is allowed to switch to inspect state from fail state
  99. */
  100. #define BSEC_SECURE_STATE_CONFIG_ALLOW_RESTART_MASK (0x1U)
  101. #define BSEC_SECURE_STATE_CONFIG_ALLOW_RESTART_SHIFT (0U)
  102. #define BSEC_SECURE_STATE_CONFIG_ALLOW_RESTART_SET(x) (((uint32_t)(x) << BSEC_SECURE_STATE_CONFIG_ALLOW_RESTART_SHIFT) & BSEC_SECURE_STATE_CONFIG_ALLOW_RESTART_MASK)
  103. #define BSEC_SECURE_STATE_CONFIG_ALLOW_RESTART_GET(x) (((uint32_t)(x) & BSEC_SECURE_STATE_CONFIG_ALLOW_RESTART_MASK) >> BSEC_SECURE_STATE_CONFIG_ALLOW_RESTART_SHIFT)
  104. /* Bitfield definition for register: VIOLATION_CONFIG */
  105. /*
  106. * LOCK_NSC (RW)
  107. *
  108. * Lock bit non-secure violation setting, once locked, lock bit itself and configuration will keep value until next reset
  109. * 0: not locked, configuration can be modified
  110. * 1: register locked, write access to the configuration is ignored
  111. */
  112. #define BSEC_VIOLATION_CONFIG_LOCK_NSC_MASK (0x80000000UL)
  113. #define BSEC_VIOLATION_CONFIG_LOCK_NSC_SHIFT (31U)
  114. #define BSEC_VIOLATION_CONFIG_LOCK_NSC_SET(x) (((uint32_t)(x) << BSEC_VIOLATION_CONFIG_LOCK_NSC_SHIFT) & BSEC_VIOLATION_CONFIG_LOCK_NSC_MASK)
  115. #define BSEC_VIOLATION_CONFIG_LOCK_NSC_GET(x) (((uint32_t)(x) & BSEC_VIOLATION_CONFIG_LOCK_NSC_MASK) >> BSEC_VIOLATION_CONFIG_LOCK_NSC_SHIFT)
  116. /*
  117. * NSC_VIO_CFG (RW)
  118. *
  119. * configuration of non-secure state violations, each bit represents one security event
  120. * 0: event is not a security violation
  121. * 1: event is a security violation
  122. */
  123. #define BSEC_VIOLATION_CONFIG_NSC_VIO_CFG_MASK (0x7FFF0000UL)
  124. #define BSEC_VIOLATION_CONFIG_NSC_VIO_CFG_SHIFT (16U)
  125. #define BSEC_VIOLATION_CONFIG_NSC_VIO_CFG_SET(x) (((uint32_t)(x) << BSEC_VIOLATION_CONFIG_NSC_VIO_CFG_SHIFT) & BSEC_VIOLATION_CONFIG_NSC_VIO_CFG_MASK)
  126. #define BSEC_VIOLATION_CONFIG_NSC_VIO_CFG_GET(x) (((uint32_t)(x) & BSEC_VIOLATION_CONFIG_NSC_VIO_CFG_MASK) >> BSEC_VIOLATION_CONFIG_NSC_VIO_CFG_SHIFT)
  127. /*
  128. * LOCK_SEC (RW)
  129. *
  130. * Lock bit secure violation setting, once locked, lock bit itself and configuration will keep value until next reset
  131. * 0: not locked, configuration can be modified
  132. * 1: register locked, write access to the configuration is ignored
  133. */
  134. #define BSEC_VIOLATION_CONFIG_LOCK_SEC_MASK (0x8000U)
  135. #define BSEC_VIOLATION_CONFIG_LOCK_SEC_SHIFT (15U)
  136. #define BSEC_VIOLATION_CONFIG_LOCK_SEC_SET(x) (((uint32_t)(x) << BSEC_VIOLATION_CONFIG_LOCK_SEC_SHIFT) & BSEC_VIOLATION_CONFIG_LOCK_SEC_MASK)
  137. #define BSEC_VIOLATION_CONFIG_LOCK_SEC_GET(x) (((uint32_t)(x) & BSEC_VIOLATION_CONFIG_LOCK_SEC_MASK) >> BSEC_VIOLATION_CONFIG_LOCK_SEC_SHIFT)
  138. /*
  139. * SEC_VIO_CFG (RW)
  140. *
  141. * configuration of secure state violations, each bit represents one security event
  142. * 0: event is not a security violation
  143. * 1: event is a security violation
  144. */
  145. #define BSEC_VIOLATION_CONFIG_SEC_VIO_CFG_MASK (0x7FFFU)
  146. #define BSEC_VIOLATION_CONFIG_SEC_VIO_CFG_SHIFT (0U)
  147. #define BSEC_VIOLATION_CONFIG_SEC_VIO_CFG_SET(x) (((uint32_t)(x) << BSEC_VIOLATION_CONFIG_SEC_VIO_CFG_SHIFT) & BSEC_VIOLATION_CONFIG_SEC_VIO_CFG_MASK)
  148. #define BSEC_VIOLATION_CONFIG_SEC_VIO_CFG_GET(x) (((uint32_t)(x) & BSEC_VIOLATION_CONFIG_SEC_VIO_CFG_MASK) >> BSEC_VIOLATION_CONFIG_SEC_VIO_CFG_SHIFT)
  149. /* Bitfield definition for register: ESCALATE_CONFIG */
  150. /*
  151. * LOCK_NSC (RW)
  152. *
  153. * Lock bit non-secure escalate setting, once locked, lock bit itself and configuration will keep value until next reset
  154. * 0: not locked, configuration can be modified
  155. * 1: register locked, write access to the configuration is ignored
  156. */
  157. #define BSEC_ESCALATE_CONFIG_LOCK_NSC_MASK (0x80000000UL)
  158. #define BSEC_ESCALATE_CONFIG_LOCK_NSC_SHIFT (31U)
  159. #define BSEC_ESCALATE_CONFIG_LOCK_NSC_SET(x) (((uint32_t)(x) << BSEC_ESCALATE_CONFIG_LOCK_NSC_SHIFT) & BSEC_ESCALATE_CONFIG_LOCK_NSC_MASK)
  160. #define BSEC_ESCALATE_CONFIG_LOCK_NSC_GET(x) (((uint32_t)(x) & BSEC_ESCALATE_CONFIG_LOCK_NSC_MASK) >> BSEC_ESCALATE_CONFIG_LOCK_NSC_SHIFT)
  161. /*
  162. * NSC_VIO_CFG (RW)
  163. *
  164. * configuration of non-secure state escalates, each bit represents one security event
  165. * 0: event is not a security escalate
  166. * 1: event is a security escalate
  167. */
  168. #define BSEC_ESCALATE_CONFIG_NSC_VIO_CFG_MASK (0x7FFF0000UL)
  169. #define BSEC_ESCALATE_CONFIG_NSC_VIO_CFG_SHIFT (16U)
  170. #define BSEC_ESCALATE_CONFIG_NSC_VIO_CFG_SET(x) (((uint32_t)(x) << BSEC_ESCALATE_CONFIG_NSC_VIO_CFG_SHIFT) & BSEC_ESCALATE_CONFIG_NSC_VIO_CFG_MASK)
  171. #define BSEC_ESCALATE_CONFIG_NSC_VIO_CFG_GET(x) (((uint32_t)(x) & BSEC_ESCALATE_CONFIG_NSC_VIO_CFG_MASK) >> BSEC_ESCALATE_CONFIG_NSC_VIO_CFG_SHIFT)
  172. /*
  173. * LOCK_SEC (RW)
  174. *
  175. * Lock bit secure escalate setting, once locked, lock bit itself and configuration will keep value until next reset
  176. * 0: not locked, configuration can be modified1: register locked, write access to the configuration is ignored
  177. */
  178. #define BSEC_ESCALATE_CONFIG_LOCK_SEC_MASK (0x8000U)
  179. #define BSEC_ESCALATE_CONFIG_LOCK_SEC_SHIFT (15U)
  180. #define BSEC_ESCALATE_CONFIG_LOCK_SEC_SET(x) (((uint32_t)(x) << BSEC_ESCALATE_CONFIG_LOCK_SEC_SHIFT) & BSEC_ESCALATE_CONFIG_LOCK_SEC_MASK)
  181. #define BSEC_ESCALATE_CONFIG_LOCK_SEC_GET(x) (((uint32_t)(x) & BSEC_ESCALATE_CONFIG_LOCK_SEC_MASK) >> BSEC_ESCALATE_CONFIG_LOCK_SEC_SHIFT)
  182. /*
  183. * SEC_VIO_CFG (RW)
  184. *
  185. * configuration of secure state escalates, each bit represents one security event
  186. * 0: event is not a security escalate
  187. * 1: event is a security escalate
  188. */
  189. #define BSEC_ESCALATE_CONFIG_SEC_VIO_CFG_MASK (0x7FFFU)
  190. #define BSEC_ESCALATE_CONFIG_SEC_VIO_CFG_SHIFT (0U)
  191. #define BSEC_ESCALATE_CONFIG_SEC_VIO_CFG_SET(x) (((uint32_t)(x) << BSEC_ESCALATE_CONFIG_SEC_VIO_CFG_SHIFT) & BSEC_ESCALATE_CONFIG_SEC_VIO_CFG_MASK)
  192. #define BSEC_ESCALATE_CONFIG_SEC_VIO_CFG_GET(x) (((uint32_t)(x) & BSEC_ESCALATE_CONFIG_SEC_VIO_CFG_MASK) >> BSEC_ESCALATE_CONFIG_SEC_VIO_CFG_SHIFT)
  193. /* Bitfield definition for register: EVENT */
  194. /*
  195. * EVENT (RO)
  196. *
  197. * local event statue, each bit represents one security event
  198. */
  199. #define BSEC_EVENT_EVENT_MASK (0xFFFF0000UL)
  200. #define BSEC_EVENT_EVENT_SHIFT (16U)
  201. #define BSEC_EVENT_EVENT_GET(x) (((uint32_t)(x) & BSEC_EVENT_EVENT_MASK) >> BSEC_EVENT_EVENT_SHIFT)
  202. /*
  203. * BATT_ESC_NSC (RO)
  204. *
  205. * BATT is escalating non-secure event
  206. */
  207. #define BSEC_EVENT_BATT_ESC_NSC_MASK (0x2U)
  208. #define BSEC_EVENT_BATT_ESC_NSC_SHIFT (1U)
  209. #define BSEC_EVENT_BATT_ESC_NSC_GET(x) (((uint32_t)(x) & BSEC_EVENT_BATT_ESC_NSC_MASK) >> BSEC_EVENT_BATT_ESC_NSC_SHIFT)
  210. /*
  211. * BATT_ESC_SEC (RO)
  212. *
  213. * BATT is escalting ssecure event
  214. */
  215. #define BSEC_EVENT_BATT_ESC_SEC_MASK (0x1U)
  216. #define BSEC_EVENT_BATT_ESC_SEC_SHIFT (0U)
  217. #define BSEC_EVENT_BATT_ESC_SEC_GET(x) (((uint32_t)(x) & BSEC_EVENT_BATT_ESC_SEC_MASK) >> BSEC_EVENT_BATT_ESC_SEC_SHIFT)
  218. #endif /* HPM_BSEC_H */