]>
git.ipfire.org Git - people/ms/u-boot.git/blob - lib_arm/bootm.c
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
);
47 static void setup_ramdisk_tag (bd_t
*bd
);
49 # ifdef CONFIG_INITRD_TAG
50 static void setup_initrd_tag (bd_t
*bd
, ulong initrd_start
,
53 static void setup_end_tag (bd_t
*bd
);
55 # if defined (CONFIG_VFD) || defined (CONFIG_LCD)
56 static void setup_videolfb_tag (gd_t
*gd
);
59 static struct tag
*params
;
60 #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */
62 extern int do_reset (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[]);
64 void do_bootm_linux (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[],
65 bootm_headers_t
*images
)
67 ulong initrd_start
, initrd_end
;
71 int machid
= bd
->bi_arch_number
;
72 void (*theKernel
)(int zero
, int arch
, uint params
);
75 #ifdef CONFIG_CMDLINE_TAG
76 char *commandline
= getenv ("bootargs");
79 /* find kernel entry point */
80 if (images
->legacy_hdr_valid
) {
81 ep
= image_get_ep (&images
->legacy_hdr_os_copy
);
82 #if defined(CONFIG_FIT)
83 } else if (images
->fit_uname_os
) {
84 ret
= fit_image_get_entry (images
->fit_hdr_os
,
85 images
->fit_noffset_os
, &ep
);
87 puts ("Can't get entry point property!\n");
92 puts ("Could not find kernel entry point!\n");
95 theKernel
= (void (*)(int, int, uint
))ep
;
97 s
= getenv ("machid");
99 machid
= simple_strtoul (s
, NULL
, 16);
100 printf ("Using machid 0x%x from environment\n", machid
);
103 ret
= boot_get_ramdisk (argc
, argv
, images
, IH_ARCH_ARM
,
104 &initrd_start
, &initrd_end
);
108 show_boot_progress (15);
110 debug ("## Transferring control to Linux (at address %08lx) ...\n",
113 #if defined (CONFIG_SETUP_MEMORY_TAGS) || \
114 defined (CONFIG_CMDLINE_TAG) || \
115 defined (CONFIG_INITRD_TAG) || \
116 defined (CONFIG_SERIAL_TAG) || \
117 defined (CONFIG_REVISION_TAG) || \
118 defined (CONFIG_LCD) || \
120 setup_start_tag (bd
);
121 #ifdef CONFIG_SERIAL_TAG
122 setup_serial_tag (¶ms
);
124 #ifdef CONFIG_REVISION_TAG
125 setup_revision_tag (¶ms
);
127 #ifdef CONFIG_SETUP_MEMORY_TAGS
128 setup_memory_tags (bd
);
130 #ifdef CONFIG_CMDLINE_TAG
131 setup_commandline_tag (bd
, commandline
);
133 #ifdef CONFIG_INITRD_TAG
134 if (initrd_start
&& initrd_end
)
135 setup_initrd_tag (bd
, initrd_start
, initrd_end
);
137 #if defined (CONFIG_VFD) || defined (CONFIG_LCD)
138 setup_videolfb_tag ((gd_t
*) gd
);
143 if (!images
->autostart
)
146 /* we assume that the kernel is in place */
147 printf ("\nStarting kernel ...\n\n");
149 #ifdef CONFIG_USB_DEVICE
151 extern void udc_disconnect (void);
156 cleanup_before_linux ();
158 theKernel (0, machid
, bd
->bi_boot_params
);
159 /* does not return */
163 if (images
->autostart
)
164 do_reset (cmdtp
, flag
, argc
, argv
);
169 #if defined (CONFIG_SETUP_MEMORY_TAGS) || \
170 defined (CONFIG_CMDLINE_TAG) || \
171 defined (CONFIG_INITRD_TAG) || \
172 defined (CONFIG_SERIAL_TAG) || \
173 defined (CONFIG_REVISION_TAG) || \
174 defined (CONFIG_LCD) || \
176 static void setup_start_tag (bd_t
*bd
)
178 params
= (struct tag
*) bd
->bi_boot_params
;
180 params
->hdr
.tag
= ATAG_CORE
;
181 params
->hdr
.size
= tag_size (tag_core
);
183 params
->u
.core
.flags
= 0;
184 params
->u
.core
.pagesize
= 0;
185 params
->u
.core
.rootdev
= 0;
187 params
= tag_next (params
);
191 #ifdef CONFIG_SETUP_MEMORY_TAGS
192 static void setup_memory_tags (bd_t
*bd
)
196 for (i
= 0; i
< CONFIG_NR_DRAM_BANKS
; i
++) {
197 params
->hdr
.tag
= ATAG_MEM
;
198 params
->hdr
.size
= tag_size (tag_mem32
);
200 params
->u
.mem
.start
= bd
->bi_dram
[i
].start
;
201 params
->u
.mem
.size
= bd
->bi_dram
[i
].size
;
203 params
= tag_next (params
);
206 #endif /* CONFIG_SETUP_MEMORY_TAGS */
209 static void setup_commandline_tag (bd_t
*bd
, char *commandline
)
216 /* eat leading white space */
217 for (p
= commandline
; *p
== ' '; p
++);
219 /* skip non-existent command lines so the kernel will still
220 * use its default command line.
225 params
->hdr
.tag
= ATAG_CMDLINE
;
227 (sizeof (struct tag_header
) + strlen (p
) + 1 + 4) >> 2;
229 strcpy (params
->u
.cmdline
.cmdline
, p
);
231 params
= tag_next (params
);
235 #ifdef CONFIG_INITRD_TAG
236 static void setup_initrd_tag (bd_t
*bd
, ulong initrd_start
, ulong initrd_end
)
238 /* an ATAG_INITRD node tells the kernel where the compressed
239 * ramdisk can be found. ATAG_RDIMG is a better name, actually.
241 params
->hdr
.tag
= ATAG_INITRD2
;
242 params
->hdr
.size
= tag_size (tag_initrd
);
244 params
->u
.initrd
.start
= initrd_start
;
245 params
->u
.initrd
.size
= initrd_end
- initrd_start
;
247 params
= tag_next (params
);
249 #endif /* CONFIG_INITRD_TAG */
252 #if defined (CONFIG_VFD) || defined (CONFIG_LCD)
253 extern ulong
calc_fbsize (void);
254 static void setup_videolfb_tag (gd_t
*gd
)
256 /* An ATAG_VIDEOLFB node tells the kernel where and how large
257 * the framebuffer for video was allocated (among other things).
258 * Note that a _physical_ address is passed !
260 * We only use it to pass the address and size, the other entries
261 * in the tag_videolfb are not of interest.
263 params
->hdr
.tag
= ATAG_VIDEOLFB
;
264 params
->hdr
.size
= tag_size (tag_videolfb
);
266 params
->u
.videolfb
.lfb_base
= (u32
) gd
->fb_base
;
267 /* Fb size is calculated according to parameters for our panel
269 params
->u
.videolfb
.lfb_size
= calc_fbsize();
271 params
= tag_next (params
);
273 #endif /* CONFIG_VFD || CONFIG_LCD */
275 #ifdef CONFIG_SERIAL_TAG
276 void setup_serial_tag (struct tag
**tmp
)
278 struct tag
*params
= *tmp
;
279 struct tag_serialnr serialnr
;
280 void get_board_serial(struct tag_serialnr
*serialnr
);
282 get_board_serial(&serialnr
);
283 params
->hdr
.tag
= ATAG_SERIAL
;
284 params
->hdr
.size
= tag_size (tag_serialnr
);
285 params
->u
.serialnr
.low
= serialnr
.low
;
286 params
->u
.serialnr
.high
= serialnr
.high
;
287 params
= tag_next (params
);
292 #ifdef CONFIG_REVISION_TAG
293 void setup_revision_tag(struct tag
**in_params
)
296 u32
get_board_rev(void);
298 rev
= get_board_rev();
299 params
->hdr
.tag
= ATAG_REVISION
;
300 params
->hdr
.size
= tag_size (tag_revision
);
301 params
->u
.revision
.rev
= rev
;
302 params
= tag_next (params
);
304 #endif /* CONFIG_REVISION_TAG */
307 static void setup_end_tag (bd_t
*bd
)
309 params
->hdr
.tag
= ATAG_NONE
;
310 params
->hdr
.size
= 0;
313 #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */