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>
12fdff5b05SPurna Chandra Mandal #include <asm/io.h>
13ea0364f1SPeter Tyser
14ea0364f1SPeter Tyser DECLARE_GLOBAL_DATA_PTR;
15ea0364f1SPeter Tyser
16ea0364f1SPeter Tyser #define LINUX_MAX_ENVS 256
17ea0364f1SPeter Tyser #define LINUX_MAX_ARGS 256
18ea0364f1SPeter Tyser
19ea0364f1SPeter Tyser static int linux_argc;
20ea0364f1SPeter Tyser static char **linux_argv;
2159e8cbdbSDaniel Schwierzeck static char *linux_argp;
22ea0364f1SPeter Tyser
23ea0364f1SPeter Tyser static char **linux_env;
24ea0364f1SPeter Tyser static char *linux_env_p;
25ea0364f1SPeter Tyser static int linux_env_idx;
26ea0364f1SPeter Tyser
arch_get_sp(void)27f66cc1e3SDaniel Schwierzeck static ulong arch_get_sp(void)
28f66cc1e3SDaniel Schwierzeck {
29f66cc1e3SDaniel Schwierzeck ulong ret;
30f66cc1e3SDaniel Schwierzeck
31f66cc1e3SDaniel Schwierzeck __asm__ __volatile__("move %0, $sp" : "=r"(ret) : );
32f66cc1e3SDaniel Schwierzeck
33f66cc1e3SDaniel Schwierzeck return ret;
34f66cc1e3SDaniel Schwierzeck }
35f66cc1e3SDaniel Schwierzeck
arch_lmb_reserve(struct lmb * lmb)36f66cc1e3SDaniel Schwierzeck void arch_lmb_reserve(struct lmb *lmb)
37f66cc1e3SDaniel Schwierzeck {
38f66cc1e3SDaniel Schwierzeck ulong sp;
39f66cc1e3SDaniel Schwierzeck
40f66cc1e3SDaniel Schwierzeck sp = arch_get_sp();
41f66cc1e3SDaniel Schwierzeck debug("## Current stack ends at 0x%08lx\n", sp);
42f66cc1e3SDaniel Schwierzeck
43f66cc1e3SDaniel Schwierzeck /* adjust sp by 4K to be safe */
44f66cc1e3SDaniel Schwierzeck sp -= 4096;
457a3e0f74SPaul Burton lmb_reserve(lmb, sp, gd->ram_top - sp);
46f66cc1e3SDaniel Schwierzeck }
47f66cc1e3SDaniel Schwierzeck
linux_cmdline_init(void)4859e8cbdbSDaniel Schwierzeck static void linux_cmdline_init(void)
4959e8cbdbSDaniel Schwierzeck {
5059e8cbdbSDaniel Schwierzeck linux_argc = 1;
5159e8cbdbSDaniel Schwierzeck linux_argv = (char **)UNCACHED_SDRAM(gd->bd->bi_boot_params);
5259e8cbdbSDaniel Schwierzeck linux_argv[0] = 0;
5359e8cbdbSDaniel Schwierzeck linux_argp = (char *)(linux_argv + LINUX_MAX_ARGS);
5459e8cbdbSDaniel Schwierzeck }
5559e8cbdbSDaniel Schwierzeck
linux_cmdline_set(const char * value,size_t len)5659e8cbdbSDaniel Schwierzeck static void linux_cmdline_set(const char *value, size_t len)
5759e8cbdbSDaniel Schwierzeck {
5859e8cbdbSDaniel Schwierzeck linux_argv[linux_argc] = linux_argp;
5959e8cbdbSDaniel Schwierzeck memcpy(linux_argp, value, len);
6059e8cbdbSDaniel Schwierzeck linux_argp[len] = 0;
6159e8cbdbSDaniel Schwierzeck
6259e8cbdbSDaniel Schwierzeck linux_argp += len + 1;
6359e8cbdbSDaniel Schwierzeck linux_argc++;
6459e8cbdbSDaniel Schwierzeck }
6559e8cbdbSDaniel Schwierzeck
linux_cmdline_dump(void)6659e8cbdbSDaniel Schwierzeck static void linux_cmdline_dump(void)
6759e8cbdbSDaniel Schwierzeck {
6859e8cbdbSDaniel Schwierzeck int i;
6959e8cbdbSDaniel Schwierzeck
7059e8cbdbSDaniel Schwierzeck debug("## cmdline argv at 0x%p, argp at 0x%p\n",
7159e8cbdbSDaniel Schwierzeck linux_argv, linux_argp);
7259e8cbdbSDaniel Schwierzeck
7359e8cbdbSDaniel Schwierzeck for (i = 1; i < linux_argc; i++)
7459e8cbdbSDaniel Schwierzeck debug(" arg %03d: %s\n", i, linux_argv[i]);
7559e8cbdbSDaniel Schwierzeck }
7659e8cbdbSDaniel Schwierzeck
linux_cmdline_legacy(bootm_headers_t * images)7725fc664fSDaniel Schwierzeck static void linux_cmdline_legacy(bootm_headers_t *images)
7859e8cbdbSDaniel Schwierzeck {
7959e8cbdbSDaniel Schwierzeck const char *bootargs, *next, *quote;
8059e8cbdbSDaniel Schwierzeck
8159e8cbdbSDaniel Schwierzeck linux_cmdline_init();
8259e8cbdbSDaniel Schwierzeck
8300caae6dSSimon Glass bootargs = env_get("bootargs");
8459e8cbdbSDaniel Schwierzeck if (!bootargs)
8559e8cbdbSDaniel Schwierzeck return;
8659e8cbdbSDaniel Schwierzeck
8759e8cbdbSDaniel Schwierzeck next = bootargs;
8859e8cbdbSDaniel Schwierzeck
8959e8cbdbSDaniel Schwierzeck while (bootargs && *bootargs && linux_argc < LINUX_MAX_ARGS) {
9059e8cbdbSDaniel Schwierzeck quote = strchr(bootargs, '"');
9159e8cbdbSDaniel Schwierzeck next = strchr(bootargs, ' ');
9259e8cbdbSDaniel Schwierzeck
9359e8cbdbSDaniel Schwierzeck while (next && quote && quote < next) {
9459e8cbdbSDaniel Schwierzeck /*
9559e8cbdbSDaniel Schwierzeck * we found a left quote before the next blank
9659e8cbdbSDaniel Schwierzeck * now we have to find the matching right quote
9759e8cbdbSDaniel Schwierzeck */
9859e8cbdbSDaniel Schwierzeck next = strchr(quote + 1, '"');
9959e8cbdbSDaniel Schwierzeck if (next) {
10059e8cbdbSDaniel Schwierzeck quote = strchr(next + 1, '"');
10159e8cbdbSDaniel Schwierzeck next = strchr(next + 1, ' ');
10259e8cbdbSDaniel Schwierzeck }
10359e8cbdbSDaniel Schwierzeck }
10459e8cbdbSDaniel Schwierzeck
10559e8cbdbSDaniel Schwierzeck if (!next)
10659e8cbdbSDaniel Schwierzeck next = bootargs + strlen(bootargs);
10759e8cbdbSDaniel Schwierzeck
10859e8cbdbSDaniel Schwierzeck linux_cmdline_set(bootargs, next - bootargs);
10959e8cbdbSDaniel Schwierzeck
11059e8cbdbSDaniel Schwierzeck if (*next)
11159e8cbdbSDaniel Schwierzeck next++;
11259e8cbdbSDaniel Schwierzeck
11359e8cbdbSDaniel Schwierzeck bootargs = next;
11459e8cbdbSDaniel Schwierzeck }
11525fc664fSDaniel Schwierzeck }
11659e8cbdbSDaniel Schwierzeck
linux_cmdline_append(bootm_headers_t * images)1178cec725aSDaniel Schwierzeck static void linux_cmdline_append(bootm_headers_t *images)
1188cec725aSDaniel Schwierzeck {
1198cec725aSDaniel Schwierzeck char buf[24];
1208cec725aSDaniel Schwierzeck ulong mem, rd_start, rd_size;
1218cec725aSDaniel Schwierzeck
1228cec725aSDaniel Schwierzeck /* append mem */
1238cec725aSDaniel Schwierzeck mem = gd->ram_size >> 20;
1248cec725aSDaniel Schwierzeck sprintf(buf, "mem=%luM", mem);
1258cec725aSDaniel Schwierzeck linux_cmdline_set(buf, strlen(buf));
1268cec725aSDaniel Schwierzeck
1278cec725aSDaniel Schwierzeck /* append rd_start and rd_size */
1288cec725aSDaniel Schwierzeck rd_start = images->initrd_start;
1298cec725aSDaniel Schwierzeck rd_size = images->initrd_end - images->initrd_start;
1308cec725aSDaniel Schwierzeck
1318cec725aSDaniel Schwierzeck if (rd_size) {
1328cec725aSDaniel Schwierzeck sprintf(buf, "rd_start=0x%08lX", rd_start);
1338cec725aSDaniel Schwierzeck linux_cmdline_set(buf, strlen(buf));
1348cec725aSDaniel Schwierzeck sprintf(buf, "rd_size=0x%lX", rd_size);
1358cec725aSDaniel Schwierzeck linux_cmdline_set(buf, strlen(buf));
1368cec725aSDaniel Schwierzeck }
1378cec725aSDaniel Schwierzeck }
1388cec725aSDaniel Schwierzeck
linux_env_init(void)13915f8aa90SDaniel Schwierzeck static void linux_env_init(void)
14015f8aa90SDaniel Schwierzeck {
14115f8aa90SDaniel Schwierzeck linux_env = (char **)(((ulong) linux_argp + 15) & ~15);
14215f8aa90SDaniel Schwierzeck linux_env[0] = 0;
14315f8aa90SDaniel Schwierzeck linux_env_p = (char *)(linux_env + LINUX_MAX_ENVS);
14415f8aa90SDaniel Schwierzeck linux_env_idx = 0;
14515f8aa90SDaniel Schwierzeck }
14615f8aa90SDaniel Schwierzeck
linux_env_set(const char * env_name,const char * env_val)14715f8aa90SDaniel Schwierzeck static void linux_env_set(const char *env_name, const char *env_val)
14815f8aa90SDaniel Schwierzeck {
14915f8aa90SDaniel Schwierzeck if (linux_env_idx < LINUX_MAX_ENVS - 1) {
15015f8aa90SDaniel Schwierzeck linux_env[linux_env_idx] = linux_env_p;
15115f8aa90SDaniel Schwierzeck
15215f8aa90SDaniel Schwierzeck strcpy(linux_env_p, env_name);
15315f8aa90SDaniel Schwierzeck linux_env_p += strlen(env_name);
15415f8aa90SDaniel Schwierzeck
155347ea94eSDaniel Schwierzeck if (CONFIG_IS_ENABLED(MALTA)) {
156b87493f4SDaniel Schwierzeck linux_env_p++;
157b87493f4SDaniel Schwierzeck linux_env[++linux_env_idx] = linux_env_p;
158b87493f4SDaniel Schwierzeck } else {
15915f8aa90SDaniel Schwierzeck *linux_env_p++ = '=';
160b87493f4SDaniel Schwierzeck }
16115f8aa90SDaniel Schwierzeck
16215f8aa90SDaniel Schwierzeck strcpy(linux_env_p, env_val);
16315f8aa90SDaniel Schwierzeck linux_env_p += strlen(env_val);
16415f8aa90SDaniel Schwierzeck
16515f8aa90SDaniel Schwierzeck linux_env_p++;
16615f8aa90SDaniel Schwierzeck linux_env[++linux_env_idx] = 0;
16715f8aa90SDaniel Schwierzeck }
16815f8aa90SDaniel Schwierzeck }
16915f8aa90SDaniel Schwierzeck
linux_env_legacy(bootm_headers_t * images)170ca65e585SDaniel Schwierzeck static void linux_env_legacy(bootm_headers_t *images)
171ea0364f1SPeter Tyser {
172ea0364f1SPeter Tyser char env_buf[12];
17315f8aa90SDaniel Schwierzeck const char *cp;
1746c154552SDaniel Schwierzeck ulong rd_start, rd_size;
175ea0364f1SPeter Tyser
176347ea94eSDaniel Schwierzeck if (CONFIG_IS_ENABLED(MEMSIZE_IN_BYTES)) {
177ea0364f1SPeter Tyser sprintf(env_buf, "%lu", (ulong)gd->ram_size);
178347ea94eSDaniel Schwierzeck debug("## Giving linux memsize in bytes, %lu\n",
179347ea94eSDaniel Schwierzeck (ulong)gd->ram_size);
180347ea94eSDaniel Schwierzeck } else {
181ea0364f1SPeter Tyser sprintf(env_buf, "%lu", (ulong)(gd->ram_size >> 20));
182e51a6b7aSDaniel Schwierzeck debug("## Giving linux memsize in MB, %lu\n",
183e51a6b7aSDaniel Schwierzeck (ulong)(gd->ram_size >> 20));
184347ea94eSDaniel Schwierzeck }
185ea0364f1SPeter Tyser
1866c154552SDaniel Schwierzeck rd_start = UNCACHED_SDRAM(images->initrd_start);
1876c154552SDaniel Schwierzeck rd_size = images->initrd_end - images->initrd_start;
1886c154552SDaniel Schwierzeck
18915f8aa90SDaniel Schwierzeck linux_env_init();
19015f8aa90SDaniel Schwierzeck
191ea0364f1SPeter Tyser linux_env_set("memsize", env_buf);
192ea0364f1SPeter Tyser
1936c154552SDaniel Schwierzeck sprintf(env_buf, "0x%08lX", rd_start);
194ea0364f1SPeter Tyser linux_env_set("initrd_start", env_buf);
195ea0364f1SPeter Tyser
1966c154552SDaniel Schwierzeck sprintf(env_buf, "0x%lX", rd_size);
197ea0364f1SPeter Tyser linux_env_set("initrd_size", env_buf);
198ea0364f1SPeter Tyser
199ea0364f1SPeter Tyser sprintf(env_buf, "0x%08X", (uint) (gd->bd->bi_flashstart));
200ea0364f1SPeter Tyser linux_env_set("flash_start", env_buf);
201ea0364f1SPeter Tyser
202ea0364f1SPeter Tyser sprintf(env_buf, "0x%X", (uint) (gd->bd->bi_flashsize));
203ea0364f1SPeter Tyser linux_env_set("flash_size", env_buf);
204ea0364f1SPeter Tyser
20500caae6dSSimon Glass cp = env_get("ethaddr");
206e51a6b7aSDaniel Schwierzeck if (cp)
207ea0364f1SPeter Tyser linux_env_set("ethaddr", cp);
208ea0364f1SPeter Tyser
20900caae6dSSimon Glass cp = env_get("eth1addr");
210e51a6b7aSDaniel Schwierzeck if (cp)
211ea0364f1SPeter Tyser linux_env_set("eth1addr", cp);
212b87493f4SDaniel Schwierzeck
213347ea94eSDaniel Schwierzeck if (CONFIG_IS_ENABLED(MALTA)) {
214d18d49d7SPaul Burton sprintf(env_buf, "%un8r", gd->baudrate);
215d18d49d7SPaul Burton linux_env_set("modetty0", env_buf);
216d18d49d7SPaul Burton }
2170ea7213fSGabor Juhos }
218ea0364f1SPeter Tyser
boot_reloc_ramdisk(bootm_headers_t * images)2192bb5b638SDaniel Schwierzeck static int boot_reloc_ramdisk(bootm_headers_t *images)
2202bb5b638SDaniel Schwierzeck {
2212bb5b638SDaniel Schwierzeck ulong rd_len = images->rd_end - images->rd_start;
2222bb5b638SDaniel Schwierzeck
2232bb5b638SDaniel Schwierzeck /*
2242bb5b638SDaniel Schwierzeck * In case of legacy uImage's, relocation of ramdisk is already done
2252bb5b638SDaniel Schwierzeck * by do_bootm_states() and should not repeated in 'bootm prep'.
2262bb5b638SDaniel Schwierzeck */
2272bb5b638SDaniel Schwierzeck if (images->state & BOOTM_STATE_RAMDISK) {
2282bb5b638SDaniel Schwierzeck debug("## Ramdisk already relocated\n");
2292bb5b638SDaniel Schwierzeck return 0;
2302bb5b638SDaniel Schwierzeck }
2312bb5b638SDaniel Schwierzeck
2322bb5b638SDaniel Schwierzeck return boot_ramdisk_high(&images->lmb, images->rd_start,
2332bb5b638SDaniel Schwierzeck rd_len, &images->initrd_start, &images->initrd_end);
2342bb5b638SDaniel Schwierzeck }
2352bb5b638SDaniel Schwierzeck
boot_reloc_fdt(bootm_headers_t * images)2362bb5b638SDaniel Schwierzeck static int boot_reloc_fdt(bootm_headers_t *images)
2372bb5b638SDaniel Schwierzeck {
2382bb5b638SDaniel Schwierzeck /*
2392bb5b638SDaniel Schwierzeck * In case of legacy uImage's, relocation of FDT is already done
2402bb5b638SDaniel Schwierzeck * by do_bootm_states() and should not repeated in 'bootm prep'.
2412bb5b638SDaniel Schwierzeck */
2422bb5b638SDaniel Schwierzeck if (images->state & BOOTM_STATE_FDT) {
2432bb5b638SDaniel Schwierzeck debug("## FDT already relocated\n");
2442bb5b638SDaniel Schwierzeck return 0;
2452bb5b638SDaniel Schwierzeck }
2462bb5b638SDaniel Schwierzeck
2472bb5b638SDaniel Schwierzeck #if CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && CONFIG_IS_ENABLED(OF_LIBFDT)
2482bb5b638SDaniel Schwierzeck boot_fdt_add_mem_rsv_regions(&images->lmb, images->ft_addr);
2492bb5b638SDaniel Schwierzeck return boot_relocate_fdt(&images->lmb, &images->ft_addr,
2502bb5b638SDaniel Schwierzeck &images->ft_len);
2512bb5b638SDaniel Schwierzeck #else
2522bb5b638SDaniel Schwierzeck return 0;
2532bb5b638SDaniel Schwierzeck #endif
2542bb5b638SDaniel Schwierzeck }
2552bb5b638SDaniel Schwierzeck
256*f05ce847SAlexey Brodkin #if CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && CONFIG_IS_ENABLED(OF_LIBFDT)
arch_fixup_fdt(void * blob)257fdff5b05SPurna Chandra Mandal int arch_fixup_fdt(void *blob)
2582bb5b638SDaniel Schwierzeck {
259fdff5b05SPurna Chandra Mandal u64 mem_start = virt_to_phys((void *)gd->bd->bi_memstart);
2602bb5b638SDaniel Schwierzeck u64 mem_size = gd->ram_size;
2612bb5b638SDaniel Schwierzeck
2622bb5b638SDaniel Schwierzeck return fdt_fixup_memory_banks(blob, &mem_start, &mem_size, 1);
2632bb5b638SDaniel Schwierzeck }
264*f05ce847SAlexey Brodkin #endif
2652bb5b638SDaniel Schwierzeck
boot_setup_fdt(bootm_headers_t * images)2662bb5b638SDaniel Schwierzeck static int boot_setup_fdt(bootm_headers_t *images)
2672bb5b638SDaniel Schwierzeck {
2682bb5b638SDaniel Schwierzeck return image_setup_libfdt(images, images->ft_addr, images->ft_len,
2692bb5b638SDaniel Schwierzeck &images->lmb);
2702bb5b638SDaniel Schwierzeck }
2712bb5b638SDaniel Schwierzeck
boot_prep_linux(bootm_headers_t * images)272ca65e585SDaniel Schwierzeck static void boot_prep_linux(bootm_headers_t *images)
273ca65e585SDaniel Schwierzeck {
2742bb5b638SDaniel Schwierzeck boot_reloc_ramdisk(images);
2752bb5b638SDaniel Schwierzeck
2762bb5b638SDaniel Schwierzeck if (CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && images->ft_len) {
2772bb5b638SDaniel Schwierzeck boot_reloc_fdt(images);
2782bb5b638SDaniel Schwierzeck boot_setup_fdt(images);
2792bb5b638SDaniel Schwierzeck } else {
2802bb5b638SDaniel Schwierzeck if (CONFIG_IS_ENABLED(MIPS_BOOT_CMDLINE_LEGACY)) {
2812bb5b638SDaniel Schwierzeck linux_cmdline_legacy(images);
2822bb5b638SDaniel Schwierzeck
28348bfc31bSZubair Lutfullah Kakakhel if (!CONFIG_IS_ENABLED(MIPS_BOOT_ENV_LEGACY))
2842bb5b638SDaniel Schwierzeck linux_cmdline_append(images);
2852bb5b638SDaniel Schwierzeck
2862bb5b638SDaniel Schwierzeck linux_cmdline_dump();
2872bb5b638SDaniel Schwierzeck }
28848bfc31bSZubair Lutfullah Kakakhel
28948bfc31bSZubair Lutfullah Kakakhel if (CONFIG_IS_ENABLED(MIPS_BOOT_ENV_LEGACY))
29048bfc31bSZubair Lutfullah Kakakhel linux_env_legacy(images);
2912bb5b638SDaniel Schwierzeck }
292ca65e585SDaniel Schwierzeck }
293ca65e585SDaniel Schwierzeck
boot_jump_linux(bootm_headers_t * images)2940ea7213fSGabor Juhos static void boot_jump_linux(bootm_headers_t *images)
2950ea7213fSGabor Juhos {
296c4b37847SDaniel Schwierzeck typedef void __noreturn (*kernel_entry_t)(int, ulong, ulong, ulong);
297c4b37847SDaniel Schwierzeck kernel_entry_t kernel = (kernel_entry_t) images->ep;
298b87493f4SDaniel Schwierzeck ulong linux_extra = 0;
2990ea7213fSGabor Juhos
300c4b37847SDaniel Schwierzeck debug("## Transferring control to Linux (at address %p) ...\n", kernel);
3010ea7213fSGabor Juhos
3020ea7213fSGabor Juhos bootstage_mark(BOOTSTAGE_ID_RUN_OS);
3030ea7213fSGabor Juhos
304347ea94eSDaniel Schwierzeck if (CONFIG_IS_ENABLED(MALTA))
305b87493f4SDaniel Schwierzeck linux_extra = gd->ram_size;
306b87493f4SDaniel Schwierzeck
307347ea94eSDaniel Schwierzeck #if CONFIG_IS_ENABLED(BOOTSTAGE_FDT)
308e13a50b3SDaniel Schwierzeck bootstage_fdt_add_report();
309e13a50b3SDaniel Schwierzeck #endif
310347ea94eSDaniel Schwierzeck #if CONFIG_IS_ENABLED(BOOTSTAGE_REPORT)
311e13a50b3SDaniel Schwierzeck bootstage_report();
312e13a50b3SDaniel Schwierzeck #endif
3130ea7213fSGabor Juhos
31490b1c9faSDaniel Schwierzeck if (images->ft_len)
31590b1c9faSDaniel Schwierzeck kernel(-2, (ulong)images->ft_addr, 0, 0);
31690b1c9faSDaniel Schwierzeck else
31790b1c9faSDaniel Schwierzeck kernel(linux_argc, (ulong)linux_argv, (ulong)linux_env,
31890b1c9faSDaniel Schwierzeck linux_extra);
3190ea7213fSGabor Juhos }
3200ea7213fSGabor Juhos
do_bootm_linux(int flag,int argc,char * const argv[],bootm_headers_t * images)3210ea7213fSGabor Juhos int do_bootm_linux(int flag, int argc, char * const argv[],
3220ea7213fSGabor Juhos bootm_headers_t *images)
3230ea7213fSGabor Juhos {
3249c170e2eSGabor Juhos /* No need for those on MIPS */
32559e8cbdbSDaniel Schwierzeck if (flag & BOOTM_STATE_OS_BD_T)
3269c170e2eSGabor Juhos return -1;
3279c170e2eSGabor Juhos
3282bb5b638SDaniel Schwierzeck /*
3292bb5b638SDaniel Schwierzeck * Cmdline init has been moved to 'bootm prep' because it has to be
3302bb5b638SDaniel Schwierzeck * done after relocation of ramdisk to always pass correct values
3312bb5b638SDaniel Schwierzeck * for rd_start and rd_size to Linux kernel.
3322bb5b638SDaniel Schwierzeck */
3332bb5b638SDaniel Schwierzeck if (flag & BOOTM_STATE_OS_CMDLINE)
33459e8cbdbSDaniel Schwierzeck return 0;
33559e8cbdbSDaniel Schwierzeck
3369c170e2eSGabor Juhos if (flag & BOOTM_STATE_OS_PREP) {
3379c170e2eSGabor Juhos boot_prep_linux(images);
3389c170e2eSGabor Juhos return 0;
3399c170e2eSGabor Juhos }
3409c170e2eSGabor Juhos
3412bb5b638SDaniel Schwierzeck if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
3429c170e2eSGabor Juhos boot_jump_linux(images);
3439c170e2eSGabor Juhos return 0;
3449c170e2eSGabor Juhos }
3450ea7213fSGabor Juhos
346ea0364f1SPeter Tyser /* does not return */
347ea0364f1SPeter Tyser return 1;
348ea0364f1SPeter Tyser }
349