xref: /rk3399_rockchip-uboot/arch/mips/lib/bootm.c (revision 347ea94e2a954ab70f64a3f43d9b374cf4640f26)
1ea0364f1SPeter Tyser /*
2ea0364f1SPeter Tyser  * (C) Copyright 2003
3ea0364f1SPeter Tyser  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4ea0364f1SPeter Tyser  *
51a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
6ea0364f1SPeter Tyser  */
7ea0364f1SPeter Tyser 
8ea0364f1SPeter Tyser #include <common.h>
9ea0364f1SPeter Tyser #include <image.h>
105002d8ccSDaniel Schwierzeck #include <fdt_support.h>
11ea0364f1SPeter Tyser #include <asm/addrspace.h>
12ea0364f1SPeter Tyser 
13ea0364f1SPeter Tyser DECLARE_GLOBAL_DATA_PTR;
14ea0364f1SPeter Tyser 
15ea0364f1SPeter Tyser #define	LINUX_MAX_ENVS		256
16ea0364f1SPeter Tyser #define	LINUX_MAX_ARGS		256
17ea0364f1SPeter Tyser 
18ea0364f1SPeter Tyser static int linux_argc;
19ea0364f1SPeter Tyser static char **linux_argv;
2059e8cbdbSDaniel Schwierzeck static char *linux_argp;
21ea0364f1SPeter Tyser 
22ea0364f1SPeter Tyser static char **linux_env;
23ea0364f1SPeter Tyser static char *linux_env_p;
24ea0364f1SPeter Tyser static int linux_env_idx;
25ea0364f1SPeter Tyser 
26f66cc1e3SDaniel Schwierzeck static ulong arch_get_sp(void)
27f66cc1e3SDaniel Schwierzeck {
28f66cc1e3SDaniel Schwierzeck 	ulong ret;
29f66cc1e3SDaniel Schwierzeck 
30f66cc1e3SDaniel Schwierzeck 	__asm__ __volatile__("move %0, $sp" : "=r"(ret) : );
31f66cc1e3SDaniel Schwierzeck 
32f66cc1e3SDaniel Schwierzeck 	return ret;
33f66cc1e3SDaniel Schwierzeck }
34f66cc1e3SDaniel Schwierzeck 
35f66cc1e3SDaniel Schwierzeck void arch_lmb_reserve(struct lmb *lmb)
36f66cc1e3SDaniel Schwierzeck {
37f66cc1e3SDaniel Schwierzeck 	ulong sp;
38f66cc1e3SDaniel Schwierzeck 
39f66cc1e3SDaniel Schwierzeck 	sp = arch_get_sp();
40f66cc1e3SDaniel Schwierzeck 	debug("## Current stack ends at 0x%08lx\n", sp);
41f66cc1e3SDaniel Schwierzeck 
42f66cc1e3SDaniel Schwierzeck 	/* adjust sp by 4K to be safe */
43f66cc1e3SDaniel Schwierzeck 	sp -= 4096;
44f66cc1e3SDaniel Schwierzeck 	lmb_reserve(lmb, sp, CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp);
45f66cc1e3SDaniel Schwierzeck }
46f66cc1e3SDaniel Schwierzeck 
4759e8cbdbSDaniel Schwierzeck static void linux_cmdline_init(void)
4859e8cbdbSDaniel Schwierzeck {
4959e8cbdbSDaniel Schwierzeck 	linux_argc = 1;
5059e8cbdbSDaniel Schwierzeck 	linux_argv = (char **)UNCACHED_SDRAM(gd->bd->bi_boot_params);
5159e8cbdbSDaniel Schwierzeck 	linux_argv[0] = 0;
5259e8cbdbSDaniel Schwierzeck 	linux_argp = (char *)(linux_argv + LINUX_MAX_ARGS);
5359e8cbdbSDaniel Schwierzeck }
5459e8cbdbSDaniel Schwierzeck 
5559e8cbdbSDaniel Schwierzeck static void linux_cmdline_set(const char *value, size_t len)
5659e8cbdbSDaniel Schwierzeck {
5759e8cbdbSDaniel Schwierzeck 	linux_argv[linux_argc] = linux_argp;
5859e8cbdbSDaniel Schwierzeck 	memcpy(linux_argp, value, len);
5959e8cbdbSDaniel Schwierzeck 	linux_argp[len] = 0;
6059e8cbdbSDaniel Schwierzeck 
6159e8cbdbSDaniel Schwierzeck 	linux_argp += len + 1;
6259e8cbdbSDaniel Schwierzeck 	linux_argc++;
6359e8cbdbSDaniel Schwierzeck }
6459e8cbdbSDaniel Schwierzeck 
6559e8cbdbSDaniel Schwierzeck static void linux_cmdline_dump(void)
6659e8cbdbSDaniel Schwierzeck {
6759e8cbdbSDaniel Schwierzeck 	int i;
6859e8cbdbSDaniel Schwierzeck 
6959e8cbdbSDaniel Schwierzeck 	debug("## cmdline argv at 0x%p, argp at 0x%p\n",
7059e8cbdbSDaniel Schwierzeck 	      linux_argv, linux_argp);
7159e8cbdbSDaniel Schwierzeck 
7259e8cbdbSDaniel Schwierzeck 	for (i = 1; i < linux_argc; i++)
7359e8cbdbSDaniel Schwierzeck 		debug("   arg %03d: %s\n", i, linux_argv[i]);
7459e8cbdbSDaniel Schwierzeck }
7559e8cbdbSDaniel Schwierzeck 
7625fc664fSDaniel Schwierzeck static void linux_cmdline_legacy(bootm_headers_t *images)
7759e8cbdbSDaniel Schwierzeck {
7859e8cbdbSDaniel Schwierzeck 	const char *bootargs, *next, *quote;
7959e8cbdbSDaniel Schwierzeck 
8059e8cbdbSDaniel Schwierzeck 	linux_cmdline_init();
8159e8cbdbSDaniel Schwierzeck 
8259e8cbdbSDaniel Schwierzeck 	bootargs = getenv("bootargs");
8359e8cbdbSDaniel Schwierzeck 	if (!bootargs)
8459e8cbdbSDaniel Schwierzeck 		return;
8559e8cbdbSDaniel Schwierzeck 
8659e8cbdbSDaniel Schwierzeck 	next = bootargs;
8759e8cbdbSDaniel Schwierzeck 
8859e8cbdbSDaniel Schwierzeck 	while (bootargs && *bootargs && linux_argc < LINUX_MAX_ARGS) {
8959e8cbdbSDaniel Schwierzeck 		quote = strchr(bootargs, '"');
9059e8cbdbSDaniel Schwierzeck 		next = strchr(bootargs, ' ');
9159e8cbdbSDaniel Schwierzeck 
9259e8cbdbSDaniel Schwierzeck 		while (next && quote && quote < next) {
9359e8cbdbSDaniel Schwierzeck 			/*
9459e8cbdbSDaniel Schwierzeck 			 * we found a left quote before the next blank
9559e8cbdbSDaniel Schwierzeck 			 * now we have to find the matching right quote
9659e8cbdbSDaniel Schwierzeck 			 */
9759e8cbdbSDaniel Schwierzeck 			next = strchr(quote + 1, '"');
9859e8cbdbSDaniel Schwierzeck 			if (next) {
9959e8cbdbSDaniel Schwierzeck 				quote = strchr(next + 1, '"');
10059e8cbdbSDaniel Schwierzeck 				next = strchr(next + 1, ' ');
10159e8cbdbSDaniel Schwierzeck 			}
10259e8cbdbSDaniel Schwierzeck 		}
10359e8cbdbSDaniel Schwierzeck 
10459e8cbdbSDaniel Schwierzeck 		if (!next)
10559e8cbdbSDaniel Schwierzeck 			next = bootargs + strlen(bootargs);
10659e8cbdbSDaniel Schwierzeck 
10759e8cbdbSDaniel Schwierzeck 		linux_cmdline_set(bootargs, next - bootargs);
10859e8cbdbSDaniel Schwierzeck 
10959e8cbdbSDaniel Schwierzeck 		if (*next)
11059e8cbdbSDaniel Schwierzeck 			next++;
11159e8cbdbSDaniel Schwierzeck 
11259e8cbdbSDaniel Schwierzeck 		bootargs = next;
11359e8cbdbSDaniel Schwierzeck 	}
11425fc664fSDaniel Schwierzeck }
11559e8cbdbSDaniel Schwierzeck 
1168cec725aSDaniel Schwierzeck static void linux_cmdline_append(bootm_headers_t *images)
1178cec725aSDaniel Schwierzeck {
1188cec725aSDaniel Schwierzeck 	char buf[24];
1198cec725aSDaniel Schwierzeck 	ulong mem, rd_start, rd_size;
1208cec725aSDaniel Schwierzeck 
1218cec725aSDaniel Schwierzeck 	/* append mem */
1228cec725aSDaniel Schwierzeck 	mem = gd->ram_size >> 20;
1238cec725aSDaniel Schwierzeck 	sprintf(buf, "mem=%luM", mem);
1248cec725aSDaniel Schwierzeck 	linux_cmdline_set(buf, strlen(buf));
1258cec725aSDaniel Schwierzeck 
1268cec725aSDaniel Schwierzeck 	/* append rd_start and rd_size */
1278cec725aSDaniel Schwierzeck 	rd_start = images->initrd_start;
1288cec725aSDaniel Schwierzeck 	rd_size = images->initrd_end - images->initrd_start;
1298cec725aSDaniel Schwierzeck 
1308cec725aSDaniel Schwierzeck 	if (rd_size) {
1318cec725aSDaniel Schwierzeck 		sprintf(buf, "rd_start=0x%08lX", rd_start);
1328cec725aSDaniel Schwierzeck 		linux_cmdline_set(buf, strlen(buf));
1338cec725aSDaniel Schwierzeck 		sprintf(buf, "rd_size=0x%lX", rd_size);
1348cec725aSDaniel Schwierzeck 		linux_cmdline_set(buf, strlen(buf));
1358cec725aSDaniel Schwierzeck 	}
1368cec725aSDaniel Schwierzeck }
1378cec725aSDaniel Schwierzeck 
13815f8aa90SDaniel Schwierzeck static void linux_env_init(void)
13915f8aa90SDaniel Schwierzeck {
14015f8aa90SDaniel Schwierzeck 	linux_env = (char **)(((ulong) linux_argp + 15) & ~15);
14115f8aa90SDaniel Schwierzeck 	linux_env[0] = 0;
14215f8aa90SDaniel Schwierzeck 	linux_env_p = (char *)(linux_env + LINUX_MAX_ENVS);
14315f8aa90SDaniel Schwierzeck 	linux_env_idx = 0;
14415f8aa90SDaniel Schwierzeck }
14515f8aa90SDaniel Schwierzeck 
14615f8aa90SDaniel Schwierzeck static void linux_env_set(const char *env_name, const char *env_val)
14715f8aa90SDaniel Schwierzeck {
14815f8aa90SDaniel Schwierzeck 	if (linux_env_idx < LINUX_MAX_ENVS - 1) {
14915f8aa90SDaniel Schwierzeck 		linux_env[linux_env_idx] = linux_env_p;
15015f8aa90SDaniel Schwierzeck 
15115f8aa90SDaniel Schwierzeck 		strcpy(linux_env_p, env_name);
15215f8aa90SDaniel Schwierzeck 		linux_env_p += strlen(env_name);
15315f8aa90SDaniel Schwierzeck 
154*347ea94eSDaniel Schwierzeck 		if (CONFIG_IS_ENABLED(MALTA)) {
155b87493f4SDaniel Schwierzeck 			linux_env_p++;
156b87493f4SDaniel Schwierzeck 			linux_env[++linux_env_idx] = linux_env_p;
157b87493f4SDaniel Schwierzeck 		} else {
15815f8aa90SDaniel Schwierzeck 			*linux_env_p++ = '=';
159b87493f4SDaniel Schwierzeck 		}
16015f8aa90SDaniel Schwierzeck 
16115f8aa90SDaniel Schwierzeck 		strcpy(linux_env_p, env_val);
16215f8aa90SDaniel Schwierzeck 		linux_env_p += strlen(env_val);
16315f8aa90SDaniel Schwierzeck 
16415f8aa90SDaniel Schwierzeck 		linux_env_p++;
16515f8aa90SDaniel Schwierzeck 		linux_env[++linux_env_idx] = 0;
16615f8aa90SDaniel Schwierzeck 	}
16715f8aa90SDaniel Schwierzeck }
16815f8aa90SDaniel Schwierzeck 
169ca65e585SDaniel Schwierzeck static void linux_env_legacy(bootm_headers_t *images)
170ea0364f1SPeter Tyser {
171ea0364f1SPeter Tyser 	char env_buf[12];
17215f8aa90SDaniel Schwierzeck 	const char *cp;
1736c154552SDaniel Schwierzeck 	ulong rd_start, rd_size;
174ea0364f1SPeter Tyser 
175*347ea94eSDaniel Schwierzeck 	if (CONFIG_IS_ENABLED(MEMSIZE_IN_BYTES)) {
176ea0364f1SPeter Tyser 		sprintf(env_buf, "%lu", (ulong)gd->ram_size);
177*347ea94eSDaniel Schwierzeck 		debug("## Giving linux memsize in bytes, %lu\n",
178*347ea94eSDaniel Schwierzeck 		      (ulong)gd->ram_size);
179*347ea94eSDaniel Schwierzeck 	} else {
180ea0364f1SPeter Tyser 		sprintf(env_buf, "%lu", (ulong)(gd->ram_size >> 20));
181e51a6b7aSDaniel Schwierzeck 		debug("## Giving linux memsize in MB, %lu\n",
182e51a6b7aSDaniel Schwierzeck 		      (ulong)(gd->ram_size >> 20));
183*347ea94eSDaniel Schwierzeck 	}
184ea0364f1SPeter Tyser 
1856c154552SDaniel Schwierzeck 	rd_start = UNCACHED_SDRAM(images->initrd_start);
1866c154552SDaniel Schwierzeck 	rd_size = images->initrd_end - images->initrd_start;
1876c154552SDaniel Schwierzeck 
18815f8aa90SDaniel Schwierzeck 	linux_env_init();
18915f8aa90SDaniel Schwierzeck 
190ea0364f1SPeter Tyser 	linux_env_set("memsize", env_buf);
191ea0364f1SPeter Tyser 
1926c154552SDaniel Schwierzeck 	sprintf(env_buf, "0x%08lX", rd_start);
193ea0364f1SPeter Tyser 	linux_env_set("initrd_start", env_buf);
194ea0364f1SPeter Tyser 
1956c154552SDaniel Schwierzeck 	sprintf(env_buf, "0x%lX", rd_size);
196ea0364f1SPeter Tyser 	linux_env_set("initrd_size", env_buf);
197ea0364f1SPeter Tyser 
198ea0364f1SPeter Tyser 	sprintf(env_buf, "0x%08X", (uint) (gd->bd->bi_flashstart));
199ea0364f1SPeter Tyser 	linux_env_set("flash_start", env_buf);
200ea0364f1SPeter Tyser 
201ea0364f1SPeter Tyser 	sprintf(env_buf, "0x%X", (uint) (gd->bd->bi_flashsize));
202ea0364f1SPeter Tyser 	linux_env_set("flash_size", env_buf);
203ea0364f1SPeter Tyser 
204ea0364f1SPeter Tyser 	cp = getenv("ethaddr");
205e51a6b7aSDaniel Schwierzeck 	if (cp)
206ea0364f1SPeter Tyser 		linux_env_set("ethaddr", cp);
207ea0364f1SPeter Tyser 
208ea0364f1SPeter Tyser 	cp = getenv("eth1addr");
209e51a6b7aSDaniel Schwierzeck 	if (cp)
210ea0364f1SPeter Tyser 		linux_env_set("eth1addr", cp);
211b87493f4SDaniel Schwierzeck 
212*347ea94eSDaniel Schwierzeck 	if (CONFIG_IS_ENABLED(MALTA)) {
213d18d49d7SPaul Burton 		sprintf(env_buf, "%un8r", gd->baudrate);
214d18d49d7SPaul Burton 		linux_env_set("modetty0", env_buf);
215d18d49d7SPaul Burton 	}
2160ea7213fSGabor Juhos }
217ea0364f1SPeter Tyser 
2182bb5b638SDaniel Schwierzeck static int boot_reloc_ramdisk(bootm_headers_t *images)
2192bb5b638SDaniel Schwierzeck {
2202bb5b638SDaniel Schwierzeck 	ulong rd_len = images->rd_end - images->rd_start;
2212bb5b638SDaniel Schwierzeck 
2222bb5b638SDaniel Schwierzeck 	/*
2232bb5b638SDaniel Schwierzeck 	 * In case of legacy uImage's, relocation of ramdisk is already done
2242bb5b638SDaniel Schwierzeck 	 * by do_bootm_states() and should not repeated in 'bootm prep'.
2252bb5b638SDaniel Schwierzeck 	 */
2262bb5b638SDaniel Schwierzeck 	if (images->state & BOOTM_STATE_RAMDISK) {
2272bb5b638SDaniel Schwierzeck 		debug("## Ramdisk already relocated\n");
2282bb5b638SDaniel Schwierzeck 		return 0;
2292bb5b638SDaniel Schwierzeck 	}
2302bb5b638SDaniel Schwierzeck 
2312bb5b638SDaniel Schwierzeck 	return boot_ramdisk_high(&images->lmb, images->rd_start,
2322bb5b638SDaniel Schwierzeck 		rd_len, &images->initrd_start, &images->initrd_end);
2332bb5b638SDaniel Schwierzeck }
2342bb5b638SDaniel Schwierzeck 
2352bb5b638SDaniel Schwierzeck static int boot_reloc_fdt(bootm_headers_t *images)
2362bb5b638SDaniel Schwierzeck {
2372bb5b638SDaniel Schwierzeck 	/*
2382bb5b638SDaniel Schwierzeck 	 * In case of legacy uImage's, relocation of FDT is already done
2392bb5b638SDaniel Schwierzeck 	 * by do_bootm_states() and should not repeated in 'bootm prep'.
2402bb5b638SDaniel Schwierzeck 	 */
2412bb5b638SDaniel Schwierzeck 	if (images->state & BOOTM_STATE_FDT) {
2422bb5b638SDaniel Schwierzeck 		debug("## FDT already relocated\n");
2432bb5b638SDaniel Schwierzeck 		return 0;
2442bb5b638SDaniel Schwierzeck 	}
2452bb5b638SDaniel Schwierzeck 
2462bb5b638SDaniel Schwierzeck #if CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && CONFIG_IS_ENABLED(OF_LIBFDT)
2472bb5b638SDaniel Schwierzeck 	boot_fdt_add_mem_rsv_regions(&images->lmb, images->ft_addr);
2482bb5b638SDaniel Schwierzeck 	return boot_relocate_fdt(&images->lmb, &images->ft_addr,
2492bb5b638SDaniel Schwierzeck 		&images->ft_len);
2502bb5b638SDaniel Schwierzeck #else
2512bb5b638SDaniel Schwierzeck 	return 0;
2522bb5b638SDaniel Schwierzeck #endif
2532bb5b638SDaniel Schwierzeck }
2542bb5b638SDaniel Schwierzeck 
2552bb5b638SDaniel Schwierzeck int arch_fixup_memory_node(void *blob)
2562bb5b638SDaniel Schwierzeck {
2572bb5b638SDaniel Schwierzeck #if CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && CONFIG_IS_ENABLED(OF_LIBFDT)
2582bb5b638SDaniel Schwierzeck 	u64 mem_start = 0;
2592bb5b638SDaniel Schwierzeck 	u64 mem_size = gd->ram_size;
2602bb5b638SDaniel Schwierzeck 
2612bb5b638SDaniel Schwierzeck 	return fdt_fixup_memory_banks(blob, &mem_start, &mem_size, 1);
2622bb5b638SDaniel Schwierzeck #else
2632bb5b638SDaniel Schwierzeck 	return 0;
2642bb5b638SDaniel Schwierzeck #endif
2652bb5b638SDaniel Schwierzeck }
2662bb5b638SDaniel Schwierzeck 
2672bb5b638SDaniel Schwierzeck static int boot_setup_fdt(bootm_headers_t *images)
2682bb5b638SDaniel Schwierzeck {
2692bb5b638SDaniel Schwierzeck 	return image_setup_libfdt(images, images->ft_addr, images->ft_len,
2702bb5b638SDaniel Schwierzeck 		&images->lmb);
2712bb5b638SDaniel Schwierzeck }
2722bb5b638SDaniel Schwierzeck 
273ca65e585SDaniel Schwierzeck static void boot_prep_linux(bootm_headers_t *images)
274ca65e585SDaniel Schwierzeck {
2752bb5b638SDaniel Schwierzeck 	boot_reloc_ramdisk(images);
2762bb5b638SDaniel Schwierzeck 
2772bb5b638SDaniel Schwierzeck 	if (CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && images->ft_len) {
2782bb5b638SDaniel Schwierzeck 		boot_reloc_fdt(images);
2792bb5b638SDaniel Schwierzeck 		boot_setup_fdt(images);
2802bb5b638SDaniel Schwierzeck 	} else {
2812bb5b638SDaniel Schwierzeck 		if (CONFIG_IS_ENABLED(CONFIG_MIPS_BOOT_ENV_LEGACY))
282ca65e585SDaniel Schwierzeck 			linux_env_legacy(images);
2835002d8ccSDaniel Schwierzeck 
2842bb5b638SDaniel Schwierzeck 		if (CONFIG_IS_ENABLED(MIPS_BOOT_CMDLINE_LEGACY)) {
2852bb5b638SDaniel Schwierzeck 			linux_cmdline_legacy(images);
2862bb5b638SDaniel Schwierzeck 
2872bb5b638SDaniel Schwierzeck 			if (!CONFIG_IS_ENABLED(CONFIG_MIPS_BOOT_ENV_LEGACY))
2882bb5b638SDaniel Schwierzeck 				linux_cmdline_append(images);
2892bb5b638SDaniel Schwierzeck 
2902bb5b638SDaniel Schwierzeck 			linux_cmdline_dump();
2912bb5b638SDaniel Schwierzeck 		}
2922bb5b638SDaniel Schwierzeck 	}
293ca65e585SDaniel Schwierzeck }
294ca65e585SDaniel Schwierzeck 
2950ea7213fSGabor Juhos static void boot_jump_linux(bootm_headers_t *images)
2960ea7213fSGabor Juhos {
297c4b37847SDaniel Schwierzeck 	typedef void __noreturn (*kernel_entry_t)(int, ulong, ulong, ulong);
298c4b37847SDaniel Schwierzeck 	kernel_entry_t kernel = (kernel_entry_t) images->ep;
299b87493f4SDaniel Schwierzeck 	ulong linux_extra = 0;
3000ea7213fSGabor Juhos 
301c4b37847SDaniel Schwierzeck 	debug("## Transferring control to Linux (at address %p) ...\n", kernel);
3020ea7213fSGabor Juhos 
3030ea7213fSGabor Juhos 	bootstage_mark(BOOTSTAGE_ID_RUN_OS);
3040ea7213fSGabor Juhos 
305*347ea94eSDaniel Schwierzeck 	if (CONFIG_IS_ENABLED(MALTA))
306b87493f4SDaniel Schwierzeck 		linux_extra = gd->ram_size;
307b87493f4SDaniel Schwierzeck 
308*347ea94eSDaniel Schwierzeck #if CONFIG_IS_ENABLED(BOOTSTAGE_FDT)
309e13a50b3SDaniel Schwierzeck 	bootstage_fdt_add_report();
310e13a50b3SDaniel Schwierzeck #endif
311*347ea94eSDaniel Schwierzeck #if CONFIG_IS_ENABLED(BOOTSTAGE_REPORT)
312e13a50b3SDaniel Schwierzeck 	bootstage_report();
313e13a50b3SDaniel Schwierzeck #endif
3140ea7213fSGabor Juhos 
31590b1c9faSDaniel Schwierzeck 	if (images->ft_len)
31690b1c9faSDaniel Schwierzeck 		kernel(-2, (ulong)images->ft_addr, 0, 0);
31790b1c9faSDaniel Schwierzeck 	else
31890b1c9faSDaniel Schwierzeck 		kernel(linux_argc, (ulong)linux_argv, (ulong)linux_env,
31990b1c9faSDaniel Schwierzeck 			linux_extra);
3200ea7213fSGabor Juhos }
3210ea7213fSGabor Juhos 
3220ea7213fSGabor Juhos int do_bootm_linux(int flag, int argc, char * const argv[],
3230ea7213fSGabor Juhos 			bootm_headers_t *images)
3240ea7213fSGabor Juhos {
3259c170e2eSGabor Juhos 	/* No need for those on MIPS */
32659e8cbdbSDaniel Schwierzeck 	if (flag & BOOTM_STATE_OS_BD_T)
3279c170e2eSGabor Juhos 		return -1;
3289c170e2eSGabor Juhos 
3292bb5b638SDaniel Schwierzeck 	/*
3302bb5b638SDaniel Schwierzeck 	 * Cmdline init has been moved to 'bootm prep' because it has to be
3312bb5b638SDaniel Schwierzeck 	 * done after relocation of ramdisk to always pass correct values
3322bb5b638SDaniel Schwierzeck 	 * for rd_start and rd_size to Linux kernel.
3332bb5b638SDaniel Schwierzeck 	 */
3342bb5b638SDaniel Schwierzeck 	if (flag & BOOTM_STATE_OS_CMDLINE)
33559e8cbdbSDaniel Schwierzeck 		return 0;
33659e8cbdbSDaniel Schwierzeck 
3379c170e2eSGabor Juhos 	if (flag & BOOTM_STATE_OS_PREP) {
3389c170e2eSGabor Juhos 		boot_prep_linux(images);
3399c170e2eSGabor Juhos 		return 0;
3409c170e2eSGabor Juhos 	}
3419c170e2eSGabor Juhos 
3422bb5b638SDaniel Schwierzeck 	if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
3439c170e2eSGabor Juhos 		boot_jump_linux(images);
3449c170e2eSGabor Juhos 		return 0;
3459c170e2eSGabor Juhos 	}
3460ea7213fSGabor Juhos 
347ea0364f1SPeter Tyser 	/* does not return */
348ea0364f1SPeter Tyser 	return 1;
349ea0364f1SPeter Tyser }
350