[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [PATCH 08/25] pci: use helper functions to access pci c
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] Re: [PATCH 08/25] pci: use helper functions to access pci config space. |
Date: |
Sun, 4 Oct 2009 11:47:29 +0200 |
User-agent: |
Mutt/1.5.19 (2009-01-05) |
On Sat, Oct 03, 2009 at 05:16:00AM +0900, Isaku Yamahata wrote:
> 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 | 38 ++++++++++++++++++--------------------
> 1 files changed, 18 insertions(+), 20 deletions(-)
>
> diff --git a/hw/pci.c b/hw/pci.c
> index 39791d0..21e23b0 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -426,9 +426,9 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
> } else {
> addr = 0x10 + region_num * 4;
> }
> - *(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)
> @@ -437,7 +437,7 @@ static void pci_update_mappings(PCIDevice *d)
> int cmd, i;
> uint32_t last_addr, new_addr, config_ofs;
>
> - 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 (i == PCI_ROM_SLOT) {
> @@ -448,8 +448,7 @@ static void pci_update_mappings(PCIDevice *d)
> if (r->size != 0) {
> if (r->type & PCI_ADDRESS_SPACE_IO) {
> if (cmd & PCI_COMMAND_IO) {
> - new_addr = le32_to_cpu(*(uint32_t *)(d->config +
> - config_ofs));
> + new_addr = pci_get_long(d->config + config_ofs);
> new_addr = new_addr & ~(r->size - 1);
> last_addr = new_addr + r->size - 1;
> /* NOTE: we have only 64K ioports on PC */
> @@ -462,8 +461,7 @@ static void pci_update_mappings(PCIDevice *d)
> }
> } else {
> if (cmd & PCI_COMMAND_MEMORY) {
> - new_addr = le32_to_cpu(*(uint32_t *)(d->config +
> - config_ofs));
> + new_addr = pci_get_long(d->config + config_ofs);
> /* the ROM slot has a specific enable bit */
> if (i == PCI_ROM_SLOT && !(new_addr & 1))
> goto no_mem_map;
> @@ -489,7 +487,7 @@ static void pci_update_mappings(PCIDevice *d)
> int class;
> /* NOTE: specific hack for IDE in PC case:
> only one byte must be mapped. */
> - class = d->config[0x0a] | (d->config[0x0b] << 8);
> + class = pci_get_word(d->config + PCI_CLASS_DEVICE);
> if (class == 0x0101 && r->size == 4) {
> isa_unassign_ioport(r->addr + 2, 1);
> } else {
> @@ -520,18 +518,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;
> @@ -704,7 +702,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)
> @@ -715,8 +713,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",
> @@ -1026,7 +1024,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++;
> @@ -1040,10 +1038,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 06/25] pci: define a constant to represent a unmapped bar and use it., (continued)
[Qemu-devel] [PATCH 08/25] pci: use helper functions to access pci config space., Isaku Yamahata, 2009/10/02
- [Qemu-devel] Re: [PATCH 08/25] pci: use helper functions to access pci config space.,
Michael S. Tsirkin <=
[Qemu-devel] [PATCH 10/25] pci: introduce FMT_pcibus for printf format for pcibus_t., Isaku Yamahata, 2009/10/02
[Qemu-devel] [PATCH 14/25] pci: factor out the logic to get pci device from address., Isaku Yamahata, 2009/10/02
[Qemu-devel] [PATCH 25/25] pci/monitor: print out bridge's filtering values and so on., Isaku Yamahata, 2009/10/02
[Qemu-devel] [PATCH 04/25] pci: use the symbolic constant, PCI_ROM_ADDRESS_ENABLE instead of 1., Isaku Yamahata, 2009/10/02
[Qemu-devel] [PATCH 15/25] pci_host.h: split non-inline static function in pci_host.h into pci_host.c, Isaku Yamahata, 2009/10/02
[Qemu-devel] [PATCH 20/25] pci: factor out config update logic., Isaku Yamahata, 2009/10/02
[Qemu-devel] [PATCH 18/25] pci: add helper functions for pci config write function., Isaku Yamahata, 2009/10/02