mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-12-25 16:57:20 +00:00
[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
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user