aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/boot/main.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2007-03-04 22:24:52 -0500
committerPaul Mackerras <paulus@samba.org>2007-03-12 22:35:03 -0400
commitcd197ffcf10bcc1a260efe5c09a3188fd9228c83 (patch)
tree280d1c3026b263fbdb95961ae77efb79739e8daf /arch/powerpc/boot/main.c
parent79c8541924a220964f9f2cbed31eaa9fdb042eab (diff)
[POWERPC] zImage: Cleanup and improve zImage entry point
This patch re-organises the way the zImage wrapper code is entered, to allow more flexibility on platforms with unusual entry conditions. After this patch, a platform .o file has two options: 1) It can define a _zimage_start, in which case the platform code gets control from the very beginning of execution. In this case the platform code is responsible for relocating the zImage if necessary, clearing the BSS, performing any platform specific initialization, and finally calling start() to load and enter the kernel. 2) It can define platform_init(). In this case the generic crt0.S handles initial entry, and calls platform_init() before calling start(). The signature of platform_init() is changed, however, to take up to 5 parameters (in r3..r7) as they come from the platform's initial loader, instead of a fixed set of parameters based on OF's usage. When using the generic crt0.S, the platform .o can optionally supply a custom stack to use, using the BSS_STACK() macro. If this is not supplied, the crt0.S will assume that the loader has supplied a usable stack. In either case, the platform code communicates information to the generic code (specifically, a PROM pointer for OF systems, and/or an initrd image address supplied by the bootloader) via a global structure "loader_info". In addition the wrapper script is rearranged to ensure that the platform .o is always linked first. This means that platforms where the zImage entry point is at a fixed address or offset, rather than being encoded in the binary header can be supported using option (1). Signed-off-by: David Gibson <dwg@au1.ibm.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/boot/main.c')
-rw-r--r--arch/powerpc/boot/main.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index 05de6cfafeeb..8a60e13777d7 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -254,21 +254,15 @@ static void set_cmdline(char *buf)
254struct platform_ops platform_ops; 254struct platform_ops platform_ops;
255struct dt_ops dt_ops; 255struct dt_ops dt_ops;
256struct console_ops console_ops; 256struct console_ops console_ops;
257struct loader_info loader_info;
257 258
258void start(unsigned long a1, unsigned long a2, void *promptr, void *sp) 259void start(void *sp)
259{ 260{
260 struct addr_range vmlinux, initrd; 261 struct addr_range vmlinux, initrd;
261 kernel_entry_t kentry; 262 kernel_entry_t kentry;
262 char cmdline[COMMAND_LINE_SIZE]; 263 char cmdline[COMMAND_LINE_SIZE];
263 unsigned long ft_addr = 0; 264 unsigned long ft_addr = 0;
264 265
265 memset(__bss_start, 0, _end - __bss_start);
266 memset(&platform_ops, 0, sizeof(platform_ops));
267 memset(&dt_ops, 0, sizeof(dt_ops));
268 memset(&console_ops, 0, sizeof(console_ops));
269
270 if (platform_init(promptr, _dtb_start, _dtb_end))
271 exit();
272 if (console_ops.open && (console_ops.open() < 0)) 266 if (console_ops.open && (console_ops.open() < 0))
273 exit(); 267 exit();
274 if (platform_ops.fixups) 268 if (platform_ops.fixups)
@@ -278,7 +272,8 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
278 _start, sp); 272 _start, sp);
279 273
280 vmlinux = prep_kernel(); 274 vmlinux = prep_kernel();
281 initrd = prep_initrd(vmlinux, a1, a2); 275 initrd = prep_initrd(vmlinux, loader_info.initrd_addr,
276 loader_info.initrd_size);
282 277
283 /* If cmdline came from zimage wrapper or if we can edit the one 278 /* If cmdline came from zimage wrapper or if we can edit the one
284 * in the dt, print it out and edit it, if possible. 279 * in the dt, print it out and edit it, if possible.
@@ -298,7 +293,7 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
298 if (ft_addr) 293 if (ft_addr)
299 printf(" flat tree at 0x%lx\n\r", ft_addr); 294 printf(" flat tree at 0x%lx\n\r", ft_addr);
300 else 295 else
301 printf(" using OF tree (promptr=%p)\n\r", promptr); 296 printf(" using OF tree (promptr=%p)\n\r", loader_info.promptr);
302 297
303 if (console_ops.close) 298 if (console_ops.close)
304 console_ops.close(); 299 console_ops.close();
@@ -307,7 +302,8 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
307 if (ft_addr) 302 if (ft_addr)
308 kentry(ft_addr, 0, NULL); 303 kentry(ft_addr, 0, NULL);
309 else 304 else
310 kentry((unsigned long)initrd.addr, initrd.size, promptr); 305 kentry((unsigned long)initrd.addr, initrd.size,
306 loader_info.promptr);
311 307
312 /* console closed so printf below may not work */ 308 /* console closed so printf below may not work */
313 printf("Error: Linux kernel returned to zImage boot wrapper!\n\r"); 309 printf("Error: Linux kernel returned to zImage boot wrapper!\n\r");