Blame view

common/main.c 1.3 KB
83d290c56   Tom Rini   SPDX: Convert all...
1
  // SPDX-License-Identifier: GPL-2.0+
c609719b8   wdenk   Initial revision
2
3
4
  /*
   * (C) Copyright 2000
   * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
c609719b8   wdenk   Initial revision
5
   */
a6c7ad2f6   wdenk   * Fix startup pro...
6
  /* #define	DEBUG	*/
c609719b8   wdenk   Initial revision
7
  #include <common.h>
66ded17df   Simon Glass   Move autoboot cod...
8
  #include <autoboot.h>
18d66533a   Simon Glass   move CLI prototyp...
9
  #include <cli.h>
24b852a7a   Simon Glass   Move console defi...
10
  #include <console.h>
fbcdf32af   Simon Glass   main: Correct hea...
11
  #include <version.h>
bdccc4fed   wdenk   * Map ISP1362 USB...
12

fad634071   Heiko Schocher   make show_boot_pr...
13
14
15
  /*
   * Board-specific Platform code can reimplement show_boot_progress () if needed
   */
3422299dc   Jeroen Hofstee   common: main.c: m...
16
  __weak void show_boot_progress(int val) {}
fad634071   Heiko Schocher   make show_boot_pr...
17

1364a0e48   Simon Glass   Simplify the main...
18
19
  static void run_preboot_environment_command(void)
  {
bc2b4c27d   Simon Glass   main: Move boot_d...
20
  #ifdef CONFIG_PREBOOT
1364a0e48   Simon Glass   Simplify the main...
21
  	char *p;
00caae6d4   Simon Glass   env: Rename geten...
22
  	p = env_get("preboot");
bc2b4c27d   Simon Glass   main: Move boot_d...
23
  	if (p != NULL) {
2cb132ad2   Simon Glass   main: Drop more #...
24
25
26
27
  		int prev = 0;
  
  		if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED))
  			prev = disable_ctrlc(1); /* disable Ctrl-C checking */
bc2b4c27d   Simon Glass   main: Move boot_d...
28
29
  
  		run_command_list(p, -1, 0);
2cb132ad2   Simon Glass   main: Drop more #...
30
31
  		if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED))
  			disable_ctrlc(prev);	/* restore Ctrl-C checking */
bc2b4c27d   Simon Glass   main: Move boot_d...
32
33
  	}
  #endif /* CONFIG_PREBOOT */
1364a0e48   Simon Glass   Simplify the main...
34
  }
affb21562   Simon Glass   main: Make the ex...
35
  /* We come here after U-Boot is initialised and ready to process commands */
1364a0e48   Simon Glass   Simplify the main...
36
37
  void main_loop(void)
  {
affb21562   Simon Glass   main: Make the ex...
38
  	const char *s;
1364a0e48   Simon Glass   Simplify the main...
39
  	bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
2cb132ad2   Simon Glass   main: Drop more #...
40
41
  	if (IS_ENABLED(CONFIG_VERSION_VARIABLE))
  		env_set("ver", version_string);  /* set version variable */
1364a0e48   Simon Glass   Simplify the main...
42

c1bb2cd0b   Simon Glass   main: Hide the hu...
43
  	cli_init();
1364a0e48   Simon Glass   Simplify the main...
44
45
  
  	run_preboot_environment_command();
bc2b4c27d   Simon Glass   main: Move boot_d...
46

2cb132ad2   Simon Glass   main: Drop more #...
47
48
  	if (IS_ENABLED(CONFIG_UPDATE_TFTP))
  		update_tftp(0UL, NULL, NULL);
bc2b4c27d   Simon Glass   main: Move boot_d...
49

affb21562   Simon Glass   main: Make the ex...
50
51
52
53
54
  	s = bootdelay_process();
  	if (cli_process_fdt(&s))
  		cli_secure_boot_cmd(s);
  
  	autoboot_command(s);
c1bb2cd0b   Simon Glass   main: Hide the hu...
55

6493ccc7c   Simon Glass   Split out simple ...
56
  	cli_loop();
045e6f0d4   Simon Glass   Panic when no com...
57
  	panic("No CLI available");
c609719b8   wdenk   Initial revision
58
  }