accept bigger PC BIOSes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@946 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
		
							parent
							
								
									7086749072
								
							
						
					
					
						commit
						7587cf4401
					
				
							
								
								
									
										36
									
								
								hw/pc.c
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								hw/pc.c
									
									
									
									
									
								
							@ -322,6 +322,8 @@ void pc_init(int ram_size, int vga_ram_size, int boot_device,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    char buf[1024];
 | 
					    char buf[1024];
 | 
				
			||||||
    int ret, linux_boot, initrd_size, i, nb_nics1, fd;
 | 
					    int ret, linux_boot, initrd_size, i, nb_nics1, fd;
 | 
				
			||||||
 | 
					    unsigned long bios_offset, vga_bios_offset;
 | 
				
			||||||
 | 
					    int bios_size, isa_bios_size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    linux_boot = (kernel_filename != NULL);
 | 
					    linux_boot = (kernel_filename != NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -329,9 +331,19 @@ void pc_init(int ram_size, int vga_ram_size, int boot_device,
 | 
				
			|||||||
    cpu_register_physical_memory(0, ram_size, 0);
 | 
					    cpu_register_physical_memory(0, ram_size, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* BIOS load */
 | 
					    /* BIOS load */
 | 
				
			||||||
 | 
					    bios_offset = ram_size + vga_ram_size;
 | 
				
			||||||
 | 
					    vga_bios_offset = bios_offset + 256 * 1024;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
 | 
					    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
 | 
				
			||||||
    ret = load_image(buf, phys_ram_base + 0x000f0000);
 | 
					    bios_size = get_image_size(buf);
 | 
				
			||||||
    if (ret != 0x10000) {
 | 
					    if (bios_size <= 0 || 
 | 
				
			||||||
 | 
					        (bios_size % 65536) != 0 ||
 | 
				
			||||||
 | 
					        bios_size > (256 * 1024)) {
 | 
				
			||||||
 | 
					        goto bios_error;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    ret = load_image(buf, phys_ram_base + bios_offset);
 | 
				
			||||||
 | 
					    if (ret != bios_size) {
 | 
				
			||||||
 | 
					    bios_error:
 | 
				
			||||||
        fprintf(stderr, "qemu: could not load PC bios '%s'\n", buf);
 | 
					        fprintf(stderr, "qemu: could not load PC bios '%s'\n", buf);
 | 
				
			||||||
        exit(1);
 | 
					        exit(1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -342,12 +354,24 @@ void pc_init(int ram_size, int vga_ram_size, int boot_device,
 | 
				
			|||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME);
 | 
					        snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    ret = load_image(buf, phys_ram_base + 0x000c0000);
 | 
					    ret = load_image(buf, phys_ram_base + vga_bios_offset);
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    /* setup basic memory access */
 | 
					    /* setup basic memory access */
 | 
				
			||||||
    cpu_register_physical_memory(0xc0000, 0x10000, 0xc0000 | IO_MEM_ROM);
 | 
					    cpu_register_physical_memory(0xc0000, 0x10000, 
 | 
				
			||||||
    cpu_register_physical_memory(0xd0000, 0x20000, IO_MEM_UNASSIGNED);
 | 
					                                 vga_bios_offset | IO_MEM_ROM);
 | 
				
			||||||
    cpu_register_physical_memory(0xf0000, 0x10000, 0xf0000 | IO_MEM_ROM);
 | 
					
 | 
				
			||||||
 | 
					    /* map the last 128KB of the BIOS in ISA space */
 | 
				
			||||||
 | 
					    isa_bios_size = bios_size;
 | 
				
			||||||
 | 
					    if (isa_bios_size > (128 * 1024))
 | 
				
			||||||
 | 
					        isa_bios_size = 128 * 1024;
 | 
				
			||||||
 | 
					    cpu_register_physical_memory(0xd0000, (192 * 1024) - isa_bios_size, 
 | 
				
			||||||
 | 
					                                 IO_MEM_UNASSIGNED);
 | 
				
			||||||
 | 
					    cpu_register_physical_memory(0x100000 - isa_bios_size, 
 | 
				
			||||||
 | 
					                                 isa_bios_size, 
 | 
				
			||||||
 | 
					                                 (bios_offset + bios_size - isa_bios_size) | IO_MEM_ROM);
 | 
				
			||||||
 | 
					    /* map all the bios at the top of memory */
 | 
				
			||||||
 | 
					    cpu_register_physical_memory((uint32_t)(-bios_size), 
 | 
				
			||||||
 | 
					                                 bios_size, bios_offset | IO_MEM_ROM);
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    bochs_bios_init();
 | 
					    bochs_bios_init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										12
									
								
								vl.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								vl.c
									
									
									
									
									
								
							@ -290,6 +290,18 @@ char *pstrcat(char *buf, int buf_size, const char *s)
 | 
				
			|||||||
    return buf;
 | 
					    return buf;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* return the size or -1 if error */
 | 
				
			||||||
 | 
					int get_image_size(const char *filename)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int fd, size;
 | 
				
			||||||
 | 
					    fd = open(filename, O_RDONLY | O_BINARY);
 | 
				
			||||||
 | 
					    if (fd < 0)
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
 | 
					    size = lseek(fd, 0, SEEK_END);
 | 
				
			||||||
 | 
					    close(fd);
 | 
				
			||||||
 | 
					    return size;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* return the size or -1 if error */
 | 
					/* return the size or -1 if error */
 | 
				
			||||||
int load_image(const char *filename, uint8_t *addr)
 | 
					int load_image(const char *filename, uint8_t *addr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										3
									
								
								vl.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								vl.h
									
									
									
									
									
								
							@ -209,6 +209,7 @@ uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void hw_error(const char *fmt, ...);
 | 
					void hw_error(const char *fmt, ...);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int get_image_size(const char *filename);
 | 
				
			||||||
int load_image(const char *filename, uint8_t *addr);
 | 
					int load_image(const char *filename, uint8_t *addr);
 | 
				
			||||||
extern const char *bios_dir;
 | 
					extern const char *bios_dir;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -243,7 +244,7 @@ extern int cirrus_vga_enabled;
 | 
				
			|||||||
#if defined (TARGET_PPC)
 | 
					#if defined (TARGET_PPC)
 | 
				
			||||||
#define BIOS_SIZE (512 * 1024)
 | 
					#define BIOS_SIZE (512 * 1024)
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#define BIOS_SIZE 0
 | 
					#define BIOS_SIZE ((256 + 64) * 1024)
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* keyboard/mouse support */
 | 
					/* keyboard/mouse support */
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user