cpuinfo.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. #ifndef __CPUINFO_H__
  2. #define __CPUINFO_H__
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <stdint.h>
  7. /* IREGION Offsets */
  8. #define CPUINFO_IRG_IINFO_OFS (0x0)
  9. #define CPUINFO_IRG_DEBUG_OFS (0x10000)
  10. #define CPUINFO_IRG_ECLIC_OFS (0x20000)
  11. #define CPUINFO_IRG_TIMER_OFS (0x30000)
  12. #define CPUINFO_IRG_SMP_OFS (0x40000)
  13. #define CPUINFO_IRG_IDU_OFS (0x50000)
  14. #define CPUINFO_IRG_PL2_OFS (0x60000)
  15. #define CPUINFO_IRG_DPREFETCH_OFS (0x70000)
  16. #define CPUINFO_IRG_PLIC_OFS (0x4000000)
  17. /* NOTE: The CSR register length various between 32-bit and 64-bit
  18. * but usually the effective data is in the lower 32 bits. So we
  19. * use 32-bit data type to represent most of these registers. */
  20. typedef uint32_t u32_csr_t;
  21. typedef uint64_t u64_csr_t;
  22. /**
  23. * \brief Union type to access MCFG_INFO CSR register.
  24. */
  25. typedef union {
  26. struct {
  27. u32_csr_t tee:1; /*!< bit: 0 TEE present */
  28. u32_csr_t ecc:1; /*!< bit: 1 ECC present */
  29. u32_csr_t eclic:1; /*!< bit: 2 ECLIC present */
  30. u32_csr_t plic:1; /*!< bit: 3 PLIC present */
  31. u32_csr_t fio:1; /*!< bit: 4 FIO present */
  32. u32_csr_t ppi:1; /*!< bit: 5 PPI present */
  33. u32_csr_t nice:1; /*!< bit: 6 NICE present */
  34. u32_csr_t ilm:1; /*!< bit: 7 ILM present */
  35. u32_csr_t dlm:1; /*!< bit: 8 DLM present */
  36. u32_csr_t icache:1; /*!< bit: 9 ICache present */
  37. u32_csr_t dcache:1; /*!< bit: 10 DCache present */
  38. u32_csr_t smp:1; /*!< bit: 11 SMP present */
  39. u32_csr_t dsp_n1:1; /*!< bit: 12 DSP N1 present */
  40. u32_csr_t dsp_n2:1; /*!< bit: 13 DSP N2 present */
  41. u32_csr_t dsp_n3:1; /*!< bit: 14 DSP N3 present */
  42. u32_csr_t zc_xlcz:1; /*!< bit: 15 Zc or Zc and xlcz extension present */
  43. u32_csr_t iregion:1; /*!< bit: 16 IREGION present */
  44. u32_csr_t vpu_degree:2; /*!< bit: 17..18 Indicate the VPU degree of parallel */
  45. u32_csr_t sec_mode:1; /*!< bit: 19 Smwg extension present */
  46. u32_csr_t etrace:1; /*!< bit: 20 Etrace present */
  47. u32_csr_t safety_mecha:2; /*!< bit: 21..22 Indicate Core's safety mechanism */
  48. u32_csr_t vnice:1; /*!< bit: 23 VNICE present */
  49. u32_csr_t xlcz:1; /*!< bit: 24 XLCZ extension present */
  50. u32_csr_t zilsd:1; /*!< bit: 25 Zilsd/Zclsd extension present */
  51. u32_csr_t sstc:1; /*!< bit: 26 SSTC extension present */
  52. u32_csr_t :5; /*!< bit: 27..31 Reserved */
  53. } b; /*!< Structure used for bit access */
  54. u32_csr_t d; /*!< Type used for csr data access */
  55. } U32_CSR_MCFG_INFO_Type;
  56. /**
  57. * \brief Union type to access MICFG_INFO CSR register.
  58. */
  59. typedef union {
  60. struct {
  61. u32_csr_t set:4; /*!< bit: 0..3 I-Cache sets per way */
  62. u32_csr_t way:3; /*!< bit: 4..6 I-Cache way */
  63. u32_csr_t lsize:3; /*!< bit: 7..9 I-Cache line size */
  64. u32_csr_t ecc:1; /*!< bit: 10 I-Cache ECC support */
  65. u32_csr_t :5; /*!< bit: 11..15 Reserved */
  66. u32_csr_t lm_size:5; /*!< bit: 16..20 ILM size, need to be 2^n size */
  67. u32_csr_t lm_xonly:1; /*!< bit: 21 ILM Execute only permission or Reserved */
  68. u32_csr_t lm_ecc:1; /*!< bit: 22 ILM ECC support */
  69. u32_csr_t :9; /*!< bit: 23..31 Reserved */
  70. } b; /*!< Structure used for bit access */
  71. u32_csr_t d; /*!< Type used for csr data access */
  72. } U32_CSR_MICFG_INFO_Type;
  73. /**
  74. * \brief Union type to access MDCFG_INFO CSR register.
  75. */
  76. typedef union {
  77. struct {
  78. u32_csr_t set:4; /*!< bit: 0..3 D-Cache sets per way */
  79. u32_csr_t way:3; /*!< bit: 4..6 D-Cache way */
  80. u32_csr_t lsize:3; /*!< bit: 7..9 D-Cache line size */
  81. u32_csr_t ecc:1; /*!< bit: 10 D-Cache ECC support */
  82. u32_csr_t :5; /*!< bit: 11..15 Reserved */
  83. u32_csr_t lm_size:5; /*!< bit: 16..20 DLM size, need to be 2^n size */
  84. u32_csr_t lm_ecc:1; /*!< bit: 21 DLM ECC present */
  85. u32_csr_t :10; /*!< bit: 22..31 Reserved */
  86. } b; /*!< Structure used for bit access */
  87. u32_csr_t d; /*!< Type used for csr data access */
  88. } U32_CSR_MDCFG_INFO_Type;
  89. /**
  90. * \brief Union type to access MTLBCFG_INFO CSR register.
  91. */
  92. typedef union {
  93. struct {
  94. u32_csr_t set:4; /*!< bit: 0..3 Main TLB entry per way */
  95. u32_csr_t way:3; /*!< bit: 4..6 Main TLB ways */
  96. u32_csr_t lsize:3; /*!< bit: 7..9 Main TLB line size or Reserved */
  97. u32_csr_t ecc:1; /*!< bit: 10 Main TLB supports ECC or not */
  98. u32_csr_t napot:1; /*!< bit: 11 TLB supports Svnapot or not */
  99. u32_csr_t :4; /*!< bit: 12..15 Reserved */
  100. u32_csr_t i_size:3; /*!< bit: 16..18 ITLB size */
  101. u32_csr_t d_size:3; /*!< bit: 19..21 DTLB size */
  102. u32_csr_t :9; /*!< bit: 22..30 Reserved */
  103. u32_csr_t mapping:1; /*!< bit: 31 TLB mapping type */
  104. } b; /*!< Structure used for bit access */
  105. struct {
  106. u32_csr_t set:4; /*!< bit: 0..3 Main TLB entry per way */
  107. u32_csr_t way:3; /*!< bit: 4..6 Main TLB ways */
  108. u32_csr_t lsize:3; /*!< bit: 7..9 Main TLB line size or Reserved */
  109. u32_csr_t ecc:1; /*!< bit: 10 Main TLB supports ECC or not */
  110. u32_csr_t napot:1; /*!< bit: 11 TLB supports Svnapot or not */
  111. u32_csr_t i_size:7; /*!< bit: 12..18 ITLB size */
  112. u32_csr_t d_size:8; /*!< bit: 19..26 DTLB size */
  113. u32_csr_t :4; /*!< bit: 27..30 Reserved */
  114. u32_csr_t mapping:1; /*!< bit: 31 mapping type */
  115. } nb; /*!< Structure used for bit access */
  116. u32_csr_t d; /*!< Type used for csr data access */
  117. } U32_CSR_MTLBCFG_INFO_Type;
  118. /**
  119. * \brief Union type to access MARCHID CSR register.
  120. */
  121. typedef union {
  122. struct {
  123. u32_csr_t last_name:4; /*!< bit: 0..3 the last series name */
  124. u32_csr_t third_name:4; /*!< bit: 4..7 the third series name */
  125. u32_csr_t second_name:4; /*!< bit: 8..11 the second series name */
  126. u32_csr_t first_name:4; /*!< bit: 12..15 the first series name */
  127. u32_csr_t :16; /*!< bit: 16..31 Reserved */
  128. } b; /*!< Structure used for bit access */
  129. u32_csr_t d; /*!< Type used for csr data access */
  130. } U32_CSR_MARCHID_Type;
  131. /**
  132. * \brief Union type to access MIMPID CSR register.
  133. */
  134. typedef union {
  135. struct {
  136. u32_csr_t last_vernum:8; /*!< bit: 0..7 the last version number */
  137. u32_csr_t mid_vernum:8; /*!< bit: 8..15 the middle version number */
  138. u32_csr_t first_vernum:8; /*!< bit: 16..23 the first version number */
  139. u32_csr_t :8; /*!< bit: 24..31 Reserved */
  140. } b; /*!< Structure used for bit access */
  141. u32_csr_t d; /*!< Type used for csr data access */
  142. } U32_CSR_MIMPID_Type;
  143. /**
  144. * \brief Union type to access low 26 bits of MISA CSR register.
  145. *
  146. */
  147. typedef union {
  148. struct {
  149. u32_csr_t A:1; /*!< bit: 0 Atomic extension */
  150. u32_csr_t B:1; /*!< bit: 1 B extension */
  151. u32_csr_t C:1; /*!< bit: 2 Compressed exteionsion */
  152. u32_csr_t D:1; /*!< bit: 3 Double-precision floating-point extension */
  153. u32_csr_t E:1; /*!< bit: 4 RV32E/64E base ISA */
  154. u32_csr_t F:1; /*!< bit: 5 Single-precision floating-point extension */
  155. u32_csr_t G:1; /*!< bit: 6 Reserved */
  156. u32_csr_t H:1; /*!< bit: 7 Hypervisor extension */
  157. u32_csr_t I:1; /*!< bit: 8 RV32I/64I/128I base ISA */
  158. u32_csr_t J:1; /*!< bit: 9 Reserved */
  159. u32_csr_t K:1; /*!< bit: 10 Reserved */
  160. u32_csr_t L:1; /*!< bit: 11 Reserved */
  161. u32_csr_t M:1; /*!< bit: 12 Integer Multiply/Divide extension */
  162. u32_csr_t N:1; /*!< bit: 13 Tentatively reserved for User-Level Interrupts extension */
  163. u32_csr_t O:1; /*!< bit: 14 Reserved */
  164. u32_csr_t P:1; /*!< bit: 15 Tentatively reserved for Packed-SIMD extension */
  165. u32_csr_t Q:1; /*!< bit: 16 Quad-precision floating-point extension */
  166. u32_csr_t R:1; /*!< bit: 17 Reserved */
  167. u32_csr_t S:1; /*!< bit: 18 Supervisor mode implemented */
  168. u32_csr_t T:1; /*!< bit: 19 Reserved */
  169. u32_csr_t U:1; /*!< bit: 20 User mode implemented */
  170. u32_csr_t V:1; /*!< bit: 21 Vector extension */
  171. u32_csr_t W:1; /*!< bit: 22 Reserved */
  172. u32_csr_t X:1; /*!< bit: 23 Non-standard extension present */
  173. u32_csr_t Y:1; /*!< bit: 24 Reserved */
  174. u32_csr_t Z:1; /*!< bit: 25 Reserved */
  175. u32_csr_t :6; /*!< bit: 26..31 Reserved */
  176. } b; /*!< Structure used for bit access */
  177. u32_csr_t d; /*!< Type used for csr data access */
  178. } U32_CSR_MISA_Type;
  179. /**
  180. * \brief Union type to access MIRGB_INFO CSR register.
  181. */
  182. typedef union {
  183. struct {
  184. u64_csr_t :1; /*!< bit: 0 Reserved */
  185. u64_csr_t iregion_size:5; /*!< bit: 1..5 IREGION size */
  186. u64_csr_t :4; /*!< bit: 6..9 Reserved */
  187. u64_csr_t iregion_base:54; /*!< bit: 10..63 IREGION base */
  188. } b; /*!< Structure used for bit access */
  189. u64_csr_t d; /*!< Type used for csr data access */
  190. } U64_CSR_MIRGB_INFO_Type;
  191. /**
  192. * \brief Union type to access MPPICFG_INFO CSR register.
  193. */
  194. typedef union {
  195. struct {
  196. u64_csr_t :1; /*!< bit: 0 Reserved */
  197. u64_csr_t ppi_size:5; /*!< bit: 1..5 PPI size */
  198. u64_csr_t :3; /*!< bit: 6..8 Reserved */
  199. u64_csr_t :1; /*!< bit: 9 PPI Enable */
  200. u64_csr_t ppi_base:54; /*!< bit: 10..63 PPI base */
  201. } b; /*!< Structure used for bit access */
  202. u64_csr_t d; /*!< Type used for csr data access */
  203. } U64_CSR_MPPICFG_INFO_Type;
  204. /**
  205. * \brief Union type to access MFIOCFG_INFO CSR register.
  206. */
  207. typedef union {
  208. struct {
  209. u64_csr_t :1; /*!< bit: 0 Reserved */
  210. u64_csr_t fio_size:5; /*!< bit: 1..5 FIO size */
  211. u64_csr_t :4; /*!< bit: 6..9 Reserved */
  212. u64_csr_t fio_base:54; /*!< bit: 10..63 FIO base */
  213. } b; /*!< Structure used for bit access */
  214. u64_csr_t d; /*!< Type used for csr data access */
  215. } U64_CSR_MFIOCFG_INFO_Type;
  216. /* IREGION INFO Memory-Mapped Register Type*/
  217. typedef struct {
  218. uint32_t mpasize; /*!< offset 0x0000 */
  219. uint32_t cmo_info; /*!< offset 0x0004 */
  220. uint32_t sec_base_addr_lo; /*!< offset 0x0008 */
  221. uint32_t sec_base_addr_hi; /*!< offset 0x000C */
  222. uint32_t sec_cfg_info; /*!< offset 0x0010 */
  223. uint32_t reserved0[4]; /*!< offset 0x0014 */
  224. uint32_t mvlm_cfg_lo; /*!< offset 0x0024 */
  225. uint32_t mvlm_cfg_hi; /*!< offset 0x0028 */
  226. uint32_t flash_base_addr_lo; /*!< offset 0x002C */
  227. uint32_t flash_base_addr_hi; /*!< offset 0x0030 */
  228. uint32_t reserved1[7]; /*!< offset 0x0034 */
  229. uint32_t vpu_cfg_info; /*!< offset 0x0050 */
  230. uint32_t mem_region0_cfg_lo; /*!< offset 0x0054 */
  231. uint32_t mem_region0_cfg_hi; /*!< offset 0x0058 */
  232. uint32_t mem_region1_cfg_lo; /*!< offset 0x005c */
  233. uint32_t mem_region1_cfg_hi; /*!< offset 0x0060 */
  234. uint32_t reserved2[3]; /*!< offset 0x0064 */
  235. uint32_t isa_support0; /*!< offset 0x0070 */
  236. uint32_t isa_support1; /*!< offset 0x0074 */
  237. uint32_t reserved3[2]; /*!< offset 0x0078 */
  238. uint32_t mcppi_cfg_lo; /*!< offset 0x0080 */
  239. uint32_t mcppi_cfg_hi; /*!< offset 0x0084 */
  240. uint32_t reserved4[2]; /*!< offset 0x0088 */
  241. uint32_t performance_cfg0; /*!< offset 0x0090 */
  242. uint32_t performance_cfg1; /*!< offset 0x0094 */
  243. uint32_t reserved5[26]; /*!< offset 0x0098 */
  244. uint32_t pfl1dctrl1; /*!< offset 0x0100 */
  245. uint32_t pfl1dctrl2; /*!< offset 0x0104 */
  246. uint32_t mergel1dctrl; /*!< offset 0x0108 */
  247. uint32_t reserved6; /*!< offset 0x010C */
  248. uint32_t safety_ctrl; /*!< offset 0x0110 */
  249. uint32_t access_ctrl; /*!< offset 0x0114 */
  250. uint32_t reserved7[2]; /*!< offset 0x0118 */
  251. uint32_t pfl1dctrl3; /*!< offset 0x0120 */
  252. uint32_t pfl1dctrl4; /*!< offset 0x0124 */
  253. uint32_t pfl1info; /*!< offset 0x0128 */
  254. uint32_t reserved8[27]; /*!< offset 0x012C */
  255. uint32_t crc_rf0; /*!< offset 0x0198 */
  256. uint32_t crc_rf1; /*!< offset 0x019C */
  257. uint32_t crc_fp0; /*!< offset 0x01A0 */
  258. } CIF_IINFO_Type;
  259. /**
  260. * \brief Union type to access SMP_CFG register.
  261. */
  262. typedef union {
  263. struct {
  264. u32_csr_t cc:1; /*!< bit: 0 Cluster Cache present */
  265. u32_csr_t smp_core_num:6; /*!< bit: 1..6 smp core number */
  266. u32_csr_t iocp_num:6; /*!< bit: 7..12 IO Coherency port number */
  267. u32_csr_t pmon_num:6; /*!< bit: 13..18 performance monitor number */
  268. u32_csr_t :13; /*!< bit: 19..31 Reserved 0 */
  269. } b; /*!< Structure used for bit access */
  270. u32_csr_t d; /*!< Type used for register data access */
  271. } U32_SMP_CFG_Type;
  272. /**
  273. * \brief Union type to access CC_CFG register.
  274. */
  275. typedef union {
  276. struct {
  277. u32_csr_t set:4; /*!< bit: 0..3 Cluster cache set number */
  278. u32_csr_t way:4; /*!< bit: 4..7 Cluster cache way number */
  279. u32_csr_t lsize:3; /*!< bit: 8..10 Cluster cache line size */
  280. u32_csr_t ecc:1; /*!< bit: 11 Cluster cache ECC support */
  281. u32_csr_t tcycle:3; /*!< bit: 12..14 Tag ram access cycle */
  282. u32_csr_t dcycle:3; /*!< bit: 15..17 Data ram access cycle */
  283. u32_csr_t :14; /*!< bit: 18..31 Reserved */
  284. } b; /*!< Structure used for bit access */
  285. u32_csr_t d; /*!< Type used for register data access */
  286. } U32_CC_CFG_Type;
  287. /**
  288. * \brief Union type to access ECLIC_INFO register.
  289. */
  290. typedef union {
  291. struct {
  292. u32_csr_t num_interrupt:13; /*!< bit: 0..12 interrupt source number */
  293. u32_csr_t version:8; /*!< bit: 13..20 version number */
  294. u32_csr_t clicintctlbits:4; /*!< bit: 21..24 clicintctl register bit-width */
  295. u32_csr_t :7; /*!< bit: 25..31 Reserved 0 */
  296. } b; /*!< Structure used for bit access */
  297. u32_csr_t d; /*!< Type used for register data access */
  298. } U32_ECLIC_INFO_Type;
  299. /**
  300. * \brief Access to the structure of ECLIC Memory Map, which is compatible with TEE.
  301. */
  302. typedef struct {
  303. uint8_t cfg; /*!< Offset: 0x000 (R/W) CLIC configuration register */
  304. uint8_t reserved0[3];
  305. U32_ECLIC_INFO_Type info; /*!< Offset: 0x004 (R/ ) CLIC information register */
  306. uint8_t reserved1;
  307. uint8_t reserved2;
  308. uint8_t reserved3;
  309. uint8_t mth; /*!< Offset: 0x00B(R/W) CLIC machine mode interrupt-level threshold */
  310. } CIF_ECLIC_Type;
  311. /**
  312. * \brief CPU INFO Structure
  313. */
  314. typedef struct {
  315. U32_CSR_MARCHID_Type marchid;
  316. uint32_t mhartid;
  317. U32_CSR_MIMPID_Type mimpid;
  318. U32_CSR_MISA_Type misa;
  319. uint32_t mcfg_exist;
  320. U32_CSR_MCFG_INFO_Type mcfginfo;
  321. U32_CSR_MICFG_INFO_Type micfginfo;
  322. U32_CSR_MDCFG_INFO_Type mdcfginfo;
  323. U32_CSR_MTLBCFG_INFO_Type mtlbcfginfo;
  324. U64_CSR_MIRGB_INFO_Type mirgbinfo;
  325. uint64_t iregion_base;
  326. U64_CSR_MPPICFG_INFO_Type mppicfginfo;
  327. U64_CSR_MFIOCFG_INFO_Type mfiocfginfo;
  328. U32_SMP_CFG_Type smpcfg;
  329. U32_CC_CFG_Type cccfg;
  330. uint32_t xlen;
  331. uint32_t vlenb;
  332. CIF_IINFO_Type *iinfo; /*!< IREGION INFO memory pointer */
  333. CIF_ECLIC_Type *eclic; /*!< ECLIC memory pointer */
  334. } CPU_INFO_Group;
  335. /**
  336. * \brief Union type to access MCMO_INFO register.
  337. */
  338. typedef union {
  339. struct {
  340. uint32_t cmo_cfg:1; /*!< bit: 0 CMO exist */
  341. uint32_t cmo_pft:1; /*!< bit: 1 CMO has prefetch */
  342. uint32_t cmo_size:4; /*!< bit: 2..5 cache block size */
  343. uint32_t cbozero_size:4; /*!< bit: 6..9 cache block size of cbo.zero */
  344. uint32_t :22; /*!< bit: 10..31 Reserved 0 */
  345. } b; /*!< Structure used for bit access */
  346. uint32_t d; /*!< Type used for register data access */
  347. } CIF_IINFO_MCMO_INFO_Type;
  348. /**
  349. * \brief Union type to access MVLM_CFG_LO register.
  350. */
  351. typedef union {
  352. struct {
  353. uint32_t vlm:1; /*!< bit: 0 whether VLM configuration exist */
  354. uint32_t vlm_size:5; /*!< bit: 1..5 VLM size */
  355. uint32_t :4; /*!< bit: 6..9 reserved */
  356. uint32_t vlm_base_lo:22; /*!< bit: 10..31 VLM base address */
  357. } b; /*!< Structure used for bit access */
  358. uint32_t d; /*!< Type used for register data access */
  359. } CIF_IINFO_MVLM_CFG_LO_Type;
  360. typedef uint32_t CIF_IINFO_MVLM_CFG_HI_Type;
  361. /**
  362. * \brief Union type to access ISA_SUPPORT0 register.
  363. */
  364. typedef union {
  365. struct {
  366. uint32_t exist:1; /*!< bit: 0 whether this register is valid */
  367. uint32_t vector:1; /*!< bit: 1 support Vector extension */
  368. uint32_t vector_b:1; /*!< bit: 2 support Vector-B extension */
  369. uint32_t vector_k:1; /*!< bit: 3 support Vector-K extension */
  370. uint32_t smepmp:1; /*!< bit: 4 support Smepmp extension */
  371. uint32_t sscofpmf:1; /*!< bit: 5 support Sscofpmf extension */
  372. uint32_t zfh:1; /*!< bit: 6 support Zfh extension */
  373. uint32_t zfhmin:1; /*!< bit: 7 support Zfhmin extension */
  374. uint32_t zfa:1; /*!< bit: 8 support Zfa extension */
  375. uint32_t svnapot:1; /*!< bit: 9 support Svnapot extension */
  376. uint32_t svpbmt:1; /*!< bit: 10 support Svpbmt extension */
  377. uint32_t svinval:1; /*!< bit: 11 support Svinval extension */
  378. uint32_t bf16:1; /*!< bit: 12 support Bf16 extension */
  379. uint32_t zve32x:1; /*!< bit: 13 support Zve32x extension */
  380. uint32_t zve32f:1; /*!< bit: 14 support Zve32f extension */
  381. uint32_t zve64x:1; /*!< bit: 15 support Zve64x extension */
  382. uint32_t zve64f:1; /*!< bit: 16 support Zve64f extension */
  383. uint32_t zve64d:1; /*!< bit: 17 support Zve64d extension */
  384. uint32_t zimop:1; /*!< bit: 18 support Zimop extension */
  385. uint32_t zcmop:1; /*!< bit: 19 support Zomop extension */
  386. uint32_t zicond:1; /*!< bit: 20 support Zicond extension */
  387. uint32_t zihintntl:1; /*!< bit: 21 support Zihintntl extension */
  388. uint32_t zihintpause:1; /*!< bit: 22 support Zihintpause extension */
  389. uint32_t zvfh:1; /*!< bit: 23 support Zvfh extension */
  390. uint32_t zvfhmin:1; /*!< bit: 24 support Zvfhmin extension */
  391. uint32_t smrnmi:1; /*!< bit: 25 support Smrnmi extension */
  392. uint32_t zihpm:1; /*!< bit: 26 support Zihpm extension */
  393. uint32_t smcntrpmf:1; /*!< bit: 27 support Smcntrpmf extension */
  394. uint32_t zicntr:1; /*!< bit: 28 support Zicntr extension */
  395. uint32_t zawrs:1; /*!< bit: 29 support Zawrs extension */
  396. uint32_t :2; /*!< bit: 30..31 reserved */
  397. } b; /*!< Structure used for bit access */
  398. uint32_t d; /*!< Type used for register data access */
  399. } CIF_IINFO_ISA_SUPPORT0_Type;
  400. /**
  401. * \brief Union type to access ISA_SUPPORT1 register.
  402. */
  403. typedef union {
  404. struct {
  405. uint32_t exist:1; /*!< bit: 0 whether this register is valid */
  406. uint32_t ssqosid:1; /*!< bit: 1 support Ssqosid extension */
  407. uint32_t zicflip:1; /*!< bit: 2 support zicflip extension */
  408. uint32_t zicfiss:1; /*!< bit: 3 support zicfiss extension */
  409. uint32_t smctr:1; /*!< bit: 4 support Smctr extension */
  410. uint32_t zacas:1; /*!< bit: 5 support Zacas extension */
  411. uint32_t zabha:1; /*!< bit: 6 support Zabha extension */
  412. uint32_t smdbltrp:1; /*!< bit: 7 support Smdbltrp extension */
  413. uint32_t ssdbltrp:1; /*!< bit: 8 support Ssdbltrp extension */
  414. uint32_t smcdeleg:1; /*!< bit: 9 support Smcdeleg extension */
  415. uint32_t smmpm:1; /*!< bit: 10 support Smmpm extension */
  416. uint32_t smnpm:1; /*!< bit: 11 support Smnpm extension */
  417. uint32_t ssnpm:1; /*!< bit: 12 support Smnpm extension */
  418. uint32_t smstateen:1; /*!< bit: 13 support Smstateen extension */
  419. uint32_t sstateen:1; /*!< bit: 14 support Sstateen extension */
  420. uint32_t smcsrind:1; /*!< bit: 15 support Smcsrind extension */
  421. uint32_t sscsrind:1; /*!< bit: 16 support Sscsrind extension */
  422. uint32_t svadu:1; /*!< bit: 17 support Svadu extension */
  423. uint32_t :14; /*!< bit: 18..31 reserved */
  424. } b; /*!< Structure used for bit access */
  425. uint32_t d; /*!< Type used for register data access */
  426. } CIF_IINFO_ISA_SUPPORT1_Type;
  427. /**
  428. * \brief Union type to access PERFORMANCE_CFG0 register.
  429. */
  430. typedef union {
  431. struct {
  432. uint32_t exist:1; /*!< bit: 0 whether this register is valid */
  433. uint32_t fpu_cycle:5; /*!< bit: 1..5 fpu cycle count */
  434. uint32_t high_div:1; /*!< bit: 6 high performance divider */
  435. uint32_t dcache_2stage:1; /*!< bit: 7 dcache 2 stage */
  436. uint32_t delay_branch_flush:1; /*!< bit: 8 delay branch flash */
  437. uint32_t bus_type:3; /*!< bit: 9..11 memory bus protocol type */
  438. uint32_t dual_issue:1; /*!< bit: 12 dual issue */
  439. uint32_t cross_4k:1; /*!< bit: 13 cross 4k */
  440. uint32_t dlm_2stage:1; /*!< bit: 14 DLM 2 stage */
  441. uint32_t lsu_cut_fwd:1; /*!< bit: 15 LSU cut forwarding */
  442. uint32_t dsp_cycle:4; /*!< bit: 16..19 DSP cycle */
  443. uint32_t ifu_cut_timing:1; /*!< bit: 20 IFU cut timing */
  444. uint32_t mem_cut_timing:1; /*!< bit: 21 MEM cut timing */
  445. uint32_t dcache_prefetch:1; /*!< bit: 22 dcache prefetch */
  446. uint32_t dcache_lbuf_num:5; /*!< bit: 23..27 dcache line buffer number */
  447. uint32_t mul_cyc:3; /*!< bit: 28..30 multiplier cycle */
  448. uint32_t :1; /*!< bit: 31 reserved */
  449. } b; /*!< Structure used for bit access */
  450. uint32_t d; /*!< Type used for register data access */
  451. } CIF_IINFO_PERFORMANCE_CFG0_Type;
  452. /**
  453. * \brief Union type to access PERFORMANCE_CFG1 register.
  454. */
  455. typedef union {
  456. struct {
  457. uint32_t exist:1; /*!< bit: 0 whether this register is valid */
  458. uint32_t vfpu_cyc:5; /*!< bit: 1..5 Vector FPU cycle */
  459. uint32_t bht_entry_width:5; /*!< bit: 6..10 BHT entry width */
  460. uint32_t high_performance:1; /*!< bit: 11 high performance */
  461. uint32_t agu_quick_forward:1; /*!< bit: 12 agu quick forward */
  462. uint32_t cau_fwd:1; /*!< bit: 13 crypto instruction forward */
  463. uint32_t hpm_ver:2; /*!< bit: 14..15 HPM version */
  464. uint32_t :16; /*!< bit: 16..31 reserved */
  465. } b; /*!< Structure used for bit access */
  466. uint32_t d; /*!< Type used for register data access */
  467. } CIF_IINFO_PERFORMANCE_CFG1_Type;
  468. /**
  469. * \brief Union type to access PFL1INFO register.
  470. */
  471. typedef union {
  472. struct {
  473. uint32_t pf_cfg:8; /*!< bit: 0..7 prefetch configuration */
  474. uint32_t l2_pf_lbuf_num:8; /*!< bit: 8..15 L2 prefetch req address buf number */
  475. uint32_t l2_pf_dbuf_num:8; /*!< bit: 16..23 L2 prefetch data buf number */
  476. uint32_t pf_ver:8; /*!< bit: 24..31 prefetch version */
  477. } b; /*!< Structure used for bit access */
  478. uint32_t d; /*!< Type used for register data access */
  479. } CIF_IINFO_PFL1INFO_Type;
  480. /**
  481. * \brief Union type to access PFL1DCTRL1 register.
  482. */
  483. typedef union {
  484. struct {
  485. uint32_t l1d_ena:1; /*!< bit: 0 L1 dcache prefetch enable */
  486. uint32_t cc_ena:1; /*!< bit: 1 cluster cache prefetch enable */
  487. uint32_t scalar_ena:1; /*!< bit: 2 scalar pipeline prefetch enable */
  488. uint32_t vector_ena:1; /*!< bit: 3 vector pipeline prefetch enable */
  489. uint32_t write_pref_ena:1; /*!< bit: 4 store prefetch enable */
  490. uint32_t cross_page_pref_ena:1; /*!< bit: 5 prefetch cross page enable */
  491. uint32_t :2; /*!< bit: 6..7 reserved */
  492. uint32_t pref_conflict_stop_th:4; /*!< bit: 8..11 prefetch inc counter stop threshold */
  493. uint32_t pref_conflict_decr_sel:3; /*!< bit: 12..14 prefetch num to dec counter */
  494. uint32_t :17; /*!< bit: 15..31 reserved */
  495. } b; /*!< Structure used for bit access */
  496. uint32_t d; /*!< Type used for register data access */
  497. } CIF_IINFO_PFL1DCTRL1_Type;
  498. /**
  499. * \brief Union type to access PFL1DCTRL2 register.
  500. */
  501. typedef union {
  502. struct {
  503. uint32_t degree_incr_th:6; /*!< bit: 0..5 prefetch degree threshold of incr */
  504. uint32_t degree_decr_th:6; /*!< bit: 6..11 prefetch degree threshold of decr */
  505. uint32_t next_line_ena_th:4; /*!< bit: 12..15 next line enable threshold */
  506. uint32_t write_noalloc_l1_th:2; /*!< bit: 16..17 see ISA doc */
  507. uint32_t write_noalloc_l2_th:2; /*!< bit: 18..19 see ISA doc */
  508. uint32_t :12; /*!< bit: 20..31 reserved */
  509. } b; /*!< Structure used for bit access */
  510. uint32_t d; /*!< Type used for register data access */
  511. } CIF_IINFO_PFL1DCTRL2_Type;
  512. /**
  513. * \brief Union type to access PFL1DCTRL3 register.
  514. */
  515. typedef union {
  516. struct {
  517. uint32_t max_stream_l1_degree:4; /*!< bit: 0..3 mat stream prefetch L1 degree */
  518. uint32_t :1; /*!< bit: 4 reserved */
  519. uint32_t max_stream_l2_degree:7; /*!< bit: 5..11 next line enable threshold */
  520. uint32_t :4; /*!< bit: 12..15 reserved */
  521. uint32_t max_stride_cplx_l1_degree:4; /*!< bit: 16..19 the max stride/cplx pref L1 degree */
  522. uint32_t :1; /*!< bit: 20 reserved */
  523. uint32_t max_stride_cplx_l2_degree:7; /*!< bit: 21..27 the max stride/cplx pref L2 degree */
  524. uint32_t :4; /*!< bit: 28..31 reserved */
  525. } b; /*!< Structure used for bit access */
  526. uint32_t d; /*!< Type used for register data access */
  527. } CIF_IINFO_PFL1DCTRL3_Type;
  528. /**
  529. * \brief Union type to access MERGEL1DCTRL register.
  530. */
  531. typedef union {
  532. struct {
  533. uint32_t ws_tmout_max:12; /*!< bit: 0..11 write streaming tmout cnt max value */
  534. uint32_t :4; /*!< bit: 12..15 reserved */
  535. uint32_t nc_tmout_max:8; /*!< bit: 16..23 non-cacheable tmout cnt max value */
  536. uint32_t dev_store_early_ret: 1; /*!< bit: 24 whether device region store is blocking */
  537. uint32_t :7; /*!< bit: 25..31 reserved */
  538. } b; /*!< Structure used for bit access */
  539. uint32_t d; /*!< Type used for register data access */
  540. } CIF_IINFO_MERGEL1DCTRL_Type;
  541. /**
  542. * \brief Union type to access SAFETY_CTRL register.
  543. */
  544. typedef union {
  545. struct {
  546. uint32_t reg_prot_chck_en:2; /*!< bit: 0..1 register protect check enable */
  547. uint32_t :30; /*!< bit: 2..31 reserved */
  548. } b; /*!< Structure used for bit access */
  549. uint32_t d; /*!< Type used for register data access */
  550. } CIF_IINFO_SAFETY_CTRL_Type;
  551. /**
  552. * \brief Union type to access ACCESS_CTRL register.
  553. */
  554. typedef union {
  555. struct {
  556. uint32_t :1; /*!< bit: 0 reversed */
  557. uint32_t pf_access: 1; /*!< bit: 1 s-mode register access, 0 is enable */
  558. uint32_t cache_csr_access: 1; /*!< bit: 2 s-mode cache csr access */
  559. uint32_t pma_csr_access: 1; /*!< bit: 3 s-mode pma csr access */
  560. uint32_t :28; /*!< bit: 4..31 reserved */
  561. } b; /*!< Structure used for bit access */
  562. uint32_t d; /*!< Type used for register data access */
  563. } CIF_IINFO_ACCESS_CTRL_Type;
  564. /**
  565. * \brief Union type to access FLASH_BASE_ADDR_LO register.
  566. */
  567. typedef union {
  568. struct {
  569. uint32_t flash:1; /*!< bit: 0 whether flash bus configuration exist */
  570. uint32_t flash_size:5; /*!< bit: 1..5 flash size */
  571. uint32_t :4; /*!< bit: 6..9 reserved */
  572. uint32_t flash_base_lo:22; /*!< bit: 10..31 flash base address low */
  573. } b; /*!< Structure used for bit access */
  574. uint32_t d; /*!< Type used for register data access */
  575. } CIF_IINFO_FLASH_BASE_ADDR_LO_Type;
  576. typedef uint32_t CIF_IINFO_FLASH_BASE_ADDR_HI_Type;
  577. /**
  578. * \brief Union type to access MEM_REGION_CFG_LO register.
  579. */
  580. typedef union {
  581. struct {
  582. uint32_t exist:1; /*!< bit: 0 whether mem_region_cfg exist */
  583. uint32_t mem_region_size:5; /*!< bit: 1..5 mem region size */
  584. uint32_t :3; /*!< bit: 6..8 reserved */
  585. uint32_t mem_region_ena: 1; /*!< bit: 9 enable mem region or not */
  586. uint32_t mem_region_base_lo:22; /*!< bit: 10..31 mem region base address low */
  587. } b; /*!< Structure used for bit access */
  588. uint32_t d; /*!< Type used for register data access */
  589. } CIF_IINFO_MEM_REGION_CFG_LO_Type;
  590. typedef uint32_t CIF_IINFO_MEM_REGION_CFG_HI_Type;
  591. /**
  592. * \brief Union type to access MCPPI_CFG_LO register.
  593. */
  594. typedef union {
  595. struct {
  596. uint32_t exist:1; /*!< bit: 0 whether cppi_cfg exist */
  597. uint32_t cppi_size:5; /*!< bit: 1..5 cppi size */
  598. uint32_t :3; /*!< bit: 6..8 reserved */
  599. uint32_t cppi_ena: 1; /*!< bit: 9 enable cppi or not */
  600. uint32_t cppi_base_lo:22; /*!< bit: 10..31 cppi base address low */
  601. } b; /*!< Structure used for bit access */
  602. uint32_t d; /*!< Type used for register data access */
  603. } CIF_IINFO_MCPPI_CFG_LO_Type;
  604. typedef uint32_t CIF_IINFO_MCPPI_CFG_HI_Type;
  605. /**
  606. * \brief Nuclei CPU INFO Structure For OpenOCD Usage
  607. */
  608. typedef struct {
  609. CPU_INFO_Group cpuinfo;
  610. CIF_IINFO_Type iinfo;
  611. CIF_ECLIC_Type eclic;
  612. } NUCLEI_CPUINFO;
  613. /**
  614. * \brief Show full CPU information about ISA, ILD/DLM, I/D cache, etc.
  615. * \param cpuinfo: pointer to CPU_INFO_Group
  616. */
  617. void show_cpuinfo(const CPU_INFO_Group *cpuinfo);
  618. /**
  619. * \brief Get basic CPU information in a single line.
  620. * This function is **not reentrant** because it uses
  621. * a shared static buffer.
  622. * \param cpuinfo: pointer to CPU_INFO_Group
  623. * \param str: pointer to string buffer
  624. * \param len: length of string buffer
  625. * \return actual length of result string or '-1' for `str == NULL`,
  626. * it is same as the return value of `snprintf`
  627. */
  628. int get_basic_cpuinfo(const CPU_INFO_Group *cpuinfo, char *str, unsigned long len);
  629. #ifdef __cplusplus
  630. }
  631. #endif
  632. #endif /* #ifndef __IREGION_INFO_H__ */