]> git.ipfire.org Git - thirdparty/u-boot.git/blame - arch/nios2/lib/bootm.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[thirdparty/u-boot.git] / arch / nios2 / lib / bootm.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
5c952cf0
WD
2/*
3 * (C) Copyright 2003, Psyent Corporation <www.psyent.com>
4 * Scott McNutt <smcnutt@psyent.com>
5c952cf0
WD
5 */
6
d678a59d 7#include <common.h>
a48336e5 8#include <bootm.h>
1eb69ae4 9#include <cpu_func.h>
09140113 10#include <env.h>
4d72caa5 11#include <image.h>
36bf446b 12#include <irq_func.h>
f7ae49fc 13#include <log.h>
a02c18f3
MV
14#include <asm/global_data.h>
15
16DECLARE_GLOBAL_DATA_PTR;
0c1c117c 17
ed294157
TC
18#define NIOS_MAGIC 0x534f494e /* enable command line and initrd passing */
19
a48336e5 20int do_bootm_linux(int flag, struct bootm_info *bmi)
5c952cf0 21{
a48336e5 22 struct bootm_headers *images = bmi->images;
ed294157 23 void (*kernel)(int, int, int, char *) = (void *)images->ep;
00caae6d 24 char *commandline = env_get("bootargs");
ed294157
TC
25 ulong initrd_start = images->rd_start;
26 ulong initrd_end = images->rd_end;
06c5d30d
TC
27 char *of_flat_tree = NULL;
28#if defined(CONFIG_OF_LIBFDT)
5a75e121
JR
29 /* did generic code already find a device tree? */
30 if (images->ft_len)
31 of_flat_tree = images->ft_addr;
06c5d30d 32#endif
a48336e5
SG
33 /* TODO: Clean this up - the DT should already be set up */
34 if (!of_flat_tree && bmi->argc > 1)
35 of_flat_tree = (char *)hextoul(bmi->argv[1], NULL);
06c5d30d
TC
36 if (of_flat_tree)
37 initrd_end = (ulong)of_flat_tree;
0c1c117c 38
2cb0e55a
AB
39 /*
40 * allow the PREP bootm subcommand, it is required for bootm to work
41 */
42 if (flag & BOOTM_STATE_OS_PREP)
43 return 0;
44
49c3a861
KG
45 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
46 return 1;
47
0a7691e8 48 /* flushes data and instruction caches before calling the kernel */
ed294157 49 disable_interrupts();
21ff7344 50 flush_dcache_all();
0a7691e8 51
ed294157
TC
52 debug("bootargs=%s @ 0x%lx\n", commandline, (ulong)&commandline);
53 debug("initrd=0x%lx-0x%lx\n", (ulong)initrd_start, (ulong)initrd_end);
06c5d30d
TC
54 /* kernel parameters passing
55 * r4 : NIOS magic
56 * r5 : initrd start
57 * r6 : initrd end or fdt
58 * r7 : kernel command line
59 * fdt is passed to kernel via r6, the same as initrd_end. fdt will be
60 * verified with fdt magic. when both initrd and fdt are used at the
61 * same time, fdt must follow immediately after initrd.
62 */
ed294157 63 kernel(NIOS_MAGIC, initrd_start, initrd_end, commandline);
cd7c596e 64 /* does not return */
cd7c596e 65
40d7e99d 66 return 1;
5c952cf0 67}
a02c18f3
MV
68
69static ulong get_sp(void)
70{
71 ulong ret;
72
73 asm("mov %0, sp" : "=r"(ret) : );
74 return ret;
75}
76
77void arch_lmb_reserve(struct lmb *lmb)
78{
79 arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
80}