On 10/18/2010 12:58 PM, Michael S. Tsirkin wrote:
On Mon, Oct 18, 2010 at 07:55:11PM +0200, Stefan Weil wrote:
PCI devices with different vendor or device ids sometimes share
the same rom code. Only the ids and the checksum
differs in a boot rom for such devices.

The i825xx ethernet controller family is a typical example
which is implemented in hw/eepro100.c. It uses at least
3 different device ids, so normally 3 boot roms would be needed.

By automatically patching vendor id and device id (and the checksum)
in qemu, all emulated family members can share the same boot rom.

VGA bios roms are another example with different vendor and device ids.

v2:

* Patch also the vendor id (and remove the sanity check for vendor id).

Cc: Gerd Hoffmann<kra...@redhat.com>
Cc: Markus Armbruster<arm...@redhat.com>
Cc: Michael S. Tsirkin<m...@redhat.com>
Signed-off-by: Stefan Weil<w...@mail.berlios.de>
---
  hw/pci.c |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index 1280d4d..139eb24 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1797,6 +1797,62 @@ static void pci_map_option_rom(PCIDevice *pdev, int 
region_num, pcibus_t addr, p
      cpu_register_physical_memory(addr, size, pdev->rom_offset);
  }

+/* Patch the PCI vendor and device ids in a PCI rom image if necessary.
+   This is needed for an option rom which is used for more than one device. */
+static void pci_patch_ids(PCIDevice *pdev, uint8_t *ptr, int size)
let's return an error code on malformed roms so management can detect errors?

A bad/missing PnP header does not mean it's an invalid ROM.

Regards,

Anthony Liguori



Reply via email to