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