]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/powerpc/boot/main.c
[POWERPC] 85xx: Cleaned up platform dts files
[linux-2.6-omap-h63xx.git] / arch / powerpc / boot / main.c
index 418497482b6ef3bc2e9ad1f95f658d7d46e0801c..6f6b50d238b6fa17a19f62552c2560610967927b 100644 (file)
@@ -169,7 +169,7 @@ static int is_elf32(void *hdr)
        return 1;
 }
 
-static void prep_kernel(unsigned long *a1, unsigned long *a2)
+static void prep_kernel(unsigned long a1, unsigned long a2)
 {
        int len;
 
@@ -205,11 +205,14 @@ static void prep_kernel(unsigned long *a1, unsigned long *a2)
        }
 
        /*
-        * Now we try to alloc memory for the initrd (and copy it there)
+        * Now find the initrd
+        *
+        * First see if we have an image attached to us.  If so
+        * allocate memory for it and copy it there.
         */
        initrd.size = (unsigned long)(_initrd_end - _initrd_start);
        initrd.memsize = initrd.size;
-       if ( initrd.size > 0 ) {
+       if (initrd.size > 0) {
                printf("Allocating 0x%lx bytes for initrd ...\n\r",
                       initrd.size);
                initrd.addr = (unsigned long)malloc((u32)initrd.size);
@@ -218,8 +221,6 @@ static void prep_kernel(unsigned long *a1, unsigned long *a2)
                                        "ramdisk !\n\r");
                        exit();
                }
-               *a1 = initrd.addr;
-               *a2 = initrd.size;
                printf("initial ramdisk moving 0x%lx <- 0x%lx "
                        "(0x%lx bytes)\n\r", initrd.addr,
                        (unsigned long)_initrd_start, initrd.size);
@@ -227,6 +228,12 @@ static void prep_kernel(unsigned long *a1, unsigned long *a2)
                        initrd.size);
                printf("initrd head: 0x%lx\n\r",
                                *((unsigned long *)initrd.addr));
+       } else if (a2 != 0) {
+               /* Otherwise, see if yaboot or another loader gave us an initrd */
+               initrd.addr = a1;
+               initrd.memsize = initrd.size = a2;
+               printf("Using loader supplied initrd at 0x%lx (0x%lx bytes)\n\r",
+                      initrd.addr, initrd.size);
        }
 
        /* Eventually gunzip the kernel */
@@ -291,6 +298,7 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
 {
        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));
@@ -307,7 +315,7 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
        printf("\n\rzImage starting: loaded at 0x%p (sp: 0x%p)\n\r",
               _start, sp);
 
-       prep_kernel(&a1, &a2);
+       prep_kernel(a1, a2);
 
        /* If cmdline came from zimage wrapper or if we can edit the one
         * in the dt, print it out and edit it, if possible.
@@ -321,17 +329,23 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
                set_cmdline(cmdline);
        }
 
+       printf("Finalizing device tree...");
+       if (dt_ops.finalize)
+               ft_addr = dt_ops.finalize();
+       if (ft_addr)
+               printf(" flat tree at 0x%lx\n\r", ft_addr);
+       else
+               printf(" using OF tree (promptr=%p)\n\r", promptr);
+
        if (console_ops.close)
                console_ops.close();
 
        kentry = (kernel_entry_t) vmlinux.addr;
-       if (_dtb_end > _dtb_start) {
-               dt_ops.ft_pack();
-               kentry(dt_ops.ft_addr(), 0, NULL);
-       }
+       if (ft_addr)
+               kentry(ft_addr, 0, NULL);
        else
                /* XXX initrd addr/size should be passed in properties */
-               kentry(a1, a2, promptr);
+               kentry(initrd.addr, initrd.size, promptr);
 
        /* console closed so printf below may not work */
        printf("Error: Linux kernel returned to zImage boot wrapper!\n\r");