Commit b533415989c55d929804d56ea4bfb93e8d5ce021

Authored by ths
1 parent 82790064

Only map BIOS space when it was actually loaded.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3408 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 8 additions and 9 deletions
hw/mips_mipssim.c
@@ -82,7 +82,7 @@ mips_mipssim_init (int ram_size, int vga_ram_size, int boot_device, @@ -82,7 +82,7 @@ mips_mipssim_init (int ram_size, int vga_ram_size, int boot_device,
82 char buf[1024]; 82 char buf[1024];
83 unsigned long bios_offset; 83 unsigned long bios_offset;
84 CPUState *env; 84 CPUState *env;
85 - int ret; 85 + int bios_size;
86 mips_def_t *def; 86 mips_def_t *def;
87 87
88 /* Init CPUs. */ 88 /* Init CPUs. */
@@ -103,25 +103,24 @@ mips_mipssim_init (int ram_size, int vga_ram_size, int boot_device, @@ -103,25 +103,24 @@ mips_mipssim_init (int ram_size, int vga_ram_size, int boot_device,
103 /* Allocate RAM. */ 103 /* Allocate RAM. */
104 cpu_register_physical_memory(0, ram_size, IO_MEM_RAM); 104 cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
105 105
106 - /* Map the BIOS / boot exception handler. */  
107 - bios_offset = ram_size + vga_ram_size;  
108 -  
109 /* Load a BIOS / boot exception handler image. */ 106 /* Load a BIOS / boot exception handler image. */
  107 + bios_offset = ram_size + vga_ram_size;
110 if (bios_name == NULL) 108 if (bios_name == NULL)
111 bios_name = BIOS_FILENAME; 109 bios_name = BIOS_FILENAME;
112 snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); 110 snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
113 - ret = load_image(buf, phys_ram_base + bios_offset);  
114 - if ((ret < 0 || ret > BIOS_SIZE) && !kernel_filename) { 111 + bios_size = load_image(buf, phys_ram_base + bios_offset);
  112 + if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename) {
115 /* Bail out if we have neither a kernel image nor boot vector code. */ 113 /* Bail out if we have neither a kernel image nor boot vector code. */
116 fprintf(stderr, 114 fprintf(stderr,
117 "qemu: Could not load MIPS bios '%s', and no -kernel argument was specified\n", 115 "qemu: Could not load MIPS bios '%s', and no -kernel argument was specified\n",
118 buf); 116 buf);
119 exit(1); 117 exit(1);
120 } else { 118 } else {
121 - /* We have a boot vector start address. */  
122 - env->PC[env->current_tc] = (target_long)0xbfc00000; 119 + /* Map the BIOS / boot exception handler. */
123 cpu_register_physical_memory(0x1fc00000LL, 120 cpu_register_physical_memory(0x1fc00000LL,
124 - ret, bios_offset | IO_MEM_ROM); 121 + bios_size, bios_offset | IO_MEM_ROM);
  122 + /* We have a boot vector start address. */
  123 + env->PC[env->current_tc] = (target_long)(int32_t)0xbfc00000;
125 } 124 }
126 125
127 if (kernel_filename) { 126 if (kernel_filename) {