xref: /rk3399_rockchip-uboot/arch/mips/lib/bootm.c (revision 5002d8cc54f5be2230c4ccf60448e8720444671c)
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>
10*5002d8ccSDaniel 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 
187a9d109bSPaul Burton #if defined(CONFIG_MALTA)
197a9d109bSPaul Burton #define mips_boot_malta		1
20b87493f4SDaniel Schwierzeck #else
217a9d109bSPaul Burton #define mips_boot_malta		0
22b87493f4SDaniel Schwierzeck #endif
23b87493f4SDaniel Schwierzeck 
2425fc664fSDaniel Schwierzeck #if defined(CONFIG_MIPS_BOOT_CMDLINE_LEGACY)
2525fc664fSDaniel Schwierzeck #define mips_boot_cmdline_legacy	1
2625fc664fSDaniel Schwierzeck #else
2725fc664fSDaniel Schwierzeck #define mips_boot_cmdline_legacy	0
2825fc664fSDaniel Schwierzeck #endif
2925fc664fSDaniel Schwierzeck 
30ca65e585SDaniel Schwierzeck #if defined(CONFIG_MIPS_BOOT_ENV_LEGACY)
31ca65e585SDaniel Schwierzeck #define mips_boot_env_legacy	1
32ca65e585SDaniel Schwierzeck #else
33ca65e585SDaniel Schwierzeck #define mips_boot_env_legacy	0
34ca65e585SDaniel Schwierzeck #endif
35ca65e585SDaniel Schwierzeck 
36ea0364f1SPeter Tyser static int linux_argc;
37ea0364f1SPeter Tyser static char **linux_argv;
3859e8cbdbSDaniel Schwierzeck static char *linux_argp;
39ea0364f1SPeter Tyser 
40ea0364f1SPeter Tyser static char **linux_env;
41ea0364f1SPeter Tyser static char *linux_env_p;
42ea0364f1SPeter Tyser static int linux_env_idx;
43ea0364f1SPeter Tyser 
44f66cc1e3SDaniel Schwierzeck static ulong arch_get_sp(void)
45f66cc1e3SDaniel Schwierzeck {
46f66cc1e3SDaniel Schwierzeck 	ulong ret;
47f66cc1e3SDaniel Schwierzeck 
48f66cc1e3SDaniel Schwierzeck 	__asm__ __volatile__("move %0, $sp" : "=r"(ret) : );
49f66cc1e3SDaniel Schwierzeck 
50f66cc1e3SDaniel Schwierzeck 	return ret;
51f66cc1e3SDaniel Schwierzeck }
52f66cc1e3SDaniel Schwierzeck 
53f66cc1e3SDaniel Schwierzeck void arch_lmb_reserve(struct lmb *lmb)
54f66cc1e3SDaniel Schwierzeck {
55f66cc1e3SDaniel Schwierzeck 	ulong sp;
56f66cc1e3SDaniel Schwierzeck 
57f66cc1e3SDaniel Schwierzeck 	sp = arch_get_sp();
58f66cc1e3SDaniel Schwierzeck 	debug("## Current stack ends at 0x%08lx\n", sp);
59f66cc1e3SDaniel Schwierzeck 
60f66cc1e3SDaniel Schwierzeck 	/* adjust sp by 4K to be safe */
61f66cc1e3SDaniel Schwierzeck 	sp -= 4096;
62f66cc1e3SDaniel Schwierzeck 	lmb_reserve(lmb, sp, CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp);
63f66cc1e3SDaniel Schwierzeck }
64f66cc1e3SDaniel Schwierzeck 
65c9639421SDaniel Schwierzeck static int boot_setup_linux(bootm_headers_t *images)
66c9639421SDaniel Schwierzeck {
67c9639421SDaniel Schwierzeck 	int ret;
68c9639421SDaniel Schwierzeck 	ulong rd_len;
69c9639421SDaniel Schwierzeck 
70c9639421SDaniel Schwierzeck 	rd_len = images->rd_end - images->rd_start;
71c9639421SDaniel Schwierzeck 	ret = boot_ramdisk_high(&images->lmb, images->rd_start,
72c9639421SDaniel Schwierzeck 		rd_len, &images->initrd_start, &images->initrd_end);
73c9639421SDaniel Schwierzeck 	if (ret)
74c9639421SDaniel Schwierzeck 		return ret;
75c9639421SDaniel Schwierzeck 
76*5002d8ccSDaniel Schwierzeck #if defined(CONFIG_MIPS_BOOT_FDT) && defined(CONFIG_OF_LIBFDT)
77*5002d8ccSDaniel Schwierzeck 	if (images->ft_len) {
78*5002d8ccSDaniel Schwierzeck 		boot_fdt_add_mem_rsv_regions(&images->lmb, images->ft_addr);
79*5002d8ccSDaniel Schwierzeck 
80*5002d8ccSDaniel Schwierzeck 		ret = boot_relocate_fdt(&images->lmb, &images->ft_addr,
81*5002d8ccSDaniel Schwierzeck 			&images->ft_len);
82*5002d8ccSDaniel Schwierzeck 		if (ret)
83*5002d8ccSDaniel Schwierzeck 			return ret;
84*5002d8ccSDaniel Schwierzeck 	}
85*5002d8ccSDaniel Schwierzeck #endif
86*5002d8ccSDaniel Schwierzeck 
87c9639421SDaniel Schwierzeck 	return 0;
88c9639421SDaniel Schwierzeck }
89c9639421SDaniel Schwierzeck 
90*5002d8ccSDaniel Schwierzeck static void boot_setup_fdt(bootm_headers_t *images)
91*5002d8ccSDaniel Schwierzeck {
92*5002d8ccSDaniel Schwierzeck #if defined(CONFIG_MIPS_BOOT_FDT) && defined(CONFIG_OF_LIBFDT)
93*5002d8ccSDaniel Schwierzeck 	u64 mem_start = 0;
94*5002d8ccSDaniel Schwierzeck 	u64 mem_size = gd->ram_size;
95*5002d8ccSDaniel Schwierzeck 
96*5002d8ccSDaniel Schwierzeck 	debug("## setup FDT\n");
97*5002d8ccSDaniel Schwierzeck 
98*5002d8ccSDaniel Schwierzeck 	fdt_chosen(images->ft_addr, 1);
99*5002d8ccSDaniel Schwierzeck 	fdt_fixup_memory_banks(images->ft_addr, &mem_start, &mem_size, 1);
100*5002d8ccSDaniel Schwierzeck 	fdt_fixup_ethernet(images->ft_addr);
101*5002d8ccSDaniel Schwierzeck 	fdt_initrd(images->ft_addr, images->initrd_start, images->initrd_end, 1);
102*5002d8ccSDaniel Schwierzeck 
103*5002d8ccSDaniel Schwierzeck #if defined(CONFIG_OF_BOARD_SETUP)
104*5002d8ccSDaniel Schwierzeck 	ft_board_setup(images->ft_addr, gd->bd);
105*5002d8ccSDaniel Schwierzeck #endif
106*5002d8ccSDaniel Schwierzeck #endif
107*5002d8ccSDaniel Schwierzeck }
108*5002d8ccSDaniel Schwierzeck 
10959e8cbdbSDaniel Schwierzeck static void linux_cmdline_init(void)
11059e8cbdbSDaniel Schwierzeck {
11159e8cbdbSDaniel Schwierzeck 	linux_argc = 1;
11259e8cbdbSDaniel Schwierzeck 	linux_argv = (char **)UNCACHED_SDRAM(gd->bd->bi_boot_params);
11359e8cbdbSDaniel Schwierzeck 	linux_argv[0] = 0;
11459e8cbdbSDaniel Schwierzeck 	linux_argp = (char *)(linux_argv + LINUX_MAX_ARGS);
11559e8cbdbSDaniel Schwierzeck }
11659e8cbdbSDaniel Schwierzeck 
11759e8cbdbSDaniel Schwierzeck static void linux_cmdline_set(const char *value, size_t len)
11859e8cbdbSDaniel Schwierzeck {
11959e8cbdbSDaniel Schwierzeck 	linux_argv[linux_argc] = linux_argp;
12059e8cbdbSDaniel Schwierzeck 	memcpy(linux_argp, value, len);
12159e8cbdbSDaniel Schwierzeck 	linux_argp[len] = 0;
12259e8cbdbSDaniel Schwierzeck 
12359e8cbdbSDaniel Schwierzeck 	linux_argp += len + 1;
12459e8cbdbSDaniel Schwierzeck 	linux_argc++;
12559e8cbdbSDaniel Schwierzeck }
12659e8cbdbSDaniel Schwierzeck 
12759e8cbdbSDaniel Schwierzeck static void linux_cmdline_dump(void)
12859e8cbdbSDaniel Schwierzeck {
12959e8cbdbSDaniel Schwierzeck 	int i;
13059e8cbdbSDaniel Schwierzeck 
13159e8cbdbSDaniel Schwierzeck 	debug("## cmdline argv at 0x%p, argp at 0x%p\n",
13259e8cbdbSDaniel Schwierzeck 	      linux_argv, linux_argp);
13359e8cbdbSDaniel Schwierzeck 
13459e8cbdbSDaniel Schwierzeck 	for (i = 1; i < linux_argc; i++)
13559e8cbdbSDaniel Schwierzeck 		debug("   arg %03d: %s\n", i, linux_argv[i]);
13659e8cbdbSDaniel Schwierzeck }
13759e8cbdbSDaniel Schwierzeck 
13825fc664fSDaniel Schwierzeck static void linux_cmdline_legacy(bootm_headers_t *images)
13959e8cbdbSDaniel Schwierzeck {
14059e8cbdbSDaniel Schwierzeck 	const char *bootargs, *next, *quote;
14159e8cbdbSDaniel Schwierzeck 
14259e8cbdbSDaniel Schwierzeck 	linux_cmdline_init();
14359e8cbdbSDaniel Schwierzeck 
14459e8cbdbSDaniel Schwierzeck 	bootargs = getenv("bootargs");
14559e8cbdbSDaniel Schwierzeck 	if (!bootargs)
14659e8cbdbSDaniel Schwierzeck 		return;
14759e8cbdbSDaniel Schwierzeck 
14859e8cbdbSDaniel Schwierzeck 	next = bootargs;
14959e8cbdbSDaniel Schwierzeck 
15059e8cbdbSDaniel Schwierzeck 	while (bootargs && *bootargs && linux_argc < LINUX_MAX_ARGS) {
15159e8cbdbSDaniel Schwierzeck 		quote = strchr(bootargs, '"');
15259e8cbdbSDaniel Schwierzeck 		next = strchr(bootargs, ' ');
15359e8cbdbSDaniel Schwierzeck 
15459e8cbdbSDaniel Schwierzeck 		while (next && quote && quote < next) {
15559e8cbdbSDaniel Schwierzeck 			/*
15659e8cbdbSDaniel Schwierzeck 			 * we found a left quote before the next blank
15759e8cbdbSDaniel Schwierzeck 			 * now we have to find the matching right quote
15859e8cbdbSDaniel Schwierzeck 			 */
15959e8cbdbSDaniel Schwierzeck 			next = strchr(quote + 1, '"');
16059e8cbdbSDaniel Schwierzeck 			if (next) {
16159e8cbdbSDaniel Schwierzeck 				quote = strchr(next + 1, '"');
16259e8cbdbSDaniel Schwierzeck 				next = strchr(next + 1, ' ');
16359e8cbdbSDaniel Schwierzeck 			}
16459e8cbdbSDaniel Schwierzeck 		}
16559e8cbdbSDaniel Schwierzeck 
16659e8cbdbSDaniel Schwierzeck 		if (!next)
16759e8cbdbSDaniel Schwierzeck 			next = bootargs + strlen(bootargs);
16859e8cbdbSDaniel Schwierzeck 
16959e8cbdbSDaniel Schwierzeck 		linux_cmdline_set(bootargs, next - bootargs);
17059e8cbdbSDaniel Schwierzeck 
17159e8cbdbSDaniel Schwierzeck 		if (*next)
17259e8cbdbSDaniel Schwierzeck 			next++;
17359e8cbdbSDaniel Schwierzeck 
17459e8cbdbSDaniel Schwierzeck 		bootargs = next;
17559e8cbdbSDaniel Schwierzeck 	}
17625fc664fSDaniel Schwierzeck }
17759e8cbdbSDaniel Schwierzeck 
1788cec725aSDaniel Schwierzeck static void linux_cmdline_append(bootm_headers_t *images)
1798cec725aSDaniel Schwierzeck {
1808cec725aSDaniel Schwierzeck 	char buf[24];
1818cec725aSDaniel Schwierzeck 	ulong mem, rd_start, rd_size;
1828cec725aSDaniel Schwierzeck 
1838cec725aSDaniel Schwierzeck 	/* append mem */
1848cec725aSDaniel Schwierzeck 	mem = gd->ram_size >> 20;
1858cec725aSDaniel Schwierzeck 	sprintf(buf, "mem=%luM", mem);
1868cec725aSDaniel Schwierzeck 	linux_cmdline_set(buf, strlen(buf));
1878cec725aSDaniel Schwierzeck 
1888cec725aSDaniel Schwierzeck 	/* append rd_start and rd_size */
1898cec725aSDaniel Schwierzeck 	rd_start = images->initrd_start;
1908cec725aSDaniel Schwierzeck 	rd_size = images->initrd_end - images->initrd_start;
1918cec725aSDaniel Schwierzeck 
1928cec725aSDaniel Schwierzeck 	if (rd_size) {
1938cec725aSDaniel Schwierzeck 		sprintf(buf, "rd_start=0x%08lX", rd_start);
1948cec725aSDaniel Schwierzeck 		linux_cmdline_set(buf, strlen(buf));
1958cec725aSDaniel Schwierzeck 		sprintf(buf, "rd_size=0x%lX", rd_size);
1968cec725aSDaniel Schwierzeck 		linux_cmdline_set(buf, strlen(buf));
1978cec725aSDaniel Schwierzeck 	}
1988cec725aSDaniel Schwierzeck }
1998cec725aSDaniel Schwierzeck 
20025fc664fSDaniel Schwierzeck static void boot_cmdline_linux(bootm_headers_t *images)
20125fc664fSDaniel Schwierzeck {
202*5002d8ccSDaniel Schwierzeck 	if (mips_boot_cmdline_legacy && !images->ft_len) {
20325fc664fSDaniel Schwierzeck 		linux_cmdline_legacy(images);
2048cec725aSDaniel Schwierzeck 
2058cec725aSDaniel Schwierzeck 		if (!mips_boot_env_legacy)
2068cec725aSDaniel Schwierzeck 			linux_cmdline_append(images);
2078cec725aSDaniel Schwierzeck 
20859e8cbdbSDaniel Schwierzeck 		linux_cmdline_dump();
20959e8cbdbSDaniel Schwierzeck 	}
21025fc664fSDaniel Schwierzeck }
21159e8cbdbSDaniel Schwierzeck 
21215f8aa90SDaniel Schwierzeck static void linux_env_init(void)
21315f8aa90SDaniel Schwierzeck {
21415f8aa90SDaniel Schwierzeck 	linux_env = (char **)(((ulong) linux_argp + 15) & ~15);
21515f8aa90SDaniel Schwierzeck 	linux_env[0] = 0;
21615f8aa90SDaniel Schwierzeck 	linux_env_p = (char *)(linux_env + LINUX_MAX_ENVS);
21715f8aa90SDaniel Schwierzeck 	linux_env_idx = 0;
21815f8aa90SDaniel Schwierzeck }
21915f8aa90SDaniel Schwierzeck 
22015f8aa90SDaniel Schwierzeck static void linux_env_set(const char *env_name, const char *env_val)
22115f8aa90SDaniel Schwierzeck {
22215f8aa90SDaniel Schwierzeck 	if (linux_env_idx < LINUX_MAX_ENVS - 1) {
22315f8aa90SDaniel Schwierzeck 		linux_env[linux_env_idx] = linux_env_p;
22415f8aa90SDaniel Schwierzeck 
22515f8aa90SDaniel Schwierzeck 		strcpy(linux_env_p, env_name);
22615f8aa90SDaniel Schwierzeck 		linux_env_p += strlen(env_name);
22715f8aa90SDaniel Schwierzeck 
2287a9d109bSPaul Burton 		if (mips_boot_malta) {
229b87493f4SDaniel Schwierzeck 			linux_env_p++;
230b87493f4SDaniel Schwierzeck 			linux_env[++linux_env_idx] = linux_env_p;
231b87493f4SDaniel Schwierzeck 		} else {
23215f8aa90SDaniel Schwierzeck 			*linux_env_p++ = '=';
233b87493f4SDaniel Schwierzeck 		}
23415f8aa90SDaniel Schwierzeck 
23515f8aa90SDaniel Schwierzeck 		strcpy(linux_env_p, env_val);
23615f8aa90SDaniel Schwierzeck 		linux_env_p += strlen(env_val);
23715f8aa90SDaniel Schwierzeck 
23815f8aa90SDaniel Schwierzeck 		linux_env_p++;
23915f8aa90SDaniel Schwierzeck 		linux_env[++linux_env_idx] = 0;
24015f8aa90SDaniel Schwierzeck 	}
24115f8aa90SDaniel Schwierzeck }
24215f8aa90SDaniel Schwierzeck 
243ca65e585SDaniel Schwierzeck static void linux_env_legacy(bootm_headers_t *images)
244ea0364f1SPeter Tyser {
245ea0364f1SPeter Tyser 	char env_buf[12];
24615f8aa90SDaniel Schwierzeck 	const char *cp;
2476c154552SDaniel Schwierzeck 	ulong rd_start, rd_size;
248ea0364f1SPeter Tyser 
249ea0364f1SPeter Tyser #ifdef CONFIG_MEMSIZE_IN_BYTES
250ea0364f1SPeter Tyser 	sprintf(env_buf, "%lu", (ulong)gd->ram_size);
251ea0364f1SPeter Tyser 	debug("## Giving linux memsize in bytes, %lu\n", (ulong)gd->ram_size);
252ea0364f1SPeter Tyser #else
253ea0364f1SPeter Tyser 	sprintf(env_buf, "%lu", (ulong)(gd->ram_size >> 20));
254e51a6b7aSDaniel Schwierzeck 	debug("## Giving linux memsize in MB, %lu\n",
255e51a6b7aSDaniel Schwierzeck 	      (ulong)(gd->ram_size >> 20));
256ea0364f1SPeter Tyser #endif /* CONFIG_MEMSIZE_IN_BYTES */
257ea0364f1SPeter Tyser 
2586c154552SDaniel Schwierzeck 	rd_start = UNCACHED_SDRAM(images->initrd_start);
2596c154552SDaniel Schwierzeck 	rd_size = images->initrd_end - images->initrd_start;
2606c154552SDaniel Schwierzeck 
26115f8aa90SDaniel Schwierzeck 	linux_env_init();
26215f8aa90SDaniel Schwierzeck 
263ea0364f1SPeter Tyser 	linux_env_set("memsize", env_buf);
264ea0364f1SPeter Tyser 
2656c154552SDaniel Schwierzeck 	sprintf(env_buf, "0x%08lX", rd_start);
266ea0364f1SPeter Tyser 	linux_env_set("initrd_start", env_buf);
267ea0364f1SPeter Tyser 
2686c154552SDaniel Schwierzeck 	sprintf(env_buf, "0x%lX", rd_size);
269ea0364f1SPeter Tyser 	linux_env_set("initrd_size", env_buf);
270ea0364f1SPeter Tyser 
271ea0364f1SPeter Tyser 	sprintf(env_buf, "0x%08X", (uint) (gd->bd->bi_flashstart));
272ea0364f1SPeter Tyser 	linux_env_set("flash_start", env_buf);
273ea0364f1SPeter Tyser 
274ea0364f1SPeter Tyser 	sprintf(env_buf, "0x%X", (uint) (gd->bd->bi_flashsize));
275ea0364f1SPeter Tyser 	linux_env_set("flash_size", env_buf);
276ea0364f1SPeter Tyser 
277ea0364f1SPeter Tyser 	cp = getenv("ethaddr");
278e51a6b7aSDaniel Schwierzeck 	if (cp)
279ea0364f1SPeter Tyser 		linux_env_set("ethaddr", cp);
280ea0364f1SPeter Tyser 
281ea0364f1SPeter Tyser 	cp = getenv("eth1addr");
282e51a6b7aSDaniel Schwierzeck 	if (cp)
283ea0364f1SPeter Tyser 		linux_env_set("eth1addr", cp);
284b87493f4SDaniel Schwierzeck 
285d18d49d7SPaul Burton 	if (mips_boot_malta) {
286d18d49d7SPaul Burton 		sprintf(env_buf, "%un8r", gd->baudrate);
287d18d49d7SPaul Burton 		linux_env_set("modetty0", env_buf);
288d18d49d7SPaul Burton 	}
2890ea7213fSGabor Juhos }
290ea0364f1SPeter Tyser 
291ca65e585SDaniel Schwierzeck static void boot_prep_linux(bootm_headers_t *images)
292ca65e585SDaniel Schwierzeck {
293*5002d8ccSDaniel Schwierzeck 	if (mips_boot_env_legacy && !images->ft_len)
294ca65e585SDaniel Schwierzeck 		linux_env_legacy(images);
295*5002d8ccSDaniel Schwierzeck 
296*5002d8ccSDaniel Schwierzeck 	if (images->ft_len)
297*5002d8ccSDaniel Schwierzeck 		boot_setup_fdt(images);
298ca65e585SDaniel Schwierzeck }
299ca65e585SDaniel Schwierzeck 
3000ea7213fSGabor Juhos static void boot_jump_linux(bootm_headers_t *images)
3010ea7213fSGabor Juhos {
302c4b37847SDaniel Schwierzeck 	typedef void __noreturn (*kernel_entry_t)(int, ulong, ulong, ulong);
303c4b37847SDaniel Schwierzeck 	kernel_entry_t kernel = (kernel_entry_t) images->ep;
304b87493f4SDaniel Schwierzeck 	ulong linux_extra = 0;
3050ea7213fSGabor Juhos 
306c4b37847SDaniel Schwierzeck 	debug("## Transferring control to Linux (at address %p) ...\n", kernel);
3070ea7213fSGabor Juhos 
3080ea7213fSGabor Juhos 	bootstage_mark(BOOTSTAGE_ID_RUN_OS);
3090ea7213fSGabor Juhos 
3107a9d109bSPaul Burton 	if (mips_boot_malta)
311b87493f4SDaniel Schwierzeck 		linux_extra = gd->ram_size;
312b87493f4SDaniel Schwierzeck 
3130ea7213fSGabor Juhos 	/* we assume that the kernel is in place */
3140ea7213fSGabor Juhos 	printf("\nStarting kernel ...\n\n");
3150ea7213fSGabor Juhos 
316b87493f4SDaniel Schwierzeck 	kernel(linux_argc, (ulong)linux_argv, (ulong)linux_env, linux_extra);
3170ea7213fSGabor Juhos }
3180ea7213fSGabor Juhos 
3190ea7213fSGabor Juhos int do_bootm_linux(int flag, int argc, char * const argv[],
3200ea7213fSGabor Juhos 			bootm_headers_t *images)
3210ea7213fSGabor Juhos {
322c9639421SDaniel Schwierzeck 	int ret;
323c9639421SDaniel Schwierzeck 
3249c170e2eSGabor Juhos 	/* No need for those on MIPS */
32559e8cbdbSDaniel Schwierzeck 	if (flag & BOOTM_STATE_OS_BD_T)
3269c170e2eSGabor Juhos 		return -1;
3279c170e2eSGabor Juhos 
32859e8cbdbSDaniel Schwierzeck 	if (flag & BOOTM_STATE_OS_CMDLINE) {
32959e8cbdbSDaniel Schwierzeck 		boot_cmdline_linux(images);
33059e8cbdbSDaniel Schwierzeck 		return 0;
33159e8cbdbSDaniel Schwierzeck 	}
33259e8cbdbSDaniel Schwierzeck 
3339c170e2eSGabor Juhos 	if (flag & BOOTM_STATE_OS_PREP) {
3349c170e2eSGabor Juhos 		boot_prep_linux(images);
3359c170e2eSGabor Juhos 		return 0;
3369c170e2eSGabor Juhos 	}
3379c170e2eSGabor Juhos 
3389c170e2eSGabor Juhos 	if (flag & BOOTM_STATE_OS_GO) {
3399c170e2eSGabor Juhos 		boot_jump_linux(images);
3409c170e2eSGabor Juhos 		return 0;
3419c170e2eSGabor Juhos 	}
3420ea7213fSGabor Juhos 
343c9639421SDaniel Schwierzeck 	ret = boot_setup_linux(images);
344c9639421SDaniel Schwierzeck 	if (ret)
345c9639421SDaniel Schwierzeck 		return ret;
346c9639421SDaniel Schwierzeck 
34759e8cbdbSDaniel Schwierzeck 	boot_cmdline_linux(images);
3480ea7213fSGabor Juhos 	boot_prep_linux(images);
349e08634c7SGabor Juhos 	boot_jump_linux(images);
350e51a6b7aSDaniel Schwierzeck 
351ea0364f1SPeter Tyser 	/* does not return */
352ea0364f1SPeter Tyser 	return 1;
353ea0364f1SPeter Tyser }
354