[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 02/13] pci: implement RW1C register framework.
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH v3 02/13] pci: implement RW1C register framework. |
Date: |
Wed, 15 Sep 2010 14:38:15 +0900 |
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 <address@hidden>
---
hw/pci.c | 5 +++++
hw/pci.h | 3 +++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index ceee291..afb52dd 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -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) ||
diff --git a/hw/pci.h b/hw/pci.h
index 3879708..f4ea97a 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -130,6 +130,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;
--
1.7.1.1
- [Qemu-devel] [PATCH v3 00/13] pcie port switch emulators, Isaku Yamahata, 2010/09/15
- [Qemu-devel] [PATCH v3 03/13] pci: introduce helper function pci_shift_word/long which returns shifted value., Isaku Yamahata, 2010/09/15
- [Qemu-devel] [PATCH v3 07/13] pcie port: define struct PCIEPort/PCIESlot and helper functions, Isaku Yamahata, 2010/09/15
- [Qemu-devel] [PATCH v3 02/13] pci: implement RW1C register framework.,
Isaku Yamahata <=
- [Qemu-devel] [PATCH v3 01/13] msi: implemented msi., Isaku Yamahata, 2010/09/15
- [Qemu-devel] [PATCH v3 12/13] pcie/aer: glue aer error injection into qemu monitor., Isaku Yamahata, 2010/09/15
- [Qemu-devel] [PATCH v3 10/13] pcie downstream port: pci express switch downstream port., Isaku Yamahata, 2010/09/15
- [Qemu-devel] [PATCH v3 05/13] pcie: helper functions for pcie capability and extended capability., Isaku Yamahata, 2010/09/15