3 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
4 * Marius Groeger <mgroeger@sysgo.de>
6 * Copyright (C) 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl)
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.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
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
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include <asm/byteorder.h>
30 DECLARE_GLOBAL_DATA_PTR;
32 #if defined (CONFIG_SETUP_MEMORY_TAGS) || \
33 defined (CONFIG_CMDLINE_TAG) || \
34 defined (CONFIG_INITRD_TAG) || \
35 defined (CONFIG_SERIAL_TAG) || \
36 defined (CONFIG_REVISION_TAG) || \
37 defined (CONFIG_VFD) || \
39 static void setup_start_tag (bd_t *bd);
41 # ifdef CONFIG_SETUP_MEMORY_TAGS
42 static void setup_memory_tags (bd_t *bd);
44 static void setup_commandline_tag (bd_t *bd, char *commandline);
46 # ifdef CONFIG_INITRD_TAG
47 static void setup_initrd_tag (bd_t *bd, ulong initrd_start,
50 static void setup_end_tag (bd_t *bd);
52 # if defined (CONFIG_VFD) || defined (CONFIG_LCD)
53 static void setup_videolfb_tag (gd_t *gd);
56 static struct tag *params;
57 #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */
59 extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
61 void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
62 bootm_headers_t *images)
64 ulong initrd_start, initrd_end;
68 int machid = bd->bi_arch_number;
69 void (*theKernel)(int zero, int arch, uint params);
72 #ifdef CONFIG_CMDLINE_TAG
73 char *commandline = getenv ("bootargs");
76 /* find kernel entry point */
77 if (images->legacy_hdr_valid) {
78 ep = image_get_ep (&images->legacy_hdr_os_copy);
79 #if defined(CONFIG_FIT)
80 } else if (images->fit_uname_os) {
81 ret = fit_image_get_entry (images->fit_hdr_os,
82 images->fit_noffset_os, &ep);
84 puts ("Can't get entry point property!\n");
89 puts ("Could not find kernel entry point!\n");
92 theKernel = (void (*)(int, int, uint))ep;
94 s = getenv ("machid");
96 machid = simple_strtoul (s, NULL, 16);
97 printf ("Using machid 0x%x from environment\n", machid);
100 ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_ARM,
101 &initrd_start, &initrd_end);
105 show_boot_progress (15);
107 debug ("## Transferring control to Linux (at address %08lx) ...\n",
110 #if defined (CONFIG_SETUP_MEMORY_TAGS) || \
111 defined (CONFIG_CMDLINE_TAG) || \
112 defined (CONFIG_INITRD_TAG) || \
113 defined (CONFIG_SERIAL_TAG) || \
114 defined (CONFIG_REVISION_TAG) || \
115 defined (CONFIG_LCD) || \
117 setup_start_tag (bd);
118 #ifdef CONFIG_SERIAL_TAG
119 setup_serial_tag (¶ms);
121 #ifdef CONFIG_REVISION_TAG
122 setup_revision_tag (¶ms);
124 #ifdef CONFIG_SETUP_MEMORY_TAGS
125 setup_memory_tags (bd);
127 #ifdef CONFIG_CMDLINE_TAG
128 setup_commandline_tag (bd, commandline);
130 #ifdef CONFIG_INITRD_TAG
131 if (initrd_start && initrd_end)
132 setup_initrd_tag (bd, initrd_start, initrd_end);
134 #if defined (CONFIG_VFD) || defined (CONFIG_LCD)
135 setup_videolfb_tag ((gd_t *) gd);
140 /* we assume that the kernel is in place */
141 printf ("\nStarting kernel ...\n\n");
143 #ifdef CONFIG_USB_DEVICE
145 extern void udc_disconnect (void);
150 cleanup_before_linux ();
152 theKernel (0, machid, bd->bi_boot_params);
153 /* does not return */
157 do_reset (cmdtp, flag, argc, argv);
162 #if defined (CONFIG_SETUP_MEMORY_TAGS) || \
163 defined (CONFIG_CMDLINE_TAG) || \
164 defined (CONFIG_INITRD_TAG) || \
165 defined (CONFIG_SERIAL_TAG) || \
166 defined (CONFIG_REVISION_TAG) || \
167 defined (CONFIG_LCD) || \
169 static void setup_start_tag (bd_t *bd)
171 params = (struct tag *) bd->bi_boot_params;
173 params->hdr.tag = ATAG_CORE;
174 params->hdr.size = tag_size (tag_core);
176 params->u.core.flags = 0;
177 params->u.core.pagesize = 0;
178 params->u.core.rootdev = 0;
180 params = tag_next (params);
184 #ifdef CONFIG_SETUP_MEMORY_TAGS
185 static void setup_memory_tags (bd_t *bd)
189 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
190 params->hdr.tag = ATAG_MEM;
191 params->hdr.size = tag_size (tag_mem32);
193 params->u.mem.start = bd->bi_dram[i].start;
194 params->u.mem.size = bd->bi_dram[i].size;
196 params = tag_next (params);
199 #endif /* CONFIG_SETUP_MEMORY_TAGS */
202 static void setup_commandline_tag (bd_t *bd, char *commandline)
209 /* eat leading white space */
210 for (p = commandline; *p == ' '; p++);
212 /* skip non-existent command lines so the kernel will still
213 * use its default command line.
218 params->hdr.tag = ATAG_CMDLINE;
220 (sizeof (struct tag_header) + strlen (p) + 1 + 4) >> 2;
222 strcpy (params->u.cmdline.cmdline, p);
224 params = tag_next (params);
228 #ifdef CONFIG_INITRD_TAG
229 static void setup_initrd_tag (bd_t *bd, ulong initrd_start, ulong initrd_end)
231 /* an ATAG_INITRD node tells the kernel where the compressed
232 * ramdisk can be found. ATAG_RDIMG is a better name, actually.
234 params->hdr.tag = ATAG_INITRD2;
235 params->hdr.size = tag_size (tag_initrd);
237 params->u.initrd.start = initrd_start;
238 params->u.initrd.size = initrd_end - initrd_start;
240 params = tag_next (params);
242 #endif /* CONFIG_INITRD_TAG */
245 #if defined (CONFIG_VFD) || defined (CONFIG_LCD)
246 extern ulong calc_fbsize (void);
247 static void setup_videolfb_tag (gd_t *gd)
249 /* An ATAG_VIDEOLFB node tells the kernel where and how large
250 * the framebuffer for video was allocated (among other things).
251 * Note that a _physical_ address is passed !
253 * We only use it to pass the address and size, the other entries
254 * in the tag_videolfb are not of interest.
256 params->hdr.tag = ATAG_VIDEOLFB;
257 params->hdr.size = tag_size (tag_videolfb);
259 params->u.videolfb.lfb_base = (u32) gd->fb_base;
260 /* Fb size is calculated according to parameters for our panel
262 params->u.videolfb.lfb_size = calc_fbsize();
264 params = tag_next (params);
266 #endif /* CONFIG_VFD || CONFIG_LCD */
268 #ifdef CONFIG_SERIAL_TAG
269 void setup_serial_tag (struct tag **tmp)
271 struct tag *params = *tmp;
272 struct tag_serialnr serialnr;
273 void get_board_serial(struct tag_serialnr *serialnr);
275 get_board_serial(&serialnr);
276 params->hdr.tag = ATAG_SERIAL;
277 params->hdr.size = tag_size (tag_serialnr);
278 params->u.serialnr.low = serialnr.low;
279 params->u.serialnr.high= serialnr.high;
280 params = tag_next (params);
285 #ifdef CONFIG_REVISION_TAG
286 void setup_revision_tag(struct tag **in_params)
289 u32 get_board_rev(void);
291 rev = get_board_rev();
292 params->hdr.tag = ATAG_REVISION;
293 params->hdr.size = tag_size (tag_revision);
294 params->u.revision.rev = rev;
295 params = tag_next (params);
297 #endif /* CONFIG_REVISION_TAG */
300 static void setup_end_tag (bd_t *bd)
302 params->hdr.tag = ATAG_NONE;
303 params->hdr.size = 0;
306 #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */