[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/3] iommu: add generic mapping support for the isa
From: |
Jason Baron |
Subject: |
[Qemu-devel] [PATCH 3/3] iommu: add generic mapping support for the isa bus |
Date: |
Wed, 20 Jun 2012 16:11:14 -0400 |
Introduce 'isa_setup_iommu()' to allow chipsets to associate an iommu mapping
function with the isa bus. This allows isa devices which sit behind an iommu
to be correctly configured. This is based on Benjamin Herrenschmidt's iommu
series. It has no consumers for now.
Signed-off-by: Jason Baron <address@hidden>
---
hw/isa-bus.c | 11 +++++++++++
hw/isa.h | 5 +++++
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index cfd7501..0232799 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -118,10 +118,17 @@ void isa_register_portio_list(ISADevice *dev, uint16_t
start,
portio_list_add(piolist, isabus->address_space_io, start);
}
+void isa_setup_iommu(ISABus *bus, ISADMAContextFunc fn, void *opaque)
+{
+ bus->dma_context_fn = fn;
+ bus->dma_context_opaque = opaque;
+}
+
static int isa_qdev_init(DeviceState *qdev)
{
ISADevice *dev = ISA_DEVICE(qdev);
ISADeviceClass *klass = ISA_DEVICE_GET_CLASS(dev);
+ ISABus *isabus;
dev->isairq[0] = -1;
dev->isairq[1] = -1;
@@ -132,6 +139,10 @@ static int isa_qdev_init(DeviceState *qdev)
/* iommu setup */
dev->dma = NULL;
+ isabus = FROM_QBUS(ISABus, qdev_get_parent_bus(qdev));
+ if (isabus->dma_context_fn) {
+ dev->dma = isabus->dma_context_fn(isabus, isabus->dma_context_opaque);
+ }
return 0;
}
diff --git a/hw/isa.h b/hw/isa.h
index a1c3f25..e6a0bb1 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -26,10 +26,15 @@ typedef struct ISADeviceClass {
int (*init)(ISADevice *dev);
} ISADeviceClass;
+typedef DMAContext *(*ISADMAContextFunc)(ISABus *, void *);
+void isa_setup_iommu(ISABus *bus, ISADMAContextFunc fn, void *opaque);
+
struct ISABus {
BusState qbus;
MemoryRegion *address_space_io;
qemu_irq *irqs;
+ ISADMAContextFunc dma_context_fn;
+ void *dma_context_opaque;
};
struct ISADevice {
--
1.7.1