1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2011 Andes Technology Corporation
14 #include <asm/byteorder.h>
16 #include <dm/device.h>
18 #include <u-boot/zlib.h>
20 DECLARE_GLOBAL_DATA_PTR;
22 __weak void board_quiesce_devices(void)
26 int arch_fixup_fdt(void *blob)
32 * announce_and_cleanup() - Print message and prepare for kernel boot
34 * @fake: non-zero to do everything except actually boot
36 static void announce_and_cleanup(int fake)
38 printf("\nStarting kernel ...%s\n\n", fake ?
39 "(fake run for tracing)" : "");
40 bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel");
41 #ifdef CONFIG_BOOTSTAGE_FDT
42 bootstage_fdt_add_report();
44 #ifdef CONFIG_BOOTSTAGE_REPORT
48 #ifdef CONFIG_USB_DEVICE
52 board_quiesce_devices();
55 * Call remove function of all devices with a removal flag set.
56 * This may be useful for last-stage operations, like cancelling
57 * of DMA operation or releasing device internal buffers.
59 dm_remove_devices_flags(DM_REMOVE_ACTIVE_ALL);
61 cleanup_before_linux();
64 static void boot_prep_linux(bootm_headers_t *images)
66 if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
67 #ifdef CONFIG_OF_LIBFDT
68 debug("using: FDT\n");
69 if (image_setup_linux(images)) {
70 printf("FDT creation failed! hanging...");
75 printf("Device tree not found or missing FDT support\n");
80 static void boot_jump_linux(bootm_headers_t *images, int flag)
82 void (*kernel)(ulong hart, void *dtb);
83 int fake = (flag & BOOTM_STATE_OS_FAKE_GO);
85 kernel = (void (*)(ulong, void *))images->ep;
87 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
89 debug("## Transferring control to kernel (at address %08lx) ...\n",
92 announce_and_cleanup(fake);
95 if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len)
96 kernel(gd->arch.boot_hart, images->ft_addr);
100 int do_bootm_linux(int flag, int argc, char * const argv[],
101 bootm_headers_t *images)
103 /* No need for those on RISC-V */
104 if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE)
107 if (flag & BOOTM_STATE_OS_PREP) {
108 boot_prep_linux(images);
112 if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
113 boot_jump_linux(images, flag);
117 boot_prep_linux(images);
118 boot_jump_linux(images, flag);
122 int do_bootm_vxworks(int flag, int argc, char * const argv[],
123 bootm_headers_t *images)
125 return do_bootm_linux(flag, argc, argv, images);