kernel: expose k_busy_wait() to user mode
If we just had the kernel's implementation, we could just move this to lib/, but possible arch-specific implementations dictate that we just make this a syscall. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
f253d0779d
commit
42cfd4ff26
6 changed files with 23 additions and 11 deletions
|
@ -14,9 +14,9 @@
|
|||
* Will block this thread (and therefore the whole zephyr) during usec_to_wait
|
||||
*
|
||||
* Note that interrupts may be received in the meanwhile and that therefore this
|
||||
* thread may loose context
|
||||
* thread may lose context
|
||||
*/
|
||||
void k_busy_wait(u32_t usec_to_wait)
|
||||
void z_arch_busy_wait(u32_t usec_to_wait)
|
||||
{
|
||||
bs_time_t time_end = tm_get_hw_time() + usec_to_wait;
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ int z_clock_driver_init(struct device *device)
|
|||
* Note that interrupts may be received in the meanwhile and that therefore this
|
||||
* thread may loose context
|
||||
*/
|
||||
void k_busy_wait(u32_t usec_to_wait)
|
||||
void z_arch_busy_wait(u32_t usec_to_wait)
|
||||
{
|
||||
u64_t time_end = hwm_get_time() + usec_to_wait;
|
||||
|
||||
|
|
|
@ -800,7 +800,7 @@ __syscall s32_t k_sleep(s32_t duration);
|
|||
*
|
||||
* @return N/A
|
||||
*/
|
||||
extern void k_busy_wait(u32_t usec_to_wait);
|
||||
__syscall void k_busy_wait(u32_t usec_to_wait);
|
||||
|
||||
/**
|
||||
* @brief Yield the current thread.
|
||||
|
|
|
@ -227,6 +227,10 @@ extern u32_t z_early_boot_rand32_get(void);
|
|||
extern int z_stack_adjust_initialized;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT)
|
||||
extern void z_arch_busy_wait(u32_t usec_to_wait);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -94,9 +94,10 @@ int _is_thread_essential(void)
|
|||
return _current->base.user_options & K_ESSENTIAL;
|
||||
}
|
||||
|
||||
#if !defined(CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT)
|
||||
void k_busy_wait(u32_t usec_to_wait)
|
||||
#ifdef CONFIG_SYS_CLOCK_EXISTS
|
||||
void _impl_k_busy_wait(u32_t usec_to_wait)
|
||||
{
|
||||
#if !defined(CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT)
|
||||
/* use 64-bit math to prevent overflow when multiplying */
|
||||
u32_t cycles_to_wait = (u32_t)(
|
||||
(u64_t)usec_to_wait *
|
||||
|
@ -113,8 +114,19 @@ void k_busy_wait(u32_t usec_to_wait)
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
z_arch_busy_wait(usec_to_wait);
|
||||
#endif /* CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT */
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
Z_SYSCALL_HANDLER(k_busy_wait, usec_to_wait)
|
||||
{
|
||||
_impl_k_busy_wait(usec_to_wait);
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
#endif /* CONFIG_SYS_CLOCK_EXISTS */
|
||||
|
||||
#ifdef CONFIG_THREAD_CUSTOM_DATA
|
||||
void _impl_k_thread_custom_data_set(void *value)
|
||||
|
|
|
@ -25,10 +25,6 @@ void posix_irq_handler(void);
|
|||
void posix_exit(int exit_code);
|
||||
u64_t posix_get_hw_cycle(void);
|
||||
|
||||
#if defined(CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT)
|
||||
void k_busy_wait(u32_t usec_to_wait);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue