cpuinfo.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  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[2]; /*!< offset 0x010C */
  248. uint32_t access_ctrl; /*!< offset 0x0114 */
  249. uint32_t reserved7[2]; /*!< offset 0x0118 */
  250. uint32_t pfl1dctrl3; /*!< offset 0x0120 */
  251. uint32_t pfl1dctrl4; /*!< offset 0x0124 */
  252. uint32_t pfl1info; /*!< offset 0x0128 */
  253. uint32_t reserved8[27]; /*!< offset 0x012C */
  254. uint32_t crc_rf0; /*!< offset 0x0198 */
  255. uint32_t crc_rf1; /*!< offset 0x019C */
  256. uint32_t crc_fp0; /*!< offset 0x01A0 */
  257. } IINFO_Type;
  258. /**
  259. * \brief Union type to access SMP_CFG register.
  260. */
  261. typedef union {
  262. struct {
  263. u32_csr_t cc:1; /*!< bit: 0 Cluster Cache present */
  264. u32_csr_t smp_core_num:6; /*!< bit: 1..6 smp core number */
  265. u32_csr_t iocp_num:6; /*!< bit: 7..12 IO Coherency port number */
  266. u32_csr_t pmon_num:6; /*!< bit: 13..18 performance monitor number */
  267. u32_csr_t :13; /*!< bit: 19..31 Reserved 0 */
  268. } b; /*!< Structure used for bit access */
  269. u32_csr_t d; /*!< Type used for register data access */
  270. } U32_SMP_CFG_Type;
  271. /**
  272. * \brief Union type to access CC_CFG register.
  273. */
  274. typedef union {
  275. struct {
  276. u32_csr_t set:4; /*!< bit: 0..3 Cluster cache set number */
  277. u32_csr_t way:4; /*!< bit: 4..7 Cluster cache way number */
  278. u32_csr_t lsize:3; /*!< bit: 8..10 Cluster cache line size */
  279. u32_csr_t ecc:1; /*!< bit: 11 Cluster cache ECC support */
  280. u32_csr_t tcycle:3; /*!< bit: 12..14 Tag ram access cycle */
  281. u32_csr_t dcycle:3; /*!< bit: 15..17 Data ram access cycle */
  282. u32_csr_t :14; /*!< bit: 18..31 Reserved */
  283. } b; /*!< Structure used for bit access */
  284. u32_csr_t d; /*!< Type used for register data access */
  285. } U32_CC_CFG_Type;
  286. /**
  287. * \brief Union type to access ECLIC_INFO register.
  288. */
  289. typedef union {
  290. struct {
  291. u32_csr_t num_interrupt:13; /*!< bit: 0..12 interrupt source number */
  292. u32_csr_t version:8; /*!< bit: 13..20 version number */
  293. u32_csr_t clicintctlbits:4; /*!< bit: 21..24 clicintctl register bit-width */
  294. u32_csr_t :7; /*!< bit: 25..31 Reserved 0 */
  295. } b; /*!< Structure used for bit access */
  296. u32_csr_t d; /*!< Type used for register data access */
  297. } U32_ECLIC_INFO_Type;
  298. /**
  299. * \brief Access to the structure of ECLIC Memory Map, which is compatible with TEE.
  300. */
  301. typedef struct {
  302. uint8_t cfg; /*!< Offset: 0x000 (R/W) CLIC configuration register */
  303. uint8_t reserved0[3];
  304. U32_ECLIC_INFO_Type info; /*!< Offset: 0x004 (R/ ) CLIC information register */
  305. uint8_t reserved1;
  306. uint8_t reserved2;
  307. uint8_t reserved3;
  308. uint8_t mth; /*!< Offset: 0x00B(R/W) CLIC machine mode interrupt-level threshold */
  309. } ECLIC_Type;
  310. /**
  311. * \brief CPU INFO Structure
  312. */
  313. typedef struct {
  314. U32_CSR_MARCHID_Type marchid;
  315. uint32_t mhartid;
  316. U32_CSR_MIMPID_Type mimpid;
  317. U32_CSR_MISA_Type misa;
  318. uint32_t mcfg_exist;
  319. U32_CSR_MCFG_INFO_Type mcfginfo;
  320. U32_CSR_MICFG_INFO_Type micfginfo;
  321. U32_CSR_MDCFG_INFO_Type mdcfginfo;
  322. U32_CSR_MTLBCFG_INFO_Type mtlbcfginfo;
  323. U64_CSR_MIRGB_INFO_Type mirgbinfo;
  324. uint64_t iregion_base;
  325. U64_CSR_MPPICFG_INFO_Type mppicfginfo;
  326. U64_CSR_MFIOCFG_INFO_Type mfiocfginfo;
  327. U32_SMP_CFG_Type smpcfg;
  328. U32_CC_CFG_Type cccfg;
  329. uint32_t xlen;
  330. uint32_t vlenb;
  331. IINFO_Type *iinfo; /*!< IREGION INFO memory pointer */
  332. ECLIC_Type *eclic; /*!< ECLIC memory pointer */
  333. } CPU_INFO_Group;
  334. /**
  335. * \brief Union type to access MVLM_CFG_LO register.
  336. */
  337. typedef union {
  338. struct {
  339. uint32_t cmo_cfg:1; /*!< bit: 0 CMO exist */
  340. uint32_t cmo_pft:1; /*!< bit: 1 CMO has prefetch */
  341. uint32_t cmo_size:4; /*!< bit: 2..5 cache block size */
  342. uint32_t cbozero_size:4; /*!< bit: 6..9 cache block size of cbo.zero */
  343. uint32_t vlm_base_lo:22; /*!< bit: 10..31 Reserved 0 */
  344. } b; /*!< Structure used for bit access */
  345. uint32_t d; /*!< Type used for register data access */
  346. } IINFO_MCMO_INFO_Type;
  347. /**
  348. * \brief Union type to access MVLM_CFG_LO register.
  349. */
  350. typedef union {
  351. struct {
  352. uint32_t vlm:1; /*!< bit: 0 whether VLM configuration exist */
  353. uint32_t vlm_size:5; /*!< bit: 1..5 VLM size */
  354. uint32_t :4; /*!< bit: 6..9 reserved */
  355. uint32_t vlm_base_lo:22; /*!< bit: 10..31 VLM base address */
  356. } b; /*!< Structure used for bit access */
  357. uint32_t d; /*!< Type used for register data access */
  358. } IINFO_MVLM_CFG_LO_Type;
  359. typedef uint32_t IINFO_MVLM_CFG_HI_Type;
  360. /**
  361. * \brief Union type to access ISA_SUPPORT0 register.
  362. */
  363. typedef union {
  364. struct {
  365. uint32_t exist:1; /*!< bit: 0 whether this register is valid */
  366. uint32_t vector:1; /*!< bit: 1 support Vector extension */
  367. uint32_t vector_b:1; /*!< bit: 2 support Vector-B extension */
  368. uint32_t vector_k:1; /*!< bit: 3 support Vector-K extension */
  369. uint32_t smepmp:1; /*!< bit: 4 support Smepmp extension */
  370. uint32_t sscofpmf:1; /*!< bit: 5 support Sscofpmf extension */
  371. uint32_t zfh:1; /*!< bit: 6 support Zfh extension */
  372. uint32_t zfhmin:1; /*!< bit: 7 support Zfhmin extension */
  373. uint32_t zfa:1; /*!< bit: 8 support Zfa extension */
  374. uint32_t svnapot:1; /*!< bit: 9 support Svnapot extension */
  375. uint32_t svpbmt:1; /*!< bit: 10 support Svpbmt extension */
  376. uint32_t svinval:1; /*!< bit: 11 support Svinval extension */
  377. uint32_t bf16:1; /*!< bit: 12 support Bf16 extension */
  378. uint32_t zve32x:1; /*!< bit: 13 support Zve32x extension */
  379. uint32_t zve32f:1; /*!< bit: 14 support Zve32f extension */
  380. uint32_t zve64x:1; /*!< bit: 15 support Zve64x extension */
  381. uint32_t zve64f:1; /*!< bit: 16 support Zve64f extension */
  382. uint32_t zve64d:1; /*!< bit: 17 support Zve64d extension */
  383. uint32_t zimop:1; /*!< bit: 18 support Zimop extension */
  384. uint32_t zcmop:1; /*!< bit: 19 support Zomop extension */
  385. uint32_t zicond:1; /*!< bit: 20 support Zicond extension */
  386. uint32_t zihintntl:1; /*!< bit: 21 support Zihintntl extension */
  387. uint32_t zihintpause:1; /*!< bit: 22 support Zihintpause extension */
  388. uint32_t zvfh:1; /*!< bit: 23 support Zvfh extension */
  389. uint32_t zvfhmin:1; /*!< bit: 24 support Zvfhmin extension */
  390. uint32_t smrnmi:1; /*!< bit: 25 support Smrnmi extension */
  391. uint32_t zihpm:1; /*!< bit: 26 support Zihpm extension */
  392. uint32_t smcntrpmf:1; /*!< bit: 27 support Smcntrpmf extension */
  393. uint32_t zicntr:1; /*!< bit: 28 support Zicntr extension */
  394. uint32_t zawrs:1; /*!< bit: 29 support Zawrs extension */
  395. uint32_t :2;
  396. } b; /*!< Structure used for bit access */
  397. uint32_t d; /*!< Type used for register data access */
  398. } IINFO_ISA_SUPPORT0_Type;
  399. /**
  400. * \brief Union type to access ISA_SUPPORT1 register.
  401. */
  402. typedef union {
  403. struct {
  404. uint32_t exist:1; /*!< bit: 0 whether this register is valid */
  405. uint32_t ssqosid:1; /*!< bit: 1 support Ssqosid extension */
  406. uint32_t zicflip:1; /*!< bit: 2 support zicflip extension */
  407. uint32_t zicfiss:1; /*!< bit: 3 support zicfiss extension */
  408. uint32_t smctr:1; /*!< bit: 4 support Smctr extension */
  409. uint32_t zacas:1; /*!< bit: 5 support Zacas extension */
  410. uint32_t zabha:1; /*!< bit: 6 support Zabha extension */
  411. uint32_t smdbltrp:1; /*!< bit: 7 support Smdbltrp extension */
  412. uint32_t ssdbltrp:1; /*!< bit: 8 support Ssdbltrp extension */
  413. uint32_t smcdeleg:1; /*!< bit: 9 support Smcdeleg extension */
  414. uint32_t smmpm:1; /*!< bit: 10 support Smmpm extension */
  415. uint32_t smnpm:1; /*!< bit: 11 support Smnpm extension */
  416. uint32_t ssnpm:1; /*!< bit: 12 support Smnpm extension */
  417. uint32_t smstateen:1; /*!< bit: 13 support Smstateen extension */
  418. uint32_t sstateen:1; /*!< bit: 14 support Sstateen extension */
  419. uint32_t smcsrind:1; /*!< bit: 15 support Smcsrind extension */
  420. uint32_t sscsrind:1; /*!< bit: 16 support Sscsrind extension */
  421. uint32_t svadu:1; /*!< bit: 17 support Svadu extension */
  422. uint32_t :14;
  423. } b; /*!< Structure used for bit access */
  424. uint32_t d; /*!< Type used for register data access */
  425. } IINFO_ISA_SUPPORT1_Type;
  426. /**
  427. * \brief Union type to access PERFORMANCE_CFG0 register.
  428. */
  429. typedef union {
  430. struct {
  431. uint32_t exist:1; /*!< bit: 0 whether this register is valid */
  432. uint32_t fpu_cycle:5; /*!< bit: 1..5 fpu cycle count */
  433. uint32_t high_div:1; /*!< bit: 6 high performance divider */
  434. uint32_t dcache_2stage:1; /*!< bit: 7 dcache 2 stage */
  435. uint32_t delay_branch_flush:1; /*!< bit: 8 delay branch flash */
  436. uint32_t bus_type:3; /*!< bit: 9..11 memory bus protocol type */
  437. uint32_t dual_issue:1; /*!< bit: 12 dual issue */
  438. uint32_t cross_4k:1; /*!< bit: 13 cross 4k */
  439. uint32_t dlm_2stage:1; /*!< bit: 14 DLM 2 stage */
  440. uint32_t lsu_cut_fwd:1; /*!< bit: 15 LSU cut forwarding */
  441. uint32_t dsp_cycle:4; /*!< bit: 16..19 DSP cycle */
  442. uint32_t ifu_cut_timing:1; /*!< bit: 20 IFU cut timing */
  443. uint32_t mem_cut_timing:1; /*!< bit: 21 MEM cut timing */
  444. uint32_t dcache_prefetch:1; /*!< bit: 22 dcache prefetch */
  445. uint32_t dcache_lbuf_num:5; /*!< bit: 23..27 dcache line buffer number */
  446. uint32_t mul_cyc:3; /*!< bit: 28..30 multiplier cycle */
  447. uint32_t :1;
  448. } b; /*!< Structure used for bit access */
  449. uint32_t d; /*!< Type used for register data access */
  450. } IINFO_PERFORMANCE_CFG0_Type;
  451. /**
  452. * \brief Union type to access PERFORMANCE_CFG1 register.
  453. */
  454. typedef union {
  455. struct {
  456. uint32_t exist:1; /*!< bit: 0 whether this register is valid */
  457. uint32_t vfpu_cyc:5; /*!< bit: 1..5 Vector FPU cycle */
  458. uint32_t bht_entry_width:5; /*!< bit: 6..10 BHT entry width */
  459. uint32_t high_performance:1; /*!< bit: 11 high performance */
  460. uint32_t agu_quick_forward:1; /*!< bit: 12 agu quick forward */
  461. uint32_t cau_fwd:1; /*!< bit: 13 crypto instruction forward */
  462. uint32_t hpm_ver:2; /*!< bit: 14..15 HPM version */
  463. uint32_t :16;
  464. } b; /*!< Structure used for bit access */
  465. uint32_t d; /*!< Type used for register data access */
  466. } IINFO_PERFORMANCE_CFG1_Type;
  467. /**
  468. * \brief Union type to access PFL1INFO register.
  469. */
  470. typedef union {
  471. struct {
  472. uint32_t pf_cfg:8; /*!< bit: 0..7 prefetch configuration */
  473. uint32_t l2_pf_lbuf_num:8; /*!< bit: 8..15 L2 prefetch req address buf number */
  474. uint32_t l2_pf_dbuf_num:8; /*!< bit: 16..23 L2 prefetch data buf number */
  475. uint32_t pf_ver:8; /*!< bit: 24..31 prefetch version */
  476. } b; /*!< Structure used for bit access */
  477. uint32_t d; /*!< Type used for register data access */
  478. } IINFO_PFL1INFO_Type;
  479. /**
  480. * \brief Union type to access PFL1DCTRL1 register.
  481. */
  482. typedef union {
  483. struct {
  484. uint32_t l1d_ena:1; /*!< bit: 0 L1 dcache prefetch enable */
  485. uint32_t cc_ena:1; /*!< bit: 1 cluster cache prefetch enable */
  486. uint32_t scalar_ena:1; /*!< bit: 2 scalar pipeline prefetch enable */
  487. uint32_t vector_ena:1; /*!< bit: 3 vector pipeline prefetch enable */
  488. uint32_t write_pref_ena:1; /*!< bit: 4 store prefetch enable */
  489. uint32_t cross_page_pref_ena:1; /*!< bit: 5 prefetch cross page enable */
  490. uint32_t :2; /*!< bit: 6..7 reserved */
  491. uint32_t pref_conflict_stop_th:4; /*!< bit: 8..11 prefetch inc counter stop threshold */
  492. uint32_t pref_conflict_decr_sel:3; /*!< bit: 12..14 prefetch num to dec counter */
  493. uint32_t :16; /*!< bit: 15..31 reserved */
  494. } b; /*!< Structure used for bit access */
  495. uint32_t d; /*!< Type used for register data access */
  496. } IINFO_PFL1DCTRL1_Type;
  497. /**
  498. * \brief Union type to access PFL1DCTRL2 register.
  499. */
  500. typedef union {
  501. struct {
  502. uint32_t degree_incr_th:6; /*!< bit: 0..5 prefetch degree threshold of incr */
  503. uint32_t degree_decr_th:6; /*!< bit: 6..11 prefetch degree threshold of decr */
  504. uint32_t next_line_ena_th:4; /*!< bit: 12..15 next line enable threshold */
  505. uint32_t write_noalloc_l1_th:2; /*!< bit: 16..17 see ISA doc */
  506. uint32_t write_noalloc_l2_th:2; /*!< bit: 18..19 see ISA doc */
  507. uint32_t :12; /*!< bit: 20..31 reserved */
  508. } b; /*!< Structure used for bit access */
  509. uint32_t d; /*!< Type used for register data access */
  510. } IINFO_PFL1DCTRL2_Type;
  511. /**
  512. * \brief Union type to access PFL1DCTRL3 register.
  513. */
  514. typedef union {
  515. struct {
  516. uint32_t max_stream_l1_degree:4; /*!< bit: 0..3 mat stream prefetch L1 degree */
  517. uint32_t :1; /*!< bit: 4 reserved */
  518. uint32_t max_stream_l2_degree:7; /*!< bit: 5..11 next line enable threshold */
  519. uint32_t :4; /*!< bit: 12..15 reserved */
  520. uint32_t max_stride_cplx_l1_degree:4; /*!< bit: 16..19 the max stride/cplx pref L1 degree */
  521. uint32_t :1; /*!< bit: 20 reserved */
  522. uint32_t max_stride_cplx_l2_degree:7; /*!< bit: 21..27 the max stride/cplx pref L2 degree */
  523. uint32_t :4; /*!< bit: 28..31 reserved */
  524. } b; /*!< Structure used for bit access */
  525. uint32_t d; /*!< Type used for register data access */
  526. } IINFO_PFL1DCTRL3_Type;
  527. /**
  528. * \brief Union type to access MERGEL1DCTRL register.
  529. */
  530. typedef union {
  531. struct {
  532. uint32_t ws_tmout_max:12; /*!< bit: 0..11 write streaming tmout cnt max value */
  533. uint32_t :4; /*!< bit: 12..15 reserved */
  534. uint32_t nc_tmout_max:8; /*!< bit: 16..23 non-cacheable tmout cnt max value */
  535. uint32_t dev_store_early_ret: 1; /*!< bit: 24 whether device region store is blocking */
  536. uint32_t :7; /*!< bit: 25..31 reserved */
  537. } b; /*!< Structure used for bit access */
  538. uint32_t d; /*!< Type used for register data access */
  539. } IINFO_MERGEL1DCTRL_Type;
  540. /**
  541. * \brief Union type to access ACCESS_CTRL register.
  542. */
  543. typedef union {
  544. struct {
  545. uint32_t :1; /*!< bit: 0 reversed */
  546. uint32_t pf_access: 1; /*!< bit: 1 s-mode register access, 0 is enable */
  547. uint32_t cache_csr_access: 1; /*!< bit: 2 s-mode cache csr access */
  548. uint32_t pma_csr_access: 1; /*!< bit: 3 s-mode pma csr access */
  549. uint32_t :28; /*!< bit: 4..31 reserved */
  550. } b; /*!< Structure used for bit access */
  551. uint32_t d; /*!< Type used for register data access */
  552. } IINFO_ACCESS_CTRL_Type;
  553. /**
  554. * \brief Union type to access FLASH_BASE_ADDR_LO register.
  555. */
  556. typedef union {
  557. struct {
  558. uint32_t flash:1; /*!< bit: 0 whether flash bus configuration exist */
  559. uint32_t flash_size:5; /*!< bit: 1..5 flash size */
  560. uint32_t :4; /*!< bit: 6..9 reserved */
  561. uint32_t flash_base_lo:22; /*!< bit: 10..31 flash base address low */
  562. } b; /*!< Structure used for bit access */
  563. uint32_t d; /*!< Type used for register data access */
  564. } IINFO_FLASH_BASE_ADDR_LO_Type;
  565. typedef uint32_t IINFO_FLASH_BASE_ADDR_HI_Type;
  566. /**
  567. * \brief Union type to access MEM_REGION_CFG_LO register.
  568. */
  569. typedef union {
  570. struct {
  571. uint32_t exist:1; /*!< bit: 0 whether mem_region_cfg exist */
  572. uint32_t mem_region_size:5; /*!< bit: 1..5 mem region size */
  573. uint32_t :3; /*!< bit: 6..8 reserved */
  574. uint32_t mem_region_ena: 1; /*!< bit: 9 enable mem region or not */
  575. uint32_t mem_region_base_lo:22; /*!< bit: 10..31 mem region base address low */
  576. } b; /*!< Structure used for bit access */
  577. uint32_t d; /*!< Type used for register data access */
  578. } IINFO_MEM_REGION_CFG_LO_Type;
  579. typedef uint32_t IINFO_MEM_REGION_CFG_HI_Type;
  580. /**
  581. * \brief Union type to access MCPPI_CFG_LO register.
  582. */
  583. typedef union {
  584. struct {
  585. uint32_t exist:1; /*!< bit: 0 whether cppi_cfg exist */
  586. uint32_t cppi_size:5; /*!< bit: 1..5 cppi size */
  587. uint32_t :3; /*!< bit: 6..8 reserved */
  588. uint32_t cppi_ena: 1; /*!< bit: 9 enable cppi or not */
  589. uint32_t cppi_base_lo:22; /*!< bit: 10..31 cppi base address low */
  590. } b; /*!< Structure used for bit access */
  591. uint32_t d; /*!< Type used for register data access */
  592. } IINFO_MCPPI_CFG_LO_Type;
  593. typedef uint32_t IINFO_MCPPI_CFG_HI_Type;
  594. /**
  595. * \brief Nuclei CPU INFO Structure For OpenOCD Usage
  596. */
  597. typedef struct {
  598. CPU_INFO_Group cpuinfo;
  599. IINFO_Type iinfo;
  600. ECLIC_Type eclic;
  601. } NUCLEI_CPUINFO;
  602. /**
  603. * \brief Show full CPU information about ISA, ILD/DLM, I/D cache, etc.
  604. * \param cpuinfo: pointer to CPU_INFO_Group
  605. */
  606. void show_cpuinfo(const CPU_INFO_Group *cpuinfo);
  607. /**
  608. * \brief Get basic CPU information in a single line.
  609. * This function is **not reentrant** because it uses
  610. * a shared static buffer.
  611. * \param cpuinfo: pointer to CPU_INFO_Group
  612. * \param str: pointer to string buffer
  613. * \param len: length of string buffer
  614. * \return actual length of result string or '-1' for `str == NULL`,
  615. * it is same as the return value of `snprintf`
  616. */
  617. int get_basic_cpuinfo(const CPU_INFO_Group *cpuinfo, char *str, unsigned long len);
  618. #ifdef __cplusplus
  619. }
  620. #endif
  621. #endif /* #ifndef __IREGION_INFO_H__ */