kernel: move test of kernel startup state to more visible location

The original implementation left this function hidden in init.h which
prevented it from showing up in documentation.  Move it to kernel.h,
and document it consistent with the other functions that allow caller
customization based on context.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2019-12-23 11:48:43 -06:00 committed by Anas Nashif
commit 74ef395332
5 changed files with 25 additions and 19 deletions

View file

@ -25,22 +25,6 @@ extern "C" {
#define _SYS_INIT_LEVEL_POST_KERNEL 2
#define _SYS_INIT_LEVEL_APPLICATION 3
extern s8_t z_sys_device_level;
/**
* @brief Test whether startup is in the before-main-task phase.
*
* This impacts which services are available for use, and the context
* in which functions are run.
*
* @return true if and only if start up is still running pre-kernel
* initialization.
*/
static inline bool k_is_pre_kernel(void)
{
return (z_sys_device_level < _SYS_INIT_LEVEL_POST_KERNEL);
}
/* A counter is used to avoid issues when two or more system devices
* are declared in the same C file with the same init function.
*/

View file

@ -1295,6 +1295,24 @@ extern bool k_is_in_isr(void);
*/
__syscall int k_is_preempt_thread(void);
/**
* @brief Test whether startup is in the before-main-task phase.
*
* This routine allows the caller to customize its actions, depending on
* whether it being invoked before the kernel is fully active.
*
* @note Can be called by ISRs.
*
* @return true if invoked before post-kernel initialization
* @return false if invoked during/after post-kernel initialization
*/
static inline bool k_is_pre_kernel(void)
{
extern bool z_sys_post_kernel; /* in init.c */
return !z_sys_post_kernel;
}
/**
* @}
*/