]> git.ipfire.org Git - people/ms/u-boot.git/blob - lib_arm/bootm.c
[new uImage] Remove unnecessary arguments passed to ramdisk routines
[people/ms/u-boot.git] / lib_arm / bootm.c
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
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24 #include <common.h>
25 #include <command.h>
26 #include <image.h>
27 #include <zlib.h>
28 #include <asm/byteorder.h>
29
30 DECLARE_GLOBAL_DATA_PTR;
31
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) || \
38 defined (CONFIG_LCD)
39 static void setup_start_tag (bd_t *bd);
40
41 # ifdef CONFIG_SETUP_MEMORY_TAGS
42 static void setup_memory_tags (bd_t *bd);
43 # endif
44 static void setup_commandline_tag (bd_t *bd, char *commandline);
45
46 #if 0
47 static void setup_ramdisk_tag (bd_t *bd);
48 #endif
49 # ifdef CONFIG_INITRD_TAG
50 static void setup_initrd_tag (bd_t *bd, ulong initrd_start,
51 ulong initrd_end);
52 # endif
53 static void setup_end_tag (bd_t *bd);
54
55 # if defined (CONFIG_VFD) || defined (CONFIG_LCD)
56 static void setup_videolfb_tag (gd_t *gd);
57 # endif
58
59 static struct tag *params;
60 #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */
61
62 extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
63
64 void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
65 bootm_headers_t *images)
66 {
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);
73
74 #ifdef CONFIG_CMDLINE_TAG
75 char *commandline = getenv ("bootargs");
76 #endif
77
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;
91
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
98 ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_ARM,
99 &initrd_start, &initrd_end);
100 if (ret)
101 do_reset (cmdtp, flag, argc, argv);
102
103 show_boot_progress (15);
104
105 debug ("## Transferring control to Linux (at address %08lx) ...\n",
106 (ulong) theKernel);
107
108 #if defined (CONFIG_SETUP_MEMORY_TAGS) || \
109 defined (CONFIG_CMDLINE_TAG) || \
110 defined (CONFIG_INITRD_TAG) || \
111 defined (CONFIG_SERIAL_TAG) || \
112 defined (CONFIG_REVISION_TAG) || \
113 defined (CONFIG_LCD) || \
114 defined (CONFIG_VFD)
115 setup_start_tag (bd);
116 #ifdef CONFIG_SERIAL_TAG
117 setup_serial_tag (&params);
118 #endif
119 #ifdef CONFIG_REVISION_TAG
120 setup_revision_tag (&params);
121 #endif
122 #ifdef CONFIG_SETUP_MEMORY_TAGS
123 setup_memory_tags (bd);
124 #endif
125 #ifdef CONFIG_CMDLINE_TAG
126 setup_commandline_tag (bd, commandline);
127 #endif
128 #ifdef CONFIG_INITRD_TAG
129 if (initrd_start && initrd_end)
130 setup_initrd_tag (bd, initrd_start, initrd_end);
131 #endif
132 #if defined (CONFIG_VFD) || defined (CONFIG_LCD)
133 setup_videolfb_tag ((gd_t *) gd);
134 #endif
135 setup_end_tag (bd);
136 #endif
137
138 if (!images->autostart)
139 return ;
140
141 /* we assume that the kernel is in place */
142 printf ("\nStarting kernel ...\n\n");
143
144 #ifdef CONFIG_USB_DEVICE
145 {
146 extern void udc_disconnect (void);
147 udc_disconnect ();
148 }
149 #endif
150
151 cleanup_before_linux ();
152
153 theKernel (0, machid, bd->bi_boot_params);
154 }
155
156
157 #if defined (CONFIG_SETUP_MEMORY_TAGS) || \
158 defined (CONFIG_CMDLINE_TAG) || \
159 defined (CONFIG_INITRD_TAG) || \
160 defined (CONFIG_SERIAL_TAG) || \
161 defined (CONFIG_REVISION_TAG) || \
162 defined (CONFIG_LCD) || \
163 defined (CONFIG_VFD)
164 static void setup_start_tag (bd_t *bd)
165 {
166 params = (struct tag *) bd->bi_boot_params;
167
168 params->hdr.tag = ATAG_CORE;
169 params->hdr.size = tag_size (tag_core);
170
171 params->u.core.flags = 0;
172 params->u.core.pagesize = 0;
173 params->u.core.rootdev = 0;
174
175 params = tag_next (params);
176 }
177
178
179 #ifdef CONFIG_SETUP_MEMORY_TAGS
180 static void setup_memory_tags (bd_t *bd)
181 {
182 int i;
183
184 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
185 params->hdr.tag = ATAG_MEM;
186 params->hdr.size = tag_size (tag_mem32);
187
188 params->u.mem.start = bd->bi_dram[i].start;
189 params->u.mem.size = bd->bi_dram[i].size;
190
191 params = tag_next (params);
192 }
193 }
194 #endif /* CONFIG_SETUP_MEMORY_TAGS */
195
196
197 static void setup_commandline_tag (bd_t *bd, char *commandline)
198 {
199 char *p;
200
201 if (!commandline)
202 return;
203
204 /* eat leading white space */
205 for (p = commandline; *p == ' '; p++);
206
207 /* skip non-existent command lines so the kernel will still
208 * use its default command line.
209 */
210 if (*p == '\0')
211 return;
212
213 params->hdr.tag = ATAG_CMDLINE;
214 params->hdr.size =
215 (sizeof (struct tag_header) + strlen (p) + 1 + 4) >> 2;
216
217 strcpy (params->u.cmdline.cmdline, p);
218
219 params = tag_next (params);
220 }
221
222
223 #ifdef CONFIG_INITRD_TAG
224 static void setup_initrd_tag (bd_t *bd, ulong initrd_start, ulong initrd_end)
225 {
226 /* an ATAG_INITRD node tells the kernel where the compressed
227 * ramdisk can be found. ATAG_RDIMG is a better name, actually.
228 */
229 params->hdr.tag = ATAG_INITRD2;
230 params->hdr.size = tag_size (tag_initrd);
231
232 params->u.initrd.start = initrd_start;
233 params->u.initrd.size = initrd_end - initrd_start;
234
235 params = tag_next (params);
236 }
237 #endif /* CONFIG_INITRD_TAG */
238
239
240 #if defined (CONFIG_VFD) || defined (CONFIG_LCD)
241 extern ulong calc_fbsize (void);
242 static void setup_videolfb_tag (gd_t *gd)
243 {
244 /* An ATAG_VIDEOLFB node tells the kernel where and how large
245 * the framebuffer for video was allocated (among other things).
246 * Note that a _physical_ address is passed !
247 *
248 * We only use it to pass the address and size, the other entries
249 * in the tag_videolfb are not of interest.
250 */
251 params->hdr.tag = ATAG_VIDEOLFB;
252 params->hdr.size = tag_size (tag_videolfb);
253
254 params->u.videolfb.lfb_base = (u32) gd->fb_base;
255 /* Fb size is calculated according to parameters for our panel
256 */
257 params->u.videolfb.lfb_size = calc_fbsize();
258
259 params = tag_next (params);
260 }
261 #endif /* CONFIG_VFD || CONFIG_LCD */
262
263 #ifdef CONFIG_SERIAL_TAG
264 void setup_serial_tag (struct tag **tmp)
265 {
266 struct tag *params = *tmp;
267 struct tag_serialnr serialnr;
268 void get_board_serial(struct tag_serialnr *serialnr);
269
270 get_board_serial(&serialnr);
271 params->hdr.tag = ATAG_SERIAL;
272 params->hdr.size = tag_size (tag_serialnr);
273 params->u.serialnr.low = serialnr.low;
274 params->u.serialnr.high= serialnr.high;
275 params = tag_next (params);
276 *tmp = params;
277 }
278 #endif
279
280 #ifdef CONFIG_REVISION_TAG
281 void setup_revision_tag(struct tag **in_params)
282 {
283 u32 rev = 0;
284 u32 get_board_rev(void);
285
286 rev = get_board_rev();
287 params->hdr.tag = ATAG_REVISION;
288 params->hdr.size = tag_size (tag_revision);
289 params->u.revision.rev = rev;
290 params = tag_next (params);
291 }
292 #endif /* CONFIG_REVISION_TAG */
293
294
295 static void setup_end_tag (bd_t *bd)
296 {
297 params->hdr.tag = ATAG_NONE;
298 params->hdr.size = 0;
299 }
300
301 #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */