1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include <common.h>
28#include <command.h>
29#include <asm/byteorder.h>
30#include <asm/zimage.h>
31
32#ifdef CONFIG_SYS_DEBUG
33static void hexdump(unsigned char *buf, int len)
34{
35 int i;
36
37 for (i = 0; i < len; i++) {
38 if ((i % 16) == 0)
39 printf("%s%08x: ", i ? "\n" : "",
40 (unsigned int)&buf[i]);
41 printf("%02x ", buf[i]);
42 }
43 printf("\n");
44}
45#endif
46
47#ifdef CONFIG_SH_SDRAM_OFFSET
48#define GET_INITRD_START(initrd, linux) (initrd - linux + CONFIG_SH_SDRAM_OFFSET)
49#else
50#define GET_INITRD_START(initrd, linux) (initrd - linux)
51#endif
52
53static void set_sh_linux_param(unsigned long param_addr, unsigned long data)
54{
55 *(unsigned long *)(param_addr) = data;
56}
57
58static unsigned long sh_check_cmd_arg(char *cmdline, char *key, int base)
59{
60 unsigned long val = 0;
61 char *p = strstr(cmdline, key);
62 if (p) {
63 p += strlen(key);
64 val = simple_strtol(p, NULL, base);
65 }
66 return val;
67}
68
69int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images)
70{
71
72 void (*kernel) (void) = (void (*)(void))images->ep;
73
74 unsigned char *param
75 = (unsigned char *)image_get_load(images->legacy_hdr_os);
76
77 char *cmdline = (char *)param + COMMAND_LINE;
78
79 unsigned long size = images->ep - (unsigned long)param;
80 char *bootargs = getenv("bootargs");
81
82 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
83 return 1;
84
85
86 memset(param, 0, size);
87
88
89 strcpy(cmdline, bootargs);
90
91
92 if (images->rd_start || images->rd_end) {
93 unsigned long ramdisk_flags = 0;
94 int val = sh_check_cmd_arg(bootargs, CMD_ARG_RD_PROMPT, 10);
95 if (val == 1)
96 ramdisk_flags |= RD_PROMPT;
97 else
98 ramdisk_flags &= ~RD_PROMPT;
99
100 val = sh_check_cmd_arg(bootargs, CMD_ARG_RD_DOLOAD, 10);
101 if (val == 1)
102 ramdisk_flags |= RD_DOLOAD;
103 else
104 ramdisk_flags &= ~RD_DOLOAD;
105
106 set_sh_linux_param((unsigned long)param + MOUNT_ROOT_RDONLY, 0x0001);
107 set_sh_linux_param((unsigned long)param + RAMDISK_FLAGS, ramdisk_flags);
108 set_sh_linux_param((unsigned long)param + ORIG_ROOT_DEV, 0x0200);
109 set_sh_linux_param((unsigned long)param + LOADER_TYPE, 0x0001);
110 set_sh_linux_param((unsigned long)param + INITRD_START,
111 GET_INITRD_START(images->rd_start, CONFIG_SYS_SDRAM_BASE));
112 set_sh_linux_param((unsigned long)param + INITRD_SIZE,
113 images->rd_end - images->rd_start);
114 }
115
116
117 kernel();
118
119
120 return 1;
121}
122