cpufeature.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. #ifndef __CPUFEATURE_H__
  2. #define __CPUFEATURE_H__
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. // NOTE: This header file is used to tell us the Nuclei CPU Feature
  7. // Currently for the evalsoc's cpu feature, we manually create this header file
  8. // but for our customer, you can use nuclei_gen tool to generate it, and just replace it
  9. // If you want to create it on your own, please modify these files:
  10. // cpufeature.h, cpufeature.mk, openocd_evalsoc.cfg and evalsoc.memory
  11. // and the iar project linker script files *.icf
  12. // TODO: You can replace this file using the generated one by `nuclei_gen` tool
  13. // NOTE:
  14. // These `XLCFG_xxx` macros are defined by `SoC/evalsoc/cpuconfig.mk` and it should be only used
  15. // in this not generated `cpufeature.h` file.
  16. // It will control the RTL defined macros when CPU RTL configuration defined, for example:
  17. // - When XLCFG_SMPU is defined as 1, it will define CFG_HAS_SMPU
  18. // - When XLCFG_ECLIC is defined as 2, it will define CFG_HAS_ECLICV2 and CFG_HAS_CLIC
  19. // - When XLCFG_ECLIC is defined as 0, it will undef CFG_HAS_CLIC
  20. // These feature allow dynamic enable/disable cpu feature via make command when this cpufeature.h is not generated,
  21. // it is useful for internal testing for different bitstream file with different CPU RTL configuration
  22. // NOTE: CPU FEATURE CONFIGURATION MAP:
  23. // ENABLED_BY_DEFAULT = [
  24. // "ECLIC", "SYSTIMER", "SMPCC", "PMP", "SMEPMP", "NICE", "VNICE",
  25. // "EXCP", "ILM", "DLM", "ICACHE", "DCACHE", "UMODE", "PMA", "PMA_MACRO",
  26. // "STACK_CHECK", "AMO", "ECC", "MISALIGNED_ACCESS", "SRAM", "DDR", "HPM-v1"
  27. // ]
  28. // DISABLED_BY_DEFAULT = [
  29. // "CCM", "CIDU", "TEE", "SMPU", "SPMP", "SSTC", "SMODE", "PLIC"
  30. // ]
  31. //
  32. // The CFG_IREGION_BASE_ADDR is only defined in generated cpufeature.h or if you know the
  33. // cpu iregion baseaddr you can set it
  34. // #define CFG_IREGION_BASE_ADDR YOUR_CPU_IREGION_BASE_ADDR
  35. #define CFG_CPU_SERIES 0xFFFFFF
  36. #define CFG_CPU_VER 0xFFFFFF
  37. // NOTE: By default enabled features
  38. #if !(defined(XLCFG_ECLIC) && XLCFG_ECLIC == 0)
  39. #define CFG_HAS_CLIC
  40. #if XLCFG_ECLIC == 2
  41. #define CFG_HAS_ECLICV2
  42. #endif
  43. #endif
  44. // External Interrupt Number
  45. #if defined(XLCFG_IRQ_NUM)
  46. #define CFG_IRQ_NUM XLCFG_IRQ_NUM
  47. #else
  48. #define CFG_IRQ_NUM 50
  49. #endif
  50. #if !(defined(XLCFG_SYSTIMER) && XLCFG_SYSTIMER == 0)
  51. #define CFG_TMR_PRIVATE
  52. #endif
  53. #if !(defined(XLCFG_SMPCC) && XLCFG_SMPCC == 0)
  54. #define CFG_HAS_SMP
  55. #endif
  56. #if !(defined(XLCFG_PMP) && XLCFG_PMP == 0)
  57. #define CFG_HAS_PMP
  58. #define CFG_HAS_UMODE
  59. #ifdef XLCFG_PMP_ENTRY_NUM
  60. #define CFG_PMP_ENTRY_NUM XLCFG_PMP_ENTRY_NUM
  61. #else
  62. #define CFG_PMP_ENTRY_NUM 8
  63. #endif
  64. #ifdef XLCFG_PMP_GRAIN
  65. #define CFG_PMP_GRAIN XLCFG_PMP_GRAIN
  66. #else
  67. #define CFG_PMP_GRAIN 10
  68. #endif
  69. #endif
  70. #if !(defined(XLCFG_SMEPMP) && XLCFG_SMEPMP == 0)
  71. #define CFG_HAS_SMEPMP
  72. #endif
  73. #if !(defined(XLCFG_NICE) && XLCFG_NICE == 0)
  74. #define CFG_HAS_NICE
  75. #endif
  76. #if !(defined(XLCFG_VNICE) && XLCFG_VNICE == 0)
  77. #define CFG_HAS_VNICE
  78. #endif
  79. #if !(defined(XLCFG_EXCP) && XLCFG_EXCP == 0)
  80. #define CFG_HAS_EXCP
  81. #endif
  82. #if !(defined(XLCFG_ILM) && XLCFG_ILM == 0)
  83. #define CFG_HAS_ILM
  84. #endif
  85. #if !(defined(XLCFG_DLM) && XLCFG_DLM == 0)
  86. #define CFG_HAS_DLM
  87. #endif
  88. #if !(defined(XLCFG_ICACHE) && XLCFG_ICACHE == 0)
  89. #define CFG_HAS_ICACHE
  90. #endif
  91. #if !(defined(XLCFG_DCACHE) && XLCFG_DCACHE == 0)
  92. #define CFG_HAS_DCACHE
  93. #endif
  94. #if !(defined(XLCFG_ECC) && XLCFG_ECC == 0)
  95. #define CFG_HAS_ECC
  96. #if XLCFG_ECC == 2
  97. #define CFG_ECC_CODE_XOR
  98. #endif
  99. #endif
  100. #if !(defined(XLCFG_PMA) && XLCFG_PMA == 0)
  101. #define CFG_HAS_PMA
  102. #if defined(XLCFG_PMA_CSR_NUM)
  103. #define CFG_PMA_CSR_NUM XLCFG_PMA_CSR_NUM
  104. #else
  105. #define CFG_PMA_CSR_NUM 8
  106. #endif
  107. #if defined(XLCFG_PMA_SEC_CSR_NUM)
  108. #define CFG_PMA_SEC_CSR_NUM XLCFG_PMA_SEC_CSR_NUM
  109. #else
  110. #define CFG_PMA_SEC_CSR_NUM 8
  111. #endif
  112. #endif
  113. #if !(defined(XLCFG_PMA_MACRO) && XLCFG_PMA_MACRO == 0)
  114. #define CFG_HAS_PMA_MACRO
  115. #endif
  116. #if !(defined(XLCFG_STACK_CHECK) && XLCFG_STACK_CHECK == 0)
  117. #define CFG_HAS_STACK_CHECK
  118. #endif
  119. #if !(defined(XLCFG_AMO) && XLCFG_AMO == 0)
  120. #define CFG_HAS_AMO
  121. #endif
  122. #if !(defined(XLCFG_MISALIGNED_ACCESS) && XLCFG_MISALIGNED_ACCESS == 0)
  123. #define CFG_HAS_MISALIGNED_ACCESS
  124. #endif
  125. #if !(defined(XLCFG_SRAM) && XLCFG_SRAM == 0)
  126. #define CFG_HAS_SRAM
  127. #endif
  128. #if !(defined(XLCFG_DDR) && XLCFG_DDR == 0)
  129. #define CFG_HAS_DDR
  130. #endif
  131. #if !(defined(XLCFG_HPM) && XLCFG_HPM == 0)
  132. #define CFG_HAS_HPM
  133. #define CFG_HPM_VER XLCFG_HPM
  134. #endif
  135. // NOTE: By default disabled features
  136. #if defined(XLCFG_CCM) && XLCFG_CCM != 0
  137. #define CFG_HAS_CCM
  138. #endif
  139. #if defined(XLCFG_CIDU) && XLCFG_CIDU != 0
  140. #define CFG_HAS_IDU
  141. #endif
  142. #if defined(XLCFG_PLIC) && XLCFG_PLIC != 0
  143. #define CFG_HAS_PLIC
  144. #endif
  145. #if defined(XLCFG_TEE) && XLCFG_TEE != 0
  146. #define CFG_HAS_TEE
  147. #endif
  148. #if defined(XLCFG_UMODE) && XLCFG_UMODE != 0
  149. #ifndef CFG_HAS_UMODE
  150. #define CFG_HAS_UMODE
  151. #endif
  152. #endif
  153. #if defined(XLCFG_SMPU) && XLCFG_SMPU != 0
  154. #define CFG_HAS_SMPU
  155. #endif
  156. #if defined(XLCFG_SPMP) && XLCFG_SPMP != 0
  157. #define CFG_HAS_SPMP
  158. #endif
  159. #if defined(XLCFG_SSTC) && XLCFG_SSTC != 0
  160. #define CFG_HAS_ISA_SSTC
  161. #endif
  162. #if defined(XLCFG_SMODE) && XLCFG_SMODE != 0
  163. #define CFG_HAS_SMODE
  164. #endif
  165. #if defined(XLCFG_CCM) && XLCFG_CCM != 0
  166. #define CFG_HAS_IOCC
  167. #endif
  168. #define CFG_ILM_BASE_ADDR (0x80000000UL)
  169. #define CFG_DLM_BASE_ADDR (0x90000000UL)
  170. // EVALSOC Features
  171. #define EVALSOC_FLASH_XIP_BASE (0x20000000UL)
  172. #define EVALSOC_SYSMEM_BASE (0xA0000000UL)
  173. #define EVALSOC_PERIPS_BASE (0x10000000UL)
  174. #ifdef __cplusplus
  175. }
  176. #endif
  177. #endif