blob: 2979fbed630ca22d7ae9a208c18a06ab1a3e21f0 [file] [log] [blame]
wdenkc6097192002-11-03 00:24:07 +00001/*
2 * (C) Copyright 2000
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenkc6097192002-11-03 00:24:07 +00006 */
7
wdenka6c7ad22002-12-03 21:28:10 +00008/* #define DEBUG */
9
wdenkc6097192002-11-03 00:24:07 +000010#include <common.h>
Simon Glass66ded172014-04-10 20:01:28 -060011#include <autoboot.h>
Simon Glass18d66532014-04-10 20:01:25 -060012#include <cli.h>
Simon Glassfbcdf322013-05-15 06:23:59 +000013#include <version.h>
wdenkbdccc4f2003-08-05 17:43:17 +000014
Simon Glass9272a9b2014-04-10 20:01:32 -060015DECLARE_GLOBAL_DATA_PTR;
16
Heiko Schocherfad63402007-07-13 09:54:17 +020017/*
18 * Board-specific Platform code can reimplement show_boot_progress () if needed
19 */
Jeroen Hofstee34222992014-06-26 20:18:31 +020020__weak void show_boot_progress(int val) {}
Heiko Schocherfad63402007-07-13 09:54:17 +020021
Simon Glass1364a0e2014-04-10 20:01:33 -060022static void modem_init(void)
Simon Glassbc2b4c22013-05-15 06:23:56 +000023{
Simon Glassbc2b4c22013-05-15 06:23:56 +000024#ifdef CONFIG_MODEM_SUPPORT
Simon Glass9272a9b2014-04-10 20:01:32 -060025 debug("DEBUG: main_loop: gd->do_mdm_init=%lu\n", gd->do_mdm_init);
26 if (gd->do_mdm_init) {
Simon Glass95856242014-04-10 20:01:36 -060027 char *str = getenv("mdm_cmd");
28
Simon Glassbc2b4c22013-05-15 06:23:56 +000029 setenv("preboot", str); /* set or delete definition */
Simon Glassbc2b4c22013-05-15 06:23:56 +000030 mdm_init(); /* wait for modem connection */
31 }
32#endif /* CONFIG_MODEM_SUPPORT */
Simon Glass1364a0e2014-04-10 20:01:33 -060033}
Simon Glassbc2b4c22013-05-15 06:23:56 +000034
Simon Glass1364a0e2014-04-10 20:01:33 -060035static void run_preboot_environment_command(void)
36{
Simon Glassbc2b4c22013-05-15 06:23:56 +000037#ifdef CONFIG_PREBOOT
Simon Glass1364a0e2014-04-10 20:01:33 -060038 char *p;
39
Simon Glassbc2b4c22013-05-15 06:23:56 +000040 p = getenv("preboot");
41 if (p != NULL) {
42# ifdef CONFIG_AUTOBOOT_KEYED
43 int prev = disable_ctrlc(1); /* disable Control C checking */
44# endif
45
46 run_command_list(p, -1, 0);
47
48# ifdef CONFIG_AUTOBOOT_KEYED
49 disable_ctrlc(prev); /* restore Control C checking */
50# endif
51 }
52#endif /* CONFIG_PREBOOT */
Simon Glass1364a0e2014-04-10 20:01:33 -060053}
54
Simon Glassaffb2152014-04-10 20:01:35 -060055/* We come here after U-Boot is initialised and ready to process commands */
Simon Glass1364a0e2014-04-10 20:01:33 -060056void main_loop(void)
57{
Simon Glassaffb2152014-04-10 20:01:35 -060058 const char *s;
59
Simon Glass1364a0e2014-04-10 20:01:33 -060060 bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
61
62#ifndef CONFIG_SYS_GENERIC_BOARD
63 puts("Warning: Your board does not use generic board. Please read\n");
64 puts("doc/README.generic-board and take action. Boards not\n");
65 puts("upgraded by the late 2014 may break or be removed.\n");
66#endif
67
68 modem_init();
69#ifdef CONFIG_VERSION_VARIABLE
70 setenv("ver", version_string); /* set version variable */
71#endif /* CONFIG_VERSION_VARIABLE */
72
Simon Glassc1bb2cd2014-04-10 20:01:34 -060073 cli_init();
Simon Glass1364a0e2014-04-10 20:01:33 -060074
75 run_preboot_environment_command();
Simon Glassbc2b4c22013-05-15 06:23:56 +000076
77#if defined(CONFIG_UPDATE_TFTP)
78 update_tftp(0UL);
79#endif /* CONFIG_UPDATE_TFTP */
80
Simon Glassaffb2152014-04-10 20:01:35 -060081 s = bootdelay_process();
82 if (cli_process_fdt(&s))
83 cli_secure_boot_cmd(s);
84
85 autoboot_command(s);
Simon Glassc1bb2cd2014-04-10 20:01:34 -060086
Simon Glass6493ccc2014-04-10 20:01:26 -060087 cli_loop();
wdenkc6097192002-11-03 00:24:07 +000088}