]> Git Repo - u-boot.git/blame - arch/arc/lib/bootm.c
bootm: Adjust arguments of boot_os_fn
[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
a48336e5 6#include <bootm.h>
52f24238 7#include <bootstage.h>
09140113 8#include <env.h>
4d72caa5 9#include <image.h>
36bf446b 10#include <irq_func.h>
f7ae49fc 11#include <log.h>
375945ba 12#include <asm/cache.h>
401d1c4f 13#include <asm/global_data.h>
22723828
AB
14
15DECLARE_GLOBAL_DATA_PTR;
16
22723828
AB
17static int cleanup_before_linux(void)
18{
19 disable_interrupts();
375945ba 20 sync_n_cleanup_cache_all();
22723828
AB
21
22 return 0;
23}
24
d9d7c20b 25__weak int board_prep_linux(struct bootm_headers *images) { return 0; }
f665c14f 26
22723828 27/* Subcommand: PREP */
d9d7c20b 28static int boot_prep_linux(struct bootm_headers *images)
22723828 29{
f665c14f
EP
30 int ret;
31
210af549 32 if (IS_ENABLED(CONFIG_LMB)) {
65168910
ARS
33 ret = image_setup_linux(images);
34 if (ret)
35 return ret;
36 }
f665c14f
EP
37
38 return board_prep_linux(images);
22723828
AB
39}
40
f665c14f
EP
41/* Generic implementation for single core CPU */
42__weak void board_jump_and_run(ulong entry, int zero, int arch, uint params)
43{
44 void (*kernel_entry)(int zero, int arch, uint params);
45
46 kernel_entry = (void (*)(int, int, uint))entry;
47
48 kernel_entry(zero, arch, params);
49}
8b2eb776 50
22723828 51/* Subcommand: GO */
d9d7c20b 52static void boot_jump_linux(struct bootm_headers *images, int flag)
22723828 53{
f665c14f 54 ulong kernel_entry;
22723828
AB
55 unsigned int r0, r2;
56 int fake = (flag & BOOTM_STATE_OS_FAKE_GO);
57
f665c14f 58 kernel_entry = images->ep;
22723828
AB
59
60 debug("## Transferring control to Linux (at address %08lx)...\n",
f665c14f 61 kernel_entry);
22723828
AB
62 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
63
64 printf("\nStarting kernel ...%s\n\n", fake ?
65 "(fake run for tracing)" : "");
66 bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel");
67
0c303f9a 68 if (CONFIG_IS_ENABLED(OF_LIBFDT) && images->ft_len) {
22723828
AB
69 r0 = 2;
70 r2 = (unsigned int)images->ft_addr;
71 } else {
72 r0 = 1;
00caae6d 73 r2 = (unsigned int)env_get("bootargs");
22723828
AB
74 }
75
f665c14f
EP
76 cleanup_before_linux();
77
78 if (!fake)
79 board_jump_and_run(kernel_entry, r0, 0, r2);
22723828
AB
80}
81
a48336e5 82int do_bootm_linux(int flag, struct bootm_info *bmi)
22723828 83{
a48336e5
SG
84 struct bootm_headers *images = bmi->images;
85
22723828
AB
86 /* No need for those on ARC */
87 if ((flag & BOOTM_STATE_OS_BD_T) || (flag & BOOTM_STATE_OS_CMDLINE))
88 return -1;
89
f665c14f
EP
90 if (flag & BOOTM_STATE_OS_PREP)
91 return boot_prep_linux(images);
22723828
AB
92
93 if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
94 boot_jump_linux(images, flag);
95 return 0;
96 }
97
f665c14f 98 return -1;
22723828 99}
This page took 0.233298 seconds and 4 git commands to generate.