blob: 24ca0a724980813c895bc7dce104f399e62c28fe [file] [log] [blame]
Stefan Kristianssoncfbf96b2011-11-26 19:04:52 +00001/*
2 * (C) Copyright 2011 Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
3 *
4 * Based on microblaze implementation by:
5 * (C) Copyright 2007 Michal Simek
6 * (C) Copyright 2004 Atmark Techno, Inc.
7 *
8 * Michal SIMEK <monstr@monstr.eu>
9 * Yasushi SHOJI <yashi@atmark-techno.com>
10 *
11 * See file CREDITS for list of people who contributed to this
12 * project.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 * MA 02111-1307 USA
28 */
29
30#include <common.h>
31#include <command.h>
32#include <image.h>
33#include <u-boot/zlib.h>
34#include <asm/byteorder.h>
35
36DECLARE_GLOBAL_DATA_PTR;
37
38int do_bootm_linux(int flag, int argc, char * const argv[],
39 bootm_headers_t *images)
40{
41 void (*kernel) (unsigned int);
42 ulong rd_data_start, rd_data_end;
43
Andreas Bießmannda233ce2013-07-02 13:57:44 +020044 /*
45 * allow the PREP bootm subcommand, it is required for bootm to work
46 */
47 if (flag & BOOTM_STATE_OS_PREP)
48 return 0;
49
Stefan Kristianssoncfbf96b2011-11-26 19:04:52 +000050 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
51 return 1;
52
53 int ret;
54
55 char *of_flat_tree = NULL;
56#if defined(CONFIG_OF_LIBFDT)
57 /* did generic code already find a device tree? */
58 if (images->ft_len)
59 of_flat_tree = images->ft_addr;
60#endif
61
62 kernel = (void (*)(unsigned int))images->ep;
63
64 /* find ramdisk */
65 ret = boot_get_ramdisk(argc, argv, images, IH_ARCH_OPENRISC,
66 &rd_data_start, &rd_data_end);
67 if (ret)
68 return 1;
69
70 show_boot_progress(15);
71
Simon Glass794a9212013-06-11 11:14:46 -070072 if (!of_flat_tree && argc > 1)
73 of_flat_tree = (char *)simple_strtoul(argv[1], NULL, 16);
Stefan Kristianssoncfbf96b2011-11-26 19:04:52 +000074#ifdef DEBUG
75 printf("## Transferring control to Linux (at address 0x%08lx) " \
76 "ramdisk 0x%08lx, FDT 0x%08lx...\n",
77 (ulong) kernel, rd_data_start, (ulong) of_flat_tree);
78#endif
79 if (dcache_status() || icache_status())
80 flush_cache((ulong)kernel, max(checkdcache(), checkicache()));
81
82 /*
83 * Linux Kernel Parameters (passing device tree):
84 * r3: pointer to the fdt, followed by the board info data
85 */
86 kernel((unsigned int) of_flat_tree);
87 /* does not return */
88
89 return 1;
90}