[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 03/13] pci: introduce helper function pci_shift_w
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH v3 03/13] pci: introduce helper function pci_shift_word/long which returns shifted value. |
Date: |
Wed, 15 Sep 2010 14:38:16 +0900 |
introduce helper function pci_shift_{word, long}() which returns
returns shifted word/long of given position and range.
They will be used later.
Signed-off-by: Isaku Yamahata <address@hidden>
---
hw/pci.h | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/hw/pci.h b/hw/pci.h
index f4ea97a..630631b 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -327,6 +327,25 @@ pci_config_set_interrupt_pin(uint8_t *pci_config, uint8_t
val)
pci_set_byte(&pci_config[PCI_INTERRUPT_PIN], val);
}
+static inline uint32_t
+pci_shift_long(uint32_t addr, uint32_t val, uint32_t pos)
+{
+ if (addr >= pos) {
+ assert(addr - pos <= 32 / 8);
+ val <<= (addr - pos) * 8;
+ } else {
+ assert(pos - addr <= 32 / 8);
+ val >>= (pos - addr) * 8;
+ }
+ return val;
+}
+
+static inline uint16_t
+pci_shift_word(uint32_t addr, uint32_t val, uint32_t pos)
+{
+ return pci_shift_long(addr, val, pos);
+}
+
typedef int (*pci_qdev_initfn)(PCIDevice *dev);
typedef struct {
DeviceInfo qdev;
--
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 <=
- [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, 2010/09/15
- [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