]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - common/main.c
Move command line API into cli.c
[karo-tx-uboot.git] / common / main.c
1 /*
2  * (C) Copyright 2000
3  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 /* #define      DEBUG   */
9
10 #include <common.h>
11 #include <autoboot.h>
12 #include <cli.h>
13 #include <cli_hush.h>
14 #include <malloc.h>
15 #include <version.h>
16
17 /*
18  * Board-specific Platform code can reimplement show_boot_progress () if needed
19  */
20 void inline __show_boot_progress (int val) {}
21 void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress")));
22
23 #ifdef CONFIG_MODEM_SUPPORT
24 int do_mdm_init = 0;
25 extern void mdm_init(void); /* defined in board.c */
26 #endif
27
28 void main_loop(void)
29 {
30 #ifdef CONFIG_PREBOOT
31         char *p;
32 #endif
33
34         bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
35
36 #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
42 #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
86         bootdelay_process();
87         /*
88          * Main Loop for Monitor Command Processing
89          */
90 #ifdef CONFIG_SYS_HUSH_PARSER
91         parse_file_outer();
92         /* This point is never reached */
93         for (;;);
94 #else
95         cli_loop();
96 #endif /*CONFIG_SYS_HUSH_PARSER*/
97 }