Revision 34b39c2b hw/pc.c

b/hw/pc.c
763 763
{
764 764
    char buf[1024];
765 765
    int ret, linux_boot, i;
766
    ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset;
766
    ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset, option_rom_start = 0;
767 767
    ram_addr_t below_4g_mem_size, above_4g_mem_size = 0;
768 768
    int bios_size, isa_bios_size, vga_bios_size;
769 769
    PCIBus *pci_bus;
......
774 774
    int index;
775 775
    BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
776 776
    BlockDriverState *fd[MAX_FD];
777
    int using_vga = cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled;
777 778

  
778 779
    if (ram_size >= 0xe0000000 ) {
779 780
        above_4g_mem_size = ram_size - 0xe0000000;
......
856 857
        exit(1);
857 858
    }
858 859

  
859
    if (cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled) {
860
    if (using_vga) {
860 861
        /* VGA BIOS load */
861 862
        if (cirrus_vga_enabled) {
862 863
            snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_CIRRUS_FILENAME);
......
874 875
            fprintf(stderr, "qemu: could not load VGA BIOS '%s'\n", buf);
875 876
            exit(1);
876 877
        }
878
	/* Round up vga bios size to the next 2k boundary */
879
	vga_bios_size = (vga_bios_size + 2047) & ~2047;
880
	option_rom_start = 0xc0000 + vga_bios_size;
877 881

  
878 882
        /* setup basic memory access */
879
        cpu_register_physical_memory(0xc0000, 0x10000,
883
        cpu_register_physical_memory(0xc0000, vga_bios_size,
880 884
                                     vga_bios_offset | IO_MEM_ROM);
881 885
    }
882 886

  
887
    /* No point in placing option roms before this address, since bochs bios
888
     * will only start looking for it at 0xc8000 */
889
    if (option_rom_start < 0xc8000)
890
	    option_rom_start = 0xc8000;
891

  
892

  
883 893
    /* map the last 128KB of the BIOS in ISA space */
884 894
    isa_bios_size = bios_size;
885 895
    if (isa_bios_size > (128 * 1024))
......
892 902
        ram_addr_t option_rom_offset;
893 903
        int size, offset;
894 904

  
895
        offset = 0;
905
        offset = option_rom_start;
896 906
        if (linux_boot) {
897 907
            option_rom_offset = qemu_ram_alloc(TARGET_PAGE_SIZE);
898 908
            load_linux(phys_ram_base + option_rom_offset,
899 909
                       kernel_filename, initrd_filename, kernel_cmdline);
900
            cpu_register_physical_memory(0xd0000, TARGET_PAGE_SIZE,
910
            cpu_register_physical_memory(option_rom_start, TARGET_PAGE_SIZE,
901 911
                                         option_rom_offset | IO_MEM_ROM);
902
            offset = TARGET_PAGE_SIZE;
912
            offset += TARGET_PAGE_SIZE;
903 913
        }
904 914

  
905 915
        for (i = 0; i < nb_option_roms; i++) {
......
909 919
                        option_rom[i]);
910 920
                exit(1);
911 921
            }
912
            if (size > (0x10000 - offset))
922
            if (size > (0xe0000  - offset))
913 923
                goto option_rom_error;
914 924
            option_rom_offset = qemu_ram_alloc(size);
915 925
            ret = load_image(option_rom[i], phys_ram_base + option_rom_offset);
916 926
            if (ret != size) {
917 927
            option_rom_error:
918
                fprintf(stderr, "Too many option ROMS\n");
928
                fprintf(stderr, "Could not fit %soption roms in available space\n", using_vga ? "VGA bios and " : "");
919 929
                exit(1);
920 930
            }
921 931
            size = (size + 4095) & ~4095;
922
            cpu_register_physical_memory(0xd0000 + offset,
923
                                         size, option_rom_offset | IO_MEM_ROM);
932
            cpu_register_physical_memory(offset, size, option_rom_offset | IO_MEM_ROM);
924 933
            offset += size;
925 934
        }
926 935
    }

Also available in: Unified diff