]> git.ipfire.org Git - people/ms/u-boot.git/blob - lib_arm/bootm.c
rename CFG_ macros to CONFIG_SYS
[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 # ifdef CONFIG_INITRD_TAG
47 static void setup_initrd_tag (bd_t *bd, ulong initrd_start,
48 ulong initrd_end);
49 # endif
50 static void setup_end_tag (bd_t *bd);
51
52 # if defined (CONFIG_VFD) || defined (CONFIG_LCD)
53 static void setup_videolfb_tag (gd_t *gd);
54 # endif
55
56 static struct tag *params;
57 #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */
58
59 int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
60 {
61 bd_t *bd = gd->bd;
62 char *s;
63 int machid = bd->bi_arch_number;
64 void (*theKernel)(int zero, int arch, uint params);
65
66 #ifdef CONFIG_CMDLINE_TAG
67 char *commandline = getenv ("bootargs");
68 #endif
69
70 theKernel = (void (*)(int, int, uint))images->ep;
71
72 s = getenv ("machid");
73 if (s) {
74 machid = simple_strtoul (s, NULL, 16);
75 printf ("Using machid 0x%x from environment\n", machid);
76 }
77
78 show_boot_progress (15);
79
80 debug ("## Transferring control to Linux (at address %08lx) ...\n",
81 (ulong) theKernel);
82
83 #if defined (CONFIG_SETUP_MEMORY_TAGS) || \
84 defined (CONFIG_CMDLINE_TAG) || \
85 defined (CONFIG_INITRD_TAG) || \
86 defined (CONFIG_SERIAL_TAG) || \
87 defined (CONFIG_REVISION_TAG) || \
88 defined (CONFIG_LCD) || \
89 defined (CONFIG_VFD)
90 setup_start_tag (bd);
91 #ifdef CONFIG_SERIAL_TAG
92 setup_serial_tag (&params);
93 #endif
94 #ifdef CONFIG_REVISION_TAG
95 setup_revision_tag (&params);
96 #endif
97 #ifdef CONFIG_SETUP_MEMORY_TAGS
98 setup_memory_tags (bd);
99 #endif
100 #ifdef CONFIG_CMDLINE_TAG
101 setup_commandline_tag (bd, commandline);
102 #endif
103 #ifdef CONFIG_INITRD_TAG
104 if (images->rd_start && images->rd_end)
105 setup_initrd_tag (bd, images->rd_start, images->rd_end);
106 #endif
107 #if defined (CONFIG_VFD) || defined (CONFIG_LCD)
108 setup_videolfb_tag ((gd_t *) gd);
109 #endif
110 setup_end_tag (bd);
111 #endif
112
113 /* we assume that the kernel is in place */
114 printf ("\nStarting kernel ...\n\n");
115
116 #ifdef CONFIG_USB_DEVICE
117 {
118 extern void udc_disconnect (void);
119 udc_disconnect ();
120 }
121 #endif
122
123 cleanup_before_linux ();
124
125 theKernel (0, machid, bd->bi_boot_params);
126 /* does not return */
127
128 return 1;
129 }
130
131
132 #if defined (CONFIG_SETUP_MEMORY_TAGS) || \
133 defined (CONFIG_CMDLINE_TAG) || \
134 defined (CONFIG_INITRD_TAG) || \
135 defined (CONFIG_SERIAL_TAG) || \
136 defined (CONFIG_REVISION_TAG) || \
137 defined (CONFIG_LCD) || \
138 defined (CONFIG_VFD)
139 static void setup_start_tag (bd_t *bd)
140 {
141 params = (struct tag *) bd->bi_boot_params;
142
143 params->hdr.tag = ATAG_CORE;
144 params->hdr.size = tag_size (tag_core);
145
146 params->u.core.flags = 0;
147 params->u.core.pagesize = 0;
148 params->u.core.rootdev = 0;
149
150 params = tag_next (params);
151 }
152
153
154 #ifdef CONFIG_SETUP_MEMORY_TAGS
155 static void setup_memory_tags (bd_t *bd)
156 {
157 int i;
158
159 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
160 params->hdr.tag = ATAG_MEM;
161 params->hdr.size = tag_size (tag_mem32);
162
163 params->u.mem.start = bd->bi_dram[i].start;
164 params->u.mem.size = bd->bi_dram[i].size;
165
166 params = tag_next (params);
167 }
168 }
169 #endif /* CONFIG_SETUP_MEMORY_TAGS */
170
171
172 static void setup_commandline_tag (bd_t *bd, char *commandline)
173 {
174 char *p;
175
176 if (!commandline)
177 return;
178
179 /* eat leading white space */
180 for (p = commandline; *p == ' '; p++);
181
182 /* skip non-existent command lines so the kernel will still
183 * use its default command line.
184 */
185 if (*p == '\0')
186 return;
187
188 params->hdr.tag = ATAG_CMDLINE;
189 params->hdr.size =
190 (sizeof (struct tag_header) + strlen (p) + 1 + 4) >> 2;
191
192 strcpy (params->u.cmdline.cmdline, p);
193
194 params = tag_next (params);
195 }
196
197
198 #ifdef CONFIG_INITRD_TAG
199 static void setup_initrd_tag (bd_t *bd, ulong initrd_start, ulong initrd_end)
200 {
201 /* an ATAG_INITRD node tells the kernel where the compressed
202 * ramdisk can be found. ATAG_RDIMG is a better name, actually.
203 */
204 params->hdr.tag = ATAG_INITRD2;
205 params->hdr.size = tag_size (tag_initrd);
206
207 params->u.initrd.start = initrd_start;
208 params->u.initrd.size = initrd_end - initrd_start;
209
210 params = tag_next (params);
211 }
212 #endif /* CONFIG_INITRD_TAG */
213
214
215 #if defined (CONFIG_VFD) || defined (CONFIG_LCD)
216 extern ulong calc_fbsize (void);
217 static void setup_videolfb_tag (gd_t *gd)
218 {
219 /* An ATAG_VIDEOLFB node tells the kernel where and how large
220 * the framebuffer for video was allocated (among other things).
221 * Note that a _physical_ address is passed !
222 *
223 * We only use it to pass the address and size, the other entries
224 * in the tag_videolfb are not of interest.
225 */
226 params->hdr.tag = ATAG_VIDEOLFB;
227 params->hdr.size = tag_size (tag_videolfb);
228
229 params->u.videolfb.lfb_base = (u32) gd->fb_base;
230 /* Fb size is calculated according to parameters for our panel
231 */
232 params->u.videolfb.lfb_size = calc_fbsize();
233
234 params = tag_next (params);
235 }
236 #endif /* CONFIG_VFD || CONFIG_LCD */
237
238 #ifdef CONFIG_SERIAL_TAG
239 void setup_serial_tag (struct tag **tmp)
240 {
241 struct tag *params = *tmp;
242 struct tag_serialnr serialnr;
243 void get_board_serial(struct tag_serialnr *serialnr);
244
245 get_board_serial(&serialnr);
246 params->hdr.tag = ATAG_SERIAL;
247 params->hdr.size = tag_size (tag_serialnr);
248 params->u.serialnr.low = serialnr.low;
249 params->u.serialnr.high= serialnr.high;
250 params = tag_next (params);
251 *tmp = params;
252 }
253 #endif
254
255 #ifdef CONFIG_REVISION_TAG
256 void setup_revision_tag(struct tag **in_params)
257 {
258 u32 rev = 0;
259 u32 get_board_rev(void);
260
261 rev = get_board_rev();
262 params->hdr.tag = ATAG_REVISION;
263 params->hdr.size = tag_size (tag_revision);
264 params->u.revision.rev = rev;
265 params = tag_next (params);
266 }
267 #endif /* CONFIG_REVISION_TAG */
268
269
270 static void setup_end_tag (bd_t *bd)
271 {
272 params->hdr.tag = ATAG_NONE;
273 params->hdr.size = 0;
274 }
275
276 #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */