xref: /openbmc/u-boot/common/main.c (revision d024236e5a31a2b4b82cbcc98b31b8170fc88d28)
1 /*
2  * (C) Copyright 2000
3  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 /* #define	DEBUG	*/
9 
10 #include <common.h>
11 #include <autoboot.h>
12 #include <cli.h>
13 #include <console.h>
14 #include <version.h>
15 
16 /*
17  * Board-specific Platform code can reimplement show_boot_progress () if needed
18  */
19 __weak void show_boot_progress(int val) {}
20 
21 static void run_preboot_environment_command(void)
22 {
23 #ifdef CONFIG_PREBOOT
24 	char *p;
25 
26 	p = env_get("preboot");
27 	if (p != NULL) {
28 # ifdef CONFIG_AUTOBOOT_KEYED
29 		int prev = disable_ctrlc(1);	/* disable Control C checking */
30 # endif
31 
32 		run_command_list(p, -1, 0);
33 
34 # ifdef CONFIG_AUTOBOOT_KEYED
35 		disable_ctrlc(prev);	/* restore Control C checking */
36 # endif
37 	}
38 #endif /* CONFIG_PREBOOT */
39 }
40 
41 /* We come here after U-Boot is initialised and ready to process commands */
42 void main_loop(void)
43 {
44 	const char *s;
45 
46 	bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
47 
48 #ifdef CONFIG_VERSION_VARIABLE
49 	env_set("ver", version_string);  /* set version variable */
50 #endif /* CONFIG_VERSION_VARIABLE */
51 
52 	cli_init();
53 
54 	run_preboot_environment_command();
55 
56 #if defined(CONFIG_UPDATE_TFTP)
57 	update_tftp(0UL, NULL, NULL);
58 #endif /* CONFIG_UPDATE_TFTP */
59 
60 	s = bootdelay_process();
61 	if (cli_process_fdt(&s))
62 		cli_secure_boot_cmd(s);
63 
64 	autoboot_command(s);
65 
66 	cli_loop();
67 	panic("No CLI available");
68 }
69