Better SuperSPARC emulation (Robert Reif)
[qemu] / loader.c
index 6805692..cca9d3b 100644 (file)
--- a/loader.c
+++ b/loader.c
@@ -456,7 +456,8 @@ static ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src,
 }
 
 /* Load a U-Boot image.  */
-int load_uboot(const char *filename, target_ulong *ep, int *is_linux)
+int load_uimage(const char *filename, target_ulong *ep, target_ulong *loadaddr,
+                int *is_linux)
 {
     int fd;
     int size;
@@ -478,9 +479,9 @@ int load_uboot(const char *filename, target_ulong *ep, int *is_linux)
     if (hdr->ih_magic != IH_MAGIC)
         goto out;
 
-    /* TODO: Implement Multi-File images.  */
-    if (hdr->ih_type == IH_TYPE_MULTI) {
-        fprintf(stderr, "Unable to load multi-file u-boot images\n");
+    /* TODO: Implement other image types.  */
+    if (hdr->ih_type != IH_TYPE_KERNEL) {
+        fprintf(stderr, "Can only load u-boot image type \"kernel\"\n");
         goto out;
     }
 
@@ -497,7 +498,7 @@ int load_uboot(const char *filename, target_ulong *ep, int *is_linux)
 
     /* TODO: Check CPU type.  */
     if (is_linux) {
-        if (hdr->ih_type == IH_TYPE_KERNEL && hdr->ih_os == IH_OS_LINUX)
+        if (hdr->ih_os == IH_OS_LINUX)
             *is_linux = 1;
         else
             *is_linux = 0;
@@ -533,6 +534,9 @@ int load_uboot(const char *filename, target_ulong *ep, int *is_linux)
 
     cpu_physical_memory_write_rom(hdr->ih_load, data, hdr->ih_size);
 
+    if (loadaddr)
+        *loadaddr = hdr->ih_load;
+
     ret = hdr->ih_size;
 
 out: