[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 19/23] pci: use helper function in pci_default_write
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH 19/23] pci: use helper function in pci_default_write_config() |
Date: |
Mon, 5 Oct 2009 19:06:59 +0900 |
use helper function in pci_default_write_config() to
check whether the configuration space is changed.
Signed-off-by: Isaku Yamahata <address@hidden>
---
hw/pci.c | 23 +++++++++--------------
hw/pci.h | 1 +
2 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 65afbd2..b8d2f8f 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -681,21 +681,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 = pcie_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);
+ }
}
static void pci_data_write_common(PCIDevice *pci_dev,
diff --git a/hw/pci.h b/hw/pci.h
index 0ea08b7..37c2c23 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -118,6 +118,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_PRIMARY_BUS 0x18 /* Primary bus number */
#define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */
#define PCI_SEC_STATUS 0x1e /* Secondary status register, only bit
14 used */
--
1.6.0.2
- [Qemu-devel] [PATCH 08/23] pci: use helper functions to access pci config space., (continued)
- [Qemu-devel] [PATCH 08/23] pci: use helper functions to access pci config space., Isaku Yamahata, 2009/10/05
- [Qemu-devel] [PATCH 07/23] pci: helper functions to access PCIDevice::config, Isaku Yamahata, 2009/10/05
- [Qemu-devel] [PATCH 21/23] pci/brdige: qdevfy and initialize secondary bus and subordinate bus., Isaku Yamahata, 2009/10/05
- [Qemu-devel] [PATCH 23/23] pci/monitor: print out bridge's filtering values and so on., Isaku Yamahata, 2009/10/05
- [Qemu-devel] [PATCH 04/23] pci: use the symbolic constant, PCI_ROM_ADDRESS_ENABLE instead of 1., Isaku Yamahata, 2009/10/05
- [Qemu-devel] [PATCH 18/23] pci: add helper functions for pci config write function., Isaku Yamahata, 2009/10/05
- [Qemu-devel] [PATCH 09/23] pci: introduce pcibus_t to represent pci bus address/size instead of uint32_t, Isaku Yamahata, 2009/10/05
- [Qemu-devel] [PATCH 19/23] pci: use helper function in pci_default_write_config(),
Isaku Yamahata <=
- [Qemu-devel] Re: [PATCH v4 00/23] pci: various pci clean up and pci express support., Michael S. Tsirkin, 2009/10/05
- [Qemu-devel] [PATCH 16/23] pci: pcie host and mmcfg support., Isaku Yamahata, 2009/10/05
- [Qemu-devel] Re: [PATCH 16/23] pci: pcie host and mmcfg support., Michael S. Tsirkin, 2009/10/05