]>
Commit | Line | Data |
---|---|---|
0b135cfc NI |
1 | /* |
2 | * (C) Copyright 2003 | |
3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | |
4 | * | |
6b44a439 NI |
5 | * (c) Copyright 2008 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com> |
6 | * (c) Copyright 2008 Renesas Solutions Corp. | |
7 | * | |
1a459660 | 8 | * SPDX-License-Identifier: GPL-2.0+ |
0b135cfc NI |
9 | */ |
10 | ||
11 | #include <common.h> | |
12 | #include <command.h> | |
13 | #include <asm/byteorder.h> | |
9980df56 | 14 | #include <asm/zimage.h> |
0b135cfc | 15 | |
6d0f6bcf | 16 | #ifdef CONFIG_SYS_DEBUG |
6b44a439 | 17 | static void hexdump(unsigned char *buf, int len) |
0b135cfc NI |
18 | { |
19 | int i; | |
20 | ||
21 | for (i = 0; i < len; i++) { | |
22 | if ((i % 16) == 0) | |
6b44a439 NI |
23 | printf("%s%08x: ", i ? "\n" : "", |
24 | (unsigned int)&buf[i]); | |
25 | printf("%02x ", buf[i]); | |
0b135cfc | 26 | } |
6b44a439 | 27 | printf("\n"); |
0b135cfc NI |
28 | } |
29 | #endif | |
30 | ||
cf2c87d3 NI |
31 | #ifdef CONFIG_SH_SDRAM_OFFSET |
32 | #define GET_INITRD_START(initrd, linux) (initrd - linux + CONFIG_SH_SDRAM_OFFSET) | |
33 | #else | |
34 | #define GET_INITRD_START(initrd, linux) (initrd - linux) | |
35 | #endif | |
36 | ||
37 | static void set_sh_linux_param(unsigned long param_addr, unsigned long data) | |
38 | { | |
39 | *(unsigned long *)(param_addr) = data; | |
40 | } | |
41 | ||
42 | static unsigned long sh_check_cmd_arg(char *cmdline, char *key, int base) | |
43 | { | |
44 | unsigned long val = 0; | |
45 | char *p = strstr(cmdline, key); | |
46 | if (p) { | |
47 | p += strlen(key); | |
48 | val = simple_strtol(p, NULL, base); | |
49 | } | |
50 | return val; | |
51 | } | |
52 | ||
54841ab5 | 53 | int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images) |
0b135cfc | 54 | { |
6b44a439 | 55 | /* Linux kernel load address */ |
c160a954 | 56 | void (*kernel) (void) = (void (*)(void))images->ep; |
6b44a439 | 57 | /* empty_zero_page */ |
b5d10a13 NI |
58 | unsigned char *param |
59 | = (unsigned char *)image_get_load(images->legacy_hdr_os); | |
6b44a439 | 60 | /* Linux kernel command line */ |
cf2c87d3 | 61 | char *cmdline = (char *)param + COMMAND_LINE; |
6b44a439 | 62 | /* PAGE_SIZE */ |
b5d10a13 | 63 | unsigned long size = images->ep - (unsigned long)param; |
00caae6d | 64 | char *bootargs = env_get("bootargs"); |
0b135cfc | 65 | |
2cb0e55a AB |
66 | /* |
67 | * allow the PREP bootm subcommand, it is required for bootm to work | |
68 | */ | |
69 | if (flag & BOOTM_STATE_OS_PREP) | |
70 | return 0; | |
71 | ||
49c3a861 KG |
72 | if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) |
73 | return 1; | |
74 | ||
9980df56 NI |
75 | /* Clear zero page */ |
76 | memset(param, 0, size); | |
cf2c87d3 NI |
77 | |
78 | /* Set commandline */ | |
6b44a439 | 79 | strcpy(cmdline, bootargs); |
b02bad12 | 80 | |
cf2c87d3 NI |
81 | /* Initrd */ |
82 | if (images->rd_start || images->rd_end) { | |
de03f8bc | 83 | unsigned long ramdisk_flags = 0; |
cf2c87d3 NI |
84 | int val = sh_check_cmd_arg(bootargs, CMD_ARG_RD_PROMPT, 10); |
85 | if (val == 1) | |
86 | ramdisk_flags |= RD_PROMPT; | |
87 | else | |
88 | ramdisk_flags &= ~RD_PROMPT; | |
071bc923 | 89 | |
cf2c87d3 NI |
90 | val = sh_check_cmd_arg(bootargs, CMD_ARG_RD_DOLOAD, 10); |
91 | if (val == 1) | |
92 | ramdisk_flags |= RD_DOLOAD; | |
93 | else | |
94 | ramdisk_flags &= ~RD_DOLOAD; | |
95 | ||
96 | set_sh_linux_param((unsigned long)param + MOUNT_ROOT_RDONLY, 0x0001); | |
97 | set_sh_linux_param((unsigned long)param + RAMDISK_FLAGS, ramdisk_flags); | |
98 | set_sh_linux_param((unsigned long)param + ORIG_ROOT_DEV, 0x0200); | |
99 | set_sh_linux_param((unsigned long)param + LOADER_TYPE, 0x0001); | |
100 | set_sh_linux_param((unsigned long)param + INITRD_START, | |
101 | GET_INITRD_START(images->rd_start, CONFIG_SYS_SDRAM_BASE)); | |
102 | set_sh_linux_param((unsigned long)param + INITRD_SIZE, | |
103 | images->rd_end - images->rd_start); | |
104 | } | |
105 | ||
106 | /* Boot kernel */ | |
0b135cfc | 107 | kernel(); |
cd7c596e | 108 | |
9980df56 | 109 | /* does not return */ |
40d7e99d | 110 | return 1; |
0b135cfc | 111 | } |