diff options
author | Isaku Yamahata <yamahata@valinux.co.jp> | 2009-10-30 21:21:20 +0900 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-11-09 08:43:10 -0600 |
commit | 260c0cd3d985e51b15870ff47e17b7b930efbda1 (patch) | |
tree | 79975eccaf1c4dabd375ba7d81fc3971f28001ba /hw/pci.c | |
parent | pci: add helper functions to check ranges overlap. (diff) | |
download | qemu-kvm-260c0cd3d985e51b15870ff47e17b7b930efbda1.tar.gz qemu-kvm-260c0cd3d985e51b15870ff47e17b7b930efbda1.tar.bz2 qemu-kvm-260c0cd3d985e51b15870ff47e17b7b930efbda1.zip |
pci: use range helper functions.
clean up pci_default_write_config() by the range helper functions.
Suggested by Michael S. Tsirkin <mst@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/pci.c')
-rw-r--r-- | hw/pci.c | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -699,19 +699,15 @@ uint32_t pci_default_read_config(PCIDevice *d, void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l) { - uint8_t orig[PCI_CONFIG_SPACE_SIZE]; int i; uint32_t config_size = pci_config_size(d); - /* not efficient, but simple */ - memcpy(orig, d->config, PCI_CONFIG_SPACE_SIZE); for(i = 0; i < l && addr < config_size; val >>= 8, ++i, ++addr) { uint8_t wmask = d->wmask[addr]; d->config[addr] = (d->config[addr] & ~wmask) | (val & wmask); } - if (memcmp(orig + PCI_BASE_ADDRESS_0, d->config + PCI_BASE_ADDRESS_0, 24) - || ((orig[PCI_COMMAND] ^ d->config[PCI_COMMAND]) - & (PCI_COMMAND_MEMORY | PCI_COMMAND_IO))) + if (ranges_overlap(addr, l, PCI_BASE_ADDRESS_0, 24) || + range_covers_byte(addr, l, PCI_COMMAND)) pci_update_mappings(d); } |