HPM SDK
HPMicro Software Development Kit
hpm_l1c_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021,2025 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef _HPM_L1_CACHE_H
9 #define _HPM_L1_CACHE_H
10 #include "hpm_common.h"
11 #include "hpm_csr_drv.h"
12 #include "hpm_soc_feature.h"
13 
21 /* mcache_ctl register */
22 /*
23  * Controls if the instruction cache is enabled or not.
24  *
25  * 0 I-Cache is disabled
26  * 1 I-Cache is enabled
27  */
28 #define HPM_MCACHE_CTL_IC_EN_SHIFT (0UL)
29 #define HPM_MCACHE_CTL_IC_EN_MASK (1UL << HPM_MCACHE_CTL_IC_EN_SHIFT)
30 #define HPM_MCACHE_CTL_IC_EN(x) \
31  (uint32_t)(((x) << HPM_MCACHE_CTL_IC_EN_SHIFT) & HPM_MCACHE_CTL_IC_EN_MASK)
32 
33 /*
34  * Controls if the data cache is enabled or not.
35  *
36  * 0 D-Cache is disabled
37  * 1 D-Cache is enabled
38  */
39 #define HPM_MCACHE_CTL_DC_EN_SHIFT (1UL)
40 #define HPM_MCACHE_CTL_DC_EN_MASK (1UL << HPM_MCACHE_CTL_DC_EN_SHIFT)
41 #define HPM_MCACHE_CTL_DC_EN(x) \
42  (uint32_t)(((x) << HPM_MCACHE_CTL_DC_EN_SHIFT) & HPM_MCACHE_CTL_DC_EN_MASK)
43 
44 /*
45  * Parity/ECC error checking enable control for the instruction cache.
46  *
47  * 0 Disable parity/ECC
48  * 1 Reserved
49  * 2 Generate exceptions only on uncorrectable parity/ECC errors
50  * 3 Generate exceptions on any type of parity/ECC errors
51  */
52 #define HPM_MCACHE_CTL_IC_ECCEN_SHIFT (2UL)
53 #define HPM_MCACHE_CTL_IC_ECCEN_MASK (0x3UL << HPM_MCACHE_CTL_IC_ECCEN_SHIFT)
54 #define HPM_MCACHE_CTL_IC_ECCEN(x) \
55  (uint32_t)(((x) << HPM_MCACHE_CTL_IC_ECCEN_SHIFT) & HPM_MCACHE_CTL_IC_ECCEN_MASK)
56 
57 /*
58  *
59  * Parity/ECC error checking enable control for the data cache.
60  *
61  * 0 Disable parity/ECC
62  * 1 Reserved
63  * 2 Generate exceptions only on uncorrectable parity/ECC errors
64  * 3 Generate exceptions on any type of parity/ECC errors
65  */
66 #define HPM_MCACHE_CTL_DC_ECCEN_SHIFT (4UL)
67 #define HPM_MCACHE_CTL_DC_ECCEN_MASK (0x3UL << HPM_MCACHE_CTL_DC_ECCEN_SHIFT)
68 #define HPM_MCACHE_CTL_DC_ECCEN(x) \
69  (uint32_t)(((x) << HPM_MCACHE_CTL_DC_ECCEN_SHIFT) & HPM_MCACHE_CTL_DC_ECCEN_MASK)
70 
71 /*
72  *
73  * Controls diagnostic accesses of ECC codes of the instruction cache RAMs.
74  * It is set to enable CCTL operations to access the ECC codes. This bit
75  * can be set for injecting ECC errors to test the ECC handler.
76  *
77  * 0 Disable diagnostic accesses of ECC codes
78  * 1 Enable diagnostic accesses of ECC codes
79  */
80 #define HPM_MCACHE_CTL_IC_RWECC_SHIFT (6UL)
81 #define HPM_MCACHE_CTL_IC_RWECC_MASK (0x1UL << HPM_MCACHE_CTL_IC_RWECC_SHIFT)
82 #define HPM_MCACHE_CTL_IC_RWECC(x) \
83  (uint32_t)(((x) << HPM_MCACHE_CTL_IC_RWECC_SHIFT) & HPM_MCACHE_CTL_IC_RWECC_MASK)
84 
85 /*
86  *
87  * Controls diagnostic accesses of ECC codes of the data cache RAMs. It is
88  * set to enable CCTL operations to access the ECC codes. This bit can be
89  * set for injecting
90  *
91  * ECC errors to test the ECC handler.
92  * 0 Disable diagnostic accesses of ECC codes
93  * 1 Enable diagnostic accesses of ECC codes
94  */
95 #define HPM_MCACHE_CTL_DC_RWECC_SHIFT (7UL)
96 #define HPM_MCACHE_CTL_DC_RWECC_MASK (0x1UL << HPM_MCACHE_CTL_DC_RWECC_SHIFT)
97 #define HPM_MCACHE_CTL_DC_RWECC(x) \
98  (uint32_t)(((x) << HPM_MCACHE_CTL_DC_RWECC_SHIFT) & HPM_MCACHE_CTL_DC_RWECC_MASK)
99 
100 /*
101  * Enable bit for Superuser-mode and User-mode software to access
102  * ucctlbeginaddr and ucctlcommand CSRs.
103  *
104  * 0 Disable ucctlbeginaddr and ucctlcommand accesses in S/U mode
105  * 1 Enable ucctlbeginaddr and ucctlcommand accesses in S/U mode
106  */
107 #define HPM_MCACHE_CTL_CCTL_SUEN_SHIFT (8UL)
108 #define HPM_MCACHE_CTL_CCTL_SUEN_MASK (0x1UL << HPM_MCACHE_CTL_CCTL_SUEN_SHIFT)
109 #define HPM_MCACHE_CTL_CCTL_SUEN(x) \
110  (uint32_t)(((x) << HPM_MCACHE_CTL_CCTL_SUEN_SHIFT) & HPM_MCACHE_CTL_CCTL_SUEN_MASK)
111 
112 /*
113  * This bit controls hardware prefetch for instruction fetches to cacheable
114  * memory regions when I-Cache size is not 0.
115  *
116  * 0 Disable hardware prefetch on instruction fetches
117  * 1 Enable hardware prefetch on instruction fetches
118  */
119 #define HPM_MCACHE_CTL_IPREF_EN_SHIFT (9UL)
120 #define HPM_MCACHE_CTL_IPREF_EN_MASK (0x1UL << HPM_MCACHE_CTL_IPREF_EN_SHIFT)
121 #define HPM_MCACHE_CTL_IPREF_EN(x) \
122  (uint32_t)(((x) << HPM_MCACHE_CTL_IPREF_EN_SHIFT) & HPM_MCACHE_CTL_IPREF_EN_MASK)
123 
124 /*
125  * This bit controls hardware prefetch for load/store accesses to cacheable
126  * memory regions when D-Cache size is not 0.
127  *
128  * 0 Disable hardware prefetch on load/store memory accesses.
129  * 1 Enable hardware prefetch on load/store memory accesses.
130  */
131 #define HPM_MCACHE_CTL_DPREF_EN_SHIFT (10UL)
132 #define HPM_MCACHE_CTL_DPREF_EN_MASK (0x1UL << HPM_MCACHE_CTL_DPREF_EN_SHIFT)
133 #define HPM_MCACHE_CTL_DPREF_EN(x) \
134  (uint32_t)(((x) << HPM_MCACHE_CTL_DPREF_EN_SHIFT) & HPM_MCACHE_CTL_DPREF_EN_MASK)
135 
136 /*
137  * I-Cache miss allocation filling policy Value Meaning
138  *
139  * 0 Cache line data is returned critical (double) word first
140  * 1 Cache line data is returned the lowest address (double) word first
141  */
142 #define HPM_MCACHE_CTL_IC_FIRST_WORD_SHIFT (11UL)
143 #define HPM_MCACHE_CTL_IC_FIRST_WORD_MASK (0x1UL << HPM_MCACHE_CTL_IC_FIRST_WORD_SHIFT)
144 #define HPM_MCACHE_CTL_IC_FIRST_WORD(x) \
145  (uint32_t)(((x) << HPM_MCACHE_CTL_IC_FIRST_WORD_SHIFT) & HPM_MCACHE_CTL_IC_FIRST_WORD_MASK)
146 
147 /*
148  * D-Cache miss allocation filling policy
149  *
150  * 0 Cache line data is returned critical (double) word first
151  * 1 Cache line data is returned the lowest address (double) word first
152  */
153 #define HPM_MCACHE_CTL_DC_FIRST_WORD_SHIFT (12UL)
154 #define HPM_MCACHE_CTL_DC_FIRST_WORD_MASK (0x1UL << HPM_MCACHE_CTL_DC_FIRST_WORD_SHIFT)
155 #define HPM_MCACHE_CTL_DC_FIRST_WORD(x) \
156  (uint32_t)(((x) << HPM_MCACHE_CTL_DC_FIRST_WORD_SHIFT) & HPM_MCACHE_CTL_DC_FIRST_WORD_MASK)
157 
158 /*
159  * D-Cache Write-Around threshold
160  *
161  * 0 Disables streaming. All cacheable write misses allocate a cache line
162  * according to PMA settings.
163  * 1 Override PMA setting and do not allocate D-Cache entries after
164  * consecutive stores to 4 cache lines.
165  * 2 Override PMA setting and do not allocate D-Cache entries after
166  * consecutive stores to 64 cache lines.
167  * 3 Override PMA setting and do not allocate D-Cache entries after
168  * consecutive stores to 128 cache lines.
169  */
170 #define HPM_MCACHE_CTL_DC_WAROUND_SHIFT (13UL)
171 #define HPM_MCACHE_CTL_DC_WAROUND_MASK (0x3UL << HPM_MCACHE_CTL_DC_WAROUND_SHIFT)
172 #define HPM_MCACHE_CTL_DC_WAROUND(x) \
173  (uint32_t)(((x) << HPM_MCACHE_CTL_DC_WAROUND_SHIFT) & HPM_MCACHE_CTL_DC_WAROUND_MASK)
174 
175 /* CCTL command list */
176 #define HPM_L1C_CCTL_CMD_L1D_VA_INVAL (0UL)
177 #define HPM_L1C_CCTL_CMD_L1D_VA_WB (1UL)
178 #define HPM_L1C_CCTL_CMD_L1D_VA_WBINVAL (2UL)
179 #define HPM_L1C_CCTL_CMD_L1D_VA_LOCK (3UL)
180 #define HPM_L1C_CCTL_CMD_L1D_VA_UNLOCK (4UL)
181 #define HPM_L1C_CCTL_CMD_L1D_WBINVAL_ALL (6UL)
182 #define HPM_L1C_CCTL_CMD_L1D_WB_ALL (7UL)
183 
184 #define HPM_L1C_CCTL_CMD_L1I_VA_INVAL (8UL)
185 #define HPM_L1C_CCTL_CMD_L1I_VA_LOCK (11UL)
186 #define HPM_L1C_CCTL_CMD_L1I_VA_UNLOCK (12UL)
187 
188 #define HPM_L1C_CCTL_CMD_L1D_IX_INVAL (16UL)
189 #define HPM_L1C_CCTL_CMD_L1D_IX_WB (17UL)
190 #define HPM_L1C_CCTL_CMD_L1D_IX_WBINVAL (18UL)
191 
192 #define HPM_L1C_CCTL_CMD_L1D_IX_RTAG (19UL)
193 #define HPM_L1C_CCTL_CMD_L1D_IX_RDATA (20UL)
194 #define HPM_L1C_CCTL_CMD_L1D_IX_WTAG (21UL)
195 #define HPM_L1C_CCTL_CMD_L1D_IX_WDATA (22UL)
196 
197 #define HPM_L1C_CCTL_CMD_L1D_INVAL_ALL (23UL)
198 
199 #define HPM_L1C_CCTL_CMD_L1I_IX_INVAL (24UL)
200 #define HPM_L1C_CCTL_CMD_L1I_IX_RTAG (27UL)
201 #define HPM_L1C_CCTL_CMD_L1I_IX_RDATA (28UL)
202 #define HPM_L1C_CCTL_CMD_L1I_IX_WTAG (29UL)
203 #define HPM_L1C_CCTL_CMD_L1I_IX_WDATA (30UL)
204 
205 #define HPM_L1C_CCTL_CMD_SUCCESS (1UL)
206 #define HPM_L1C_CCTL_CMD_FAIL (0UL)
207 
208 #ifdef __cplusplus
209 extern "C" {
210 #endif
211 
212 /* get cache control register value */
213 ATTR_ALWAYS_INLINE static inline uint32_t l1c_get_control(void)
214 {
215  return read_csr(CSR_MCACHE_CTL);
216 }
217 
218 ATTR_ALWAYS_INLINE static inline bool l1c_dc_is_enabled(void)
219 {
221 }
222 
223 ATTR_ALWAYS_INLINE static inline bool l1c_ic_is_enabled(void)
224 {
226 }
227 
228 /* mcctlbeginaddress register bitfield layout for CCTL IX type command */
229 #define HPM_MCCTLBEGINADDR_OFFSET_SHIFT (2UL)
230 #define HPM_MCCTLBEGINADDR_OFFSET_MASK ((uint32_t) 0xF << HPM_MCCTLBEGINADDR_OFFSET_SHIFT)
231 #define HPM_MCCTLBEGINADDR_OFFSET(x) \
232  (uint32_t)(((x) << HPM_MCCTLBEGINADDR_OFFSET_SHIFT) & HPM_MCCTLBEGINADDR_OFFSET_MASK)
233 #define HPM_MCCTLBEGINADDR_INDEX_SHIFT (6UL)
234 #define HPM_MCCTLBEGINADDR_INDEX_MASK ((uint32_t) 0x3F << HPM_MCCTLBEGINADDR_INDEX_SHIFT)
235 #define HPM_MCCTLBEGINADDR_INDEX(x) \
236  (uint32_t)(((x) << HPM_MCCTLBEGINADDR_INDEX_SHIFT) & HPM_MCCTLBEGINADDR_INDEX_MASK)
237 #define HPM_MCCTLBEGINADDR_WAY_SHIFT (13UL)
238 #define HPM_MCCTLBEGINADDR_WAY_MASK ((uint32_t) 0x3 << HPM_MCCTLBEGINADDR_WAY_SHIFT)
239 #define HPM_MCCTLBEGINADDR_WAY(x) \
240  (uint32_t)(((x) << HPM_MCCTLBEGINADDR_WAY_SHIFT) & HPM_MCCTLBEGINADDR_WAY_MASK)
241 
242 /* send IX command */
243 ATTR_ALWAYS_INLINE static inline void l1c_cctl_address(uint32_t address)
244 {
245  write_csr(CSR_MCCTLBEGINADDR, address);
246 }
247 
248 /* send command */
249 ATTR_ALWAYS_INLINE static inline void l1c_cctl_cmd(uint8_t cmd)
250 {
252 }
253 
254 ATTR_ALWAYS_INLINE static inline uint32_t l1c_cctl_get_address(void)
255 {
257 }
258 
259 /* send IX command */
260 ATTR_ALWAYS_INLINE static inline
261  void l1c_cctl_address_cmd(uint8_t cmd, uint32_t address)
262 {
263 #if defined(HPM_SDK_L1C_NO_REENTRANT) && HPM_SDK_L1C_NO_REENTRANT
264  register uint32_t mcause;
266 #endif
267 
268  write_csr(CSR_MCCTLBEGINADDR, address);
270 
271 #if defined(HPM_SDK_L1C_NO_REENTRANT) && HPM_SDK_L1C_NO_REENTRANT
272  write_csr(CSR_MSTATUS, mcause);
273 #endif
274 }
275 
276 #define HPM_MCCTLDATA_I_TAG_ADDRESS_SHIFT (2UL)
277 #define HPM_MCCTLDATA_I_TAG_ADDRESS_MASK (uint32_t)(0XFFFFF << HPM_MCCTLDATA_I_TAG_ADDRESS_SHIFT)
278 #define HPM_MCCTLDATA_I_TAG_ADDRESS(x) \
279  (uint32_t)(((x) << HPM_MCCTLDATA_I_TAG_ADDRESS_SHIFT) & HPM_MCCTLDATA_I_TAG_ADDRESS_MASK)
280 
281 #define HPM_MCCTLDATA_I_TAG_LOCK_DUP_SHIFT (29UL)
282 #define HPM_MCCTLDATA_I_TAG_LOCK_DUP_MASK (uint32_t)(1 << HPM_MCCTLDATA_I_TAG_LOCK_DUP_SHIFT)
283 #define HPM_MCCTLDATA_I_TAG_LOCK_DUP(x) \
284  (uint32_t)(((x) << HPM_MCCTLDATA_I_TAG_LOCK_DUP_SHIFT) & HPM_MCCTLDATA_I_TAG_LOCK_DUP_MASK)
285 
286 #define HPM_MCCTLDATA_I_TAG_LOCK_SHIFT (30UL)
287 #define HPM_MCCTLDATA_I_TAG_LOCK_MASK (uint32_t)(1 << HPM_MCCTLDATA_I_TAG_LOCK_SHIFT)
288 #define HPM_MCCTLDATA_I_TAG_LOCK(x) \
289  (uint32_t)(((x) << HPM_MCCTLDATA_I_TAG_LOCK_SHIFT) & HPM_MCCTLDATA_I_TAG_LOCK_MASK)
290 
291 #define HPM_MCCTLDATA_I_TAG_VALID_SHIFT (31UL)
292 #define HPM_MCCTLDATA_I_TAG_VALID_MASK (uint32_t)(1 << HPM_MCCTLDATA_I_TAG_VALID_SHIFT)
293 #define HPM_MCCTLDATA_I_TAG_VALID(x) \
294  (uint32_t)(((x) << HPM_MCCTLDATA_I_TAG_VALID_SHIFT) & HPM_MCCTLDATA_I_TAG_VALID_MASK)
295 
296 #define HPM_MCCTLDATA_D_TAG_MESI_SHIFT (0UL)
297 #define HPM_MCCTLDATA_D_TAG_MESI_MASK (uint32_t)(0x3 << HPM_MCCTLDATA_D_TAG_MESI_SHIFT)
298 #define HPM_MCCTLDATA_D_TAG_MESI(x) \
299  (uint32_t)(((x) << HPM_MCCTLDATA_D_TAG_MESI_SHIFT) & HPM_MCCTLDATA_D_TAG_MESI_MASK)
300 
301 #define HPM_MCCTLDATA_D_TAG_LOCK_SHIFT (3UL)
302 #define HPM_MCCTLDATA_D_TAG_LOCK_MASK (uint32_t)(0x1 << HPM_MCCTLDATA_D_TAG_LOCK_SHIFT)
303 #define HPM_MCCTLDATA_D_TAG_LOCK(x) \
304  (uint32_t)(((x) << HPM_MCCTLDATA_D_TAG_LOCK_SHIFT) & HPM_MCCTLDATA_D_TAG_LOCK_MASK)
305 
306 #define HPM_MCCTLDATA_D_TAG_TAG_SHIFT (4UL)
307 #define HPM_MCCTLDATA_D_TAG_TAG_MASK (uint32_t)(0xFFFF << HPM_MCCTLDATA_D_TAG_LOCK_SHIFT)
308 #define HPM_MCCTLDATA_D_TAG_TAG(x) \
309  (uint32_t)(((x) << HPM_MCCTLDATA_D_TAG_TAG_SHIFT) & HPM_MCCTLDATA_D_TAG_TAG_MASK)
310 
311 /*
312  * @brief Cache control read data
313  *
314  * @return data read
315  */
316 ATTR_ALWAYS_INLINE static inline uint32_t l1c_cctl_get_data(void)
317 {
318  return read_csr(CSR_MCCTLDATA);
319 }
320 
321 /*
322  * @brief Cache control write data
323  *
324  * @param[in] data Data to be written
325  */
326 ATTR_ALWAYS_INLINE static inline void l1c_cctl_data(uint32_t data)
327 {
328  write_csr(CSR_MCCTLDATA, data);
329 }
330 
331 #define HPM_L1C_CFG_SET_SHIFT (0UL)
332 #define HPM_L1C_CFG_SET_MASK (uint32_t)(0x7 << HPM_L1C_CFG_SET_SHIFT)
333 #define HPM_L1C_CFG_WAY_SHIFT (3UL)
334 #define HPM_L1C_CFG_WAY_MASK (uint32_t)(0x7 << HPM_L1C_CFG_WAY_SHIFT)
335 #define HPM_L1C_CFG_SIZE_SHIFT (6UL)
336 #define HPM_L1C_CFG_SIZE_MASK (uint32_t)(0x7 << HPM_L1C_CFG_SIZE_SHIFT)
337 #define HPM_L1C_CFG_LOCK_SHIFT (9UL)
338 #define HPM_L1C_CFG_LOCK_MASK (uint32_t)(0x1 << HPM_L1C_CFG_LOCK_SHIFT)
339 #define HPM_L1C_CFG_ECC_SHIFT (10UL)
340 #define HPM_L1C_CFG_ECC_MASK (uint32_t)(0x3 << HPM_L1C_CFG_ECC_SHIFT)
341 #define HPM_L1C_CFG_LMB_SHIFT (12UL)
342 #define HPM_L1C_CFG_LMB_MASK (uint32_t)(0x7 << HPM_L1C_CFG_LMB_SHIFT)
343 #define HPM_L1C_CFG_LM_SIZE_SHIFT (15UL)
344 #define HPM_L1C_CFG_LM_SIZE_MASK (uint32_t)(0x1F << HPM_L1C_CFG_LM_SIZE_SHIFT)
345 #define HPM_L1C_CFG_LM_ECC_SHIFT (21UL)
346 #define HPM_L1C_CFG_LM_ECC_MASK (uint32_t)(0x3 << HPM_L1C_CFG_LM_ECC_SHIFT)
347 #define HPM_L1C_CFG_SETH_SHIFT (24UL)
348 #define HPM_L1C_CFG_SETH_MASK (uint32_t)(0x1 << HPM_L1C_CFG_SETH_SHIFT)
349 
355 ATTR_ALWAYS_INLINE static inline uint32_t l1c_ic_get_config(void)
356 {
357  return read_csr(CSR_MICM_CFG);
358 }
359 
365 ATTR_ALWAYS_INLINE static inline uint32_t l1c_dc_get_config(void)
366 {
367  return read_csr(CSR_MDCM_CFG);
368 }
369 
370 /*
371  * @brief D-cache disable
372  */
373 void l1c_dc_disable(void);
374 
375 /*
376  * @brief D-cache enable
377  */
378 void l1c_dc_enable(void);
379 
380 /*
381  * @brief D-cache invalidate by address
382  * @param[in] address Start address to be invalidated
383  * @param[in] size Size of memory to be invalidated
384  */
385 void l1c_dc_invalidate(uint32_t address, uint32_t size);
386 
387 /*
388  * @brief D-cache writeback by address
389  * @param[in] address Start address to be writtenback
390  * @param[in] size Size of memory to be writtenback
391  */
392 void l1c_dc_writeback(uint32_t address, uint32_t size);
393 
394 /*
395  * @brief D-cache invalidate and writeback by address
396  * @param[in] address Start address to be invalidated and writtenback
397  * @param[in] size Size of memory to be invalidted and writtenback
398  */
399 void l1c_dc_flush(uint32_t address, uint32_t size);
400 
401 /*
402  * @brief D-cache fill and lock by address
403  * @param[in] address Start address to be filled and locked
404  * @param[in] size Size of memory to be filled and locked
405  */
406 void l1c_dc_fill_lock(uint32_t address, uint32_t size);
407 
408 /*
409  * @brief D-cache unlock by address
410  * @param[in] address Start address to be unlocked
411  * @param[in] size Size of memory to be unlocked
412  */
413 void l1c_dc_unlock(uint32_t address, uint32_t size);
414 
415 /*
416  * @brief I-cache disable
417  */
418 void l1c_ic_disable(void);
419 
420 /*
421  * @brief I-cache enable
422  */
423 void l1c_ic_enable(void);
424 
425 /*
426  * @brief I-cache invalidate by address
427  * @param[in] address Start address to be invalidated
428  * @param[in] size Size of memory to be invalidated
429  */
430 void l1c_ic_invalidate(uint32_t address, uint32_t size);
431 
432 /*
433  * @brief I-cache fill and lock by address
434  * @param[in] address Start address to be locked
435  * @param[in] size Size of memory to be locked
436  */
437 void l1c_ic_fill_lock(uint32_t address, uint32_t size);
438 
439 /*
440  * @brief I-cache unlock by address
441  * @param[in] address Start address to be unlocked
442  * @param[in] size Size of memory to be unlocked
443  */
444 void l1c_ic_unlock(uint32_t address, uint32_t size);
445 
446 /*
447  * @brief Invalidate all icache and writeback all dcache
448  */
449 void l1c_fence_i(void);
450 
451 /*
452  * @brief Invalidate all d-cache
453  */
454 void l1c_dc_invalidate_all(void);
455 
456 /*
457  * @brief Writeback all d-cache
458  */
459 void l1c_dc_writeback_all(void);
460 
461 /*
462  * @brief Flush all d-cache
463  */
464 void l1c_dc_flush_all(void);
465 
466 /*
467  * @brief Enable d-cache writearound
468  */
469 void l1c_dc_enable_writearound(void);
470 
471 /*
472  * @brief Disable d-cache writearound
473  */
474 void l1c_dc_disable_writearound(void);
475 
476 #ifdef __cplusplus
477 }
478 #endif
479 
484 #endif /* _HPM_L1_CACHE_H */
#define CSR_MICM_CFG
Definition: hpm_csr_regs.h:121
#define CSR_MCCTLDATA
Definition: hpm_csr_regs.h:106
#define CSR_MCACHE_CTL
Definition: hpm_csr_regs.h:103
#define CSR_MSTATUS
Definition: hpm_csr_regs.h:21
#define CSR_MSTATUS_MIE_MASK
Definition: hpm_csr_regs.h:413
#define CSR_MCCTLCOMMAND
Definition: hpm_csr_regs.h:105
#define CSR_MDCM_CFG
Definition: hpm_csr_regs.h:122
#define CSR_MCCTLBEGINADDR
Definition: hpm_csr_regs.h:104
void l1c_ic_invalidate(uint32_t address, uint32_t size)
Definition: hpm_l1c_drv.c:121
#define HPM_MCACHE_CTL_IC_EN_MASK
Definition: hpm_l1c_drv.h:29
void l1c_ic_enable(void)
Definition: hpm_l1c_drv.c:55
static ATTR_ALWAYS_INLINE bool l1c_ic_is_enabled(void)
Definition: hpm_l1c_drv.h:223
void l1c_ic_disable(void)
Definition: hpm_l1c_drv.c:64
void l1c_dc_flush_all(void)
Definition: hpm_l1c_drv.c:86
static ATTR_ALWAYS_INLINE void l1c_cctl_data(uint32_t data)
Definition: hpm_l1c_drv.h:326
void l1c_dc_enable(void)
Definition: hpm_l1c_drv.c:36
#define HPM_MCACHE_CTL_DC_EN_MASK
Definition: hpm_l1c_drv.h:40
void l1c_ic_fill_lock(uint32_t address, uint32_t size)
Definition: hpm_l1c_drv.c:127
void l1c_dc_disable(void)
Definition: hpm_l1c_drv.c:48
void l1c_dc_disable_writearound(void)
Definition: hpm_l1c_drv.c:144
void l1c_dc_writeback_all(void)
Definition: hpm_l1c_drv.c:81
void l1c_ic_unlock(uint32_t address, uint32_t size)
Definition: hpm_l1c_drv.c:133
static ATTR_ALWAYS_INLINE uint32_t l1c_ic_get_config(void)
Get I-cache configuration.
Definition: hpm_l1c_drv.h:355
static ATTR_ALWAYS_INLINE bool l1c_dc_is_enabled(void)
Definition: hpm_l1c_drv.h:218
static ATTR_ALWAYS_INLINE uint32_t l1c_dc_get_config(void)
Get D-cache configuration.
Definition: hpm_l1c_drv.h:365
void l1c_dc_flush(uint32_t address, uint32_t size)
Definition: hpm_l1c_drv.c:115
void l1c_dc_invalidate_all(void)
Definition: hpm_l1c_drv.c:76
static ATTR_ALWAYS_INLINE uint32_t l1c_get_control(void)
Definition: hpm_l1c_drv.h:213
void l1c_fence_i(void)
Definition: hpm_l1c_drv.c:71
static ATTR_ALWAYS_INLINE uint32_t l1c_cctl_get_data(void)
Definition: hpm_l1c_drv.h:316
void l1c_dc_unlock(uint32_t address, uint32_t size)
Definition: hpm_l1c_drv.c:97
static ATTR_ALWAYS_INLINE uint32_t l1c_cctl_get_address(void)
Definition: hpm_l1c_drv.h:254
void l1c_dc_writeback(uint32_t address, uint32_t size)
Definition: hpm_l1c_drv.c:109
void l1c_dc_fill_lock(uint32_t address, uint32_t size)
Definition: hpm_l1c_drv.c:91
void l1c_dc_invalidate(uint32_t address, uint32_t size)
Definition: hpm_l1c_drv.c:103
void l1c_dc_enable_writearound(void)
Definition: hpm_l1c_drv.c:139
static ATTR_ALWAYS_INLINE void l1c_cctl_address(uint32_t address)
Definition: hpm_l1c_drv.h:243
static ATTR_ALWAYS_INLINE void l1c_cctl_cmd(uint8_t cmd)
Definition: hpm_l1c_drv.h:249
static ATTR_ALWAYS_INLINE void l1c_cctl_address_cmd(uint8_t cmd, uint32_t address)
Definition: hpm_l1c_drv.h:261
static void size
Definition: hpm_math.h:6938
#define write_csr(csr_num, v)
write value to csr
Definition: riscv_core.h:66
#define read_csr(csr_num)
read value of specific csr
Definition: riscv_core.h:75
#define read_clear_csr(csr_num, bit)
read and clear bits in csr
Definition: riscv_core.h:40