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