main.c 1.3 KB
Newer Older
1
// SPDX-License-Identifier: GPL-2.0+
W
wdenk 已提交
2 3 4 5 6
/*
 * (C) Copyright 2000
 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 */

7 8
/* #define	DEBUG	*/

W
wdenk 已提交
9
#include <common.h>
S
Simon Glass 已提交
10
#include <autoboot.h>
11
#include <cli.h>
12
#include <console.h>
S
Simon Glass 已提交
13
#include <env.h>
S
Simon Glass 已提交
14
#include <version.h>
15

16 17 18
/*
 * Board-specific Platform code can reimplement show_boot_progress () if needed
 */
19
__weak void show_boot_progress(int val) {}
20

S
Simon Glass 已提交
21 22 23 24
static void run_preboot_environment_command(void)
{
	char *p;

25
	p = env_get("preboot");
26
	if (p != NULL) {
S
Simon Glass 已提交
27 28 29 30
		int prev = 0;

		if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED))
			prev = disable_ctrlc(1); /* disable Ctrl-C checking */
31 32 33

		run_command_list(p, -1, 0);

S
Simon Glass 已提交
34 35
		if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED))
			disable_ctrlc(prev);	/* restore Ctrl-C checking */
36
	}
S
Simon Glass 已提交
37 38
}

39
/* We come here after U-Boot is initialised and ready to process commands */
S
Simon Glass 已提交
40 41
void main_loop(void)
{
42 43
	const char *s;

S
Simon Glass 已提交
44 45
	bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");

S
Simon Glass 已提交
46 47
	if (IS_ENABLED(CONFIG_VERSION_VARIABLE))
		env_set("ver", version_string);  /* set version variable */
S
Simon Glass 已提交
48

49
	cli_init();
S
Simon Glass 已提交
50

51 52
	if (IS_ENABLED(CONFIG_USE_PREBOOT))
		run_preboot_environment_command();
53

S
Simon Glass 已提交
54 55
	if (IS_ENABLED(CONFIG_UPDATE_TFTP))
		update_tftp(0UL, NULL, NULL);
56

57 58 59 60 61
	s = bootdelay_process();
	if (cli_process_fdt(&s))
		cli_secure_boot_cmd(s);

	autoboot_command(s);
62

63
	cli_loop();
64
	panic("No CLI available");
W
wdenk 已提交
65
}