Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 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 | |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 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; |
Rick Chen | 0462358 | 2018-03-13 14:48:33 +0800 | [diff] [blame] | 29 | void (*theKernel)(int arch, uint params); |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 30 | |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 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 | |
Rick Chen | 0462358 | 2018-03-13 14:48:33 +0800 | [diff] [blame] | 40 | theKernel = (void (*)(int, uint))images->ep; |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 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 |
Rick Chen | 22b7e6f | 2018-03-13 14:59:41 +0800 | [diff] [blame^] | 61 | } |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 62 | |
| 63 | /* we assume that the kernel is in place */ |
| 64 | printf("\nStarting kernel ...\n\n"); |
| 65 | |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 66 | cleanup_before_linux(); |
| 67 | if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) |
Rick Chen | 0462358 | 2018-03-13 14:48:33 +0800 | [diff] [blame] | 68 | theKernel(machid, (unsigned long)images->ft_addr); |
Rick Chen | 22b7e6f | 2018-03-13 14:59:41 +0800 | [diff] [blame^] | 69 | |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 70 | /* does not return */ |
| 71 | |
| 72 | return 1; |
| 73 | } |