]>
Commit | Line | Data |
---|---|---|
c609719b WD |
1 | /* |
2 | * (C) Copyright 2002 | |
3 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> | |
4 | * Marius Groeger <mgroeger@sysgo.de> | |
5 | * | |
6 | * Copyright (C) 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
232c150a | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
c609719b WD |
16 | * GNU General Public License for more details. |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
232c150a | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
c609719b WD |
21 | * |
22 | */ | |
23 | ||
24 | #include <common.h> | |
25 | #include <command.h> | |
c609719b WD |
26 | #include <image.h> |
27 | #include <zlib.h> | |
28 | #include <asm/byteorder.h> | |
29 | ||
d87080b7 WD |
30 | DECLARE_GLOBAL_DATA_PTR; |
31 | ||
c609719b WD |
32 | #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ |
33 | defined (CONFIG_CMDLINE_TAG) || \ | |
34 | defined (CONFIG_INITRD_TAG) || \ | |
b6e4c403 WD |
35 | defined (CONFIG_SERIAL_TAG) || \ |
36 | defined (CONFIG_REVISION_TAG) || \ | |
8655b6f8 WD |
37 | defined (CONFIG_VFD) || \ |
38 | defined (CONFIG_LCD) | |
5779d8d9 WD |
39 | static void setup_start_tag (bd_t *bd); |
40 | ||
699b13a6 | 41 | # ifdef CONFIG_SETUP_MEMORY_TAGS |
5779d8d9 | 42 | static void setup_memory_tags (bd_t *bd); |
699b13a6 | 43 | # endif |
5779d8d9 WD |
44 | static void setup_commandline_tag (bd_t *bd, char *commandline); |
45 | ||
c609719b | 46 | #if 0 |
5779d8d9 | 47 | static void setup_ramdisk_tag (bd_t *bd); |
c609719b | 48 | #endif |
699b13a6 | 49 | # ifdef CONFIG_INITRD_TAG |
5779d8d9 WD |
50 | static void setup_initrd_tag (bd_t *bd, ulong initrd_start, |
51 | ulong initrd_end); | |
699b13a6 | 52 | # endif |
5779d8d9 WD |
53 | static void setup_end_tag (bd_t *bd); |
54 | ||
8655b6f8 | 55 | # if defined (CONFIG_VFD) || defined (CONFIG_LCD) |
5779d8d9 | 56 | static void setup_videolfb_tag (gd_t *gd); |
699b13a6 | 57 | # endif |
c609719b | 58 | |
c609719b WD |
59 | static struct tag *params; |
60 | #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ | |
61 | ||
d5934ad7 MB |
62 | extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); |
63 | ||
5779d8d9 | 64 | void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], |
8a5ea3e6 | 65 | bootm_headers_t *images) |
c609719b | 66 | { |
d5934ad7 MB |
67 | ulong initrd_start, initrd_end; |
68 | ulong ep = 0; | |
69 | bd_t *bd = gd->bd; | |
70 | char *s; | |
71 | int machid = bd->bi_arch_number; | |
72 | void (*theKernel)(int zero, int arch, uint params); | |
5779d8d9 | 73 | |
c609719b | 74 | #ifdef CONFIG_CMDLINE_TAG |
5779d8d9 | 75 | char *commandline = getenv ("bootargs"); |
c609719b WD |
76 | #endif |
77 | ||
d5934ad7 MB |
78 | /* find kernel entry point */ |
79 | if (images->legacy_hdr_valid) { | |
80 | ep = image_get_ep (images->legacy_hdr_os); | |
81 | #if defined(CONFIG_FIT) | |
82 | } else if (images->fit_uname_os) { | |
83 | fit_unsupported_reset ("ARM linux bootm"); | |
84 | do_reset (cmdtp, flag, argc, argv); | |
85 | #endif | |
86 | } else { | |
87 | puts ("Could not find kernel entry point!\n"); | |
88 | do_reset (cmdtp, flag, argc, argv); | |
89 | } | |
90 | theKernel = (void (*)(int, int, uint))ep; | |
c609719b | 91 | |
3c234efa UKK |
92 | s = getenv ("machid"); |
93 | if (s) { | |
94 | machid = simple_strtoul (s, NULL, 16); | |
95 | printf ("Using machid 0x%x from environment\n", machid); | |
96 | } | |
97 | ||
8a5ea3e6 | 98 | get_ramdisk (cmdtp, flag, argc, argv, images, |
5ad03eb3 | 99 | IH_ARCH_ARM, &initrd_start, &initrd_end); |
c609719b | 100 | |
fad63407 | 101 | show_boot_progress (15); |
384ae025 | 102 | |
5779d8d9 WD |
103 | debug ("## Transferring control to Linux (at address %08lx) ...\n", |
104 | (ulong) theKernel); | |
c609719b WD |
105 | |
106 | #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ | |
107 | defined (CONFIG_CMDLINE_TAG) || \ | |
108 | defined (CONFIG_INITRD_TAG) || \ | |
b6e4c403 WD |
109 | defined (CONFIG_SERIAL_TAG) || \ |
110 | defined (CONFIG_REVISION_TAG) || \ | |
8655b6f8 | 111 | defined (CONFIG_LCD) || \ |
c609719b | 112 | defined (CONFIG_VFD) |
5779d8d9 | 113 | setup_start_tag (bd); |
b6e4c403 WD |
114 | #ifdef CONFIG_SERIAL_TAG |
115 | setup_serial_tag (¶ms); | |
116 | #endif | |
117 | #ifdef CONFIG_REVISION_TAG | |
118 | setup_revision_tag (¶ms); | |
119 | #endif | |
c609719b | 120 | #ifdef CONFIG_SETUP_MEMORY_TAGS |
5779d8d9 | 121 | setup_memory_tags (bd); |
c609719b WD |
122 | #endif |
123 | #ifdef CONFIG_CMDLINE_TAG | |
5779d8d9 | 124 | setup_commandline_tag (bd, commandline); |
c609719b WD |
125 | #endif |
126 | #ifdef CONFIG_INITRD_TAG | |
5779d8d9 WD |
127 | if (initrd_start && initrd_end) |
128 | setup_initrd_tag (bd, initrd_start, initrd_end); | |
c609719b | 129 | #endif |
8655b6f8 | 130 | #if defined (CONFIG_VFD) || defined (CONFIG_LCD) |
5779d8d9 | 131 | setup_videolfb_tag ((gd_t *) gd); |
c609719b | 132 | #endif |
5779d8d9 | 133 | setup_end_tag (bd); |
c609719b WD |
134 | #endif |
135 | ||
75fa002c KG |
136 | if (!images->autostart) |
137 | return ; | |
138 | ||
5779d8d9 WD |
139 | /* we assume that the kernel is in place */ |
140 | printf ("\nStarting kernel ...\n\n"); | |
c609719b | 141 | |
232c150a WD |
142 | #ifdef CONFIG_USB_DEVICE |
143 | { | |
144 | extern void udc_disconnect (void); | |
145 | udc_disconnect (); | |
146 | } | |
147 | #endif | |
148 | ||
5779d8d9 | 149 | cleanup_before_linux (); |
c609719b | 150 | |
3c234efa | 151 | theKernel (0, machid, bd->bi_boot_params); |
c609719b WD |
152 | } |
153 | ||
154 | ||
155 | #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ | |
156 | defined (CONFIG_CMDLINE_TAG) || \ | |
157 | defined (CONFIG_INITRD_TAG) || \ | |
b6e4c403 WD |
158 | defined (CONFIG_SERIAL_TAG) || \ |
159 | defined (CONFIG_REVISION_TAG) || \ | |
8655b6f8 | 160 | defined (CONFIG_LCD) || \ |
c609719b | 161 | defined (CONFIG_VFD) |
5779d8d9 | 162 | static void setup_start_tag (bd_t *bd) |
c609719b | 163 | { |
5779d8d9 | 164 | params = (struct tag *) bd->bi_boot_params; |
c609719b | 165 | |
5779d8d9 WD |
166 | params->hdr.tag = ATAG_CORE; |
167 | params->hdr.size = tag_size (tag_core); | |
c609719b | 168 | |
5779d8d9 WD |
169 | params->u.core.flags = 0; |
170 | params->u.core.pagesize = 0; | |
171 | params->u.core.rootdev = 0; | |
c609719b | 172 | |
5779d8d9 | 173 | params = tag_next (params); |
c609719b WD |
174 | } |
175 | ||
176 | ||
699b13a6 | 177 | #ifdef CONFIG_SETUP_MEMORY_TAGS |
5779d8d9 | 178 | static void setup_memory_tags (bd_t *bd) |
c609719b | 179 | { |
5779d8d9 | 180 | int i; |
c609719b | 181 | |
5779d8d9 WD |
182 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { |
183 | params->hdr.tag = ATAG_MEM; | |
184 | params->hdr.size = tag_size (tag_mem32); | |
c609719b | 185 | |
5779d8d9 WD |
186 | params->u.mem.start = bd->bi_dram[i].start; |
187 | params->u.mem.size = bd->bi_dram[i].size; | |
c609719b | 188 | |
5779d8d9 WD |
189 | params = tag_next (params); |
190 | } | |
c609719b | 191 | } |
5779d8d9 | 192 | #endif /* CONFIG_SETUP_MEMORY_TAGS */ |
c609719b WD |
193 | |
194 | ||
5779d8d9 | 195 | static void setup_commandline_tag (bd_t *bd, char *commandline) |
c609719b | 196 | { |
5779d8d9 | 197 | char *p; |
c609719b | 198 | |
109c0e3a WD |
199 | if (!commandline) |
200 | return; | |
201 | ||
5779d8d9 WD |
202 | /* eat leading white space */ |
203 | for (p = commandline; *p == ' '; p++); | |
c609719b | 204 | |
5779d8d9 WD |
205 | /* skip non-existent command lines so the kernel will still |
206 | * use its default command line. | |
207 | */ | |
208 | if (*p == '\0') | |
209 | return; | |
c609719b | 210 | |
5779d8d9 WD |
211 | params->hdr.tag = ATAG_CMDLINE; |
212 | params->hdr.size = | |
213 | (sizeof (struct tag_header) + strlen (p) + 1 + 4) >> 2; | |
c609719b | 214 | |
5779d8d9 | 215 | strcpy (params->u.cmdline.cmdline, p); |
c609719b | 216 | |
5779d8d9 | 217 | params = tag_next (params); |
c609719b WD |
218 | } |
219 | ||
220 | ||
699b13a6 | 221 | #ifdef CONFIG_INITRD_TAG |
5779d8d9 | 222 | static void setup_initrd_tag (bd_t *bd, ulong initrd_start, ulong initrd_end) |
c609719b | 223 | { |
5779d8d9 WD |
224 | /* an ATAG_INITRD node tells the kernel where the compressed |
225 | * ramdisk can be found. ATAG_RDIMG is a better name, actually. | |
226 | */ | |
498b8db7 | 227 | params->hdr.tag = ATAG_INITRD2; |
5779d8d9 | 228 | params->hdr.size = tag_size (tag_initrd); |
c609719b | 229 | |
5779d8d9 WD |
230 | params->u.initrd.start = initrd_start; |
231 | params->u.initrd.size = initrd_end - initrd_start; | |
c609719b | 232 | |
5779d8d9 | 233 | params = tag_next (params); |
c609719b | 234 | } |
5779d8d9 | 235 | #endif /* CONFIG_INITRD_TAG */ |
c609719b WD |
236 | |
237 | ||
8655b6f8 WD |
238 | #if defined (CONFIG_VFD) || defined (CONFIG_LCD) |
239 | extern ulong calc_fbsize (void); | |
5779d8d9 | 240 | static void setup_videolfb_tag (gd_t *gd) |
c609719b | 241 | { |
5779d8d9 WD |
242 | /* An ATAG_VIDEOLFB node tells the kernel where and how large |
243 | * the framebuffer for video was allocated (among other things). | |
244 | * Note that a _physical_ address is passed ! | |
245 | * | |
246 | * We only use it to pass the address and size, the other entries | |
247 | * in the tag_videolfb are not of interest. | |
248 | */ | |
249 | params->hdr.tag = ATAG_VIDEOLFB; | |
250 | params->hdr.size = tag_size (tag_videolfb); | |
c609719b | 251 | |
5779d8d9 | 252 | params->u.videolfb.lfb_base = (u32) gd->fb_base; |
8655b6f8 WD |
253 | /* Fb size is calculated according to parameters for our panel |
254 | */ | |
255 | params->u.videolfb.lfb_size = calc_fbsize(); | |
c609719b | 256 | |
5779d8d9 | 257 | params = tag_next (params); |
c609719b | 258 | } |
8655b6f8 | 259 | #endif /* CONFIG_VFD || CONFIG_LCD */ |
c609719b | 260 | |
3a574cbe WD |
261 | #ifdef CONFIG_SERIAL_TAG |
262 | void setup_serial_tag (struct tag **tmp) | |
263 | { | |
264 | struct tag *params = *tmp; | |
265 | struct tag_serialnr serialnr; | |
266 | void get_board_serial(struct tag_serialnr *serialnr); | |
267 | ||
268 | get_board_serial(&serialnr); | |
269 | params->hdr.tag = ATAG_SERIAL; | |
270 | params->hdr.size = tag_size (tag_serialnr); | |
271 | params->u.serialnr.low = serialnr.low; | |
272 | params->u.serialnr.high= serialnr.high; | |
273 | params = tag_next (params); | |
274 | *tmp = params; | |
275 | } | |
276 | #endif | |
277 | ||
289f932c WD |
278 | #ifdef CONFIG_REVISION_TAG |
279 | void setup_revision_tag(struct tag **in_params) | |
280 | { | |
281 | u32 rev = 0; | |
289f932c WD |
282 | u32 get_board_rev(void); |
283 | ||
284 | rev = get_board_rev(); | |
289f932c WD |
285 | params->hdr.tag = ATAG_REVISION; |
286 | params->hdr.size = tag_size (tag_revision); | |
287 | params->u.revision.rev = rev; | |
288 | params = tag_next (params); | |
289 | } | |
290 | #endif /* CONFIG_REVISION_TAG */ | |
291 | ||
292 | ||
5779d8d9 | 293 | static void setup_end_tag (bd_t *bd) |
c609719b | 294 | { |
5779d8d9 WD |
295 | params->hdr.tag = ATAG_NONE; |
296 | params->hdr.size = 0; | |
c609719b WD |
297 | } |
298 | ||
299 | #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ |