aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2006-11-15 23:31:32 -0500
committerPaul Mackerras <paulus@samba.org>2006-12-04 04:39:32 -0500
commitf79e083c2fab601a1c382282344f5a251557dbac (patch)
tree91152ed552cf67b83de15843cd479ae3fad8993f /arch
parent3e00a5aec3d6af687e37f4e7482f5c7ecdcabd0b (diff)
[POWERPC] Small clarification of initrd handling
This patch makes the handling of the initrd (or initramfs) in the zImage wrapper a little easier to follow. Instead of passing the initrd addresses out from prep_kernel() via the cryptic a1 and a2 parameters, use the global struct add_range, 'initrd'. prep_kernel() already passes information through the 'vmlinux' addr_range struct, so this seems like a reasonable extension. Some comments also clarify the logic with prep_kernel(): we use an initrd included in the zImage if present, otherwise we use an initrd passed in by the bootloader in the a1 and a2 parameters (yaboot, at least, uses this mechanism to pass an initrd). Signed-off-by: David Gibson <dwg@au1.ibm.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/boot/main.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index 418497482b6e..630a453e16fa 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -169,7 +169,7 @@ static int is_elf32(void *hdr)
169 return 1; 169 return 1;
170} 170}
171 171
172static void prep_kernel(unsigned long *a1, unsigned long *a2) 172static void prep_kernel(unsigned long a1, unsigned long a2)
173{ 173{
174 int len; 174 int len;
175 175
@@ -205,11 +205,14 @@ static void prep_kernel(unsigned long *a1, unsigned long *a2)
205 } 205 }
206 206
207 /* 207 /*
208 * Now we try to alloc memory for the initrd (and copy it there) 208 * Now find the initrd
209 *
210 * First see if we have an image attached to us. If so
211 * allocate memory for it and copy it there.
209 */ 212 */
210 initrd.size = (unsigned long)(_initrd_end - _initrd_start); 213 initrd.size = (unsigned long)(_initrd_end - _initrd_start);
211 initrd.memsize = initrd.size; 214 initrd.memsize = initrd.size;
212 if ( initrd.size > 0 ) { 215 if (initrd.size > 0) {
213 printf("Allocating 0x%lx bytes for initrd ...\n\r", 216 printf("Allocating 0x%lx bytes for initrd ...\n\r",
214 initrd.size); 217 initrd.size);
215 initrd.addr = (unsigned long)malloc((u32)initrd.size); 218 initrd.addr = (unsigned long)malloc((u32)initrd.size);
@@ -218,8 +221,6 @@ static void prep_kernel(unsigned long *a1, unsigned long *a2)
218 "ramdisk !\n\r"); 221 "ramdisk !\n\r");
219 exit(); 222 exit();
220 } 223 }
221 *a1 = initrd.addr;
222 *a2 = initrd.size;
223 printf("initial ramdisk moving 0x%lx <- 0x%lx " 224 printf("initial ramdisk moving 0x%lx <- 0x%lx "
224 "(0x%lx bytes)\n\r", initrd.addr, 225 "(0x%lx bytes)\n\r", initrd.addr,
225 (unsigned long)_initrd_start, initrd.size); 226 (unsigned long)_initrd_start, initrd.size);
@@ -227,6 +228,12 @@ static void prep_kernel(unsigned long *a1, unsigned long *a2)
227 initrd.size); 228 initrd.size);
228 printf("initrd head: 0x%lx\n\r", 229 printf("initrd head: 0x%lx\n\r",
229 *((unsigned long *)initrd.addr)); 230 *((unsigned long *)initrd.addr));
231 } else if (a2 != 0) {
232 /* Otherwise, see if yaboot or another loader gave us an initrd */
233 initrd.addr = a1;
234 initrd.memsize = initrd.size = a2;
235 printf("Using loader supplied initrd at 0x%lx (0x%lx bytes)\n\r",
236 initrd.addr, initrd.size);
230 } 237 }
231 238
232 /* Eventually gunzip the kernel */ 239 /* Eventually gunzip the kernel */
@@ -307,7 +314,7 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
307 printf("\n\rzImage starting: loaded at 0x%p (sp: 0x%p)\n\r", 314 printf("\n\rzImage starting: loaded at 0x%p (sp: 0x%p)\n\r",
308 _start, sp); 315 _start, sp);
309 316
310 prep_kernel(&a1, &a2); 317 prep_kernel(a1, a2);
311 318
312 /* If cmdline came from zimage wrapper or if we can edit the one 319 /* If cmdline came from zimage wrapper or if we can edit the one
313 * in the dt, print it out and edit it, if possible. 320 * in the dt, print it out and edit it, if possible.
@@ -331,7 +338,7 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
331 } 338 }
332 else 339 else
333 /* XXX initrd addr/size should be passed in properties */ 340 /* XXX initrd addr/size should be passed in properties */
334 kentry(a1, a2, promptr); 341 kentry(initrd.addr, initrd.size, promptr);
335 342
336 /* console closed so printf below may not work */ 343 /* console closed so printf below may not work */
337 printf("Error: Linux kernel returned to zImage boot wrapper!\n\r"); 344 printf("Error: Linux kernel returned to zImage boot wrapper!\n\r");