[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/10] usb-ohci: Use PCI DMA stub functions
From: |
David Gibson |
Subject: |
[Qemu-devel] [PATCH 09/10] usb-ohci: Use PCI DMA stub functions |
Date: |
Thu, 1 Sep 2011 15:01:02 +1000 |
From: Eduard - Gabriel Munteanu <address@hidden>
This updates the usb-ohci device emulation to use the explicit PCI DMA
functions, instead of directly calling physical memory access functions.
Signed-off-by: Eduard - Gabriel Munteanu <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/usb-ohci.c | 46 ++++++++++++++++++++++++++++------------------
1 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c
index d30db3f..d3c0641 100644
--- a/hw/usb-ohci.c
+++ b/hw/usb-ohci.c
@@ -30,6 +30,7 @@
#include "qemu-timer.h"
#include "usb.h"
#include "pci.h"
+#include "dma.h"
#include "usb-ohci.h"
#include "sysbus.h"
#include "qdev-addr.h"
@@ -116,6 +117,14 @@ typedef struct {
} OHCIState;
+typedef struct {
+ PCIDevice pci_dev;
+ OHCIState state;
+ char *masterbus;
+ uint32_t num_ports;
+ uint32_t firstport;
+} OHCIPCIState;
+
/* Host Controller Communications Area */
struct ohci_hcca {
uint32_t intr[32];
@@ -463,12 +472,13 @@ static void ohci_reset(void *opaque)
static inline int get_dwords(OHCIState *ohci,
uint32_t addr, uint32_t *buf, int num)
{
+ OHCIPCIState *s = container_of(ohci, OHCIPCIState, state);
int i;
addr += ohci->localmem_base;
for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) {
- cpu_physical_memory_read(addr, buf, sizeof(*buf));
+ pci_dma_read(&s->pci_dev, addr, buf, sizeof(*buf));
*buf = le32_to_cpu(*buf);
}
@@ -479,13 +489,14 @@ static inline int get_dwords(OHCIState *ohci,
static inline int put_dwords(OHCIState *ohci,
uint32_t addr, uint32_t *buf, int num)
{
+ OHCIPCIState *s = container_of(ohci, OHCIPCIState, state);
int i;
addr += ohci->localmem_base;
for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) {
uint32_t tmp = cpu_to_le32(*buf);
- cpu_physical_memory_write(addr, &tmp, sizeof(tmp));
+ pci_dma_write(&s->pci_dev, addr, &tmp, sizeof(tmp));
}
return 1;
@@ -495,12 +506,13 @@ static inline int put_dwords(OHCIState *ohci,
static inline int get_words(OHCIState *ohci,
uint32_t addr, uint16_t *buf, int num)
{
+ OHCIPCIState *s = container_of(ohci, OHCIPCIState, state);
int i;
addr += ohci->localmem_base;
for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) {
- cpu_physical_memory_read(addr, buf, sizeof(*buf));
+ pci_dma_read(&s->pci_dev, addr, buf, sizeof(*buf));
*buf = le16_to_cpu(*buf);
}
@@ -511,13 +523,14 @@ static inline int get_words(OHCIState *ohci,
static inline int put_words(OHCIState *ohci,
uint32_t addr, uint16_t *buf, int num)
{
+ OHCIPCIState *s = container_of(ohci, OHCIPCIState, state);
int i;
addr += ohci->localmem_base;
for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) {
uint16_t tmp = cpu_to_le16(*buf);
- cpu_physical_memory_write(addr, &tmp, sizeof(tmp));
+ pci_dma_write(&s->pci_dev, addr, &tmp, sizeof(tmp));
}
return 1;
@@ -545,7 +558,8 @@ static inline int ohci_read_iso_td(OHCIState *ohci,
static inline int ohci_read_hcca(OHCIState *ohci,
uint32_t addr, struct ohci_hcca *hcca)
{
- cpu_physical_memory_read(addr + ohci->localmem_base, hcca, sizeof(*hcca));
+ OHCIPCIState *s = container_of(ohci, OHCIPCIState, state);
+ pci_dma_read(&s->pci_dev, addr + ohci->localmem_base, hcca, sizeof(*hcca));
return 1;
}
@@ -571,7 +585,9 @@ static inline int ohci_put_iso_td(OHCIState *ohci,
static inline int ohci_put_hcca(OHCIState *ohci,
uint32_t addr, struct ohci_hcca *hcca)
{
- cpu_physical_memory_write(addr + ohci->localmem_base, hcca, sizeof(*hcca));
+ OHCIPCIState *s = container_of(ohci, OHCIPCIState, state);
+
+ pci_dma_write(&s->pci_dev, addr + ohci->localmem_base, hcca,
sizeof(*hcca));
return 1;
}
@@ -579,6 +595,7 @@ static inline int ohci_put_hcca(OHCIState *ohci,
static void ohci_copy_td(OHCIState *ohci, struct ohci_td *td,
uint8_t *buf, int len, int write)
{
+ OHCIPCIState *s = container_of(ohci, OHCIPCIState, state);
uint32_t ptr;
uint32_t n;
@@ -586,12 +603,12 @@ static void ohci_copy_td(OHCIState *ohci, struct ohci_td
*td,
n = 0x1000 - (ptr & 0xfff);
if (n > len)
n = len;
- cpu_physical_memory_rw(ptr + ohci->localmem_base, buf, n, write);
+ pci_dma_rw(&s->pci_dev, ptr + ohci->localmem_base, buf, n, write);
if (n == len)
return;
ptr = td->be & ~0xfffu;
buf += n;
- cpu_physical_memory_rw(ptr + ohci->localmem_base, buf, len - n, write);
+ pci_dma_rw(&s->pci_dev, ptr + ohci->localmem_base, buf, len - n, write);
}
/* Read/Write the contents of an ISO TD from/to main memory. */
@@ -599,6 +616,7 @@ static void ohci_copy_iso_td(OHCIState *ohci,
uint32_t start_addr, uint32_t end_addr,
uint8_t *buf, int len, int write)
{
+ OHCIPCIState *s = container_of(ohci, OHCIPCIState, state);
uint32_t ptr;
uint32_t n;
@@ -606,12 +624,12 @@ static void ohci_copy_iso_td(OHCIState *ohci,
n = 0x1000 - (ptr & 0xfff);
if (n > len)
n = len;
- cpu_physical_memory_rw(ptr + ohci->localmem_base, buf, n, write);
+ pci_dma_rw(&s->pci_dev, ptr + ohci->localmem_base, buf, n, write);
if (n == len)
return;
ptr = end_addr & ~0xfffu;
buf += n;
- cpu_physical_memory_rw(ptr + ohci->localmem_base, buf, len - n, write);
+ pci_dma_rw(&s->pci_dev, ptr + ohci->localmem_base, buf, len - n, write);
}
static void ohci_process_lists(OHCIState *ohci, int completion);
@@ -1767,14 +1785,6 @@ static int usb_ohci_init(OHCIState *ohci, DeviceState
*dev,
return 0;
}
-typedef struct {
- PCIDevice pci_dev;
- OHCIState state;
- char *masterbus;
- uint32_t num_ports;
- uint32_t firstport;
-} OHCIPCIState;
-
static int usb_ohci_initfn_pci(struct PCIDevice *dev)
{
OHCIPCIState *ohci = DO_UPCAST(OHCIPCIState, pci_dev, dev);
--
1.7.5.4
- [Qemu-devel] [PATCH 10/10] intel-hda: Use PCI DMA stub functions, (continued)
- [Qemu-devel] [PATCH 10/10] intel-hda: Use PCI DMA stub functions, David Gibson, 2011/09/01
- [Qemu-devel] [PATCH 03/10] eepro100: Use PCI DMA stub functions, David Gibson, 2011/09/01
- [Qemu-devel] [PATCH 04/10] ac97: Use PCI DMA stub functions, David Gibson, 2011/09/01
- [Qemu-devel] [PATCH 07/10] lsi53c895a: Use PCI DMA stub functions, David Gibson, 2011/09/01
- [Qemu-devel] [PATCH 08/10] pcnet-pci: Use PCI DMA stub functions, David Gibson, 2011/09/01
- [Qemu-devel] [PATCH 05/10] es1370: Use PCI DMA stub functions, David Gibson, 2011/09/01
- [Qemu-devel] [PATCH 02/10] rtl8139: Use PCI DMA stub functions, David Gibson, 2011/09/01
- [Qemu-devel] [PATCH 06/10] e1000: Use PCI DMA stub functions, David Gibson, 2011/09/01
- [Qemu-devel] [PATCH 09/10] usb-ohci: Use PCI DMA stub functions,
David Gibson <=
- Re: [Qemu-devel] [0/10] Preliminary work for IOMMU emulation support; the easy bits, Eduard - Gabriel Munteanu, 2011/09/01