[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 01/14] pci: introduce helper functions to test-an
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH v5 01/14] pci: introduce helper functions to test-and-{clear, set} mask in configuration space |
Date: |
Tue, 19 Oct 2010 18:06:28 +0900 |
This patch introduces helper functions to test-and-{clear, set} mask in
configuration
space. pci_{byte, word, long, quad}_test_and_{clear, set}_mask().
They will be used later.
Signed-off-by: Isaku Yamahata <address@hidden>
---
hw/pci.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 70 insertions(+), 0 deletions(-)
diff --git a/hw/pci.h b/hw/pci.h
index d8b399f..752e652 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -323,6 +323,76 @@ pci_config_set_interrupt_pin(uint8_t *pci_config, uint8_t
val)
pci_set_byte(&pci_config[PCI_INTERRUPT_PIN], val);
}
+/*
+ * helper functions to do bit mask operation on configuration space.
+ * Just to set bit, use test-and-set and discard returned value.
+ * Just to clear bit, use test-and-clear and discard returned value.
+ * NOTE: They aren't atomic.
+ */
+static inline uint8_t
+pci_byte_test_and_clear_mask(uint8_t *config, uint8_t mask)
+{
+ uint8_t val = pci_get_byte(config);
+ pci_set_byte(config, val & ~mask);
+ return val & mask;
+}
+
+static inline uint8_t
+pci_byte_test_and_set_mask(uint8_t *config, uint8_t mask)
+{
+ uint8_t val = pci_get_byte(config);
+ pci_set_byte(config, val | mask);
+ return val & mask;
+}
+
+static inline uint16_t
+pci_word_test_and_clear_mask(uint8_t *config, uint16_t mask)
+{
+ uint16_t val = pci_get_word(config);
+ pci_set_word(config, val & ~mask);
+ return val & mask;
+}
+
+static inline uint16_t
+pci_word_test_and_set_mask(uint8_t *config, uint16_t mask)
+{
+ uint16_t val = pci_get_word(config);
+ pci_set_word(config, val | mask);
+ return val & mask;
+}
+
+static inline uint32_t
+pci_long_test_and_clear_mask(uint8_t *config, uint32_t mask)
+{
+ uint32_t val = pci_get_long(config);
+ pci_set_long(config, val & ~mask);
+ return val & mask;
+}
+
+static inline uint32_t
+pci_long_test_and_set_mask(uint8_t *config, uint32_t mask)
+{
+ uint32_t val = pci_get_long(config);
+ pci_set_long(config, val | mask);
+ return val & mask;
+}
+
+static inline uint64_t
+pci_quad_test_and_clear_mask(uint8_t *config, uint64_t mask)
+{
+ uint64_t val = pci_get_quad(config);
+ pci_set_quad(config, val & ~mask);
+ return val & mask;
+}
+
+static inline uint64_t
+pci_quad_test_and_set_mask(uint8_t *config, uint64_t mask)
+{
+ uint64_t val = pci_get_quad(config);
+ pci_set_quad(config, val | mask);
+ return val & mask;
+}
+
typedef int (*pci_qdev_initfn)(PCIDevice *dev);
typedef struct {
DeviceInfo qdev;
--
1.7.1.1
- [Qemu-devel] [PATCH v5 00/14] pcie port switch emulators, Isaku Yamahata, 2010/10/19
- [Qemu-devel] [PATCH v5 04/14] pci/bridge: fix pci_bridge_reset(), Isaku Yamahata, 2010/10/19
- [Qemu-devel] [PATCH v5 13/14] pcie/hotplug: introduce pushing attention button command, Isaku Yamahata, 2010/10/19
- [Qemu-devel] [PATCH v5 03/14] pci: use pci_word_test_and_clear_mask() in pci_device_reset(), Isaku Yamahata, 2010/10/19
- [Qemu-devel] [PATCH v5 02/14] pci: introduce helper function to handle msi-x and msi., Isaku Yamahata, 2010/10/19
- [Qemu-devel] [PATCH v5 14/14] pcie/aer: glue aer error injection into qemu monitor, Isaku Yamahata, 2010/10/19
- [Qemu-devel] [PATCH v5 01/14] pci: introduce helper functions to test-and-{clear, set} mask in configuration space,
Isaku Yamahata <=
- [Qemu-devel] [PATCH v5 06/14] pcie: add pcie constants to pcie_regs.h, Isaku Yamahata, 2010/10/19
- [Qemu-devel] [PATCH v5 12/14] x3130: pcie downstream port, Isaku Yamahata, 2010/10/19
- [Qemu-devel] [PATCH v5 07/14] pcie: helper functions for pcie capability and extended capability, Isaku Yamahata, 2010/10/19
- [Qemu-devel] [PATCH v5 08/14] pcie/aer: helper functions for pcie aer capability, Isaku Yamahata, 2010/10/19
- [Qemu-devel] [PATCH v5 11/14] x3130: pcie upstream port, Isaku Yamahata, 2010/10/19
- [Qemu-devel] [PATCH v5 09/14] pcie port: define struct PCIEPort/PCIESlot and helper functions, Isaku Yamahata, 2010/10/19
- [Qemu-devel] [PATCH v5 05/14] msi: implements msi, Isaku Yamahata, 2010/10/19
- [Qemu-devel] [PATCH v5 10/14] ioh3420: pcie root port in X58 ioh, Isaku Yamahata, 2010/10/19
- [Qemu-devel] Re: [PATCH v5 00/14] pcie port switch emulators, Michael S. Tsirkin, 2010/10/19