blob: 6977dd641aba734e23d599127e2a901bb2e397b8 [file] [log] [blame]
wdenk12490652004-04-18 21:13:41 +00001/*
Michal Simek922ce202007-03-11 13:48:24 +01002 * (C) Copyright 2007 Michal Simek
wdenk12490652004-04-18 21:13:41 +00003 * (C) Copyright 2004 Atmark Techno, Inc.
4 *
Michal Simek922ce202007-03-11 13:48:24 +01005 * Michal SIMEK <monstr@monstr.eu>
wdenk12490652004-04-18 21:13:41 +00006 * Yasushi SHOJI <yashi@atmark-techno.com>
7 *
Wolfgang Denkbd8ec7e2013-10-07 13:07:26 +02008 * SPDX-License-Identifier: GPL-2.0+
wdenk12490652004-04-18 21:13:41 +00009 */
10
11#include <common.h>
12#include <command.h>
Michal Simek922ce202007-03-11 13:48:24 +010013#include <image.h>
Jean-Christophe PLAGNIOL-VILLARD6bb94492009-04-04 12:49:11 +020014#include <u-boot/zlib.h>
Michal Simek922ce202007-03-11 13:48:24 +010015#include <asm/byteorder.h>
wdenk12490652004-04-18 21:13:41 +000016
Michal Simek922ce202007-03-11 13:48:24 +010017DECLARE_GLOBAL_DATA_PTR;
18
Michal Simekc78ce292013-05-02 12:51:48 +020019int do_bootm_linux(int flag, int argc, char * const argv[],
20 bootm_headers_t *images)
wdenk12490652004-04-18 21:13:41 +000021{
Michal Simek922ce202007-03-11 13:48:24 +010022 /* First parameter is mapped to $r5 for kernel boot args */
Michal Simekc78ce292013-05-02 12:51:48 +020023 void (*thekernel) (char *, ulong, ulong);
24 char *commandline = getenv("bootargs");
Arun Bhanu2304c052010-04-15 18:27:17 +080025 ulong rd_data_start, rd_data_end;
Michal Simek922ce202007-03-11 13:48:24 +010026
Andreas Bießmannda233ce2013-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 Gala18178bc2008-10-21 17:25:45 -050033 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
34 return 1;
35
Arun Bhanu2304c052010-04-15 18:27:17 +080036 int ret;
37
38 char *of_flat_tree = NULL;
39#if defined(CONFIG_OF_LIBFDT)
John Rigby708e6672010-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 Bhanu2304c052010-04-15 18:27:17 +080043#endif
44
Michal Simekc78ce292013-05-02 12:51:48 +020045 thekernel = (void (*)(char *, ulong, ulong))images->ep;
Arun Bhanu2304c052010-04-15 18:27:17 +080046
47 /* find ramdisk */
Michal Simekc78ce292013-05-02 12:51:48 +020048 ret = boot_get_ramdisk(argc, argv, images, IH_ARCH_MICROBLAZE,
Arun Bhanu2304c052010-04-15 18:27:17 +080049 &rd_data_start, &rd_data_end);
50 if (ret)
51 return 1;
Michal Simek922ce202007-03-11 13:48:24 +010052
Simon Glass0169e6b2012-02-13 13:51:18 +000053 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
Michal Simek922ce202007-03-11 13:48:24 +010054
Simon Glass794a9212013-06-11 11:14:46 -070055 if (!of_flat_tree && argc > 1)
56 of_flat_tree = (char *)simple_strtoul(argv[1], NULL, 16);
Michal Simek70b1c492013-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 Yamada5b114892014-04-18 17:40:59 +090061 images->rd_end);
Michal Simek70b1c492013-05-02 12:49:18 +020062 if (ret)
63 return 1;
64
Michal Simek922ce202007-03-11 13:48:24 +010065#ifdef DEBUG
Michal Simekc78ce292013-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 Simek922ce202007-03-11 13:48:24 +010070#endif
71
Michal Simek80c42c72010-04-16 12:01:32 +020072#ifdef XILINX_USE_DCACHE
Michal Simek80c42c72010-04-16 12:01:32 +020073 flush_cache(0, XILINX_DCACHE_BYTE_SIZE);
Michal Simek80c42c72010-04-16 12:01:32 +020074#endif
Arun Bhanu2304c052010-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 Simekc78ce292013-05-02 12:51:48 +020081 thekernel(commandline, rd_data_start, (ulong)of_flat_tree);
Marian Balakowiczdf8ff332008-03-12 10:33:00 +010082 /* does not return */
Jean-Christophe PLAGNIOL-VILLARD7ed7a272008-09-10 22:48:09 +020083
Kumar Gala48626aa2008-08-15 08:24:45 -050084 return 1;
wdenk12490652004-04-18 21:13:41 +000085}