blob: 6977dd641aba734e23d599127e2a901bb2e397b8 [file] [log] [blame]
wdenk507bbe32004-04-18 21:13:41 +00001/*
Michal Simekcfc67112007-03-11 13:48:24 +01002 * (C) Copyright 2007 Michal Simek
wdenk507bbe32004-04-18 21:13:41 +00003 * (C) Copyright 2004 Atmark Techno, Inc.
4 *
Michal Simekcfc67112007-03-11 13:48:24 +01005 * Michal SIMEK <monstr@monstr.eu>
wdenk507bbe32004-04-18 21:13:41 +00006 * Yasushi SHOJI <yashi@atmark-techno.com>
7 *
Wolfgang Denk3765b3e2013-10-07 13:07:26 +02008 * SPDX-License-Identifier: GPL-2.0+
wdenk507bbe32004-04-18 21:13:41 +00009 */
10
11#include <common.h>
12#include <command.h>
Michal Simekcfc67112007-03-11 13:48:24 +010013#include <image.h>
Jean-Christophe PLAGNIOL-VILLARDa31e0912009-04-04 12:49:11 +020014#include <u-boot/zlib.h>
Michal Simekcfc67112007-03-11 13:48:24 +010015#include <asm/byteorder.h>
wdenk507bbe32004-04-18 21:13:41 +000016
Michal Simekcfc67112007-03-11 13:48:24 +010017DECLARE_GLOBAL_DATA_PTR;
18
Michal Simek1e71fa42013-05-02 12:51:48 +020019int do_bootm_linux(int flag, int argc, char * const argv[],
20 bootm_headers_t *images)
wdenk507bbe32004-04-18 21:13:41 +000021{
Michal Simekcfc67112007-03-11 13:48:24 +010022 /* First parameter is mapped to $r5 for kernel boot args */
Michal Simek1e71fa42013-05-02 12:51:48 +020023 void (*thekernel) (char *, ulong, ulong);
24 char *commandline = getenv("bootargs");
Arun Bhanu398b1d52010-04-15 18:27:17 +080025 ulong rd_data_start, rd_data_end;
Michal Simekcfc67112007-03-11 13:48:24 +010026
Andreas Bießmann2cb0e552013-07-02 13:57:44 +020027 /*
28 * allow the PREP bootm subcommand, it is required for bootm to work
29 */
30 if (flag & BOOTM_STATE_OS_PREP)
31 return 0;
32
Kumar Gala49c3a862008-10-21 17:25:45 -050033 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
34 return 1;
35
Arun Bhanu398b1d52010-04-15 18:27:17 +080036 int ret;
37
38 char *of_flat_tree = NULL;
39#if defined(CONFIG_OF_LIBFDT)
John Rigby5a75e122010-10-13 13:57:34 -060040 /* did generic code already find a device tree? */
41 if (images->ft_len)
42 of_flat_tree = images->ft_addr;
Arun Bhanu398b1d52010-04-15 18:27:17 +080043#endif
44
Michal Simek1e71fa42013-05-02 12:51:48 +020045 thekernel = (void (*)(char *, ulong, ulong))images->ep;
Arun Bhanu398b1d52010-04-15 18:27:17 +080046
47 /* find ramdisk */
Michal Simek1e71fa42013-05-02 12:51:48 +020048 ret = boot_get_ramdisk(argc, argv, images, IH_ARCH_MICROBLAZE,
Arun Bhanu398b1d52010-04-15 18:27:17 +080049 &rd_data_start, &rd_data_end);
50 if (ret)
51 return 1;
Michal Simekcfc67112007-03-11 13:48:24 +010052
Simon Glass770605e2012-02-13 13:51:18 +000053 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
Michal Simekcfc67112007-03-11 13:48:24 +010054
Simon Glass983c72f2013-06-11 11:14:46 -070055 if (!of_flat_tree && argc > 1)
56 of_flat_tree = (char *)simple_strtoul(argv[1], NULL, 16);
Michal Simeka8425d52013-05-02 12:49:18 +020057
58 /* fixup the initrd now that we know where it should be */
59 if (images->rd_start && images->rd_end && of_flat_tree)
60 ret = fdt_initrd(of_flat_tree, images->rd_start,
Masahiro Yamadadbe963a2014-04-18 17:40:59 +090061 images->rd_end);
Michal Simeka8425d52013-05-02 12:49:18 +020062 if (ret)
63 return 1;
64
Michal Simekcfc67112007-03-11 13:48:24 +010065#ifdef DEBUG
Michal Simek1e71fa42013-05-02 12:51:48 +020066 printf("## Transferring control to Linux (at address 0x%08lx) ",
67 (ulong)thekernel);
68 printf("ramdisk 0x%08lx, FDT 0x%08lx...\n",
69 rd_data_start, (ulong) of_flat_tree);
Michal Simekcfc67112007-03-11 13:48:24 +010070#endif
71
Michal Simek9b4d9052010-04-16 12:01:32 +020072#ifdef XILINX_USE_DCACHE
Michal Simek9b4d9052010-04-16 12:01:32 +020073 flush_cache(0, XILINX_DCACHE_BYTE_SIZE);
Michal Simek9b4d9052010-04-16 12:01:32 +020074#endif
Arun Bhanu398b1d52010-04-15 18:27:17 +080075 /*
76 * Linux Kernel Parameters (passing device tree):
77 * r5: pointer to command line
78 * r6: pointer to ramdisk
79 * r7: pointer to the fdt, followed by the board info data
80 */
Michal Simek1e71fa42013-05-02 12:51:48 +020081 thekernel(commandline, rd_data_start, (ulong)of_flat_tree);
Marian Balakowiczcd7c5962008-03-12 10:33:00 +010082 /* does not return */
Jean-Christophe PLAGNIOL-VILLARDa3a08c02008-09-10 22:48:09 +020083
Kumar Gala40d7e992008-08-15 08:24:45 -050084 return 1;
wdenk507bbe32004-04-18 21:13:41 +000085}