blob: 9242fa891ac25795067dc3ede0c635342a258921 [file] [log] [blame]
Rick Chen8bbb2902017-12-26 13:55:49 +08001/*
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
17DECLARE_GLOBAL_DATA_PTR;
18
19int arch_fixup_fdt(void *blob)
20{
21 return 0;
22}
23
Rick Chen8bbb2902017-12-26 13:55:49 +080024int 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 Chen04623582018-03-13 14:48:33 +080029 void (*theKernel)(int arch, uint params);
Rick Chen8bbb2902017-12-26 13:55:49 +080030
Rick Chen8bbb2902017-12-26 13:55:49 +080031 /*
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 Chen04623582018-03-13 14:48:33 +080040 theKernel = (void (*)(int, uint))images->ep;
Rick Chen8bbb2902017-12-26 13:55:49 +080041
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 Chen22b7e6f2018-03-13 14:59:41 +080061 }
Rick Chen8bbb2902017-12-26 13:55:49 +080062
63 /* we assume that the kernel is in place */
64 printf("\nStarting kernel ...\n\n");
65
Rick Chen8bbb2902017-12-26 13:55:49 +080066 cleanup_before_linux();
67 if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len)
Rick Chen04623582018-03-13 14:48:33 +080068 theKernel(machid, (unsigned long)images->ft_addr);
Rick Chen22b7e6f2018-03-13 14:59:41 +080069
Rick Chen8bbb2902017-12-26 13:55:49 +080070 /* does not return */
71
72 return 1;
73}