1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
12 #include <asm/cache.h>
13 #include <asm/global_data.h>
15 DECLARE_GLOBAL_DATA_PTR;
17 static int cleanup_before_linux(void)
20 sync_n_cleanup_cache_all();
25 __weak int board_prep_linux(struct bootm_headers *images) { return 0; }
27 /* Subcommand: PREP */
28 static int boot_prep_linux(struct bootm_headers *images)
32 if (IS_ENABLED(CONFIG_LMB)) {
33 ret = image_setup_linux(images);
38 return board_prep_linux(images);
41 /* Generic implementation for single core CPU */
42 __weak void board_jump_and_run(ulong entry, int zero, int arch, uint params)
44 void (*kernel_entry)(int zero, int arch, uint params);
46 kernel_entry = (void (*)(int, int, uint))entry;
48 kernel_entry(zero, arch, params);
52 static void boot_jump_linux(struct bootm_headers *images, int flag)
56 int fake = (flag & BOOTM_STATE_OS_FAKE_GO);
58 kernel_entry = images->ep;
60 debug("## Transferring control to Linux (at address %08lx)...\n",
62 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
64 printf("\nStarting kernel ...%s\n\n", fake ?
65 "(fake run for tracing)" : "");
66 bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel");
68 if (CONFIG_IS_ENABLED(OF_LIBFDT) && images->ft_len) {
70 r2 = (unsigned int)images->ft_addr;
73 r2 = (unsigned int)env_get("bootargs");
76 cleanup_before_linux();
79 board_jump_and_run(kernel_entry, r0, 0, r2);
82 int do_bootm_linux(int flag, struct bootm_info *bmi)
84 struct bootm_headers *images = bmi->images;
86 /* No need for those on ARC */
87 if ((flag & BOOTM_STATE_OS_BD_T) || (flag & BOOTM_STATE_OS_CMDLINE))
90 if (flag & BOOTM_STATE_OS_PREP)
91 return boot_prep_linux(images);
93 if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
94 boot_jump_linux(images, flag);