Blame view

cmd/bootz.c 2.91 KB
5db28905c   Tom Rini   cmd: Split 'bootz...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
  /*
   * (C) Copyright 2000-2009
   * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
   *
   * SPDX-License-Identifier:	GPL-2.0+
   */
  
  #include <common.h>
  #include <bootm.h>
  #include <command.h>
  #include <lmb.h>
  #include <linux/compiler.h>
  
  int __weak bootz_setup(ulong image, ulong *start, ulong *end)
  {
  	/* Please define bootz_setup() for your platform */
  
  	puts("Your platform's zImage format isn't supported yet!
  ");
  	return -1;
  }
  
  /*
   * zImage booting support
   */
  static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
  			char * const argv[], bootm_headers_t *images)
  {
  	int ret;
  	ulong zi_start, zi_end;
  
  	ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START,
  			      images, 1);
  
  	/* Setup Linux kernel zImage entry point */
  	if (!argc) {
  		images->ep = load_addr;
  		debug("*  kernel: default image load address = 0x%08lx
  ",
  				load_addr);
  	} else {
  		images->ep = simple_strtoul(argv[0], NULL, 16);
  		debug("*  kernel: cmdline image address = 0x%08lx
  ",
  			images->ep);
  	}
  
  	ret = bootz_setup(images->ep, &zi_start, &zi_end);
  	if (ret != 0)
  		return 1;
  
  	lmb_reserve(&images->lmb, images->ep, zi_end - zi_start);
  
  	/*
  	 * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
  	 * have a header that provide this informaiton.
  	 */
  	if (bootm_find_images(flag, argc, argv))
  		return 1;
98d4faefd   Ye Li   MLK-12500-1 HAB: ...
60
61
62
63
64
65
66
67
68
  #ifdef CONFIG_SECURE_BOOT
  	extern int authenticate_image(
  			uint32_t ddr_start, uint32_t raw_image_size);
  	if (authenticate_image(images->ep, zi_end - zi_start) != 0) {
  		printf("Authenticate zImage Fail, Please check
  ");
  		return 1;
  	}
  #endif
5db28905c   Tom Rini   cmd: Split 'bootz...
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
  	return 0;
  }
  
  int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  {
  	int ret;
  
  	/* Consume 'bootz' */
  	argc--; argv++;
  
  	if (bootz_start(cmdtp, flag, argc, argv, &images))
  		return 1;
  
  	/*
  	 * We are doing the BOOTM_STATE_LOADOS state ourselves, so must
  	 * disable interrupts ourselves
  	 */
  	bootm_disable_interrupts();
  
  	images.os.os = IH_OS_LINUX;
  	ret = do_bootm_states(cmdtp, flag, argc, argv,
4943dc2f1   Cédric Schieli   bootz/booti: relo...
90
91
92
  #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
  			      BOOTM_STATE_RAMDISK |
  #endif
5db28905c   Tom Rini   cmd: Split 'bootz...
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
  			      BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
  			      BOOTM_STATE_OS_GO,
  			      &images, 1);
  
  	return ret;
  }
  
  #ifdef CONFIG_SYS_LONGHELP
  static char bootz_help_text[] =
  	"[addr [initrd[:size]] [fdt]]
  "
  	"    - boot Linux zImage stored in memory
  "
  	"\tThe argument 'initrd' is optional and specifies the address
  "
  	"\tof the initrd in memory. The optional argument ':size' allows
  "
  	"\tspecifying the size of RAW initrd.
  "
  #if defined(CONFIG_OF_LIBFDT)
  	"\tWhen booting a Linux kernel which requires a flat device-tree
  "
  	"\ta third argument is required which is the address of the
  "
  	"\tdevice-tree blob. To boot that kernel without an initrd image,
  "
  	"\tuse a '-' for the second argument. If you do not pass a third
  "
  	"\ta bd_info struct will be passed instead
  "
  #endif
  	"";
  #endif
  
  U_BOOT_CMD(
  	bootz,	CONFIG_SYS_MAXARGS,	1,	do_bootz,
  	"boot Linux zImage image from memory", bootz_help_text
  );