]> Git Repo - J-u-boot.git/blob - arch/arc/lib/bootm.c
Merge tag 'u-boot-imx-master-20250127' of https://gitlab.denx.de/u-boot/custodians...
[J-u-boot.git] / arch / arc / lib / bootm.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
4  */
5
6 #include <bootm.h>
7 #include <bootstage.h>
8 #include <env.h>
9 #include <image.h>
10 #include <irq_func.h>
11 #include <log.h>
12 #include <asm/cache.h>
13 #include <asm/global_data.h>
14
15 DECLARE_GLOBAL_DATA_PTR;
16
17 static int cleanup_before_linux(void)
18 {
19         disable_interrupts();
20         sync_n_cleanup_cache_all();
21
22         return 0;
23 }
24
25 __weak int board_prep_linux(struct bootm_headers *images) { return 0; }
26
27 /* Subcommand: PREP */
28 static int boot_prep_linux(struct bootm_headers *images)
29 {
30         int ret;
31
32         if (IS_ENABLED(CONFIG_LMB)) {
33                 ret = image_setup_linux(images);
34                 if (ret)
35                         return ret;
36         }
37
38         return board_prep_linux(images);
39 }
40
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 }
50
51 /* Subcommand: GO */
52 static void boot_jump_linux(struct bootm_headers *images, int flag)
53 {
54         ulong kernel_entry;
55         unsigned int r0, r2;
56         int fake = (flag & BOOTM_STATE_OS_FAKE_GO);
57
58         kernel_entry = images->ep;
59
60         debug("## Transferring control to Linux (at address %08lx)...\n",
61               kernel_entry);
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
68         if (CONFIG_IS_ENABLED(OF_LIBFDT) && images->ft_len) {
69                 r0 = 2;
70                 r2 = (unsigned int)images->ft_addr;
71         } else {
72                 r0 = 1;
73                 r2 = (unsigned int)env_get("bootargs");
74         }
75
76         cleanup_before_linux();
77
78         if (!fake)
79                 board_jump_and_run(kernel_entry, r0, 0, r2);
80 }
81
82 int do_bootm_linux(int flag, struct bootm_info *bmi)
83 {
84         struct bootm_headers *images = bmi->images;
85
86         /* No need for those on ARC */
87         if ((flag & BOOTM_STATE_OS_BD_T) || (flag & BOOTM_STATE_OS_CMDLINE))
88                 return -1;
89
90         if (flag & BOOTM_STATE_OS_PREP)
91                 return boot_prep_linux(images);
92
93         if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
94                 boot_jump_linux(images, flag);
95                 return 0;
96         }
97
98         return -1;
99 }
This page took 0.030021 seconds and 4 git commands to generate.