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 Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenkc6097192002-11-03 00:24:07 +00006 */
7
wdenk9dd2b882002-12-03 21:28:10 +00008/* #define DEBUG */
9
wdenkc6097192002-11-03 00:24:07 +000010#include <common.h>
Simon Glass7b6a95a2014-04-10 20:01:28 -060011#include <autoboot.h>
Simon Glassdec3c012014-04-10 20:01:25 -060012#include <cli.h>
Simon Glassb2b687f2013-05-15 06:23:59 +000013#include <version.h>
wdenk0a658552003-08-05 17:43:17 +000014
Simon Glasse3a762c2014-04-10 20:01:32 -060015DECLARE_GLOBAL_DATA_PTR;
16
Heiko Schocher8a8ec532007-07-13 09:54:17 +020017/*
18 * Board-specific Platform code can reimplement show_boot_progress () if needed
19 */
Jeroen Hofsteeb735e8c2014-06-26 20:18:31 +020020__weak void show_boot_progress(int val) {}
Heiko Schocher8a8ec532007-07-13 09:54:17 +020021
Simon Glass9f6bb182014-04-10 20:01:33 -060022static void modem_init(void)
Simon Glassde6f0c42013-05-15 06:23:56 +000023{
Simon Glassde6f0c42013-05-15 06:23:56 +000024#ifdef CONFIG_MODEM_SUPPORT
Simon Glasse3a762c2014-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 Glass36b590c2014-04-10 20:01:36 -060027 char *str = getenv("mdm_cmd");
28
Simon Glassde6f0c42013-05-15 06:23:56 +000029 setenv("preboot", str); /* set or delete definition */
Simon Glassde6f0c42013-05-15 06:23:56 +000030 mdm_init(); /* wait for modem connection */
31 }
32#endif /* CONFIG_MODEM_SUPPORT */
Simon Glass9f6bb182014-04-10 20:01:33 -060033}
Simon Glassde6f0c42013-05-15 06:23:56 +000034
Simon Glass9f6bb182014-04-10 20:01:33 -060035static void run_preboot_environment_command(void)
36{
Simon Glassde6f0c42013-05-15 06:23:56 +000037#ifdef CONFIG_PREBOOT
Simon Glass9f6bb182014-04-10 20:01:33 -060038 char *p;
39
Simon Glassde6f0c42013-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 Glass9f6bb182014-04-10 20:01:33 -060053}
54
Simon Glass5b47e302014-04-10 20:01:35 -060055/* We come here after U-Boot is initialised and ready to process commands */
Simon Glass9f6bb182014-04-10 20:01:33 -060056void main_loop(void)
57{
Simon Glass5b47e302014-04-10 20:01:35 -060058 const char *s;
59
Simon Glass9f6bb182014-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 Glass33f79132014-04-10 20:01:34 -060073 cli_init();
Simon Glass9f6bb182014-04-10 20:01:33 -060074
75 run_preboot_environment_command();
Simon Glassde6f0c42013-05-15 06:23:56 +000076
77#if defined(CONFIG_UPDATE_TFTP)
78 update_tftp(0UL);
79#endif /* CONFIG_UPDATE_TFTP */
80
Simon Glass5b47e302014-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 Glass33f79132014-04-10 20:01:34 -060086
Simon Glass66b8c8b2014-04-10 20:01:26 -060087 cli_loop();
wdenkc6097192002-11-03 00:24:07 +000088}