Skip to content

Commit

Permalink
[bsp][cvitek] add icache opration
Browse files Browse the repository at this point in the history
  • Loading branch information
zdtyuiop4444 committed Dec 2, 2024
1 parent a181fb4 commit 4b9eb0e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions bsp/cvitek/c906_little/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ config BSP_USING_C906_LITTLE
bool
select ARCH_RISCV64
select ARCH_RISCV_FPU_D
select RT_USING_CACHE
select RT_USING_COMPONENTS_INIT
select RT_USING_USER_MAIN
default y
Expand Down
23 changes: 23 additions & 0 deletions bsp/cvitek/c906_little/board/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*
* Change Logs:
* Date Author Notes
* 2024/11/27 zdtyuiop4444 Add Icache operation
* 2024/11/26 zdtyuiop4444 The first version
*/

Expand Down Expand Up @@ -34,3 +35,25 @@ inline void rt_hw_cpu_dcache_ops(int ops, void* addr, int size)
break;
}
}

inline void rt_hw_cpu_icache_enable(void)
{
asm volatile("csrs mhcr, %0;" ::"rI"(0x1));
}

inline void rt_hw_cpu_icache_disable(void)
{
asm volatile("csrc mhcr, %0;" ::"rI"(0x1));
}

inline void rt_hw_cpu_icache_ops(int ops, void* addr, int size)
{
switch (ops)
{
case RT_HW_CACHE_INVALIDATE:
CACHE_OP_RANGE(ICACHE_IPA_A0, start, size);
break;
default:
break;
}
}
6 changes: 6 additions & 0 deletions bsp/cvitek/c906_little/board/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*
* Change Logs:
* Date Author Notes
* 2024/11/27 zdtyuiop4444 Add Icache operation
* 2024/11/26 zdtyuiop4444 The first version
*/

Expand All @@ -29,13 +30,18 @@
* | 31 - 25 | 24 - 20 | 19 - 15 | 14 - 12 | 11 - 7 | 6 - 0 |
* 0000001 01011 rs1 000 00000 0001011
*
* icache.ipa rs1 (invalidate)
* | 31 - 25 | 24 - 20 | 19 - 15 | 14 - 12 | 11 - 7 | 6 - 0 |
* 0000001 11000 rs1 000 00000 0001011
*
* sync.s
* | 31 - 25 | 24 - 20 | 19 - 15 | 14 - 12 | 11 - 7 | 6 - 0 |
* 0000000 11001 00000 000 00000 0001011
*/
#define DCACHE_IPA_A0 ".long 0x02a5000b"
#define DCACHE_CPA_A0 ".long 0x0295000b"
#define DCACHE_CIPA_A0 ".long 0x02b5000b"
#define ICACHE_IPA_A0 ".long 0x0385000b"

#define SYNC_S ".long 0x0190000b"

Expand Down

0 comments on commit 4b9eb0e

Please sign in to comment.