]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/openrisc/lib/bootm.c
2c5d9aea9969650d0be7a0e4883e5121c36691e7
[karo-tx-uboot.git] / arch / openrisc / lib / bootm.c
1 /*
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
36 DECLARE_GLOBAL_DATA_PTR;
37
38 int 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
44         if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
45                 return 1;
46
47         int     ret;
48
49         char    *of_flat_tree = NULL;
50 #if defined(CONFIG_OF_LIBFDT)
51         /* did generic code already find a device tree? */
52         if (images->ft_len)
53                 of_flat_tree = images->ft_addr;
54 #endif
55
56         kernel = (void (*)(unsigned int))images->ep;
57
58         /* find ramdisk */
59         ret = boot_get_ramdisk(argc, argv, images, IH_ARCH_OPENRISC,
60                         &rd_data_start, &rd_data_end);
61         if (ret)
62                 return 1;
63
64         show_boot_progress(15);
65
66         if (!of_flat_tree && argc > 3)
67                 of_flat_tree = (char *)simple_strtoul(argv[3], NULL, 16);
68 #ifdef DEBUG
69         printf("## Transferring control to Linux (at address 0x%08lx) " \
70                                 "ramdisk 0x%08lx, FDT 0x%08lx...\n",
71                 (ulong) kernel, rd_data_start, (ulong) of_flat_tree);
72 #endif
73         if (dcache_status() || icache_status())
74                 flush_cache((ulong)kernel, max(checkdcache(), checkicache()));
75
76         /*
77          * Linux Kernel Parameters (passing device tree):
78          * r3: pointer to the fdt, followed by the board info data
79          */
80         kernel((unsigned int) of_flat_tree);
81         /* does not return */
82
83         return 1;
84 }