@@ -692,21 +692,16 @@ 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) ||
- memcmp(orig + PCI_ROM_ADDRESS, d->config + PCI_ROM_ADDRESS, 4))
- || ((orig[PCI_COMMAND] ^ d->config[PCI_COMMAND])
- & (PCI_COMMAND_MEMORY | PCI_COMMAND_IO)))
+ struct pci_config_update update;
+
+ pci_write_config_init(&update, d, addr, val, l);
+ pci_write_config_update(&update);
+ if (pci_config_changed(&update,
+ PCI_BASE_ADDRESS_0, PCI_BASE_ADDRESS_5 + 4) ||
+ pci_config_changed_with_size(&update, PCI_ROM_ADDRESS, 4) ||
+ pci_config_changed_with_size(&update, PCI_COMMAND, 1)) {
pci_update_mappings(d);
+ }
}
void pci_dev_write_config(PCIDevice *pci_dev,
@@ -112,6 +112,7 @@ typedef struct PCIIORegion {
#define PCI_HEADER_TYPE_CARDBUS 2
#define PCI_HEADER_TYPE_MULTI_FUNCTION 0x80
#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */
+#define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */
#define PCI_BASE_ADDRESS_SPACE_IO 0x01
#define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00
#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06
use helper function in pci_default_write_config() to check whether the configuration space is changed. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> --- hw/pci.c | 23 +++++++++-------------- hw/pci.h | 1 + 2 files changed, 10 insertions(+), 14 deletions(-)