tests: app_kernel: Add custom syscalls
Adds two custom syscalls. The first allows a user thread to change its priority to a higher priority level. The second is used to obtain a timestamp from a user thread. Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
parent
bf2ab9be60
commit
f9cf48313b
3 changed files with 60 additions and 0 deletions
|
@ -19,3 +19,6 @@ CONFIG_MP_MAX_NUM_CPUS=1
|
|||
|
||||
# Enable pipes
|
||||
CONFIG_PIPES=y
|
||||
|
||||
CONFIG_APPLICATION_DEFINED_SYSCALL=y
|
||||
CONFIG_TIMING_FUNCTIONS=y
|
||||
|
|
|
@ -66,6 +66,57 @@ K_PIPE_DEFINE(PIPE_NOBUFF, 0, 4);
|
|||
K_PIPE_DEFINE(PIPE_SMALLBUFF, 256, 4);
|
||||
K_PIPE_DEFINE(PIPE_BIGBUFF, 4096, 4);
|
||||
|
||||
/*
|
||||
* Custom syscalls
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Change a thread's priority
|
||||
*
|
||||
* Unlike the normal k_thread_priority_set(), this custom syscall allows
|
||||
* a user thread to raise its priority.
|
||||
*/
|
||||
void z_impl_test_thread_priority_set(k_tid_t thread, int prio)
|
||||
{
|
||||
extern void z_thread_priority_set(struct k_thread *thread, int prio);
|
||||
|
||||
z_thread_priority_set((struct k_thread *)thread, prio);
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
static void z_vrfy_test_thread_priority_set(k_tid_t thread, int prio)
|
||||
{
|
||||
z_impl_test_thread_priority_set(thread, prio);
|
||||
}
|
||||
|
||||
#include <syscalls/test_thread_priority_set_mrsh.c>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Obtain a timestamp
|
||||
*
|
||||
* Architecture timestamp routines often require MMIO that is not mapped to
|
||||
* the user threads. Use a custom system call to get the timestamp.
|
||||
*/
|
||||
timing_t z_impl_timing_timestamp_get(void)
|
||||
{
|
||||
return timing_counter_get();
|
||||
}
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
static timing_t z_vrfy_timing_timestamp_get(void)
|
||||
{
|
||||
return z_impl_timing_timestamp_get();
|
||||
}
|
||||
|
||||
#include <syscalls/timing_timestamp_get_mrsh.c>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Main test
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Entry point for test thread
|
||||
*/
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <zephyr/sys/util.h>
|
||||
|
||||
#include <zephyr/app_memory/app_memdomain.h>
|
||||
#include <zephyr/timing/timing.h>
|
||||
|
||||
/* printf format defines. */
|
||||
#define FORMAT "| %-65s|%10u|\n"
|
||||
|
@ -140,4 +141,9 @@ static inline void check_result(void)
|
|||
}
|
||||
}
|
||||
|
||||
__syscall void test_thread_priority_set(k_tid_t thread, int prio);
|
||||
__syscall timing_t timing_timestamp_get(void);
|
||||
|
||||
#include <syscalls/master.h>
|
||||
|
||||
#endif /* _MASTER_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue