aboutsummaryrefslogtreecommitdiff
path: root/hw/iommu.c
diff options
context:
space:
mode:
authorBlue Swirl <blauwirbel@gmail.com>2009-07-16 13:47:55 +0000
committerBlue Swirl <blauwirbel@gmail.com>2009-07-16 13:47:55 +0000
commit5f750b2ea04200ae68d31119fb867068d5ef2dbd (patch)
tree4fea75ef947069dcd63f6667bde0860e06aacf7e /hw/iommu.c
parentfa28ec521bbc132556a5379f28eff60207cf9d7d (diff)
Sparc32: convert iommu to qdev
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hw/iommu.c')
-rw-r--r--hw/iommu.c56
1 files changed, 45 insertions, 11 deletions
diff --git a/hw/iommu.c b/hw/iommu.c
index 0af6d32acc..f12b79756b 100644
--- a/hw/iommu.c
+++ b/hw/iommu.c
@@ -21,8 +21,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include "hw.h"
+
#include "sun4m.h"
+#include "sysbus.h"
/* debug iommu */
//#define DEBUG_IOMMU
@@ -127,6 +128,7 @@
#define IOMMU_PAGE_MASK ~(IOMMU_PAGE_SIZE - 1)
typedef struct IOMMUState {
+ SysBusDevice busdev;
uint32_t regs[IOMMU_NREGS];
target_phys_addr_t iostart;
uint32_t version;
@@ -366,20 +368,52 @@ static void iommu_reset(void *opaque)
void *iommu_init(target_phys_addr_t addr, uint32_t version, qemu_irq irq)
{
- IOMMUState *s;
- int iommu_io_memory;
+ DeviceState *dev;
+ SysBusDevice *s;
+ IOMMUState *d;
+
+ dev = qdev_create(NULL, "iommu");
+ qdev_set_prop_int(dev, "version", version);
+ qdev_init(dev);
+ s = sysbus_from_qdev(dev);
+ sysbus_connect_irq(s, 0, irq);
+ sysbus_mmio_map(s, 0, addr);
+
+ d = FROM_SYSBUS(IOMMUState, s);
+
+ return d;
+}
+
+static void iommu_init1(SysBusDevice *dev)
+{
+ IOMMUState *s = FROM_SYSBUS(IOMMUState, dev);
+ int io;
- s = qemu_mallocz(sizeof(IOMMUState));
+ sysbus_init_irq(dev, &s->irq);
- s->version = version;
- s->irq = irq;
+ s->version = qdev_get_prop_int(&dev->qdev, "version", 0);
- iommu_io_memory = cpu_register_io_memory(iommu_mem_read,
- iommu_mem_write, s);
- cpu_register_physical_memory(addr, IOMMU_NREGS * 4, iommu_io_memory);
+ io = cpu_register_io_memory(iommu_mem_read, iommu_mem_write, s);
+ sysbus_init_mmio(dev, IOMMU_NREGS * sizeof(uint32_t), io);
- register_savevm("iommu", addr, 2, iommu_save, iommu_load, s);
+ register_savevm("iommu", -1, 2, iommu_save, iommu_load, s);
qemu_register_reset(iommu_reset, s);
iommu_reset(s);
- return s;
}
+
+static SysBusDeviceInfo iommu_info = {
+ .init = iommu_init1,
+ .qdev.name = "iommu",
+ .qdev.size = sizeof(IOMMUState),
+ .qdev.props = (DevicePropList[]) {
+ {.name = "version", .type = PROP_TYPE_INT},
+ {.name = NULL}
+ }
+};
+
+static void iommu_register_devices(void)
+{
+ sysbus_register_withprop(&iommu_info);
+}
+
+device_init(iommu_register_devices)