1 /* 2 * Copyright (C) 2011 Andes Technology Corporation 3 * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com> 4 * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com> 5 * Rick Chen, Andes Technology Corporation <rick@andestech.com> 6 * 7 * SPDX-License-Identifier: GPL-2.0+ 8 */ 9 10 #include <common.h> 11 #include <command.h> 12 #include <image.h> 13 #include <u-boot/zlib.h> 14 #include <asm/byteorder.h> 15 #include <asm/bootm.h> 16 17 DECLARE_GLOBAL_DATA_PTR; 18 19 int arch_fixup_fdt(void *blob) 20 { 21 return 0; 22 } 23 24 int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) 25 { 26 bd_t *bd = gd->bd; 27 char *s; 28 int machid = bd->bi_arch_number; 29 void (*theKernel)(int arch, uint params); 30 31 /* 32 * allow the PREP bootm subcommand, it is required for bootm to work 33 */ 34 if (flag & BOOTM_STATE_OS_PREP) 35 return 0; 36 37 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) 38 return 1; 39 40 theKernel = (void (*)(int, uint))images->ep; 41 42 s = env_get("machid"); 43 if (s) { 44 machid = simple_strtoul(s, NULL, 16); 45 printf("Using machid 0x%x from environment\n", machid); 46 } 47 48 bootstage_mark(BOOTSTAGE_ID_RUN_OS); 49 50 debug("## Transferring control to Linux (at address %08lx) ...\n", 51 (ulong)theKernel); 52 53 if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) { 54 #ifdef CONFIG_OF_LIBFDT 55 debug("using: FDT\n"); 56 if (image_setup_linux(images)) { 57 printf("FDT creation failed! hanging..."); 58 hang(); 59 } 60 #endif 61 } 62 63 /* we assume that the kernel is in place */ 64 printf("\nStarting kernel ...\n\n"); 65 66 cleanup_before_linux(); 67 if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) 68 theKernel(machid, (unsigned long)images->ft_addr); 69 70 /* does not return */ 71 72 return 1; 73 } 74