diff options
author | Isaku Yamahata <yamahata@valinux.co.jp> | 2010-09-15 14:38:15 +0900 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2010-09-20 20:10:20 +0200 |
commit | 92ba5f51c305911cbfc0fcff9f259b0604681222 (patch) | |
tree | 2a11c5a118f98af364360d5795a0ba3cf46b1fa4 | |
parent | 0bb750ef9e897ba5f4d9899ddc7e222e809bcbbd (diff) |
pci: implement RW1C register framework.
Implement RW1C register framework.
With this patch, it would be easy to implement
W1C(Write 1 to Clear) register by just setting w1cmask.
Later RW1C register will be used by pcie.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r-- | hw/pci.c | 5 | ||||
-rw-r--r-- | hw/pci.h | 3 |
2 files changed, 8 insertions, 0 deletions
@@ -627,6 +627,7 @@ static void pci_config_alloc(PCIDevice *pci_dev) pci_dev->config = qemu_mallocz(config_size); pci_dev->cmask = qemu_mallocz(config_size); pci_dev->wmask = qemu_mallocz(config_size); + pci_dev->w1cmask = qemu_mallocz(config_size); pci_dev->used = qemu_mallocz(config_size); } @@ -635,6 +636,7 @@ static void pci_config_free(PCIDevice *pci_dev) qemu_free(pci_dev->config); qemu_free(pci_dev->cmask); qemu_free(pci_dev->wmask); + qemu_free(pci_dev->w1cmask); qemu_free(pci_dev->used); } @@ -997,7 +999,10 @@ void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l) for (i = 0; i < l && addr + i < config_size; val >>= 8, ++i) { uint8_t wmask = d->wmask[addr + i]; + uint8_t w1cmask = d->w1cmask[addr + i]; + assert(!(wmask & w1cmask)); d->config[addr + i] = (d->config[addr + i] & ~wmask) | (val & wmask); + d->config[addr + i] &= ~(val & w1cmask); /* W1C: Write 1 to Clear */ } if (ranges_overlap(addr, l, PCI_BASE_ADDRESS_0, 24) || ranges_overlap(addr, l, PCI_ROM_ADDRESS, 4) || @@ -129,6 +129,9 @@ struct PCIDevice { /* Used to implement R/W bytes */ uint8_t *wmask; + /* Used to implement RW1C(Write 1 to Clear) bytes */ + uint8_t *w1cmask; + /* Used to allocate config space for capabilities. */ uint8_t *used; |