From dfa191f9ae12e97ad0647fb1b54f46c1f671925e Mon Sep 17 00:00:00 2001 From: jasonhu <2323168280@qq.com> Date: Mon, 27 Dec 2021 13:55:35 +0800 Subject: [PATCH] [libcpu][c906] fix the bug where the cache is optimized --- libcpu/risc-v/t-head/c906/cache.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libcpu/risc-v/t-head/c906/cache.c b/libcpu/risc-v/t-head/c906/cache.c index 4250f3a1d2..1bb01edec7 100644 --- a/libcpu/risc-v/t-head/c906/cache.c +++ b/libcpu/risc-v/t-head/c906/cache.c @@ -16,6 +16,15 @@ #define L1_CACHE_BYTES (64) +/** + * GCC version not support t-head cache flush, so we use fixed code to achieve. + * The following function cannot be optimized. + */ +static void dcache_wb_range(unsigned long start, unsigned long end) __attribute__((optimize("O0"))); +static void dcache_inv_range(unsigned long start, unsigned long end) __attribute__((optimize("O0"))); +static void dcache_wbinv_range(unsigned long start, unsigned long end) __attribute__((optimize("O0"))); +static void icache_inv_range(unsigned long start, unsigned long end) __attribute__((optimize("O0"))); + static void dcache_wb_range(unsigned long start, unsigned long end) { unsigned long i = start & ~(L1_CACHE_BYTES - 1); -- Gitee