Commit 34b39c2ba6cc08239a707b52bfb2886df2aa8dec

Authored by aliguori
1 parent 221f715d

get roms more room. (Glauber Costa)

This patch increases by 50 % the size available for option roms.
The main motivator is that some roms grew bigger than the 64k we
currently allocate for them (Hey, it's 2009!)

One example is the gpxe project, that produces some roms with 69k,
70k, etc. The space proposed by this patch actually makes it as
big as 84k. Probably still a fit for some time.

But there is no free lunch. This space must come from somewhere,
and we take it from vga rom space. Currently, our vga roms are
around 35k in size. With this patch, option rom space will begin
just after vga ends, aligned to the next 2k boundary.

Technicaly, we could do the same with the uper space (the bios itself),
but since bochs bios is already 128 k in size, I don't see an
urgent need to do it.

[ fix case for vgabioses smaller than 30k, by Carl-Daniel Hailfinger ]

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6896 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 19 additions and 10 deletions
... ... @@ -763,7 +763,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
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,6 +774,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
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,7 +857,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
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,12 +875,21 @@ vga_bios_error:
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,14 +902,14 @@ vga_bios_error:
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,18 +919,17 @@ vga_bios_error:
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 }
... ...