blob: 2732203b93e7f30489aa97b3d31f401ad28ee045 [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>
Simon Glass73223f02016-02-22 22:55:43 -070013#include <fdt_support.h>
Michal Simekcfc67112007-03-11 13:48:24 +010014#include <image.h>
Jean-Christophe PLAGNIOL-VILLARDa31e0912009-04-04 12:49:11 +020015#include <u-boot/zlib.h>
Michal Simekcfc67112007-03-11 13:48:24 +010016#include <asm/byteorder.h>
wdenk507bbe32004-04-18 21:13:41 +000017
Michal Simekcfc67112007-03-11 13:48:24 +010018DECLARE_GLOBAL_DATA_PTR;
19
Masahiro Yamada63c09412016-11-26 11:02:10 +090020int arch_fixup_fdt(void *blob)
21{
22 return 0;
23}
24
Michal Simek1e71fa42013-05-02 12:51:48 +020025int do_bootm_linux(int flag, int argc, char * const argv[],
26 bootm_headers_t *images)
wdenk507bbe32004-04-18 21:13:41 +000027{
Michal Simekcfc67112007-03-11 13:48:24 +010028 /* First parameter is mapped to $r5 for kernel boot args */
Michal Simek1e71fa42013-05-02 12:51:48 +020029 void (*thekernel) (char *, ulong, ulong);
30 char *commandline = getenv("bootargs");
Arun Bhanu398b1d52010-04-15 18:27:17 +080031 ulong rd_data_start, rd_data_end;
Michal Simekcfc67112007-03-11 13:48:24 +010032
Andreas Bießmann2cb0e552013-07-02 13:57:44 +020033 /*
34 * allow the PREP bootm subcommand, it is required for bootm to work
35 */
36 if (flag & BOOTM_STATE_OS_PREP)
37 return 0;
38
Kumar Gala49c3a862008-10-21 17:25:45 -050039 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
40 return 1;
41
Arun Bhanu398b1d52010-04-15 18:27:17 +080042 int ret;
43
44 char *of_flat_tree = NULL;
45#if defined(CONFIG_OF_LIBFDT)
John Rigby5a75e122010-10-13 13:57:34 -060046 /* did generic code already find a device tree? */
47 if (images->ft_len)
48 of_flat_tree = images->ft_addr;
Arun Bhanu398b1d52010-04-15 18:27:17 +080049#endif
50
Michal Simek1e71fa42013-05-02 12:51:48 +020051 thekernel = (void (*)(char *, ulong, ulong))images->ep;
Arun Bhanu398b1d52010-04-15 18:27:17 +080052
53 /* find ramdisk */
Michal Simek1e71fa42013-05-02 12:51:48 +020054 ret = boot_get_ramdisk(argc, argv, images, IH_ARCH_MICROBLAZE,
Arun Bhanu398b1d52010-04-15 18:27:17 +080055 &rd_data_start, &rd_data_end);
56 if (ret)
57 return 1;
Michal Simekcfc67112007-03-11 13:48:24 +010058
Simon Glass770605e2012-02-13 13:51:18 +000059 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
Michal Simekcfc67112007-03-11 13:48:24 +010060
Simon Glass983c72f2013-06-11 11:14:46 -070061 if (!of_flat_tree && argc > 1)
62 of_flat_tree = (char *)simple_strtoul(argv[1], NULL, 16);
Michal Simeka8425d52013-05-02 12:49:18 +020063
64 /* fixup the initrd now that we know where it should be */
65 if (images->rd_start && images->rd_end && of_flat_tree)
66 ret = fdt_initrd(of_flat_tree, images->rd_start,
Masahiro Yamadadbe963a2014-04-18 17:40:59 +090067 images->rd_end);
Michal Simeka8425d52013-05-02 12:49:18 +020068 if (ret)
69 return 1;
70
Michal Simekcfc67112007-03-11 13:48:24 +010071#ifdef DEBUG
Michal Simek1e71fa42013-05-02 12:51:48 +020072 printf("## Transferring control to Linux (at address 0x%08lx) ",
73 (ulong)thekernel);
74 printf("ramdisk 0x%08lx, FDT 0x%08lx...\n",
75 rd_data_start, (ulong) of_flat_tree);
Michal Simekcfc67112007-03-11 13:48:24 +010076#endif
77
Michal Simek9b4d9052010-04-16 12:01:32 +020078#ifdef XILINX_USE_DCACHE
Michal Simek9b4d9052010-04-16 12:01:32 +020079 flush_cache(0, XILINX_DCACHE_BYTE_SIZE);
Michal Simek9b4d9052010-04-16 12:01:32 +020080#endif
Arun Bhanu398b1d52010-04-15 18:27:17 +080081 /*
82 * Linux Kernel Parameters (passing device tree):
83 * r5: pointer to command line
84 * r6: pointer to ramdisk
85 * r7: pointer to the fdt, followed by the board info data
86 */
Michal Simek1e71fa42013-05-02 12:51:48 +020087 thekernel(commandline, rd_data_start, (ulong)of_flat_tree);
Marian Balakowiczcd7c5962008-03-12 10:33:00 +010088 /* does not return */
Jean-Christophe PLAGNIOL-VILLARDa3a08c02008-09-10 22:48:09 +020089
Kumar Gala40d7e992008-08-15 08:24:45 -050090 return 1;
wdenk507bbe32004-04-18 21:13:41 +000091}