diff options
| author | Shell <[email protected]> | 2023-03-17 15:11:38 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-03-17 15:11:38 +0800 |
| commit | 18a14cc9351e9c44df539ad21ce825679bc023ca (patch) | |
| tree | ee4ba510ece3819a9ceb14ed30b9b4a4e5a777e2 /components | |
| parent | dfddd79b2453ab13d12b69c7db14e2f685175af7 (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 'components')
| -rw-r--r-- | components/lwp/lwp_syscall.c | 34 | ||||
| -rw-r--r-- | components/mm/mm_page.c | 15 |
2 files changed, 30 insertions, 19 deletions
diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index 9c42ccf0fd..9c06d84f4c 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -1237,6 +1237,9 @@ struct ksigevent int sigev_tid; }; +/* to protect unsafe implementation in current rt-smart toolchain */ +RT_CTASSERT(sigevent_compatible, offsetof(struct ksigevent, sigev_tid) == offsetof(struct sigevent, sigev_notify_function)); + rt_err_t sys_timer_create(clockid_t clockid, struct sigevent *restrict sevp, timer_t *restrict timerid) { int ret = 0; @@ -1264,17 +1267,11 @@ rt_err_t sys_timer_create(clockid_t clockid, struct sigevent *restrict sevp, tim } } - /* to protect unsafe implementation in current rt-smart toolchain */ - RT_ASSERT(((struct ksigevent *)sevp)->sigev_tid == *(int *)(&sevp_k.sigev_notify_function)); - ret = _SYS_WRAP(timer_create(clockid, &sevp_k, &timerid_k)); - /* ID should not extend 32-bits size for libc */ - RT_ASSERT((rt_ubase_t)timerid_k < UINT32_MAX); - utimer = (rt_ubase_t)timerid_k; - if (ret != -RT_ERROR) { + utimer = (rt_ubase_t)timerid_k; if (!lwp_put_to_user(sevp, (void *)&sevp_k, sizeof(struct ksigevent)) || !lwp_put_to_user(timerid, (void *)&utimer, sizeof(utimer))) ret = -EINVAL; @@ -4546,6 +4543,29 @@ sysret_t sys_mq_close(mqd_t mqd) return (ret < 0 ? GET_ERRNO() : ret); } +#define ICACHE (1<<0) +#define DCACHE (1<<1) +#define BCACHE (ICACHE|DCACHE) + +rt_weak sysret_t sys_cacheflush(void *addr, int size, int cache) +{ + if (addr < addr + size && + (size_t)addr >= USER_VADDR_START && + (size_t)addr + size < USER_VADDR_TOP) + { + if ((cache & DCACHE)) + { + rt_hw_cpu_dcache_clean_and_invalidate(addr, size); + } + if ((cache & ICACHE)) + { + rt_hw_cpu_icache_invalidate(addr, size); + } + return 0; + } + return -EFAULT; +} + const static struct rt_syscall_def func_table[] = { SYSCALL_SIGN(sys_exit), /* 01 */ diff --git a/components/mm/mm_page.c b/components/mm/mm_page.c index a53b62aba7..03ab5327b6 100644 --- a/components/mm/mm_page.c +++ b/components/mm/mm_page.c @@ -26,20 +26,11 @@ #define DBG_LVL DBG_WARNING #include <rtdbg.h> +RT_CTASSERT(order_huge_pg, RT_PAGE_MAX_ORDER > ARCH_PAGE_SHIFT - 2); +RT_CTASSERT(size_width, sizeof(rt_size_t) == sizeof(void *)); + #ifdef RT_USING_SMART #include "lwp_arch_comm.h" - -#define CT_ASSERT(name, x) \ - struct assert_##name \ - { \ - char ary[2 * (x)-1]; \ - } -#ifdef ARCH_CPU_64BIT -CT_ASSERT(order_huge_pg, RT_PAGE_MAX_ORDER > ARCH_PAGE_SHIFT - 2); -#else -CT_ASSERT(size_width, sizeof(rt_size_t) == sizeof(rt_size_t)); -#endif /* ARCH_CPU_64BIT */ - #endif /* RT_USING_SMART */ static rt_size_t init_mpr_align_start; |
