summaryrefslogtreecommitdiff
path: root/libcpu
diff options
context:
space:
mode:
authorShell <[email protected]>2023-03-17 15:11:38 +0800
committerGitHub <[email protected]>2023-03-17 15:11:38 +0800
commit18a14cc9351e9c44df539ad21ce825679bc023ca (patch)
treeee4ba510ece3819a9ceb14ed30b9b4a4e5a777e2 /libcpu
parentdfddd79b2453ab13d12b69c7db14e2f685175af7 (diff)
[rt-smart] move sys_cacheflush to lwp_syscall.c (#7048)
* [syscall] move sys_cacheflush to lwp_syscall.c * [syscall] improve assertion * [format] rename to rt_ctassert * [debug] modified ct assertion on mm_page.c
Diffstat (limited to 'libcpu')
-rw-r--r--libcpu/aarch64/common/cache.h4
-rw-r--r--libcpu/aarch64/common/cache_ops.c23
-rw-r--r--libcpu/arm/cortex-a/cache.c23
-rw-r--r--libcpu/arm/cortex-a/cache.h3
-rw-r--r--libcpu/risc-v/t-head/c906/cache.c33
-rw-r--r--libcpu/risc-v/t-head/c906/cache.h12
-rw-r--r--libcpu/risc-v/virt64/cache.c5
-rw-r--r--libcpu/risc-v/virt64/cache.h8
8 files changed, 18 insertions, 93 deletions
diff --git a/libcpu/aarch64/common/cache.h b/libcpu/aarch64/common/cache.h
index dec4e91bb5..86f5e84ea4 100644
--- a/libcpu/aarch64/common/cache.h
+++ b/libcpu/aarch64/common/cache.h
@@ -11,6 +11,8 @@
#ifndef __CACHE_H__
#define __CACHE_H__
+#include <rtdef.h>
+
void __asm_invalidate_icache_all(void);
void rt_hw_dcache_flush_all(void);
@@ -25,5 +27,7 @@ static inline void rt_hw_icache_invalidate_all(void)
}
void rt_hw_icache_invalidate_range(unsigned long start_addr, int size);
+void rt_hw_cpu_icache_invalidate(void *addr, rt_size_t size);
+void rt_hw_cpu_dcache_clean_and_invalidate(void *addr, rt_size_t size);
#endif /* __CACHE_H__ */
diff --git a/libcpu/aarch64/common/cache_ops.c b/libcpu/aarch64/common/cache_ops.c
index 3bfa9f2056..9193434599 100644
--- a/libcpu/aarch64/common/cache_ops.c
+++ b/libcpu/aarch64/common/cache_ops.c
@@ -77,26 +77,3 @@ rt_base_t rt_hw_cpu_dcache_status(void)
{
return 0;
}
-
-#ifdef RT_USING_LWP
-#define ICACHE (1<<0)
-#define DCACHE (1<<1)
-#define BCACHE (ICACHE|DCACHE)
-
-int sys_cacheflush(void *addr, int size, int cache)
-{
- if ((size_t)addr < KERNEL_VADDR_START && (size_t)addr + size <= KERNEL_VADDR_START)
- {
- if ((cache & DCACHE) != 0)
- {
- rt_hw_cpu_dcache_clean_and_invalidate(addr, size);
- }
- if ((cache & ICACHE) != 0)
- {
- rt_hw_cpu_icache_invalidate(addr, size);
- }
- return 0;
- }
- return -1;
-}
-#endif
diff --git a/libcpu/arm/cortex-a/cache.c b/libcpu/arm/cortex-a/cache.c
index 2b609f2ff9..23f4501e15 100644
--- a/libcpu/arm/cortex-a/cache.c
+++ b/libcpu/arm/cortex-a/cache.c
@@ -153,26 +153,3 @@ rt_base_t rt_hw_cpu_dcache_status(void)
{
return 0;
}
-
-#ifdef RT_USING_SMART
-#define ICACHE (1<<0)
-#define DCACHE (1<<1)
-#define BCACHE (ICACHE|DCACHE)
-
-int sys_cacheflush(void *addr, int size, int cache)
-{
- if ((size_t)addr < KERNEL_VADDR_START && (size_t)addr + size <= KERNEL_VADDR_START)
- {
- if ((cache & DCACHE) != 0)
- {
- rt_hw_cpu_dcache_clean_and_invalidate(addr, size);
- }
- if ((cache & ICACHE) != 0)
- {
- rt_hw_cpu_icache_invalidate(addr, size);
- }
- return 0;
- }
- return -1;
-}
-#endif
diff --git a/libcpu/arm/cortex-a/cache.h b/libcpu/arm/cortex-a/cache.h
index c3e096ba0c..9dff18ac9d 100644
--- a/libcpu/arm/cortex-a/cache.h
+++ b/libcpu/arm/cortex-a/cache.h
@@ -11,6 +11,9 @@
#ifndef __CACHE_H__
#define __CACHE_H__
+void rt_hw_cpu_icache_invalidate(void *addr, int size);
+void rt_hw_cpu_dcache_clean_and_invalidate(void *addr, int size);
+
static inline void rt_hw_icache_invalidate_all(void)
{
__asm__ volatile("mcr p15, 0, %0, c7, c5, 0"::"r"(0ul));
diff --git a/libcpu/risc-v/t-head/c906/cache.c b/libcpu/risc-v/t-head/c906/cache.c
index bcb313bbc7..af493e3adf 100644
--- a/libcpu/risc-v/t-head/c906/cache.c
+++ b/libcpu/risc-v/t-head/c906/cache.c
@@ -90,7 +90,7 @@ void rt_hw_cpu_dcache_clean_local(void *addr, int size)
rt_hw_cpu_sync();
}
-void rt_hw_cpu_dcache_clean_invalidate_local(void *addr, int size)
+void rt_hw_cpu_dcache_clean_and_invalidate_local(void *addr, int size)
{
dcache_wbinv_range((unsigned long)addr, (unsigned long)((unsigned char *)addr + size));
rt_hw_cpu_sync();
@@ -127,34 +127,3 @@ void rt_hw_sync_cache_local(void *addr, int size)
rt_hw_cpu_dcache_clean_local(addr, size);
rt_hw_cpu_icache_invalidate_local(addr, size);
}
-
-#ifdef RT_USING_SMART
-#include <lwp_arch.h>
-#define ICACHE (1 << 0)
-#define DCACHE (1 << 1)
-#define BCACHE (ICACHE | DCACHE)
-
-/**
- * TODO moving syscall to kernel
- */
-int sys_cacheflush(void *addr, int size, int cache)
-{
- /* must in user space */
- if ((size_t)addr >= USER_VADDR_START && (size_t)addr + size < USER_VADDR_TOP)
- {
- /**
- * we DO NOT check argument 'cache' invalid error
- */
- if ((cache & DCACHE) != 0)
- {
- rt_hw_cpu_dcache_clean_invalidate_local(addr, size);
- }
- if ((cache & ICACHE) != 0)
- {
- rt_hw_cpu_icache_invalidate_local(addr, size);
- }
- return 0;
- }
- return -RT_ERROR;
-}
-#endif
diff --git a/libcpu/risc-v/t-head/c906/cache.h b/libcpu/risc-v/t-head/c906/cache.h
index d29c5c1e44..7476de83cf 100644
--- a/libcpu/risc-v/t-head/c906/cache.h
+++ b/libcpu/risc-v/t-head/c906/cache.h
@@ -31,7 +31,7 @@
void rt_hw_cpu_dcache_clean_local(void *addr, int size);
void rt_hw_cpu_dcache_invalidate_local(void *addr, int size);
-void rt_hw_cpu_dcache_clean_invalidate_local(void *addr, int size);
+void rt_hw_cpu_dcache_clean_and_invalidate_local(void *addr, int size);
void rt_hw_cpu_icache_invalidate_local(void *addr, int size);
@@ -49,7 +49,7 @@ ALWAYS_INLINE void rt_hw_cpu_dcache_invalidate_all_local(void)
rt_hw_cpu_sync();
}
-ALWAYS_INLINE void rt_hw_cpu_dcache_clean_invalidate_all_local(void)
+ALWAYS_INLINE void rt_hw_cpu_dcache_clean_and_invalidate_all_local(void)
{
__asm__ volatile(OPC_DCACHE_CIALL ::
: "memory");
@@ -76,11 +76,11 @@ ALWAYS_INLINE void rt_hw_cpu_icache_invalidate_all_local(void)
void rt_hw_cpu_dcache_clean(void *addr, int size);
void rt_hw_cpu_dcache_invalidate(void *addr, int size);
-void rt_hw_cpu_dcache_clean_invalidate(void *addr, int size);
+void rt_hw_cpu_dcache_clean_and_invalidate(void *addr, int size);
void rt_hw_cpu_dcache_clean_all(void);
void rt_hw_cpu_dcache_invalidate_all(void);
-void rt_hw_cpu_dcache_clean_invalidate_all(void);
+void rt_hw_cpu_dcache_clean_and_invalidate_all(void);
void rt_hw_cpu_icache_invalidate(void *addr, int size);
void rt_hw_cpu_icache_invalidate_all(void);
@@ -89,11 +89,11 @@ void rt_hw_cpu_icache_invalidate_all(void);
#define rt_hw_cpu_dcache_clean rt_hw_cpu_dcache_clean_local
#define rt_hw_cpu_dcache_invalidate rt_hw_cpu_dcache_invalidate_local
-#define rt_hw_cpu_dcache_clean_invalidate rt_hw_cpu_dcache_clean_invalidate_local
+#define rt_hw_cpu_dcache_clean_and_invalidate rt_hw_cpu_dcache_clean_and_invalidate_local
#define rt_hw_cpu_dcache_clean_all rt_hw_cpu_dcache_clean_all_local
#define rt_hw_cpu_dcache_invalidate_all rt_hw_cpu_dcache_invalidate_all_local
-#define rt_hw_cpu_dcache_clean_invalidate_all rt_hw_cpu_dcache_clean_invalidate_all_local
+#define rt_hw_cpu_dcache_clean_and_invalidate_all rt_hw_cpu_dcache_clean_and_invalidate_all_local
#define rt_hw_cpu_icache_invalidate rt_hw_cpu_icache_invalidate_local
#define rt_hw_cpu_icache_invalidate_all rt_hw_cpu_icache_invalidate_all_local
diff --git a/libcpu/risc-v/virt64/cache.c b/libcpu/risc-v/virt64/cache.c
index a7f58ee0c6..cd50602e20 100644
--- a/libcpu/risc-v/virt64/cache.c
+++ b/libcpu/risc-v/virt64/cache.c
@@ -57,8 +57,3 @@ rt_base_t rt_hw_cpu_dcache_status()
void rt_hw_sync_cache_local(void *addr, int size)
{
}
-
-int sys_cacheflush(void *addr, int size, int cache)
-{
- return 0;
-}
diff --git a/libcpu/risc-v/virt64/cache.h b/libcpu/risc-v/virt64/cache.h
index b4a041ac88..5b625a37d5 100644
--- a/libcpu/risc-v/virt64/cache.h
+++ b/libcpu/risc-v/virt64/cache.h
@@ -21,11 +21,11 @@
ALWAYS_INLINE void rt_hw_cpu_dcache_clean_local(void *addr, int size) {}
ALWAYS_INLINE void rt_hw_cpu_dcache_invalidate_local(void *addr, int size) {}
-ALWAYS_INLINE void rt_hw_cpu_dcache_clean_invalidate_local(void *addr, int size) {}
+ALWAYS_INLINE void rt_hw_cpu_dcache_clean_and_invalidate_local(void *addr, int size) {}
ALWAYS_INLINE void rt_hw_cpu_dcache_clean_all_local() {}
ALWAYS_INLINE void rt_hw_cpu_dcache_invalidate_all_local(void) {}
-ALWAYS_INLINE void rt_hw_cpu_dcache_clean_invalidate_all_local(void) {}
+ALWAYS_INLINE void rt_hw_cpu_dcache_clean_and_invalidate_all_local(void) {}
ALWAYS_INLINE void rt_hw_cpu_icache_invalidate_local(void *addr, int size) {}
ALWAYS_INLINE void rt_hw_cpu_icache_invalidate_all_local() {}
@@ -36,11 +36,11 @@ ALWAYS_INLINE void rt_hw_cpu_icache_invalidate_all_local() {}
#define rt_hw_cpu_dcache_clean rt_hw_cpu_dcache_clean_local
#define rt_hw_cpu_dcache_invalidate rt_hw_cpu_dcache_invalidate_local
-#define rt_hw_cpu_dcache_clean_invalidate rt_hw_cpu_dcache_clean_invalidate_local
+#define rt_hw_cpu_dcache_clean_and_invalidate rt_hw_cpu_dcache_clean_and_invalidate_local
#define rt_hw_cpu_dcache_clean_all rt_hw_cpu_dcache_clean_all_local
#define rt_hw_cpu_dcache_invalidate_all rt_hw_cpu_dcache_invalidate_all_local
-#define rt_hw_cpu_dcache_clean_invalidate_all rt_hw_cpu_dcache_clean_invalidate_all_local
+#define rt_hw_cpu_dcache_clean_and_invalidate_all rt_hw_cpu_dcache_clean_and_invalidate_all_local
#define rt_hw_cpu_icache_invalidate rt_hw_cpu_icache_invalidate_local
#define rt_hw_cpu_icache_invalidate_all rt_hw_cpu_icache_invalidate_all_local