1 /* 2 * (C) Copyright 2007 Michal Simek 3 * (C) Copyright 2004 Atmark Techno, Inc. 4 * 5 * Michal SIMEK <monstr@monstr.eu> 6 * Yasushi SHOJI <yashi@atmark-techno.com> 7 * 8 * SPDX-License-Identifier: GPL-2.0+ 9 */ 10 11 #include <common.h> 12 #include <command.h> 13 #include <fdt_support.h> 14 #include <image.h> 15 #include <u-boot/zlib.h> 16 #include <asm/byteorder.h> 17 18 DECLARE_GLOBAL_DATA_PTR; 19 20 int arch_fixup_fdt(void *blob) 21 { 22 return 0; 23 } 24 25 int do_bootm_linux(int flag, int argc, char * const argv[], 26 bootm_headers_t *images) 27 { 28 /* First parameter is mapped to $r5 for kernel boot args */ 29 void (*thekernel) (char *, ulong, ulong); 30 char *commandline = env_get("bootargs"); 31 ulong rd_data_start, rd_data_end; 32 33 /* 34 * allow the PREP bootm subcommand, it is required for bootm to work 35 */ 36 if (flag & BOOTM_STATE_OS_PREP) 37 return 0; 38 39 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) 40 return 1; 41 42 int ret; 43 44 char *of_flat_tree = NULL; 45 #if defined(CONFIG_OF_LIBFDT) 46 /* did generic code already find a device tree? */ 47 if (images->ft_len) 48 of_flat_tree = images->ft_addr; 49 #endif 50 51 thekernel = (void (*)(char *, ulong, ulong))images->ep; 52 53 /* find ramdisk */ 54 ret = boot_get_ramdisk(argc, argv, images, IH_ARCH_MICROBLAZE, 55 &rd_data_start, &rd_data_end); 56 if (ret) 57 return 1; 58 59 bootstage_mark(BOOTSTAGE_ID_RUN_OS); 60 61 if (!of_flat_tree && argc > 1) 62 of_flat_tree = (char *)simple_strtoul(argv[1], NULL, 16); 63 64 /* fixup the initrd now that we know where it should be */ 65 if (images->rd_start && images->rd_end && of_flat_tree) 66 ret = fdt_initrd(of_flat_tree, images->rd_start, 67 images->rd_end); 68 if (ret) 69 return 1; 70 71 #ifdef DEBUG 72 printf("## Transferring control to Linux (at address 0x%08lx) ", 73 (ulong)thekernel); 74 printf("ramdisk 0x%08lx, FDT 0x%08lx...\n", 75 rd_data_start, (ulong) of_flat_tree); 76 #endif 77 78 #ifdef XILINX_USE_DCACHE 79 flush_cache(0, XILINX_DCACHE_BYTE_SIZE); 80 #endif 81 /* 82 * Linux Kernel Parameters (passing device tree): 83 * r5: pointer to command line 84 * r6: pointer to ramdisk 85 * r7: pointer to the fdt, followed by the board info data 86 */ 87 thekernel(commandline, rd_data_start, (ulong)of_flat_tree); 88 /* does not return */ 89 90 return 1; 91 } 92