kernel: init: move banner handling
Move banner and boot delay handling out of init.c The code for banner was all over the place in init.c making it unreadable. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
de69edbf42
commit
4b59312a94
3 changed files with 54 additions and 34 deletions
|
@ -25,6 +25,7 @@ list(APPEND kernel_files
|
||||||
version.c
|
version.c
|
||||||
work_q.c
|
work_q.c
|
||||||
smp.c
|
smp.c
|
||||||
|
banner.c
|
||||||
)
|
)
|
||||||
|
|
||||||
if(CONFIG_XIP)
|
if(CONFIG_XIP)
|
||||||
|
|
51
kernel/banner.c
Normal file
51
kernel/banner.c
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <kernel.h>
|
||||||
|
#include <sys/util.h>
|
||||||
|
#include <init.h>
|
||||||
|
#include <device.h>
|
||||||
|
#include <version.h>
|
||||||
|
|
||||||
|
/* boot banner items */
|
||||||
|
#if defined(CONFIG_MULTITHREADING) && defined(CONFIG_BOOT_DELAY) && \
|
||||||
|
CONFIG_BOOT_DELAY > 0
|
||||||
|
#define BOOT_DELAY_BANNER " (delayed boot " STRINGIFY(CONFIG_BOOT_DELAY) "ms)"
|
||||||
|
#else
|
||||||
|
#define BOOT_DELAY_BANNER ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_BOOT_DELAY) || CONFIG_BOOT_DELAY > 0
|
||||||
|
void boot_banner(void)
|
||||||
|
{
|
||||||
|
#if defined(CONFIG_BOOT_DELAY) && CONFIG_BOOT_DELAY > 0
|
||||||
|
static const unsigned int boot_delay = CONFIG_BOOT_DELAY;
|
||||||
|
#else
|
||||||
|
static const unsigned int boot_delay;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (boot_delay > 0 && IS_ENABLED(CONFIG_MULTITHREADING)) {
|
||||||
|
printk("***** delaying boot " STRINGIFY(
|
||||||
|
CONFIG_BOOT_DELAY) "ms (per build configuration) *****\n");
|
||||||
|
k_busy_wait(CONFIG_BOOT_DELAY * USEC_PER_MSEC);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_BOOT_BANNER)
|
||||||
|
#ifdef BUILD_VERSION
|
||||||
|
printk("*** Booting Zephyr OS build %s %s ***\n",
|
||||||
|
STRINGIFY(BUILD_VERSION), BOOT_DELAY_BANNER);
|
||||||
|
#else
|
||||||
|
printk("*** Booting Zephyr OS version %s %s ***\n",
|
||||||
|
KERNEL_VERSION_STRING, BOOT_DELAY_BANNER);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void boot_banner(void)
|
||||||
|
{
|
||||||
|
/* do nothing */
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -24,7 +24,6 @@
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <linker/linker-defs.h>
|
#include <linker/linker-defs.h>
|
||||||
#include <ksched.h>
|
#include <ksched.h>
|
||||||
#include <version.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/dlist.h>
|
#include <sys/dlist.h>
|
||||||
#include <kernel_internal.h>
|
#include <kernel_internal.h>
|
||||||
|
@ -38,17 +37,7 @@
|
||||||
#include <logging/log.h>
|
#include <logging/log.h>
|
||||||
LOG_MODULE_REGISTER(os, CONFIG_KERNEL_LOG_LEVEL);
|
LOG_MODULE_REGISTER(os, CONFIG_KERNEL_LOG_LEVEL);
|
||||||
|
|
||||||
/* boot banner items */
|
|
||||||
#if defined(CONFIG_MULTITHREADING) && defined(CONFIG_BOOT_DELAY) \
|
|
||||||
&& CONFIG_BOOT_DELAY > 0
|
|
||||||
#define BOOT_DELAY_BANNER " (delayed boot " \
|
|
||||||
STRINGIFY(CONFIG_BOOT_DELAY) "ms)"
|
|
||||||
#else
|
|
||||||
#define BOOT_DELAY_BANNER ""
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* boot time measurement items */
|
/* boot time measurement items */
|
||||||
|
|
||||||
#ifdef CONFIG_BOOT_TIME_MEASUREMENT
|
#ifdef CONFIG_BOOT_TIME_MEASUREMENT
|
||||||
uint32_t __noinit z_timestamp_main; /* timestamp when main task starts */
|
uint32_t __noinit z_timestamp_main; /* timestamp when main task starts */
|
||||||
uint32_t __noinit z_timestamp_idle; /* timestamp when CPU goes idle */
|
uint32_t __noinit z_timestamp_idle; /* timestamp when CPU goes idle */
|
||||||
|
@ -130,6 +119,7 @@ extern volatile uintptr_t __stack_chk_guard;
|
||||||
/* LCOV_EXCL_STOP */
|
/* LCOV_EXCL_STOP */
|
||||||
|
|
||||||
bool z_sys_post_kernel;
|
bool z_sys_post_kernel;
|
||||||
|
extern void boot_banner(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -146,33 +136,13 @@ static void bg_thread_main(void *unused1, void *unused2, void *unused3)
|
||||||
ARG_UNUSED(unused2);
|
ARG_UNUSED(unused2);
|
||||||
ARG_UNUSED(unused3);
|
ARG_UNUSED(unused3);
|
||||||
|
|
||||||
#if defined(CONFIG_BOOT_DELAY) && CONFIG_BOOT_DELAY > 0
|
|
||||||
static const unsigned int boot_delay = CONFIG_BOOT_DELAY;
|
|
||||||
#else
|
|
||||||
static const unsigned int boot_delay;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
z_sys_post_kernel = true;
|
z_sys_post_kernel = true;
|
||||||
|
|
||||||
z_sys_init_run_level(_SYS_INIT_LEVEL_POST_KERNEL);
|
z_sys_init_run_level(_SYS_INIT_LEVEL_POST_KERNEL);
|
||||||
#if CONFIG_STACK_POINTER_RANDOM
|
#if CONFIG_STACK_POINTER_RANDOM
|
||||||
z_stack_adjust_initialized = 1;
|
z_stack_adjust_initialized = 1;
|
||||||
#endif
|
#endif
|
||||||
if (boot_delay > 0 && IS_ENABLED(CONFIG_MULTITHREADING)) {
|
boot_banner();
|
||||||
printk("***** delaying boot " STRINGIFY(CONFIG_BOOT_DELAY)
|
|
||||||
"ms (per build configuration) *****\n");
|
|
||||||
k_busy_wait(CONFIG_BOOT_DELAY * USEC_PER_MSEC);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_BOOT_BANNER)
|
|
||||||
#ifdef BUILD_VERSION
|
|
||||||
printk("*** Booting Zephyr OS build %s %s ***\n",
|
|
||||||
STRINGIFY(BUILD_VERSION), BOOT_DELAY_BANNER);
|
|
||||||
#else
|
|
||||||
printk("*** Booting Zephyr OS version %s %s ***\n",
|
|
||||||
KERNEL_VERSION_STRING, BOOT_DELAY_BANNER);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_CPLUSPLUS
|
#ifdef CONFIG_CPLUSPLUS
|
||||||
/* Process the .ctors and .init_array sections */
|
/* Process the .ctors and .init_array sections */
|
||||||
|
@ -247,7 +217,6 @@ static void init_idle_thread(int i)
|
||||||
thread->base.is_idle = 1U;
|
thread->base.is_idle = 1U;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_MULTITHREADING */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -261,7 +230,6 @@ static void init_idle_thread(int i)
|
||||||
*
|
*
|
||||||
* @return initial stack pointer for the main thread
|
* @return initial stack pointer for the main thread
|
||||||
*/
|
*/
|
||||||
#ifdef CONFIG_MULTITHREADING
|
|
||||||
static char *prepare_multithreading(void)
|
static char *prepare_multithreading(void)
|
||||||
{
|
{
|
||||||
char *stack_ptr;
|
char *stack_ptr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue