syscalls: reorganize headers
- syscall.h now contains those APIs needed to support invoking calls from user code. Some stuff moved out of main kernel.h. - syscall_handler.h now contains directives useful for implementing system call handler functions. This header is not pulled in by kernel.h and is intended to be used by C files implementing kernel system calls and driver subsystem APIs. - syscall_list.h now contains the #defines for system call IDs. This list is expected to grow quite large so it is put in its own header. This is now an enumerated type instead of defines to make things easier as we introduce system calls over the new few months. In the fullness of time when we desire to have a fixed userspace/kernel ABI, this can always be converted to defines. Some new code added: - _SYSCALL_MEMORY() macro added to check memory regions passed up from userspace in handler functions - _syscall_invoke{7...10}() inline functions declare for invoking system calls with more than 6 arguments. 10 was chosen as the limit as that corresponds to the largest arg list we currently have which is for k_thread_create() Other changes - auto-generated K_SYSCALL_DECLARE* macros documented - _k_syscall_table in userspace.c is not a placeholder. There's no strong need to generate it and doing so would require the introduction of a third build phase. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
1d3731f1e5
commit
13ca6fe284
7 changed files with 298 additions and 98 deletions
|
@ -28,6 +28,7 @@
|
|||
#include <kernel_version.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <kernel_arch_thread.h>
|
||||
#include <syscall.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -3893,52 +3894,6 @@ extern void _sys_power_save_idle_exit(s32_t ticks);
|
|||
|
||||
#include <arch/cpu.h>
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
/* Architecture-specific inline functions that may be indirectly called by
|
||||
* application code due to their appearance in macros or other inline functions.
|
||||
*
|
||||
* Each arch should implement these in <arch/cpu.h>
|
||||
*/
|
||||
|
||||
/* Indicate whether we are currently running in user mode
|
||||
*
|
||||
* @return nonzero if the CPU is currently running with user permissions
|
||||
*/
|
||||
static inline int _arch_is_user_context(void);
|
||||
|
||||
/**
|
||||
* Indicate whether the CPU is currently in user mode
|
||||
*
|
||||
* @return nonzero if the CPU is currently running with user permissions
|
||||
*/
|
||||
static inline int _is_user_context(void)
|
||||
{
|
||||
return _arch_is_user_context();
|
||||
}
|
||||
|
||||
/* Interfaces for invoking system calls */
|
||||
static inline u32_t _arch_syscall_invoke6(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||
u32_t arg4, u32_t arg5, u32_t arg6,
|
||||
u32_t call_id);
|
||||
|
||||
static inline u32_t _arch_syscall_invoke5(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||
u32_t arg4, u32_t arg5,
|
||||
u32_t call_id);
|
||||
|
||||
static inline u32_t _arch_syscall_invoke4(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||
u32_t arg4, u32_t call_id);
|
||||
|
||||
static inline u32_t _arch_syscall_invoke3(u32_t arg1, u32_t arg2, u32_t arg3,
|
||||
u32_t call_id);
|
||||
|
||||
static inline u32_t _arch_syscall_invoke2(u32_t arg1, u32_t arg2,
|
||||
u32_t call_id);
|
||||
|
||||
static inline u32_t _arch_syscall_invoke1(u32_t arg1, u32_t call_id);
|
||||
|
||||
static inline u32_t _arch_syscall_invoke0(u32_t call_id);
|
||||
#endif
|
||||
|
||||
#ifdef _ARCH_EXCEPT
|
||||
/* This archtecture has direct support for triggering a CPU exception */
|
||||
#define _k_except_reason(reason) _ARCH_EXCEPT(reason)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue