tzc400.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * Copyright (c) 2014-2021, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef TZC400_H
  7. #define TZC400_H
  8. #include <drivers/arm/tzc_common.h>
  9. #include <lib/utils_def.h>
  10. #define BUILD_CONFIG_OFF U(0x000)
  11. #define GATE_KEEPER_OFF U(0x008)
  12. #define SPECULATION_CTRL_OFF U(0x00c)
  13. #define INT_STATUS U(0x010)
  14. #define INT_CLEAR U(0x014)
  15. #define FAIL_ADDRESS_LOW_OFF U(0x020)
  16. #define FAIL_ADDRESS_HIGH_OFF U(0x024)
  17. #define FAIL_CONTROL_OFF U(0x028)
  18. #define FAIL_ID U(0x02c)
  19. /* ID registers not common across different varieties of TZC */
  20. #define PID5 U(0xFD4)
  21. #define PID6 U(0xFD8)
  22. #define PID7 U(0xFDC)
  23. #define BUILD_CONFIG_NF_SHIFT 24
  24. #define BUILD_CONFIG_NF_MASK U(0x3)
  25. #define BUILD_CONFIG_AW_SHIFT 8
  26. #define BUILD_CONFIG_AW_MASK U(0x3f)
  27. #define BUILD_CONFIG_NR_SHIFT 0
  28. #define BUILD_CONFIG_NR_MASK U(0x1f)
  29. /*
  30. * Number of gate keepers is implementation defined. But we know the max for
  31. * this device is 4. Get implementation details from BUILD_CONFIG.
  32. */
  33. #define GATE_KEEPER_OS_SHIFT 16
  34. #define GATE_KEEPER_OS_MASK U(0xf)
  35. #define GATE_KEEPER_OR_SHIFT 0
  36. #define GATE_KEEPER_OR_MASK U(0xf)
  37. #define GATE_KEEPER_FILTER_MASK U(0x1)
  38. /* Speculation is enabled by default. */
  39. #define SPECULATION_CTRL_WRITE_DISABLE BIT_32(1)
  40. #define SPECULATION_CTRL_READ_DISABLE BIT_32(0)
  41. /* Max number of filters allowed is 4. */
  42. #define INT_STATUS_OVERLAP_SHIFT 16
  43. #define INT_STATUS_OVERLAP_MASK U(0xf)
  44. #define INT_STATUS_OVERRUN_SHIFT 8
  45. #define INT_STATUS_OVERRUN_MASK U(0xf)
  46. #define INT_STATUS_STATUS_SHIFT 0
  47. #define INT_STATUS_STATUS_MASK U(0xf)
  48. #define INT_CLEAR_CLEAR_SHIFT 0
  49. #define INT_CLEAR_CLEAR_MASK U(0xf)
  50. #define FAIL_CONTROL_DIR_SHIFT 24
  51. #define FAIL_CONTROL_DIR_READ U(0)
  52. #define FAIL_CONTROL_DIR_WRITE U(1)
  53. #define FAIL_CONTROL_NS_SHIFT 21
  54. #define FAIL_CONTROL_NS_SECURE U(0)
  55. #define FAIL_CONTROL_NS_NONSECURE U(1)
  56. #define FAIL_CONTROL_PRIV_SHIFT 20
  57. #define FAIL_CONTROL_PRIV_UNPRIV U(0)
  58. #define FAIL_CONTROL_PRIV_PRIV U(1)
  59. /*
  60. * FAIL_ID_ID_MASK depends on AID_WIDTH which is platform specific.
  61. * Platform should provide the value on initialisation.
  62. */
  63. #define FAIL_ID_VNET_SHIFT 24
  64. #define FAIL_ID_VNET_MASK U(0xf)
  65. #define FAIL_ID_ID_SHIFT 0
  66. #define TZC_400_PERIPHERAL_ID U(0x460)
  67. /* Filter enable bits in a TZC */
  68. #define TZC_400_REGION_ATTR_F_EN_MASK U(0xf)
  69. #define TZC_400_REGION_ATTR_FILTER_BIT(x) (U(1) << (x))
  70. #define TZC_400_REGION_ATTR_FILTER_BIT_ALL TZC_400_REGION_ATTR_F_EN_MASK
  71. /*
  72. * All TZC region configuration registers are placed one after another. It
  73. * depicts size of block of registers for programming each region.
  74. */
  75. #define TZC_400_REGION_SIZE U(0x20)
  76. #define TZC_400_ACTION_OFF U(0x4)
  77. #define FILTER_OFFSET U(0x10)
  78. #ifndef __ASSEMBLER__
  79. #include <cdefs.h>
  80. #include <stdint.h>
  81. /*******************************************************************************
  82. * Function & variable prototypes
  83. ******************************************************************************/
  84. void tzc400_init(uintptr_t base);
  85. void tzc400_configure_region0(unsigned int sec_attr,
  86. unsigned int ns_device_access);
  87. void tzc400_configure_region(unsigned int filters,
  88. unsigned int region,
  89. unsigned long long region_base,
  90. unsigned long long region_top,
  91. unsigned int sec_attr,
  92. unsigned int nsaid_permissions);
  93. void tzc400_update_filters(unsigned int region, unsigned int filters);
  94. void tzc400_set_action(unsigned int action);
  95. void tzc400_enable_filters(void);
  96. void tzc400_disable_filters(void);
  97. int tzc400_it_handler(void);
  98. static inline void tzc_init(uintptr_t base)
  99. {
  100. tzc400_init(base);
  101. }
  102. static inline void tzc_configure_region0(
  103. unsigned int sec_attr,
  104. unsigned int ns_device_access)
  105. {
  106. tzc400_configure_region0(sec_attr, ns_device_access);
  107. }
  108. static inline void tzc_configure_region(
  109. unsigned int filters,
  110. unsigned int region,
  111. unsigned long long region_base,
  112. unsigned long long region_top,
  113. unsigned int sec_attr,
  114. unsigned int ns_device_access)
  115. {
  116. tzc400_configure_region(filters, region, region_base,
  117. region_top, sec_attr, ns_device_access);
  118. }
  119. static inline void tzc_set_action(unsigned int action)
  120. {
  121. tzc400_set_action(action);
  122. }
  123. static inline void tzc_enable_filters(void)
  124. {
  125. tzc400_enable_filters();
  126. }
  127. static inline void tzc_disable_filters(void)
  128. {
  129. tzc400_disable_filters();
  130. }
  131. #endif /* __ASSEMBLER__ */
  132. #endif /* TZC400_H */