core_feature_iinfo.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. /*
  2. * Copyright (c) 2019 Nuclei Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the License); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  14. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. */
  16. #ifndef __CORE_FEATURE_IINFO_H__
  17. #define __CORE_FEATURE_IINFO_H__
  18. /*!
  19. * @file core_feature_iinfo.h
  20. * @brief IREGION INFO feature API header file for Nuclei N/NX Core
  21. * @remarks Most registers in IREGION INFO are used to convey CPU information.
  22. * It is recommended to inspect or view this information using the `cpuinfo`
  23. * application. The macros and functions defined in this file provide only the
  24. * most commonly used operations and do not offer comprehensive support for
  25. * inspecting all available information.
  26. */
  27. /*
  28. * IREGION INFO Configuration Macro:
  29. *
  30. * 1. __IINFO_BASE: Base address of the IREGION INFO
  31. *
  32. */
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. #include "core_feature_base.h"
  37. /**
  38. * IREGION may not exist in legacy Nuclei CPU, so IREGION INFO related
  39. * APIs are only available when __IINFO_BASEADDR is defined
  40. */
  41. #ifdef __IINFO_BASEADDR
  42. /**
  43. * \defgroup NMSIS_Core_IINFO_Registers Register Define and Type Definitions Of IINFO
  44. * \ingroup NMSIS_Core_Registers
  45. * \brief Type definitions and defines for iinfo registers.
  46. *
  47. * @{
  48. */
  49. /**
  50. * \brief Union type to access MCMO_INFO register.
  51. */
  52. typedef union {
  53. struct {
  54. __IM uint32_t cmo_cfg:1; /*!< bit: 0 CMO exist */
  55. __IM uint32_t cmo_pft:1; /*!< bit: 1 CMO has prefetch */
  56. __IM uint32_t cmo_size:4; /*!< bit: 2..5 cache block size */
  57. __IM uint32_t cbozero_size:4; /*!< bit: 6..9 cache block size of cbo.zero */
  58. uint32_t :22; /*!< bit: 10..31 Reserved 0 */
  59. } b; /*!< Structure used for bit access */
  60. uint32_t d; /*!< Type used for register data access */
  61. } IINFO_MCMO_INFO_Type;
  62. /**
  63. * \brief Union type to access ISA_SUPPORT0 register.
  64. */
  65. typedef union {
  66. struct {
  67. __IM uint32_t exist:1; /*!< bit: 0 whether this register is valid */
  68. __IM uint32_t vector:1; /*!< bit: 1 support Vector extension */
  69. __IM uint32_t vector_b:1; /*!< bit: 2 support Vector-B extension */
  70. __IM uint32_t vector_k:1; /*!< bit: 3 support Vector-K extension */
  71. __IM uint32_t smepmp:1; /*!< bit: 4 support Smepmp extension */
  72. __IM uint32_t sscofpmf:1; /*!< bit: 5 support Sscofpmf extension */
  73. __IM uint32_t zfh:1; /*!< bit: 6 support Zfh extension */
  74. __IM uint32_t zfhmin:1; /*!< bit: 7 support Zfhmin extension */
  75. __IM uint32_t zfa:1; /*!< bit: 8 support Zfa extension */
  76. __IM uint32_t svnapot:1; /*!< bit: 9 support Svnapot extension */
  77. __IM uint32_t svpbmt:1; /*!< bit: 10 support Svpbmt extension */
  78. __IM uint32_t svinval:1; /*!< bit: 11 support Svinval extension */
  79. __IM uint32_t bf16:1; /*!< bit: 12 support Bf16 extension */
  80. __IM uint32_t zve32x:1; /*!< bit: 13 support Zve32x extension */
  81. __IM uint32_t zve32f:1; /*!< bit: 14 support Zve32f extension */
  82. __IM uint32_t zve64x:1; /*!< bit: 15 support Zve64x extension */
  83. __IM uint32_t zve64f:1; /*!< bit: 16 support Zve64f extension */
  84. __IM uint32_t zve64d:1; /*!< bit: 17 support Zve64d extension */
  85. __IM uint32_t zimop:1; /*!< bit: 18 support Zimop extension */
  86. __IM uint32_t zcmop:1; /*!< bit: 19 support Zomop extension */
  87. __IM uint32_t zicond:1; /*!< bit: 20 support Zicond extension */
  88. __IM uint32_t zihintntl:1; /*!< bit: 21 support Zihintntl extension */
  89. __IM uint32_t zihintpause:1; /*!< bit: 22 support Zihintpause extension */
  90. __IM uint32_t zvfh:1; /*!< bit: 23 support Zvfh extension */
  91. __IM uint32_t zvfhmin:1; /*!< bit: 24 support Zvfhmin extension */
  92. __IM uint32_t smrnmi:1; /*!< bit: 25 support Smrnmi extension */
  93. __IM uint32_t zihpm:1; /*!< bit: 26 support Zihpm extension */
  94. __IM uint32_t smcntrpmf:1; /*!< bit: 27 support Smcntrpmf extension */
  95. __IM uint32_t zicntr:1; /*!< bit: 28 support Zicntr extension */
  96. __IM uint32_t zawrs:1; /*!< bit: 29 support Zawrs extension */
  97. uint32_t :2; /*!< bit: 30..31 reserved */
  98. } b; /*!< Structure used for bit access */
  99. uint32_t d; /*!< Type used for register data access */
  100. } IINFO_ISA_SUPPORT0_Type;
  101. /**
  102. * \brief Union type to access ISA_SUPPORT1 register.
  103. */
  104. typedef union {
  105. struct {
  106. __IM uint32_t exist:1; /*!< bit: 0 whether this register is valid */
  107. __IM uint32_t ssqosid:1; /*!< bit: 1 support Ssqosid extension */
  108. __IM uint32_t zicflip:1; /*!< bit: 2 support zicflip extension */
  109. __IM uint32_t zicfiss:1; /*!< bit: 3 support zicfiss extension */
  110. __IM uint32_t smctr:1; /*!< bit: 4 support Smctr extension */
  111. __IM uint32_t zacas:1; /*!< bit: 5 support Zacas extension */
  112. __IM uint32_t zabha:1; /*!< bit: 6 support Zabha extension */
  113. __IM uint32_t smdbltrp:1; /*!< bit: 7 support Smdbltrp extension */
  114. __IM uint32_t ssdbltrp:1; /*!< bit: 8 support Ssdbltrp extension */
  115. __IM uint32_t smcdeleg:1; /*!< bit: 9 support Smcdeleg extension */
  116. __IM uint32_t smmpm:1; /*!< bit: 10 support Smmpm extension */
  117. __IM uint32_t smnpm:1; /*!< bit: 11 support Smnpm extension */
  118. __IM uint32_t ssnpm:1; /*!< bit: 12 support Smnpm extension */
  119. __IM uint32_t smstateen:1; /*!< bit: 13 support Smstateen extension */
  120. __IM uint32_t sstateen:1; /*!< bit: 14 support Sstateen extension */
  121. __IM uint32_t smcsrind:1; /*!< bit: 15 support Smcsrind extension */
  122. __IM uint32_t sscsrind:1; /*!< bit: 16 support Sscsrind extension */
  123. __IM uint32_t svadu:1; /*!< bit: 17 support Svadu extension */
  124. uint32_t :14; /*!< bit: 18..31 reserved */
  125. } b; /*!< Structure used for bit access */
  126. uint32_t d; /*!< Type used for register data access */
  127. } IINFO_ISA_SUPPORT1_Type;
  128. /**
  129. * \brief Union type to access PERFORMANCE_CFG0 register.
  130. */
  131. typedef union {
  132. struct {
  133. __IM uint32_t exist:1; /*!< bit: 0 whether this register is valid */
  134. __IM uint32_t fpu_cycle:5; /*!< bit: 1..5 fpu cycle count */
  135. __IM uint32_t high_div:1; /*!< bit: 6 high performance divider */
  136. __IM uint32_t dcache_2stage:1; /*!< bit: 7 dcache 2 stage */
  137. __IM uint32_t delay_branch_flush:1; /*!< bit: 8 delay branch flash */
  138. __IM uint32_t bus_type:3; /*!< bit: 9..11 memory bus protocol type */
  139. __IM uint32_t dual_issue:1; /*!< bit: 12 dual issue */
  140. __IM uint32_t cross_4k:1; /*!< bit: 13 cross 4k */
  141. __IM uint32_t dlm_2stage:1; /*!< bit: 14 DLM 2 stage */
  142. __IM uint32_t lsu_cut_fwd:1; /*!< bit: 15 LSU cut forwarding */
  143. __IM uint32_t dsp_cycle:4; /*!< bit: 16..19 DSP cycle */
  144. __IM uint32_t ifu_cut_timing:1; /*!< bit: 20 IFU cut timing */
  145. __IM uint32_t mem_cut_timing:1; /*!< bit: 21 MEM cut timing */
  146. __IM uint32_t dcache_prefetch:1; /*!< bit: 22 dcache prefetch */
  147. __IM uint32_t dcache_lbuf_num:5; /*!< bit: 23..27 dcache line buffer number */
  148. __IM uint32_t mul_cyc:3; /*!< bit: 28..30 multiplier cycle */
  149. uint32_t :1; /*!< bit: 31 reserved */
  150. } b; /*!< Structure used for bit access */
  151. uint32_t d; /*!< Type used for register data access */
  152. } IINFO_PERFORMANCE_CFG0_Type;
  153. /**
  154. * \brief Union type to access PERFORMANCE_CFG1 register.
  155. */
  156. typedef union {
  157. struct {
  158. __IM uint32_t exist:1; /*!< bit: 0 whether this register is valid */
  159. __IM uint32_t vfpu_cyc:5; /*!< bit: 1..5 Vector FPU cycle */
  160. __IM uint32_t bht_entry_width:5; /*!< bit: 6..10 BHT entry width */
  161. __IM uint32_t high_performance:1; /*!< bit: 11 high performance */
  162. __IM uint32_t agu_quick_forward:1; /*!< bit: 12 agu quick forward */
  163. __IM uint32_t cau_fwd:1; /*!< bit: 13 crypto instruction forward */
  164. __IM uint32_t hpm_ver:2; /*!< bit: 14..15 HPM version */
  165. uint32_t :16; /*!< bit: 16..31 reserved */
  166. } b; /*!< Structure used for bit access */
  167. uint32_t d; /*!< Type used for register data access */
  168. } IINFO_PERFORMANCE_CFG1_Type;
  169. /**
  170. * \brief Union type to access PFL1DCTRL1 register.
  171. */
  172. typedef union {
  173. struct {
  174. __IOM uint32_t l1d_ena:1; /*!< bit: 0 L1 dcache prefetch enable */
  175. __IOM uint32_t cc_ena:1; /*!< bit: 1 cluster cache prefetch enable */
  176. __IOM uint32_t scalar_ena:1; /*!< bit: 2 scalar pipeline prefetch enable */
  177. __IOM uint32_t vector_ena:1; /*!< bit: 3 vector pipeline prefetch enable */
  178. __IOM uint32_t write_pref_ena:1; /*!< bit: 4 store prefetch enable */
  179. __IOM uint32_t cross_page_pref_ena:1; /*!< bit: 5 prefetch cross page enable */
  180. __IOM uint32_t mmu_ena:1; /*!< bit: 6 mmu prefetch enable */
  181. __IOM uint32_t pl2_ena:1; /*!< bit: 7 private L2 prefetch enable */
  182. __IOM uint32_t pref_conflict_stop_th:4; /*!< bit: 8..11 prefetch inc counter stop threshold */
  183. __IOM uint32_t pref_conflict_decr_sel:3; /*!< bit: 12..14 prefetch num to dec counter */
  184. uint32_t :17; /*!< bit: 15..31 reserved */
  185. } b; /*!< Structure used for bit access */
  186. struct {
  187. /**
  188. * \brief 0..7 prefetch enable level
  189. * \details Writing to this bit field may use the `sb` instruction (write only one byte),
  190. * which is not allowed for IINFO registers. So this bit field is read-only here,
  191. * but actually it can be written. To write this bit field, you should write the
  192. * whole 32-bit register
  193. * \sa
  194. * - \ref IINFO_SetPrefetchLevel
  195. *
  196. * The recommended values are:
  197. * - 0x3F: Enable all prefetch except MMU and private L2 cache prefetch.
  198. * - 0xBF: Enable all prefetch except MMU prefetch.
  199. * Enabling **cross page prefetch** in bare-metal environment is always recommended
  200. * for better performance.
  201. */
  202. __IM uint32_t level:8;
  203. __IM uint32_t pref_conflict_stop_th:4; /*!< bit: 8..11 prefetch inc counter stop threshold */
  204. __IM uint32_t pref_conflict_decr_sel:3; /*!< bit: 12..14 prefetch num to dec counter */
  205. uint32_t :17; /*!< bit: 15..31 reserved */
  206. } lv; /*!< Structure used for enable level field setup */
  207. uint32_t d; /*!< Type used for register data access */
  208. } IINFO_PFL1DCTRL1_Type;
  209. #define IINFO_PFL1DCTRL1_LEVEL_Pos (1UL << 0) /* IINFO PFL1DCTRL1 level position */
  210. #define IINFO_PFL1DCTRL1_LEVEL_Msk (0xFFUL << IINFO_PFL1DCTRL1_LEVEL_Pos) /* IINFO PFL1DCTRL1 level mask */
  211. #define IINFO_PFL1DCTRL1_DISABLE (0UL) /*!< Disable all prefetch */
  212. #define IINFO_PFL1DCTRL1_L1D_ENA (1UL << 0) /*!< L1 dcache prefetch enable mask */
  213. #define IINFO_PFL1DCTRL1_CC_ENA (1UL << 1) /*!< Cluster cache prefetch enable mask */
  214. #define IINFO_PFL1DCTRL1_SCALAR_ENA (1UL << 2) /*!< Scalar pipeline prefetch enable mask */
  215. #define IINFO_PFL1DCTRL1_VECTOR_ENA (1UL << 3) /*!< Vector pipeline prefetch enable mask */
  216. #define IINFO_PFL1DCTRL1_WRITE_PREF_ENA (1UL << 4) /*!< Store prefetch enable mask */
  217. #define IINFO_PFL1DCTRL1_CROSS_PAGE_PREF_ENA (1UL << 5) /*!< Cross page prefetch enable mask */
  218. #define IINFO_PFL1DCTRL1_MMU_PREF_ENA (1UL << 6) /*!< MMU prefetch enable mask */
  219. #define IINFO_PFL1DCTRL1_PL2_ENA (1UL << 7) /*!< Private L2 prefetch enable mask */
  220. /**
  221. * \brief Union type to access PFL1DCTRL2 register.
  222. */
  223. typedef union {
  224. struct {
  225. __IOM uint32_t degree_incr_th:6; /*!< bit: 0..5 prefetch degree threshold of incr */
  226. __IOM uint32_t degree_decr_th:6; /*!< bit: 6..11 prefetch degree threshold of decr */
  227. __IOM uint32_t next_line_ena_th:4; /*!< bit: 12..15 next line enable threshold */
  228. __IOM uint32_t write_noalloc_l1_th:2; /*!< bit: 16..17 see ISA doc */
  229. __IOM uint32_t write_noalloc_l2_th:2; /*!< bit: 18..19 see ISA doc */
  230. uint32_t :12; /*!< bit: 20..31 reserved */
  231. } b; /*!< Structure used for bit access */
  232. uint32_t d; /*!< Type used for register data access */
  233. } IINFO_PFL1DCTRL2_Type;
  234. /**
  235. * \brief Union type to access MERGEL1DCTRL register.
  236. */
  237. typedef union {
  238. struct {
  239. __IOM uint32_t ws_tmout_max:12; /*!< bit: 0..11 write streaming tmout cnt max value */
  240. uint32_t :4; /*!< bit: 12..15 reserved */
  241. __IOM uint32_t nc_tmout_max:8; /*!< bit: 16..23 non-cacheable tmout cnt max value */
  242. __IOM uint32_t dev_store_early_ret: 1; /*!< bit: 24 whether device region store is blocking */
  243. uint32_t :7; /*!< bit: 25..31 reserved */
  244. } b; /*!< Structure used for bit access */
  245. uint32_t d; /*!< Type used for register data access */
  246. } IINFO_MERGEL1DCTRL_Type;
  247. /**
  248. * \brief Union type to access SAFETY_CTRL register.
  249. */
  250. typedef union {
  251. struct {
  252. __IOM uint32_t reg_prot_chck_en:2; /*!< bit: 0..1 register protect check enable */
  253. uint32_t :30; /*!< bit: 2..31 reserved */
  254. } b; /*!< Structure used for bit access */
  255. uint32_t d; /*!< Type used for register data access */
  256. } IINFO_SAFETY_CTRL_Type;
  257. /**
  258. * \brief Union type to access ACCESS_CTRL register.
  259. */
  260. typedef union {
  261. struct {
  262. uint32_t :1; /*!< bit: 0 reversed */
  263. __IOM uint32_t pf_access: 1; /*!< bit: 1 s-mode register access, 0 is enable */
  264. __IOM uint32_t cache_csr_access: 1; /*!< bit: 2 s-mode cache csr access */
  265. __IOM uint32_t pma_csr_access: 1; /*!< bit: 3 s-mode pma csr access */
  266. uint32_t :28; /*!< bit: 4..31 reserved */
  267. } b; /*!< Structure used for bit access */
  268. uint32_t d; /*!< Type used for register data access */
  269. } IINFO_ACCESS_CTRL_Type;
  270. /**
  271. * \brief Union type to access PFL1DCTRL3 register.
  272. */
  273. typedef union {
  274. struct {
  275. __IOM uint32_t max_stream_l1_degree:4; /*!< bit: 0..3 mat stream prefetch L1 degree */
  276. uint32_t :1; /*!< bit: 4 reserved */
  277. __IOM uint32_t max_stream_l2_degree:7; /*!< bit: 5..11 next line enable threshold */
  278. uint32_t :4; /*!< bit: 12..15 reserved */
  279. __IOM uint32_t max_stride_cplx_l1_degree:4; /*!< bit: 16..19 the max stride/cplx pref L1 degree */
  280. uint32_t :1; /*!< bit: 20 reserved */
  281. __IOM uint32_t max_stride_cplx_l2_degree:7; /*!< bit: 21..27 the max stride/cplx pref L2 degree */
  282. uint32_t :4; /*!< bit: 28..31 reserved */
  283. } b; /*!< Structure used for bit access */
  284. uint32_t d; /*!< Type used for register data access */
  285. } IINFO_PFL1DCTRL3_Type;
  286. /**
  287. * \brief Union type to access PFL1DCTRL4 register.
  288. */
  289. typedef union {
  290. struct {
  291. __IOM uint32_t pf_enable:1; /*!< bit: 0 prefetch overall enable */
  292. __IOM uint32_t cc_short_enable:1; /*!< bit: 1 cluster cache short enable */
  293. uint32_t :30; /*!< bit: 2..31 reserved */
  294. } b; /*!< Structure used for bit access */
  295. uint32_t d; /*!< Type used for register data access */
  296. } IINFO_PFL1DCTRL4_Type;
  297. /**
  298. * \brief Union type to access PFL1INFO register.
  299. */
  300. typedef union {
  301. struct {
  302. __IM uint32_t pf_cfg:8; /*!< bit: 0..7 prefetch configuration */
  303. __IM uint32_t l2_pf_lbuf_num:8; /*!< bit: 8..15 L2 prefetch req address buf number */
  304. __IM uint32_t l2_pf_dbuf_num:8; /*!< bit: 16..23 L2 prefetch data buf number */
  305. __IM uint32_t pf_ver:8; /*!< bit: 24..31 prefetch version */
  306. } b; /*!< Structure used for bit access */
  307. uint32_t d; /*!< Type used for register data access */
  308. } IINFO_PFL1INFO_Type;
  309. /* IREGION INFO Memory-Mapped Register Type*/
  310. typedef struct {
  311. __IM uint32_t mpasize; /*!< offset 0x0000 */
  312. __IM IINFO_MCMO_INFO_Type cmo_info; /*!< offset 0x0004 */
  313. __IM uint32_t sec_base_addr_lo; /*!< offset 0x0008 */
  314. __IM uint32_t sec_base_addr_hi; /*!< offset 0x000C */
  315. __IM uint32_t sec_cfg_info; /*!< offset 0x0010 */
  316. __IM uint32_t reserved0[4]; /*!< offset 0x0014 */
  317. __IM uint32_t mvlm_cfg_lo; /*!< offset 0x0024 */
  318. __IM uint32_t mvlm_cfg_hi; /*!< offset 0x0028 */
  319. __IM uint32_t flash_base_addr_lo; /*!< offset 0x002C */
  320. __IM uint32_t flash_base_addr_hi; /*!< offset 0x0030 */
  321. __IM uint32_t reserved1[7]; /*!< offset 0x0034 */
  322. __IM uint32_t vpu_cfg_info; /*!< offset 0x0050 */
  323. __IOM uint32_t mem_region0_cfg_lo; /*!< offset 0x0054 */
  324. __IM uint32_t mem_region0_cfg_hi; /*!< offset 0x0058 */
  325. __IOM uint32_t mem_region1_cfg_lo; /*!< offset 0x005c */
  326. __IM uint32_t mem_region1_cfg_hi; /*!< offset 0x0060 */
  327. uint32_t reserved2[3]; /*!< offset 0x0064 */
  328. __IM IINFO_ISA_SUPPORT0_Type isa_support0; /*!< offset 0x0070 */
  329. __IM IINFO_ISA_SUPPORT1_Type isa_support1; /*!< offset 0x0074 */
  330. uint32_t reserved3[2]; /*!< offset 0x0078 */
  331. __IOM uint32_t mcppi_cfg_lo; /*!< offset 0x0080 */
  332. __IM uint32_t mcppi_cfg_hi; /*!< offset 0x0084 */
  333. uint32_t reserved4[2]; /*!< offset 0x0088 */
  334. __IM IINFO_PERFORMANCE_CFG0_Type performance_cfg0; /*!< offset 0x0090 */
  335. __IM IINFO_PERFORMANCE_CFG1_Type performance_cfg1; /*!< offset 0x0094 */
  336. uint32_t reserved5[26]; /*!< offset 0x0098 */
  337. __IOM IINFO_PFL1DCTRL1_Type pfl1dctrl1; /*!< offset 0x0100 */
  338. __IOM IINFO_PFL1DCTRL2_Type pfl1dctrl2; /*!< offset 0x0104 */
  339. __IOM IINFO_MERGEL1DCTRL_Type mergel1dctrl; /*!< offset 0x0108 */
  340. uint32_t reserved6; /*!< offset 0x010C */
  341. __IOM IINFO_SAFETY_CTRL_Type safety_ctrl; /*!< offset 0x0110 */
  342. __IOM IINFO_ACCESS_CTRL_Type access_ctrl; /*!< offset 0x0114 */
  343. uint32_t reserved7[2]; /*!< offset 0x0118 */
  344. __IOM IINFO_PFL1DCTRL3_Type pfl1dctrl3; /*!< offset 0x0120 */
  345. __IOM IINFO_PFL1DCTRL4_Type pfl1dctrl4; /*!< offset 0x0124 */
  346. __IM IINFO_PFL1INFO_Type pfl1info; /*!< offset 0x0128 */
  347. uint32_t reserved8[27]; /*!< offset 0x012C */
  348. __IM uint32_t crc_rf0; /*!< offset 0x0198 */
  349. __IM uint32_t crc_rf1; /*!< offset 0x019C */
  350. __IM uint32_t crc_fp0; /*!< offset 0x01A0 */
  351. } IINFO_Type;
  352. /* IREGION INFO Memory mapping of Device */
  353. #define IINFO_BASE __IINFO_BASEADDR /*!< IINFO Base Address */
  354. #define IINFO ((IINFO_Type *)IINFO_BASE) /*!< IINFO configuration struct */
  355. /**
  356. * \brief Enum type to distinguish HPM version.
  357. */
  358. typedef enum {
  359. IINFO_HPM_VER_UNKNOWN = 0, /*!< HPM version unknown */
  360. IINFO_HPM_VER_1, /*!< HPM version 1 */
  361. IINFO_HPM_VER_2, /*!< HPM version 2 */
  362. IINFO_HPM_VER_MAX /*!< Max number of HPM version */
  363. } IINFO_HPM_VER_Type;
  364. /** @} */ /* end of group NMSIS_Core_IINFO_Registers */
  365. /**
  366. * \defgroup NMSIS_Core_IINFO_Functions IINFO Functions
  367. * \ingroup NMSIS_Core
  368. * \brief IINFO related functions
  369. *
  370. * @{
  371. */
  372. /**
  373. * \brief Check if CMO is supported
  374. * \details Checks whether the CMO feature is supported by reading the cmo_cfg bit
  375. * from the CMO_INFO register.
  376. * \return 1 if CMO is supported, 0 otherwise
  377. */
  378. __STATIC_FORCEINLINE int32_t IINFO_IsCMOSupported(void)
  379. {
  380. return IINFO->cmo_info.b.cmo_cfg;
  381. }
  382. /**
  383. * \brief Check if CMO prefetch is supported
  384. * \details Checks whether the CMO prefetch feature is supported
  385. * by reading the cmo_pft bit from the CMO_INFO register.
  386. * \return 1 if CMO prefetch is supported, 0 otherwise
  387. */
  388. __STATIC_FORCEINLINE int32_t IINFO_IsCMOPrefetchSupported(void)
  389. {
  390. return IINFO->cmo_info.b.cmo_cfg && IINFO->cmo_info.b.cmo_pft;
  391. }
  392. /**
  393. * \brief Get Hardware Performance Monitor (HPM) version
  394. * \details Gets the version of the Hardware Performance Monitor (HPM) feature
  395. * by reading the hpm_ver bits from the PERFORMANCE_CFG1 register.
  396. * If the PERFORMANCE_CFG1 register does not exist, returns IINFO_HPM_VER_UNKNOWN.
  397. * \return HPM version as IINFO_HPM_VER_Type enum value
  398. */
  399. __STATIC_FORCEINLINE IINFO_HPM_VER_Type IINFO_GetHPMVersion(void)
  400. {
  401. if (!IINFO->performance_cfg1.b.exist) {
  402. return IINFO_HPM_VER_UNKNOWN;
  403. }
  404. return (IINFO_HPM_VER_Type)IINFO->performance_cfg1.b.hpm_ver;
  405. }
  406. /**
  407. * \brief Set prefetch enable level bits
  408. * \details This function writes the specified bitmask to the prefetch enable field
  409. * (bits 0–7) of the PFL1DCTRL1 register. Each bit corresponds to a specific
  410. * prefetch, and enabling a bit activates it.
  411. *
  412. * To construct the \p val argument, use the predefined bitmask macros
  413. * (e.g., \c IINFO_PFL1DCTRL1_LEVEL_L1D_ENA). Multiple prefetch can be
  414. * enabled simultaneously by bitwise-ORing their respective masks.
  415. *
  416. * \param[in] val Bitmask value for prefetch enable bits (bits 0–7 of PFL1DCTRL1).
  417. * Only the lower 8 bits are used; higher bits are ignored.
  418. * \sa
  419. * - \ref IINFO_GetPrefetchLevel
  420. * - \ref IINFO_PFL1DCTRL1_DISABLE
  421. * - \ref IINFO_PFL1DCTRL1_L1D_ENA
  422. * - \ref IINFO_PFL1DCTRL1_CC_ENA
  423. * - \ref IINFO_PFL1DCTRL1_SCALAR_ENA
  424. * - \ref IINFO_PFL1DCTRL1_VECTOR_ENA
  425. * - \ref IINFO_PFL1DCTRL1_WRITE_PREF_ENA
  426. * - \ref IINFO_PFL1DCTRL1_CROSS_PAGE_PREF_ENA
  427. * - \ref IINFO_PFL1DCTRL1_MMU_PREF_ENA
  428. * - \ref IINFO_PFL1DCTRL1_PL2_ENA
  429. *
  430. * \example
  431. * \code
  432. * // Enable all prefetch except MMU and private L2 (PL2)
  433. * IINFO_SetPrefetchLevel(IINFO_PFL1DCTRL1_L1D_ENA |
  434. * IINFO_PFL1DCTRL1_CC_ENA |
  435. * IINFO_PFL1DCTRL1_SCALAR_ENA |
  436. * IINFO_PFL1DCTRL1_VECTOR_ENA |
  437. * IINFO_PFL1DCTRL1_WRITE_PREF_ENA |
  438. * IINFO_PFL1DCTRL1_CROSS_PAGE_PREF_ENA);
  439. * \endcode
  440. */
  441. __STATIC_FORCEINLINE void IINFO_SetPrefetchLevel(uint32_t val)
  442. {
  443. IINFO->pfl1dctrl1.d = (IINFO->pfl1dctrl1.d & ~IINFO_PFL1DCTRL1_LEVEL_Msk) |
  444. _VAL2FLD(IINFO_PFL1DCTRL1_LEVEL, val);
  445. }
  446. /**
  447. * \brief Get prefetch enable level bits
  448. * \details Gets the prefetch enable level bits from the PFL1DCTRL1 register using the enable field.
  449. * \return Current value of prefetch enable bits (bits 0-7)
  450. * \sa
  451. * - \ref IINFO_SetPrefetchLevel
  452. */
  453. __STATIC_FORCEINLINE uint32_t IINFO_GetPrefetchLevel(void)
  454. {
  455. return IINFO->pfl1dctrl1.lv.level;
  456. }
  457. /**
  458. * \brief Set PFL1DCTRL2 register value
  459. * \details Sets the value of the PFL1DCTRL2 register.
  460. * \param val Value to write to the PFL1DCTRL2 register
  461. */
  462. __STATIC_FORCEINLINE void IINFO_SetPFL1DCTRL2(uint32_t val)
  463. {
  464. IINFO->pfl1dctrl2.d = val;
  465. }
  466. /**
  467. * \brief Get PFL1DCTRL2 register value
  468. * \details Gets the current value of the PFL1DCTRL2 register.
  469. * \return Current value of the PFL1DCTRL2 register
  470. */
  471. __STATIC_FORCEINLINE uint32_t IINFO_GetPFL1DCTRL2(void)
  472. {
  473. return IINFO->pfl1dctrl2.d;
  474. }
  475. /**
  476. * \brief Set PFL1DCTRL3 register value
  477. * \details Sets the value of the PFL1DCTRL3 register.
  478. * \param val Value to write to the PFL1DCTRL3 register
  479. */
  480. __STATIC_FORCEINLINE void IINFO_SetPFL1DCTRL3(uint32_t val)
  481. {
  482. IINFO->pfl1dctrl3.d = val;
  483. }
  484. /**
  485. * \brief Get PFL1DCTRL3 register value
  486. * \details Gets the current value of the PFL1DCTRL3 register.
  487. * \return Current value of the PFL1DCTRL3 register
  488. */
  489. __STATIC_FORCEINLINE uint32_t IINFO_GetPFL1DCTRL3(void)
  490. {
  491. return IINFO->pfl1dctrl3.d;
  492. }
  493. /**
  494. * \brief Enable prefetch overall
  495. * \details Enables the prefetch overall by setting the pf_enable bit in the PFL1DCTRL4 register.
  496. */
  497. __STATIC_FORCEINLINE void IINFO_EnablePrefetchOverall(void)
  498. {
  499. IINFO->pfl1dctrl4.b.pf_enable = 1;
  500. }
  501. /**
  502. * \brief Disable prefetch overall
  503. * \details Disables the prefetch overall by clearing the pf_enable bit in the PFL1DCTRL4 register.
  504. */
  505. __STATIC_FORCEINLINE void IINFO_DisablePrefetchOverall(void)
  506. {
  507. IINFO->pfl1dctrl4.b.pf_enable = 0;
  508. }
  509. /** @} */ /* End of Doxygen Group NMSIS_Core_IINFO_Functions */
  510. #endif /* #ifdef __IINFO_BASEADDR */
  511. #ifdef __cplusplus
  512. }
  513. #endif
  514. #endif /* __CORE_FEATURE_IINFO_H__ */