diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2007-03-05 14:24:52 +1100 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-03-13 13:35:03 +1100 |
commit | cd197ffcf10bcc1a260efe5c09a3188fd9228c83 (patch) | |
tree | 280d1c3026b263fbdb95961ae77efb79739e8daf /arch/powerpc/boot/main.c | |
parent | 79c8541924a220964f9f2cbed31eaa9fdb042eab (diff) | |
download | linux-cd197ffcf10bcc1a260efe5c09a3188fd9228c83.tar.gz linux-cd197ffcf10bcc1a260efe5c09a3188fd9228c83.tar.bz2 linux-cd197ffcf10bcc1a260efe5c09a3188fd9228c83.zip |
[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.c | 18 |
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) struct platform_ops platform_ops; struct dt_ops dt_ops; struct console_ops console_ops; +struct loader_info loader_info; -void start(unsigned long a1, unsigned long a2, void *promptr, void *sp) +void start(void *sp) { struct addr_range vmlinux, initrd; kernel_entry_t kentry; char cmdline[COMMAND_LINE_SIZE]; unsigned long ft_addr = 0; - memset(__bss_start, 0, _end - __bss_start); - memset(&platform_ops, 0, sizeof(platform_ops)); - memset(&dt_ops, 0, sizeof(dt_ops)); - memset(&console_ops, 0, sizeof(console_ops)); - - if (platform_init(promptr, _dtb_start, _dtb_end)) - exit(); if (console_ops.open && (console_ops.open() < 0)) exit(); if (platform_ops.fixups) @@ -278,7 +272,8 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp) _start, sp); vmlinux = prep_kernel(); - initrd = prep_initrd(vmlinux, a1, a2); + initrd = prep_initrd(vmlinux, loader_info.initrd_addr, + loader_info.initrd_size); /* If cmdline came from zimage wrapper or if we can edit the one * 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) if (ft_addr) printf(" flat tree at 0x%lx\n\r", ft_addr); else - printf(" using OF tree (promptr=%p)\n\r", promptr); + printf(" using OF tree (promptr=%p)\n\r", loader_info.promptr); if (console_ops.close) console_ops.close(); @@ -307,7 +302,8 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp) if (ft_addr) kentry(ft_addr, 0, NULL); else - kentry((unsigned long)initrd.addr, initrd.size, promptr); + kentry((unsigned long)initrd.addr, initrd.size, + loader_info.promptr); /* console closed so printf below may not work */ printf("Error: Linux kernel returned to zImage boot wrapper!\n\r"); |