[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V6 06/32] pci: use helper functions to access pci co
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH V6 06/32] pci: use helper functions to access pci config space. |
Date: |
Fri, 30 Oct 2009 21:21:00 +0900 |
use pci_[gs]et_{byte, word, long}() to access pci configuration
space.
Signed-off-by: Isaku Yamahata <address@hidden>
Acked-by: Michael S. Tsirkin <address@hidden>
---
hw/pci.c | 30 +++++++++++++++---------------
1 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 00d407d..ab5eff8 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -477,9 +477,9 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
/* ROM enable bit is writeable */
wmask |= PCI_ROM_ADDRESS_ENABLE;
}
- *(uint32_t *)(pci_dev->config + addr) = cpu_to_le32(type);
- *(uint32_t *)(pci_dev->wmask + addr) = cpu_to_le32(wmask);
- *(uint32_t *)(pci_dev->cmask + addr) = 0xffffffff;
+ pci_set_long(pci_dev->config + addr, type);
+ pci_set_long(pci_dev->wmask + addr, wmask);
+ pci_set_long(pci_dev->cmask + addr, 0xffffffff);
}
static void pci_update_mappings(PCIDevice *d)
@@ -488,7 +488,7 @@ static void pci_update_mappings(PCIDevice *d)
int cmd, i;
uint32_t last_addr, new_addr;
- cmd = le16_to_cpu(*(uint16_t *)(d->config + PCI_COMMAND));
+ cmd = pci_get_word(d->config + PCI_COMMAND);
for(i = 0; i < PCI_NUM_REGIONS; i++) {
r = &d->io_regions[i];
if (r->size != 0) {
@@ -564,18 +564,18 @@ uint32_t pci_default_read_config(PCIDevice *d,
default:
case 4:
if (address <= 0xfc) {
- val = le32_to_cpu(*(uint32_t *)(d->config + address));
+ val = pci_get_long(d->config + address);
break;
}
/* fall through */
case 2:
if (address <= 0xfe) {
- val = le16_to_cpu(*(uint16_t *)(d->config + address));
+ val = pci_get_word(d->config + address);
break;
}
/* fall through */
case 1:
- val = d->config[address];
+ val = pci_get_byte(d->config + address);
break;
}
return val;
@@ -746,7 +746,7 @@ static void pci_info_device(PCIDevice *d)
monitor_printf(mon, " Bus %2d, device %3d, function %d:\n",
d->bus->bus_num, PCI_SLOT(d->devfn), PCI_FUNC(d->devfn));
- class = le16_to_cpu(*((uint16_t *)(d->config + PCI_CLASS_DEVICE)));
+ class = pci_get_word(d->config + PCI_CLASS_DEVICE);
monitor_printf(mon, " ");
desc = pci_class_descriptions;
while (desc->desc && class != desc->class)
@@ -757,8 +757,8 @@ static void pci_info_device(PCIDevice *d)
monitor_printf(mon, "Class %04x", class);
}
monitor_printf(mon, ": PCI device %04x:%04x\n",
- le16_to_cpu(*((uint16_t *)(d->config + PCI_VENDOR_ID))),
- le16_to_cpu(*((uint16_t *)(d->config + PCI_DEVICE_ID))));
+ pci_get_word(d->config + PCI_VENDOR_ID),
+ pci_get_word(d->config + PCI_DEVICE_ID));
if (d->config[PCI_INTERRUPT_PIN] != 0) {
monitor_printf(mon, " IRQ %d.\n",
@@ -1098,7 +1098,7 @@ static void pcibus_dev_print(Monitor *mon, DeviceState
*dev, int indent)
PCIIORegion *r;
int i, class;
- class = le16_to_cpu(*((uint16_t *)(d->config + PCI_CLASS_DEVICE)));
+ class = pci_get_word(d->config + PCI_CLASS_DEVICE);
desc = pci_class_descriptions;
while (desc->desc && class != desc->class)
desc++;
@@ -1112,10 +1112,10 @@ static void pcibus_dev_print(Monitor *mon, DeviceState
*dev, int indent)
"pci id %04x:%04x (sub %04x:%04x)\n",
indent, "", ctxt,
d->bus->bus_num, PCI_SLOT(d->devfn), PCI_FUNC(d->devfn),
- le16_to_cpu(*((uint16_t *)(d->config + PCI_VENDOR_ID))),
- le16_to_cpu(*((uint16_t *)(d->config + PCI_DEVICE_ID))),
- le16_to_cpu(*((uint16_t *)(d->config +
PCI_SUBSYSTEM_VENDOR_ID))),
- le16_to_cpu(*((uint16_t *)(d->config + PCI_SUBSYSTEM_ID))));
+ pci_get_word(d->config + PCI_VENDOR_ID),
+ pci_get_word(d->config + PCI_DEVICE_ID),
+ pci_get_word(d->config + PCI_SUBSYSTEM_VENDOR_ID),
+ pci_get_word(d->config + PCI_SUBSYSTEM_ID));
for (i = 0; i < PCI_NUM_REGIONS; i++) {
r = &d->io_regions[i];
if (!r->size)
--
1.6.0.2
- [Qemu-devel] [PATCH V6 00/32] pci: various pci clean up and pci express support., Isaku Yamahata, 2009/10/30
- [Qemu-devel] [PATCH V6 10/32] pci: clean up of pci_default_read_config., Isaku Yamahata, 2009/10/30
- [Qemu-devel] [PATCH V6 06/32] pci: use helper functions to access pci config space.,
Isaku Yamahata <=
- [Qemu-devel] [PATCH V6 05/32] pci: helper functions to access PCIDevice::config, Isaku Yamahata, 2009/10/30
- [Qemu-devel] [PATCH V6 11/32] pci: make pci_bar() aware of header type 1., Isaku Yamahata, 2009/10/30
- [Qemu-devel] [PATCH V6 17/32] pci: 64bit bar support., Isaku Yamahata, 2009/10/30
- [Qemu-devel] [PATCH V6 16/32] pci: typedef pcibus_t as uint64_t instead of uint32_t., Isaku Yamahata, 2009/10/30
- [Qemu-devel] [PATCH V6 02/32] pci: introduce constant PCI_NUM_PINS for the number of interrupt pins, 4., Isaku Yamahata, 2009/10/30
- [Qemu-devel] [PATCH V6 14/32] pci: introduce pcibus_t to represent pci bus address/size instead of uint32_t, Isaku Yamahata, 2009/10/30
- [Qemu-devel] [PATCH V6 15/32] pci: introduce FMT_PCIBUS for printf format for pcibus_t., Isaku Yamahata, 2009/10/30
- [Qemu-devel] [PATCH V6 01/32] pci: fix PCI_DPRINTF() wrt variadic macro., Isaku Yamahata, 2009/10/30
- [Qemu-devel] [PATCH V6 18/32] pci: remove bus_num member from struct PCIBus., Isaku Yamahata, 2009/10/30
- [Qemu-devel] [PATCH V6 21/32] pci: move pci host stuff from pci.c to pci_host.c, Isaku Yamahata, 2009/10/30