]> git.sur5r.net Git - u-boot/blobdiff - common/cmd_bootm.c
* Patch by Hans-Joerg Frieden, 06 Dec 2002
[u-boot] / common / cmd_bootm.c
index e8ce40d69ca7554e58b959841e3e99526800b99d..4c0d1f5bde589e06c4987857526464852041c86c 100644 (file)
@@ -70,6 +70,10 @@ static int image_info (unsigned long addr);
 #endif
 static void print_type (image_header_t *hdr);
 
+#ifdef __I386__
+image_header_t *fake_header(image_header_t *hdr, void *ptr, int size);
+#endif
+
 /*
  *  Continue booting an OS image; caller already has:
  *  - copied image header to global variable `header'
@@ -84,7 +88,7 @@ typedef void boot_os_Fcn (cmd_tbl_t *cmdtp, int flag,
                          ulong *len_ptr,       /* multi-file image length table */
                          int   verify);        /* getenv("verify")[0] != 'n' */
 
-#ifndef CONFIG_ARM
+#ifdef CONFIG_PPC
 static boot_os_Fcn do_bootm_linux;
 #else
 extern boot_os_Fcn do_bootm_linux;
@@ -128,9 +132,21 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        memmove (&header, (char *)addr, sizeof(image_header_t));
 
        if (ntohl(hdr->ih_magic) != IH_MAGIC) {
+#ifdef __I386__        /* correct image format not implemented yet - fake it */
+               if (fake_header(hdr, (void*)addr, -1) != NULL) {
+                       /* to compensate for the addition below */
+                       addr -= sizeof(image_header_t);
+                       /* turnof verify,
+                        * fake_header() does not fake the data crc
+                        */
+                       verify = 0;
+               } else
+#endif /* __I386__ */
+           {
                printf ("Bad Magic Number\n");
                SHOW_BOOT_PROGRESS (-1);
                return 1;
+           }
        }
        SHOW_BOOT_PROGRESS (2);
 
@@ -148,7 +164,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        SHOW_BOOT_PROGRESS (3);
 
        /* for multi-file images we need the data part, too */
-       print_image_hdr ((image_header_t *)addr);
+       print_image_hdr (hdr);
 
        data = addr + sizeof(image_header_t);
        len  = ntohl(hdr->ih_size);
@@ -166,8 +182,17 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
        len_ptr = (ulong *)data;
 
-       if (hdr->ih_arch != IH_CPU_PPC && hdr->ih_arch != IH_CPU_ARM) {
-               printf ("Unsupported Architecture\n");
+#if defined(__PPC__)
+       if (hdr->ih_arch != IH_CPU_PPC)
+#elif defined(__ARM__)
+       if (hdr->ih_arch != IH_CPU_ARM)
+#elif defined(__I386__)
+       if (hdr->ih_arch != IH_CPU_I386)
+#else
+# error Unknown CPU type
+#endif
+       {
+               printf ("Unsupported Architecture 0x%x\n", hdr->ih_arch);
                SHOW_BOOT_PROGRESS (-4);
                return 1;
        }
@@ -199,9 +224,20 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
        iflag = disable_interrupts();
 
+#ifdef CONFIG_AMIGAONEG3SE
+       /*
+        * We've possible left the caches enabled during 
+        * bios emulation, so turn them off again
+        */
+       icache_disable();
+       invalidate_l1_instruction_cache();
+       flush_data_cache();
+       dcache_disable();
+#endif
+
        switch (hdr->ih_comp) {
        case IH_COMP_NONE:
-               if(hdr->ih_load == addr) {
+               if(ntohl(hdr->ih_load) == addr) {
                        printf ("   XIP %s ... ", name);
                } else {
 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
@@ -294,7 +330,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        return 1;
 }
 
-#ifndef CONFIG_ARM
+#ifdef CONFIG_PPC
 static void
 do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
                int     argc, char *argv[],
@@ -325,6 +361,17 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
                initrd_high = ~0;
        }
 
+#ifdef CONFIG_LOGBUFFER
+       kbd=gd->bd;
+       if ((s = getenv ("logstart")) != NULL) {
+               kbd->bi_sramstart = simple_strtoul(s, NULL, 16);
+               /* Prevent initrd from overwriting logbuffer */
+               if (initrd_high < kbd->bi_sramstart)
+                       initrd_high = kbd->bi_sramstart-1024;
+       }
+       debug ("## Logbuffer at 0x%08lX ", kbd->bi_sramstart);
+#endif
+
        /*
         * Booting a (Linux) kernel image
         *
@@ -337,17 +384,15 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
 
        asm( "mr %0,1": "=r"(sp) : );
 
-#ifdef DEBUG
-       printf ("## Current stack ends at 0x%08lX ", sp);
-#endif
+       debug ("## Current stack ends at 0x%08lX ", sp);
+
        sp -= 2048;             /* just to be sure */
        if (sp > CFG_BOOTMAPSZ)
                sp = CFG_BOOTMAPSZ;
        sp &= ~0xF;
 
-#ifdef DEBUG
-       printf ("=> set upper limit to 0x%08lX\n", sp);
-#endif
+       debug ("=> set upper limit to 0x%08lX\n", sp);
+
        cmdline = (char *)((sp - CFG_BARGSIZE) & ~0xF);
        kbd = (bd_t *)(((ulong)cmdline - sizeof(bd_t)) & ~0xF);
 
@@ -492,11 +537,9 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
                len = data = 0;
        }
 
-#ifdef DEBUG
        if (!data) {
-               printf ("No initrd\n");
+               debug ("No initrd\n");
        }
-#endif
 
        if (data) {
                initrd_start  = (ulong)kbd - len;
@@ -527,10 +570,10 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
                }
 
                SHOW_BOOT_PROGRESS (12);
-#ifdef DEBUG
-               printf ("## initrd at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n",
+
+               debug ("## initrd at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n",
                        data, data + len - 1, len, len);
-#endif
+
                initrd_end    = initrd_start + len;
                printf ("   Loading Ramdisk to %08lx, end %08lx ... ",
                        initrd_start, initrd_end);
@@ -558,10 +601,10 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
                initrd_end = 0;
        }
 
-#ifdef DEBUG
-       printf ("## Transferring control to Linux (at address %08lx) ...\n",
+
+       debug ("## Transferring control to Linux (at address %08lx) ...\n",
                (ulong)kernel);
-#endif
+
        SHOW_BOOT_PROGRESS (15);
 
 #ifdef CFG_INIT_RAM_LOCK