aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2017-10-14 13:22:22 +0100
committerMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2017-10-31 17:25:36 +0000
commit7f773ff5d0d2172a7fb4a16a283c1fc5965f6fac (patch)
tree424fde9cfab6e18e42d3511df3bc0f640278c958
parent1b13a60c1c15d7d69164f6d89465915838ddc07b (diff)
downloadqemu-7f773ff5d0d2172a7fb4a16a283c1fc5965f6fac.zip
qemu-7f773ff5d0d2172a7fb4a16a283c1fc5965f6fac.tar.gz
qemu-7f773ff5d0d2172a7fb4a16a283c1fc5965f6fac.tar.bz2
sparc32_dma: make esp device child of espdma device
This makes it possible to reference the esp device from the espdma device as required, and by wiring up the device ourselves in sun4m.c we can drop use of the esp_init() function. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Artyom Tarasenko <atar4qemu@gmail.com> Acked-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
-rw-r--r--hw/dma/sparc32_dma.c26
-rw-r--r--hw/sparc/sun4m.c19
-rw-r--r--include/hw/sparc/sparc32_dma.h3
3 files changed, 37 insertions, 11 deletions
diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c
index c56a2ba..6009b94 100644
--- a/hw/dma/sparc32_dma.c
+++ b/hw/dma/sparc32_dma.c
@@ -298,11 +298,37 @@ static void sparc32_espdma_device_init(Object *obj)
s->is_ledma = 0;
}
+static void sparc32_espdma_device_realize(DeviceState *dev, Error **errp)
+{
+ DeviceState *d;
+ SysBusESPState *sysbus;
+ ESPState *esp;
+
+ d = qdev_create(NULL, TYPE_ESP);
+ object_property_add_child(OBJECT(dev), "esp", OBJECT(d), errp);
+ sysbus = ESP_STATE(d);
+ esp = &sysbus->esp;
+ esp->dma_memory_read = espdma_memory_read;
+ esp->dma_memory_write = espdma_memory_write;
+ esp->dma_opaque = SPARC32_DMA_DEVICE(dev);
+ sysbus->it_shift = 2;
+ esp->dma_enabled = 1;
+ qdev_init_nofail(d);
+}
+
+static void sparc32_espdma_device_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+
+ dc->realize = sparc32_espdma_device_realize;
+}
+
static const TypeInfo sparc32_espdma_device_info = {
.name = TYPE_SPARC32_ESPDMA_DEVICE,
.parent = TYPE_SPARC32_DMA_DEVICE,
.instance_size = sizeof(ESPDMADeviceState),
.instance_init = sparc32_espdma_device_init,
+ .class_init = sparc32_espdma_device_class_init,
};
static void sparc32_ledma_device_init(Object *obj)
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index e06e408..26ef35a 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -817,10 +817,9 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
DeviceState *slavio_intctl;
unsigned int i;
void *iommu, *nvram;
- DeviceState *espdma, *ledma;
+ DeviceState *espdma, *esp, *ledma;
SysBusDevice *sbd;
qemu_irq *cpu_irqs[MAX_CPUS], slavio_irq[32], slavio_cpu_irq[MAX_CPUS];
- qemu_irq esp_reset, dma_enable;
qemu_irq fdc_tc;
unsigned long kernel_size;
DriveInfo *fd[MAX_FD];
@@ -879,6 +878,13 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
sbd = SYS_BUS_DEVICE(espdma);
sysbus_connect_irq(sbd, 0, slavio_irq[18]);
+ esp = DEVICE(object_resolve_path_component(OBJECT(espdma), "esp"));
+ sbd = SYS_BUS_DEVICE(esp);
+ sysbus_mmio_map(sbd, 0, hwdef->esp_base);
+ sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(espdma, 0));
+ qdev_connect_gpio_out(espdma, 0, qdev_get_gpio_in(esp, 0));
+ qdev_connect_gpio_out(espdma, 1, qdev_get_gpio_in(esp, 1));
+
ledma = sparc32_dma_init(hwdef->dma_base + 16ULL, iommu, 1);
sbd = SYS_BUS_DEVICE(ledma);
sysbus_connect_irq(sbd, 0, slavio_irq[16]);
@@ -965,15 +971,6 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
slavio_misc_init(hwdef->slavio_base, hwdef->aux1_base, hwdef->aux2_base,
slavio_irq[30], fdc_tc);
- esp_init(hwdef->esp_base, 2,
- espdma_memory_read, espdma_memory_write,
- espdma,
- qdev_get_gpio_in(espdma, 0),
- &esp_reset, &dma_enable);
-
- qdev_connect_gpio_out(espdma, 0, esp_reset);
- qdev_connect_gpio_out(espdma, 1, dma_enable);
-
if (hwdef->cs_base) {
sysbus_create_simple("SUNW,CS4231", hwdef->cs_base,
slavio_irq[5]);
diff --git a/include/hw/sparc/sparc32_dma.h b/include/hw/sparc/sparc32_dma.h
index df7491d..365160f 100644
--- a/include/hw/sparc/sparc32_dma.h
+++ b/include/hw/sparc/sparc32_dma.h
@@ -2,6 +2,7 @@
#define SPARC32_DMA_H
#include "hw/sysbus.h"
+#include "hw/scsi/esp.h"
#define DMA_REGS 4
@@ -28,6 +29,8 @@ struct DMADeviceState {
typedef struct ESPDMADeviceState {
DMADeviceState parent_obj;
+
+ SysBusESPState *esp;
} ESPDMADeviceState;
#define TYPE_SPARC32_LEDMA_DEVICE "sparc32-ledma"