1 /*
2  * Copyright (c) 2020 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/kernel.h>
8 #include <zephyr/init.h>
9 #include <zephyr/device.h>
10 #include <zephyr/version.h>
11 
12 #if defined(CONFIG_BOOT_DELAY) && (CONFIG_BOOT_DELAY > 0)
13 #define DELAY_STR STRINGIFY(CONFIG_BOOT_DELAY)
14 #define BANNER_POSTFIX " (delayed boot " DELAY_STR "ms)"
15 #else
16 #define BANNER_POSTFIX ""
17 #endif /* defined(CONFIG_BOOT_DELAY) && (CONFIG_BOOT_DELAY > 0) */
18 
19 #ifndef BANNER_VERSION
20 #if defined(BUILD_VERSION) && !IS_EMPTY(BUILD_VERSION)
21 #define BANNER_VERSION STRINGIFY(BUILD_VERSION)
22 #else
23 #define BANNER_VERSION KERNEL_VERSION_STRING
24 #endif /* BUILD_VERSION */
25 #endif /* !BANNER_VERSION */
26 
boot_banner(void)27 void boot_banner(void)
28 {
29 #if defined(CONFIG_BOOT_DELAY) && (CONFIG_BOOT_DELAY > 0)
30 #ifdef CONFIG_BOOT_BANNER
31 	printk("***** delaying boot " DELAY_STR "ms (per build configuration) *****\n");
32 #endif /* CONFIG_BOOT_BANNER */
33 	k_busy_wait(CONFIG_BOOT_DELAY * USEC_PER_MSEC);
34 #endif /* defined(CONFIG_BOOT_DELAY) && (CONFIG_BOOT_DELAY > 0) */
35 
36 #if defined(CONFIG_BOOT_CLEAR_SCREEN)
37 	 /* \x1b[ = escape sequence
38 	  * 3J = erase scrollback
39 	  * 2J = erase screen
40 	  * H = move cursor to top left
41 	  */
42 	printk("\x1b[3J\x1b[2J\x1b[H");
43 #endif /* CONFIG_BOOT_CLEAR_SCREEN */
44 
45 #ifdef CONFIG_BOOT_BANNER
46 	printk("*** " CONFIG_BOOT_BANNER_STRING " " BANNER_VERSION BANNER_POSTFIX " ***\n");
47 #endif /* CONFIG_BOOT_BANNER */
48 }
49