blob: c4ed846c3b249b951e7bde1f0f0e7e49f95a63f0 [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
Heiko Schocherfad63402007-07-13 09:54:17 +020017/*
18 * Board-specific Platform code can reimplement show_boot_progress () if needed
19 */
20void inline __show_boot_progress (int val) {}
Emil Medve5e2c08c2009-05-12 13:48:32 -050021void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress")));
Heiko Schocherfad63402007-07-13 09:54:17 +020022
wdenkc6097192002-11-03 00:24:07 +000023#ifdef CONFIG_MODEM_SUPPORT
24int do_mdm_init = 0;
25extern void mdm_init(void); /* defined in board.c */
26#endif
27
Simon Glassbc2b4c22013-05-15 06:23:56 +000028void main_loop(void)
29{
Simon Glassbc2b4c22013-05-15 06:23:56 +000030#ifdef CONFIG_PREBOOT
31 char *p;
32#endif
33
34 bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
35
Simon Glass0f605c12014-03-22 17:14:51 -060036#ifndef CONFIG_SYS_GENERIC_BOARD
37 puts("Warning: Your board does not use generic board. Please read\n");
38 puts("doc/README.generic-board and take action. Boards not\n");
39 puts("upgraded by the late 2014 may break or be removed.\n");
40#endif
41
Simon Glassbc2b4c22013-05-15 06:23:56 +000042#ifdef CONFIG_MODEM_SUPPORT
43 debug("DEBUG: main_loop: do_mdm_init=%d\n", do_mdm_init);
44 if (do_mdm_init) {
45 char *str = strdup(getenv("mdm_cmd"));
46 setenv("preboot", str); /* set or delete definition */
47 if (str != NULL)
48 free(str);
49 mdm_init(); /* wait for modem connection */
50 }
51#endif /* CONFIG_MODEM_SUPPORT */
52
53#ifdef CONFIG_VERSION_VARIABLE
54 {
55 setenv("ver", version_string); /* set version variable */
56 }
57#endif /* CONFIG_VERSION_VARIABLE */
58
59#ifdef CONFIG_SYS_HUSH_PARSER
60 u_boot_hush_start();
61#endif
62
63#if defined(CONFIG_HUSH_INIT_VAR)
64 hush_init_var();
65#endif
66
67#ifdef CONFIG_PREBOOT
68 p = getenv("preboot");
69 if (p != NULL) {
70# ifdef CONFIG_AUTOBOOT_KEYED
71 int prev = disable_ctrlc(1); /* disable Control C checking */
72# endif
73
74 run_command_list(p, -1, 0);
75
76# ifdef CONFIG_AUTOBOOT_KEYED
77 disable_ctrlc(prev); /* restore Control C checking */
78# endif
79 }
80#endif /* CONFIG_PREBOOT */
81
82#if defined(CONFIG_UPDATE_TFTP)
83 update_tftp(0UL);
84#endif /* CONFIG_UPDATE_TFTP */
85
Simon Glass66ded172014-04-10 20:01:28 -060086 bootdelay_process();
wdenkc6097192002-11-03 00:24:07 +000087 /*
88 * Main Loop for Monitor Command Processing
89 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020090#ifdef CONFIG_SYS_HUSH_PARSER
wdenkc6097192002-11-03 00:24:07 +000091 parse_file_outer();
92 /* This point is never reached */
93 for (;;);
94#else
Simon Glass6493ccc2014-04-10 20:01:26 -060095 cli_loop();
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020096#endif /*CONFIG_SYS_HUSH_PARSER*/
wdenkc6097192002-11-03 00:24:07 +000097}