blob: b4cf289dc5dfcae2c72c1c86848b981ce9b1d879 [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 Glass299f0be2014-04-10 20:01:24 -060013#include <cli_hush.h>
Simon Glassb2b687f2013-05-15 06:23:59 +000014#include <malloc.h>
Simon Glassb2b687f2013-05-15 06:23:59 +000015#include <version.h>
wdenk0a658552003-08-05 17:43:17 +000016
Simon Glasse3a762c2014-04-10 20:01:32 -060017DECLARE_GLOBAL_DATA_PTR;
18
Heiko Schocher8a8ec532007-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 Medveace7cc82009-05-12 13:48:32 -050023void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress")));
Heiko Schocher8a8ec532007-07-13 09:54:17 +020024
Simon Glass9f6bb182014-04-10 20:01:33 -060025static void modem_init(void)
Simon Glassde6f0c42013-05-15 06:23:56 +000026{
Simon Glassde6f0c42013-05-15 06:23:56 +000027#ifdef CONFIG_MODEM_SUPPORT
Simon Glasse3a762c2014-04-10 20:01:32 -060028 debug("DEBUG: main_loop: gd->do_mdm_init=%lu\n", gd->do_mdm_init);
29 if (gd->do_mdm_init) {
Simon Glassde6f0c42013-05-15 06:23:56 +000030 char *str = strdup(getenv("mdm_cmd"));
31 setenv("preboot", str); /* set or delete definition */
32 if (str != NULL)
33 free(str);
34 mdm_init(); /* wait for modem connection */
35 }
36#endif /* CONFIG_MODEM_SUPPORT */
Simon Glass9f6bb182014-04-10 20:01:33 -060037}
Simon Glassde6f0c42013-05-15 06:23:56 +000038
Simon Glass9f6bb182014-04-10 20:01:33 -060039static void run_preboot_environment_command(void)
40{
Simon Glassde6f0c42013-05-15 06:23:56 +000041#ifdef CONFIG_PREBOOT
Simon Glass9f6bb182014-04-10 20:01:33 -060042 char *p;
43
Simon Glassde6f0c42013-05-15 06:23:56 +000044 p = getenv("preboot");
45 if (p != NULL) {
46# ifdef CONFIG_AUTOBOOT_KEYED
47 int prev = disable_ctrlc(1); /* disable Control C checking */
48# endif
49
50 run_command_list(p, -1, 0);
51
52# ifdef CONFIG_AUTOBOOT_KEYED
53 disable_ctrlc(prev); /* restore Control C checking */
54# endif
55 }
56#endif /* CONFIG_PREBOOT */
Simon Glass9f6bb182014-04-10 20:01:33 -060057}
58
59void main_loop(void)
60{
61 bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
62
63#ifndef CONFIG_SYS_GENERIC_BOARD
64 puts("Warning: Your board does not use generic board. Please read\n");
65 puts("doc/README.generic-board and take action. Boards not\n");
66 puts("upgraded by the late 2014 may break or be removed.\n");
67#endif
68
69 modem_init();
70#ifdef CONFIG_VERSION_VARIABLE
71 setenv("ver", version_string); /* set version variable */
72#endif /* CONFIG_VERSION_VARIABLE */
73
74#ifdef CONFIG_SYS_HUSH_PARSER
75 u_boot_hush_start();
76#endif
77
78#if defined(CONFIG_HUSH_INIT_VAR)
79 hush_init_var();
80#endif
81
82 run_preboot_environment_command();
Simon Glassde6f0c42013-05-15 06:23:56 +000083
84#if defined(CONFIG_UPDATE_TFTP)
85 update_tftp(0UL);
86#endif /* CONFIG_UPDATE_TFTP */
87
Simon Glass7b6a95a2014-04-10 20:01:28 -060088 bootdelay_process();
wdenkc6097192002-11-03 00:24:07 +000089 /*
90 * Main Loop for Monitor Command Processing
91 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020092#ifdef CONFIG_SYS_HUSH_PARSER
wdenkc6097192002-11-03 00:24:07 +000093 parse_file_outer();
94 /* This point is never reached */
95 for (;;);
96#else
Simon Glass66b8c8b2014-04-10 20:01:26 -060097 cli_loop();
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020098#endif /*CONFIG_SYS_HUSH_PARSER*/
wdenkc6097192002-11-03 00:24:07 +000099}