]> xenbits.xensource.com Git - qemu-xen-3.3-testing.git/commitdiff
Only map BIOS space when it was actually loaded.
authorths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 18 Oct 2007 15:05:11 +0000 (15:05 +0000)
committerths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 18 Oct 2007 15:05:11 +0000 (15:05 +0000)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3408 c046a42c-6fe2-441c-8c8c-71466251a162

hw/mips_mipssim.c

index 6c061636b3a5bb3ccd66d88e8d17febf2be3f2da..b7b834fc2874f12b28fd9719572420fc66e98175 100644 (file)
@@ -82,7 +82,7 @@ mips_mipssim_init (int ram_size, int vga_ram_size, int boot_device,
     char buf[1024];
     unsigned long bios_offset;
     CPUState *env;
-    int ret;
+    int bios_size;
     mips_def_t *def;
 
     /* Init CPUs. */
@@ -103,25 +103,24 @@ mips_mipssim_init (int ram_size, int vga_ram_size, int boot_device,
     /* Allocate RAM. */
     cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
 
-    /* Map the BIOS / boot exception handler. */
-    bios_offset = ram_size + vga_ram_size;
-
     /* Load a BIOS / boot exception handler image. */
+    bios_offset = ram_size + vga_ram_size;
     if (bios_name == NULL)
         bios_name = BIOS_FILENAME;
     snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
-    ret = load_image(buf, phys_ram_base + bios_offset);
-    if ((ret < 0 || ret > BIOS_SIZE) && !kernel_filename) {
+    bios_size = load_image(buf, phys_ram_base + bios_offset);
+    if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename) {
         /* Bail out if we have neither a kernel image nor boot vector code. */
         fprintf(stderr,
                 "qemu: Could not load MIPS bios '%s', and no -kernel argument was specified\n",
                 buf);
         exit(1);
     } else {
-        /* We have a boot vector start address. */
-        env->PC[env->current_tc] = (target_long)0xbfc00000;
+        /* Map the BIOS / boot exception handler. */
         cpu_register_physical_memory(0x1fc00000LL,
-                                     ret, bios_offset | IO_MEM_ROM);
+                                     bios_size, bios_offset | IO_MEM_ROM);
+        /* We have a boot vector start address. */
+        env->PC[env->current_tc] = (target_long)(int32_t)0xbfc00000;
     }
 
     if (kernel_filename) {