]> git.ipfire.org Git - thirdparty/u-boot.git/blame - common/main.c
Merge branch '2024-05-02-assorted-updates'
[thirdparty/u-boot.git] / common / main.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
c609719b
WD
2/*
3 * (C) Copyright 2000
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
c609719b
WD
5 */
6
a6c7ad2f
WD
7/* #define DEBUG */
8
c609719b 9#include <common.h>
66ded17d 10#include <autoboot.h>
e761035b 11#include <button.h>
52f24238 12#include <bootstage.h>
1047b534 13#include <bootstd.h>
18d66533 14#include <cli.h>
288b29e4 15#include <command.h>
24b852a7 16#include <console.h>
9fb625ce 17#include <env.h>
4023dc9c 18#include <fdtdec.h>
6b8d3cea 19#include <init.h>
90526e9f 20#include <net.h>
bdfb6d70 21#include <version_string.h>
c74cd8bd 22#include <efi_loader.h>
bdccc4fe 23
1364a0e4
SG
24static void run_preboot_environment_command(void)
25{
1364a0e4
SG
26 char *p;
27
00caae6d 28 p = env_get("preboot");
bc2b4c27 29 if (p != NULL) {
2cb132ad
SG
30 int prev = 0;
31
32 if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED))
33 prev = disable_ctrlc(1); /* disable Ctrl-C checking */
bc2b4c27
SG
34
35 run_command_list(p, -1, 0);
36
2cb132ad
SG
37 if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED))
38 disable_ctrlc(prev); /* restore Ctrl-C checking */
bc2b4c27 39 }
1364a0e4
SG
40}
41
affb2156 42/* We come here after U-Boot is initialised and ready to process commands */
1364a0e4
SG
43void main_loop(void)
44{
affb2156
SG
45 const char *s;
46
1364a0e4
SG
47 bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
48
2cb132ad
SG
49 if (IS_ENABLED(CONFIG_VERSION_VARIABLE))
50 env_set("ver", version_string); /* set version variable */
1364a0e4 51
c1bb2cd0 52 cli_init();
1364a0e4 53
e9f6a374
SG
54 if (IS_ENABLED(CONFIG_USE_PREBOOT))
55 run_preboot_environment_command();
bc2b4c27 56
2cb132ad
SG
57 if (IS_ENABLED(CONFIG_UPDATE_TFTP))
58 update_tftp(0UL, NULL, NULL);
bc2b4c27 59
a57ad20d
AT
60 if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY)) {
61 /* efi_init_early() already called */
62 if (efi_init_obj_list() == EFI_SUCCESS)
63 efi_launch_capsules();
64 }
c74cd8bd 65
e761035b
CC
66 process_button_cmds();
67
affb2156
SG
68 s = bootdelay_process();
69 if (cli_process_fdt(&s))
70 cli_secure_boot_cmd(s);
71
72 autoboot_command(s);
c1bb2cd0 73
1047b534
SG
74 /* if standard boot if enabled, assume that it will be able to boot */
75 if (IS_ENABLED(CONFIG_BOOTSTD_PROG)) {
76 int ret;
77
78 ret = bootstd_prog_boot();
79 printf("Standard boot failed (err=%dE)\n", ret);
80 panic("Failed to boot");
81 }
82
6493ccc7 83 cli_loop();
1047b534 84
045e6f0d 85 panic("No CLI available");
c609719b 86}