blob: e3e9f8487165136257a8d59ab95b6531e23a53fe [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 Glasseca86fa2014-04-10 20:01:24 -060013#include <cli_hush.h>
Simon Glassfbcdf322013-05-15 06:23:59 +000014#include <malloc.h>
Simon Glassfbcdf322013-05-15 06:23:59 +000015#include <version.h>
wdenkbdccc4f2003-08-05 17:43:17 +000016
Simon Glass9272a9b2014-04-10 20:01:32 -060017DECLARE_GLOBAL_DATA_PTR;
18
Heiko Schocherfad63402007-07-13 09:54:17 +020019/*
20 * Board-specific Platform code can reimplement show_boot_progress () if needed
21 */
22void inline __show_boot_progress (int val) {}
Emil Medve5e2c08c2009-05-12 13:48:32 -050023void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress")));
Heiko Schocherfad63402007-07-13 09:54:17 +020024
Simon Glassbc2b4c22013-05-15 06:23:56 +000025void main_loop(void)
26{
Simon Glassbc2b4c22013-05-15 06:23:56 +000027#ifdef CONFIG_PREBOOT
28 char *p;
29#endif
30
31 bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
32
Simon Glass0f605c12014-03-22 17:14:51 -060033#ifndef CONFIG_SYS_GENERIC_BOARD
34 puts("Warning: Your board does not use generic board. Please read\n");
35 puts("doc/README.generic-board and take action. Boards not\n");
36 puts("upgraded by the late 2014 may break or be removed.\n");
37#endif
38
Simon Glassbc2b4c22013-05-15 06:23:56 +000039#ifdef CONFIG_MODEM_SUPPORT
Simon Glass9272a9b2014-04-10 20:01:32 -060040 debug("DEBUG: main_loop: gd->do_mdm_init=%lu\n", gd->do_mdm_init);
41 if (gd->do_mdm_init) {
Simon Glassbc2b4c22013-05-15 06:23:56 +000042 char *str = strdup(getenv("mdm_cmd"));
43 setenv("preboot", str); /* set or delete definition */
44 if (str != NULL)
45 free(str);
46 mdm_init(); /* wait for modem connection */
47 }
48#endif /* CONFIG_MODEM_SUPPORT */
49
50#ifdef CONFIG_VERSION_VARIABLE
51 {
52 setenv("ver", version_string); /* set version variable */
53 }
54#endif /* CONFIG_VERSION_VARIABLE */
55
56#ifdef CONFIG_SYS_HUSH_PARSER
57 u_boot_hush_start();
58#endif
59
60#if defined(CONFIG_HUSH_INIT_VAR)
61 hush_init_var();
62#endif
63
64#ifdef CONFIG_PREBOOT
65 p = getenv("preboot");
66 if (p != NULL) {
67# ifdef CONFIG_AUTOBOOT_KEYED
68 int prev = disable_ctrlc(1); /* disable Control C checking */
69# endif
70
71 run_command_list(p, -1, 0);
72
73# ifdef CONFIG_AUTOBOOT_KEYED
74 disable_ctrlc(prev); /* restore Control C checking */
75# endif
76 }
77#endif /* CONFIG_PREBOOT */
78
79#if defined(CONFIG_UPDATE_TFTP)
80 update_tftp(0UL);
81#endif /* CONFIG_UPDATE_TFTP */
82
Simon Glass66ded172014-04-10 20:01:28 -060083 bootdelay_process();
wdenkc6097192002-11-03 00:24:07 +000084 /*
85 * Main Loop for Monitor Command Processing
86 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020087#ifdef CONFIG_SYS_HUSH_PARSER
wdenkc6097192002-11-03 00:24:07 +000088 parse_file_outer();
89 /* This point is never reached */
90 for (;;);
91#else
Simon Glass6493ccc2014-04-10 20:01:26 -060092 cli_loop();
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020093#endif /*CONFIG_SYS_HUSH_PARSER*/
wdenkc6097192002-11-03 00:24:07 +000094}