kernel: specify arch functions for userspace

Any arches that support userspace will need to implement these
functions.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2017-08-30 14:00:26 -07:00 committed by Andrew Boie
commit 1f32d09bd8
2 changed files with 53 additions and 0 deletions

View file

@ -3869,6 +3869,38 @@ 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);
/* Interfaces for invoking system calls */
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)

View file

@ -89,6 +89,27 @@ static inline unsigned int _Swap(unsigned int key)
* @return nonzero if the permissions don't match.
*/
extern int _arch_buffer_validate(void *addr, size_t size, int write);
/**
* Perform a one-way transition from supervisor to kernel mode.
*
* Implementations of this function must do the following:
* - Reset the thread's stack pointer to a suitable initial value. We do not
* need any prior context since this is a one-way operation.
* - Set up any kernel stack region for the CPU to use during privilege
* elevation
* - Put the CPU in whatever its equivalent of user mode is
* - Transfer execution to _new_thread() passing along all the supplied
* arguments, in user mode.
*
* @param Entry point to start executing as a user thread
* @param p1 1st parameter to user thread
* @param p2 2nd parameter to user thread
* @param p3 3rd parameter to user thread
*/
extern FUNC_NORETURN
void _arch_user_mode_enter(k_thread_entry_t user_entry, void *p1, void *p2,
void *p3);
#endif /* CONFIG_USERSPACE */
/* set and clear essential fiber/task flag */