Commit 9ae0255520fb37d9972bef9bf58d6f342ea7128a

Authored by ths
1 parent a0ae05aa

Add -option-rom option to allow loading of PCI option ROMs, by Anthony Liguori.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2292 c046a42c-6fe2-441c-8c8c-71466251a162
... ... @@ -451,7 +451,7 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
451 451 {
452 452 char buf[1024];
453 453 int ret, linux_boot, initrd_size, i;
454   - unsigned long bios_offset, vga_bios_offset;
  454 + unsigned long bios_offset, vga_bios_offset, option_rom_offset;
455 455 int bios_size, isa_bios_size;
456 456 PCIBus *pci_bus;
457 457 int piix3_devfn = -1;
... ... @@ -518,6 +518,23 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
518 518 cpu_register_physical_memory(0x100000 - isa_bios_size,
519 519 isa_bios_size,
520 520 (bios_offset + bios_size - isa_bios_size) | IO_MEM_ROM);
  521 +
  522 + option_rom_offset = 0;
  523 + for (i = 0; i < nb_option_roms; i++) {
  524 + int offset = bios_offset + bios_size + option_rom_offset;
  525 + int size;
  526 +
  527 + size = load_image(option_rom[i], phys_ram_base + offset);
  528 + if ((size + option_rom_offset) > 0x10000) {
  529 + fprintf(stderr, "Too many option ROMS\n");
  530 + exit(1);
  531 + }
  532 + cpu_register_physical_memory(0xd0000 + option_rom_offset,
  533 + size, offset | IO_MEM_ROM);
  534 + option_rom_offset += size + 2047;
  535 + option_rom_offset -= (option_rom_offset % 2048);
  536 + }
  537 +
521 538 /* map all the bios at the top of memory */
522 539 cpu_register_physical_memory((uint32_t)(-bios_size),
523 540 bios_size, bios_offset | IO_MEM_ROM);
... ...
qemu-doc.texi
... ... @@ -326,6 +326,10 @@ Use it when installing Windows 2000 to avoid a disk full bug. After
326 326 Windows 2000 is installed, you no longer need this option (this option
327 327 slows down the IDE transfers).
328 328  
  329 +@item -option-rom file
  330 +Load the contents of file as an option ROM. This option is useful to load
  331 +things like EtherBoot.
  332 +
329 333 @end table
330 334  
331 335 USB options:
... ...
... ... @@ -174,6 +174,8 @@ int acpi_enabled = 1;
174 174 int fd_bootchk = 1;
175 175 int no_reboot = 0;
176 176 int daemonize = 0;
  177 +const char *option_rom[MAX_OPTION_ROMS];
  178 +int nb_option_roms;
177 179  
178 180 /***********************************************************/
179 181 /* x86 ISA bus support */
... ... @@ -6336,6 +6338,7 @@ void help(void)
6336 6338 #ifndef _WIN32
6337 6339 "-daemonize daemonize QEMU after initializing\n"
6338 6340 #endif
  6341 + "-option-rom rom load a file, rom, into the option ROM space\n"
6339 6342 "\n"
6340 6343 "During emulation, the following keys are useful:\n"
6341 6344 "ctrl-alt-f toggle full screen\n"
... ... @@ -6418,6 +6421,7 @@ enum {
6418 6421 QEMU_OPTION_no_reboot,
6419 6422 QEMU_OPTION_daemonize,
6420 6423 QEMU_OPTION_disk,
  6424 + QEMU_OPTION_option_rom,
6421 6425 };
6422 6426  
6423 6427 typedef struct QEMUOption {
... ... @@ -6500,6 +6504,7 @@ const QEMUOption qemu_options[] = {
6500 6504 { "no-acpi", 0, QEMU_OPTION_no_acpi },
6501 6505 { "no-reboot", 0, QEMU_OPTION_no_reboot },
6502 6506 { "daemonize", 0, QEMU_OPTION_daemonize },
  6507 + { "option-rom", HAS_ARG, QEMU_OPTION_option_rom },
6503 6508 { NULL },
6504 6509 };
6505 6510  
... ... @@ -7276,6 +7281,14 @@ int main(int argc, char **argv)
7276 7281 case QEMU_OPTION_daemonize:
7277 7282 daemonize = 1;
7278 7283 break;
  7284 + case QEMU_OPTION_option_rom:
  7285 + if (nb_option_roms >= MAX_OPTION_ROMS) {
  7286 + fprintf(stderr, "Too many option ROMs\n");
  7287 + exit(1);
  7288 + }
  7289 + option_rom[nb_option_roms] = optarg;
  7290 + nb_option_roms++;
  7291 + break;
7279 7292 }
7280 7293 }
7281 7294 }
... ... @@ -7368,6 +7381,15 @@ int main(int argc, char **argv)
7368 7381 /* init the memory */
7369 7382 phys_ram_size = ram_size + vga_ram_size + bios_size;
7370 7383  
  7384 + for (i = 0; i < nb_option_roms; i++) {
  7385 + int ret = get_image_size(option_rom[i]);
  7386 + if (ret == -1) {
  7387 + fprintf(stderr, "Could not load option rom '%s'\n", option_rom[i]);
  7388 + exit(1);
  7389 + }
  7390 + phys_ram_size += ret;
  7391 + }
  7392 +
7371 7393 phys_ram_base = qemu_vmalloc(phys_ram_size);
7372 7394 if (!phys_ram_base) {
7373 7395 fprintf(stderr, "Could not allocate physical memory\n");
... ...
... ... @@ -154,6 +154,10 @@ extern int usb_enabled;
154 154 extern int smp_cpus;
155 155 extern int no_quit;
156 156  
  157 +#define MAX_OPTION_ROMS 16
  158 +extern const char *option_rom[MAX_OPTION_ROMS];
  159 +extern int nb_option_roms;
  160 +
157 161 /* XXX: make it dynamic */
158 162 #if defined (TARGET_PPC) || defined (TARGET_SPARC64)
159 163 #define BIOS_SIZE ((512 + 32) * 1024)
... ...