]> git.ipfire.org Git - people/ms/u-boot.git/blame - arch/microblaze/lib/bootm.c
fdt: Implement weak arch_fixup_fdt()
[people/ms/u-boot.git] / arch / microblaze / lib / bootm.c
CommitLineData
507bbe3e 1/*
cfc67116 2 * (C) Copyright 2007 Michal Simek
507bbe3e
WD
3 * (C) Copyright 2004 Atmark Techno, Inc.
4 *
cfc67116 5 * Michal SIMEK <monstr@monstr.eu>
507bbe3e
WD
6 * Yasushi SHOJI <yashi@atmark-techno.com>
7 *
3765b3e7 8 * SPDX-License-Identifier: GPL-2.0+
507bbe3e
WD
9 */
10
11#include <common.h>
12#include <command.h>
73223f0e 13#include <fdt_support.h>
cfc67116 14#include <image.h>
a31e091a 15#include <u-boot/zlib.h>
cfc67116 16#include <asm/byteorder.h>
507bbe3e 17
cfc67116
MS
18DECLARE_GLOBAL_DATA_PTR;
19
1e71fa43
MS
20int do_bootm_linux(int flag, int argc, char * const argv[],
21 bootm_headers_t *images)
507bbe3e 22{
cfc67116 23 /* First parameter is mapped to $r5 for kernel boot args */
1e71fa43 24 void (*thekernel) (char *, ulong, ulong);
00caae6d 25 char *commandline = env_get("bootargs");
398b1d57 26 ulong rd_data_start, rd_data_end;
cfc67116 27
2cb0e55a
AB
28 /*
29 * allow the PREP bootm subcommand, it is required for bootm to work
30 */
31 if (flag & BOOTM_STATE_OS_PREP)
32 return 0;
33
49c3a861
KG
34 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
35 return 1;
36
398b1d57
AB
37 int ret;
38
39 char *of_flat_tree = NULL;
40#if defined(CONFIG_OF_LIBFDT)
5a75e121
JR
41 /* did generic code already find a device tree? */
42 if (images->ft_len)
43 of_flat_tree = images->ft_addr;
398b1d57
AB
44#endif
45
1e71fa43 46 thekernel = (void (*)(char *, ulong, ulong))images->ep;
398b1d57
AB
47
48 /* find ramdisk */
1e71fa43 49 ret = boot_get_ramdisk(argc, argv, images, IH_ARCH_MICROBLAZE,
398b1d57
AB
50 &rd_data_start, &rd_data_end);
51 if (ret)
52 return 1;
cfc67116 53
770605e4 54 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
cfc67116 55
983c72f4
SG
56 if (!of_flat_tree && argc > 1)
57 of_flat_tree = (char *)simple_strtoul(argv[1], NULL, 16);
a8425d52
MS
58
59 /* fixup the initrd now that we know where it should be */
244ce78a 60 if (images->rd_start && images->rd_end && of_flat_tree) {
a8425d52 61 ret = fdt_initrd(of_flat_tree, images->rd_start,
dbe963ae 62 images->rd_end);
a8425d52
MS
63 if (ret)
64 return 1;
244ce78a 65 }
a8425d52 66
cfc67116 67#ifdef DEBUG
1e71fa43
MS
68 printf("## Transferring control to Linux (at address 0x%08lx) ",
69 (ulong)thekernel);
70 printf("ramdisk 0x%08lx, FDT 0x%08lx...\n",
71 rd_data_start, (ulong) of_flat_tree);
cfc67116
MS
72#endif
73
9b4d9056 74#ifdef XILINX_USE_DCACHE
9b4d9056 75 flush_cache(0, XILINX_DCACHE_BYTE_SIZE);
9b4d9056 76#endif
398b1d57
AB
77 /*
78 * Linux Kernel Parameters (passing device tree):
79 * r5: pointer to command line
80 * r6: pointer to ramdisk
81 * r7: pointer to the fdt, followed by the board info data
82 */
1e71fa43 83 thekernel(commandline, rd_data_start, (ulong)of_flat_tree);
cd7c596e 84 /* does not return */
a3a08c0c 85
40d7e99d 86 return 1;
507bbe3e 87}