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;
67 int machid = bd->bi_arch_number;
68 void (*theKernel)(int zero, int arch, uint params);
71 #ifdef CONFIG_CMDLINE_TAG
72 char *commandline = getenv ("bootargs");
75 theKernel = (void (*)(int, int, uint))images->ep;
77 s = getenv ("machid");
79 machid = simple_strtoul (s, NULL, 16);
80 printf ("Using machid 0x%x from environment\n", machid);
83 ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_ARM,
84 &initrd_start, &initrd_end);
88 show_boot_progress (15);
90 debug ("## Transferring control to Linux (at address %08lx) ...\n",
93 #if defined (CONFIG_SETUP_MEMORY_TAGS) || \
94 defined (CONFIG_CMDLINE_TAG) || \
95 defined (CONFIG_INITRD_TAG) || \
96 defined (CONFIG_SERIAL_TAG) || \
97 defined (CONFIG_REVISION_TAG) || \
98 defined (CONFIG_LCD) || \
100 setup_start_tag (bd);
101 #ifdef CONFIG_SERIAL_TAG
102 setup_serial_tag (¶ms);
104 #ifdef CONFIG_REVISION_TAG
105 setup_revision_tag (¶ms);
107 #ifdef CONFIG_SETUP_MEMORY_TAGS
108 setup_memory_tags (bd);
110 #ifdef CONFIG_CMDLINE_TAG
111 setup_commandline_tag (bd, commandline);
113 #ifdef CONFIG_INITRD_TAG
114 if (initrd_start && initrd_end)
115 setup_initrd_tag (bd, initrd_start, initrd_end);
117 #if defined (CONFIG_VFD) || defined (CONFIG_LCD)
118 setup_videolfb_tag ((gd_t *) gd);
123 /* we assume that the kernel is in place */
124 printf ("\nStarting kernel ...\n\n");
126 #ifdef CONFIG_USB_DEVICE
128 extern void udc_disconnect (void);
133 cleanup_before_linux ();
135 theKernel (0, machid, bd->bi_boot_params);
136 /* does not return */
140 do_reset (cmdtp, flag, argc, argv);
145 #if defined (CONFIG_SETUP_MEMORY_TAGS) || \
146 defined (CONFIG_CMDLINE_TAG) || \
147 defined (CONFIG_INITRD_TAG) || \
148 defined (CONFIG_SERIAL_TAG) || \
149 defined (CONFIG_REVISION_TAG) || \
150 defined (CONFIG_LCD) || \
152 static void setup_start_tag (bd_t *bd)
154 params = (struct tag *) bd->bi_boot_params;
156 params->hdr.tag = ATAG_CORE;
157 params->hdr.size = tag_size (tag_core);
159 params->u.core.flags = 0;
160 params->u.core.pagesize = 0;
161 params->u.core.rootdev = 0;
163 params = tag_next (params);
167 #ifdef CONFIG_SETUP_MEMORY_TAGS
168 static void setup_memory_tags (bd_t *bd)
172 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
173 params->hdr.tag = ATAG_MEM;
174 params->hdr.size = tag_size (tag_mem32);
176 params->u.mem.start = bd->bi_dram[i].start;
177 params->u.mem.size = bd->bi_dram[i].size;
179 params = tag_next (params);
182 #endif /* CONFIG_SETUP_MEMORY_TAGS */
185 static void setup_commandline_tag (bd_t *bd, char *commandline)
192 /* eat leading white space */
193 for (p = commandline; *p == ' '; p++);
195 /* skip non-existent command lines so the kernel will still
196 * use its default command line.
201 params->hdr.tag = ATAG_CMDLINE;
203 (sizeof (struct tag_header) + strlen (p) + 1 + 4) >> 2;
205 strcpy (params->u.cmdline.cmdline, p);
207 params = tag_next (params);
211 #ifdef CONFIG_INITRD_TAG
212 static void setup_initrd_tag (bd_t *bd, ulong initrd_start, ulong initrd_end)
214 /* an ATAG_INITRD node tells the kernel where the compressed
215 * ramdisk can be found. ATAG_RDIMG is a better name, actually.
217 params->hdr.tag = ATAG_INITRD2;
218 params->hdr.size = tag_size (tag_initrd);
220 params->u.initrd.start = initrd_start;
221 params->u.initrd.size = initrd_end - initrd_start;
223 params = tag_next (params);
225 #endif /* CONFIG_INITRD_TAG */
228 #if defined (CONFIG_VFD) || defined (CONFIG_LCD)
229 extern ulong calc_fbsize (void);
230 static void setup_videolfb_tag (gd_t *gd)
232 /* An ATAG_VIDEOLFB node tells the kernel where and how large
233 * the framebuffer for video was allocated (among other things).
234 * Note that a _physical_ address is passed !
236 * We only use it to pass the address and size, the other entries
237 * in the tag_videolfb are not of interest.
239 params->hdr.tag = ATAG_VIDEOLFB;
240 params->hdr.size = tag_size (tag_videolfb);
242 params->u.videolfb.lfb_base = (u32) gd->fb_base;
243 /* Fb size is calculated according to parameters for our panel
245 params->u.videolfb.lfb_size = calc_fbsize();
247 params = tag_next (params);
249 #endif /* CONFIG_VFD || CONFIG_LCD */
251 #ifdef CONFIG_SERIAL_TAG
252 void setup_serial_tag (struct tag **tmp)
254 struct tag *params = *tmp;
255 struct tag_serialnr serialnr;
256 void get_board_serial(struct tag_serialnr *serialnr);
258 get_board_serial(&serialnr);
259 params->hdr.tag = ATAG_SERIAL;
260 params->hdr.size = tag_size (tag_serialnr);
261 params->u.serialnr.low = serialnr.low;
262 params->u.serialnr.high= serialnr.high;
263 params = tag_next (params);
268 #ifdef CONFIG_REVISION_TAG
269 void setup_revision_tag(struct tag **in_params)
272 u32 get_board_rev(void);
274 rev = get_board_rev();
275 params->hdr.tag = ATAG_REVISION;
276 params->hdr.size = tag_size (tag_revision);
277 params->u.revision.rev = rev;
278 params = tag_next (params);
280 #endif /* CONFIG_REVISION_TAG */
283 static void setup_end_tag (bd_t *bd)
285 params->hdr.tag = ATAG_NONE;
286 params->hdr.size = 0;
289 #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */