syscalls: Add system call for cache flush & invalidate

include/cache.h: System calls declaration and implementation
kernel/cache_handlers.c: Defination of verification functions

Signed-off-by: Aastha Grover <aastha.grover@intel.com>
This commit is contained in:
Aastha Grover 2020-07-16 12:32:24 -07:00 committed by Anas Nashif
parent d5e1753eb6
commit 2d9b459f15
3 changed files with 30 additions and 2 deletions

View file

@ -32,7 +32,9 @@ void arch_dcache_invd(void *addr, size_t size);
*
* @return N/A
*/
static inline void sys_cache_flush(void *addr, size_t size)
__syscall void sys_cache_flush(void *addr, size_t size);
static inline void z_impl_sys_cache_flush(void *addr, size_t size)
{
if (IS_ENABLED(CONFIG_CACHE_FLUSHING)) {
arch_dcache_flush(addr, size);
@ -55,7 +57,9 @@ static inline void sys_cache_flush(void *addr, size_t size)
*
* @return N/A
*/
static inline void sys_cache_invd(void *addr, size_t size)
__syscall void sys_cache_invd(void *addr, size_t size);
static inline void z_impl_sys_cache_invd(void *addr, size_t size)
{
if (IS_ENABLED(CONFIG_CACHE_FLUSHING)) {
arch_dcache_invd(addr, size);
@ -83,6 +87,7 @@ static inline size_t sys_cache_line_size_get(void)
#endif /* CONFIG_CACHE_FLUSHING */
}
#include <syscalls/cache.h>
#ifdef __cplusplus
}
#endif

View file

@ -56,6 +56,7 @@ target_sources_ifdef(
kernel PRIVATE
futex.c
mem_domain.c
cache_handlers.c
userspace_handler.c
userspace.c
)

22
kernel/cache_handlers.c Normal file
View file

@ -0,0 +1,22 @@
/*
* Copyright (c) 2020 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <cache.h>
#include <syscall_handler.h>
static inline void z_vrfy_sys_cache_flush(void *addr, size_t size)
{
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(addr, size));
z_impl_sys_cache_flush(addr, size);
}
#include <syscalls/sys_cache_flush_mrsh.c>
static inline void z_vrfy_sys_cache_invd(void *addr, size_t size)
{
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(addr, size));
z_impl_sys_cache_invd(addr, size);
}
#include <syscalls/sys_cache_invd_mrsh.c>