]> Git Repo - J-u-boot.git/blame - arch/arc/lib/bootm.c
common: Drop image.h from common header
[J-u-boot.git] / arch / arc / lib / bootm.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
22723828
AB
2/*
3 * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
22723828
AB
4 */
5
52f24238
SG
6#include <common.h>
7#include <bootstage.h>
4d72caa5 8#include <image.h>
36bf446b 9#include <irq_func.h>
4d72caa5 10#include <lmb.h>
375945ba 11#include <asm/cache.h>
22723828
AB
12
13DECLARE_GLOBAL_DATA_PTR;
14
15static ulong get_sp(void)
16{
17 ulong ret;
18
19 asm("mov %0, sp" : "=r"(ret) : );
20 return ret;
21}
22
23void arch_lmb_reserve(struct lmb *lmb)
24{
25 ulong sp;
26
27 /*
28 * Booting a (Linux) kernel image
29 *
30 * Allocate space for command line and board info - the
31 * address should be as high as possible within the reach of
32 * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
33 * memory, which means far enough below the current stack
34 * pointer.
35 */
36 sp = get_sp();
37 debug("## Current stack ends at 0x%08lx ", sp);
38
39 /* adjust sp by 4K to be safe */
40 sp -= 4096;
41 lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp));
42}
43
44static int cleanup_before_linux(void)
45{
46 disable_interrupts();
375945ba 47 sync_n_cleanup_cache_all();
22723828
AB
48
49 return 0;
50}
51
f665c14f
EP
52__weak int board_prep_linux(bootm_headers_t *images) { return 0; }
53
22723828 54/* Subcommand: PREP */
f665c14f 55static int boot_prep_linux(bootm_headers_t *images)
22723828 56{
f665c14f
EP
57 int ret;
58
59 ret = image_setup_linux(images);
60 if (ret)
61 return ret;
62
63 return board_prep_linux(images);
22723828
AB
64}
65
f665c14f
EP
66/* Generic implementation for single core CPU */
67__weak void board_jump_and_run(ulong entry, int zero, int arch, uint params)
68{
69 void (*kernel_entry)(int zero, int arch, uint params);
70
71 kernel_entry = (void (*)(int, int, uint))entry;
72
73 kernel_entry(zero, arch, params);
74}
8b2eb776 75
22723828
AB
76/* Subcommand: GO */
77static void boot_jump_linux(bootm_headers_t *images, int flag)
78{
f665c14f 79 ulong kernel_entry;
22723828
AB
80 unsigned int r0, r2;
81 int fake = (flag & BOOTM_STATE_OS_FAKE_GO);
82
f665c14f 83 kernel_entry = images->ep;
22723828
AB
84
85 debug("## Transferring control to Linux (at address %08lx)...\n",
f665c14f 86 kernel_entry);
22723828
AB
87 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
88
89 printf("\nStarting kernel ...%s\n\n", fake ?
90 "(fake run for tracing)" : "");
91 bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel");
92
22723828
AB
93 if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
94 r0 = 2;
95 r2 = (unsigned int)images->ft_addr;
96 } else {
97 r0 = 1;
00caae6d 98 r2 = (unsigned int)env_get("bootargs");
22723828
AB
99 }
100
f665c14f
EP
101 cleanup_before_linux();
102
103 if (!fake)
104 board_jump_and_run(kernel_entry, r0, 0, r2);
22723828
AB
105}
106
107int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
108{
109 /* No need for those on ARC */
110 if ((flag & BOOTM_STATE_OS_BD_T) || (flag & BOOTM_STATE_OS_CMDLINE))
111 return -1;
112
f665c14f
EP
113 if (flag & BOOTM_STATE_OS_PREP)
114 return boot_prep_linux(images);
22723828
AB
115
116 if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
117 boot_jump_linux(images, flag);
118 return 0;
119 }
120
f665c14f 121 return -1;
22723828 122}
This page took 0.317534 seconds and 4 git commands to generate.