From nobody Mon May 6 20:59:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507583540697860.5182243813906; Mon, 9 Oct 2017 14:12:20 -0700 (PDT) Received: from localhost ([::1]:59822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1fLM-0007ci-AU for importer@patchew.org; Mon, 09 Oct 2017 17:12:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1fGu-0004Fr-Ps for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1fGr-0006c8-JB for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:32 -0400 Received: from chuckie.co.uk ([82.165.15.123]:40542 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1fGr-0006ZN-98 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:29 -0400 Received: from host109-153-37-179.range109-153.btcentralplus.com ([109.153.37.179] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1e1fGm-0003wf-Q5; Mon, 09 Oct 2017 22:07:26 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, atar4qemu@gmail.com Date: Mon, 9 Oct 2017 22:06:56 +0100 Message-Id: <1507583223-14819-2-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1507583223-14819-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1507583223-14819-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.153.37.179 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH 1/8] sparc32_dma: rename SPARC32_DMA type to SPARC32_DMA_DEVICE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Also update the function names to match as appropriate. While we're here rename the type from sparc32_dma to sparc32-dma in order to match the current QOM convention. Signed-off-by: Mark Cave-Ayland Reviewed-by: Artyom Tarasenko --- hw/dma/sparc32_dma.c | 67 +++++++++++++++++++++++++---------------------= ---- hw/sparc/sun4m.c | 2 +- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c index eb491b5..a8d31c1 100644 --- a/hw/dma/sparc32_dma.c +++ b/hw/dma/sparc32_dma.c @@ -61,12 +61,13 @@ /* XXX SCSI and ethernet should have different read-only bit masks */ #define DMA_CSR_RO_MASK 0xfe000007 =20 -#define TYPE_SPARC32_DMA "sparc32_dma" -#define SPARC32_DMA(obj) OBJECT_CHECK(DMAState, (obj), TYPE_SPARC32_DMA) +#define TYPE_SPARC32_DMA_DEVICE "sparc32-dma-device" +#define SPARC32_DMA_DEVICE(obj) OBJECT_CHECK(DMADeviceState, (obj), \ + TYPE_SPARC32_DMA_DEVICE) =20 -typedef struct DMAState DMAState; +typedef struct DMADeviceState DMADeviceState; =20 -struct DMAState { +struct DMADeviceState { SysBusDevice parent_obj; =20 MemoryRegion iomem; @@ -86,7 +87,7 @@ enum { void ledma_memory_read(void *opaque, hwaddr addr, uint8_t *buf, int len, int do_bswap) { - DMAState *s =3D opaque; + DMADeviceState *s =3D opaque; int i; =20 addr |=3D s->dmaregs[3]; @@ -106,7 +107,7 @@ void ledma_memory_read(void *opaque, hwaddr addr, void ledma_memory_write(void *opaque, hwaddr addr, uint8_t *buf, int len, int do_bswap) { - DMAState *s =3D opaque; + DMADeviceState *s =3D opaque; int l, i; uint16_t tmp_buf[32]; =20 @@ -134,7 +135,7 @@ void ledma_memory_write(void *opaque, hwaddr addr, =20 static void dma_set_irq(void *opaque, int irq, int level) { - DMAState *s =3D opaque; + DMADeviceState *s =3D opaque; if (level) { s->dmaregs[0] |=3D DMA_INTR; if (s->dmaregs[0] & DMA_INTREN) { @@ -154,7 +155,7 @@ static void dma_set_irq(void *opaque, int irq, int leve= l) =20 void espdma_memory_read(void *opaque, uint8_t *buf, int len) { - DMAState *s =3D opaque; + DMADeviceState *s =3D opaque; =20 trace_espdma_memory_read(s->dmaregs[1]); sparc_iommu_memory_read(s->iommu, s->dmaregs[1], buf, len); @@ -163,7 +164,7 @@ void espdma_memory_read(void *opaque, uint8_t *buf, int= len) =20 void espdma_memory_write(void *opaque, uint8_t *buf, int len) { - DMAState *s =3D opaque; + DMADeviceState *s =3D opaque; =20 trace_espdma_memory_write(s->dmaregs[1]); sparc_iommu_memory_write(s->iommu, s->dmaregs[1], buf, len); @@ -173,7 +174,7 @@ void espdma_memory_write(void *opaque, uint8_t *buf, in= t len) static uint64_t dma_mem_read(void *opaque, hwaddr addr, unsigned size) { - DMAState *s =3D opaque; + DMADeviceState *s =3D opaque; uint32_t saddr; =20 if (s->is_ledma && (addr > DMA_MAX_REG_OFFSET)) { @@ -190,7 +191,7 @@ static uint64_t dma_mem_read(void *opaque, hwaddr addr, static void dma_mem_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { - DMAState *s =3D opaque; + DMADeviceState *s =3D opaque; uint32_t saddr; =20 if (s->is_ledma && (addr > DMA_MAX_REG_OFFSET)) { @@ -252,28 +253,28 @@ static const MemoryRegionOps dma_mem_ops =3D { }, }; =20 -static void dma_reset(DeviceState *d) +static void sparc32_dma_device_reset(DeviceState *d) { - DMAState *s =3D SPARC32_DMA(d); + DMADeviceState *s =3D SPARC32_DMA_DEVICE(d); =20 memset(s->dmaregs, 0, DMA_SIZE); s->dmaregs[0] =3D DMA_VER; } =20 -static const VMStateDescription vmstate_dma =3D { +static const VMStateDescription vmstate_sparc32_dma_device =3D { .name =3D"sparc32_dma", .version_id =3D 2, .minimum_version_id =3D 2, .fields =3D (VMStateField[]) { - VMSTATE_UINT32_ARRAY(dmaregs, DMAState, DMA_REGS), + VMSTATE_UINT32_ARRAY(dmaregs, DMADeviceState, DMA_REGS), VMSTATE_END_OF_LIST() } }; =20 -static void sparc32_dma_init(Object *obj) +static void sparc32_dma_device_init(Object *obj) { DeviceState *dev =3D DEVICE(obj); - DMAState *s =3D SPARC32_DMA(obj); + DMADeviceState *s =3D SPARC32_DMA_DEVICE(obj); SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); =20 sysbus_init_irq(sbd, &s->irq); @@ -284,9 +285,9 @@ static void sparc32_dma_init(Object *obj) qdev_init_gpio_out(dev, s->gpio, 2); } =20 -static void sparc32_dma_realize(DeviceState *dev, Error **errp) +static void sparc32_dma_device_realize(DeviceState *dev, Error **errp) { - DMAState *s =3D SPARC32_DMA(dev); + DMADeviceState *s =3D SPARC32_DMA_DEVICE(dev); int reg_size; =20 reg_size =3D s->is_ledma ? DMA_ETH_SIZE : DMA_SIZE; @@ -294,35 +295,35 @@ static void sparc32_dma_realize(DeviceState *dev, Err= or **errp) "dma", reg_size); } =20 -static Property sparc32_dma_properties[] =3D { - DEFINE_PROP_PTR("iommu_opaque", DMAState, iommu), - DEFINE_PROP_UINT32("is_ledma", DMAState, is_ledma, 0), +static Property sparc32_dma_device_properties[] =3D { + DEFINE_PROP_PTR("iommu_opaque", DMADeviceState, iommu), + DEFINE_PROP_UINT32("is_ledma", DMADeviceState, is_ledma, 0), DEFINE_PROP_END_OF_LIST(), }; =20 -static void sparc32_dma_class_init(ObjectClass *klass, void *data) +static void sparc32_dma_device_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 - dc->reset =3D dma_reset; - dc->vmsd =3D &vmstate_dma; - dc->props =3D sparc32_dma_properties; - dc->realize =3D sparc32_dma_realize; + dc->reset =3D sparc32_dma_device_reset; + dc->vmsd =3D &vmstate_sparc32_dma_device; + dc->props =3D sparc32_dma_device_properties; + dc->realize =3D sparc32_dma_device_realize; /* Reason: pointer property "iommu_opaque" */ dc->user_creatable =3D false; } =20 -static const TypeInfo sparc32_dma_info =3D { - .name =3D TYPE_SPARC32_DMA, +static const TypeInfo sparc32_dma_device_info =3D { + .name =3D TYPE_SPARC32_DMA_DEVICE, .parent =3D TYPE_SYS_BUS_DEVICE, - .instance_size =3D sizeof(DMAState), - .instance_init =3D sparc32_dma_init, - .class_init =3D sparc32_dma_class_init, + .instance_size =3D sizeof(DMADeviceState), + .instance_init =3D sparc32_dma_device_init, + .class_init =3D sparc32_dma_device_class_init, }; =20 static void sparc32_dma_register_types(void) { - type_register_static(&sparc32_dma_info); + type_register_static(&sparc32_dma_device_info); } =20 type_init(sparc32_dma_register_types) diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index e1bdd48..82c553c 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -313,7 +313,7 @@ static void *sparc32_dma_init(hwaddr daddr, qemu_irq pa= rent_irq, DeviceState *dev; SysBusDevice *s; =20 - dev =3D qdev_create(NULL, "sparc32_dma"); + dev =3D qdev_create(NULL, "sparc32-dma-device"); qdev_prop_set_ptr(dev, "iommu_opaque", iommu); qdev_prop_set_uint32(dev, "is_ledma", is_ledma); qdev_init_nofail(dev); --=20 1.7.10.4 From nobody Mon May 6 20:59:25 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507583389658276.7160612783348; Mon, 9 Oct 2017 14:09:49 -0700 (PDT) Received: from localhost ([::1]:59804 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1fIr-0005PS-IG for importer@patchew.org; Mon, 09 Oct 2017 17:09:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1fGu-0004Fp-PD for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1fGr-0006c0-Gn for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:32 -0400 Received: from chuckie.co.uk ([82.165.15.123]:40545 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1fGr-0006ZR-96 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:29 -0400 Received: from host109-153-37-179.range109-153.btcentralplus.com ([109.153.37.179] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1e1fGo-0003wf-Ot; Mon, 09 Oct 2017 22:07:28 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, atar4qemu@gmail.com Date: Mon, 9 Oct 2017 22:06:57 +0100 Message-Id: <1507583223-14819-3-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1507583223-14819-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1507583223-14819-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.153.37.179 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH 2/8] sparc32_dma: split esp and le into separate DMA devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Due to slight differences in behaviour accessing the registers for the esp and le devices, create two separate SPARC32_DMA_DEVICE types and update the sun4m machine to use. Note that by using different device types we already know the size of the register block and the value of is_ledma at init time, allowing us to drop the SPARC32_DMA_DEVICE realize function and the is_ledma device property. Signed-off-by: Mark Cave-Ayland Reviewed-by: Artyom Tarasenko --- hw/dma/sparc32_dma.c | 63 ++++++++++++++++++++++++++++++++++++++++------= ---- hw/sparc/sun4m.c | 3 +-- 2 files changed, 52 insertions(+), 14 deletions(-) diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c index a8d31c1..fbbfe57 100644 --- a/hw/dma/sparc32_dma.c +++ b/hw/dma/sparc32_dma.c @@ -78,6 +78,22 @@ struct DMADeviceState { uint32_t is_ledma; }; =20 +#define TYPE_SPARC32_ESPDMA_DEVICE "sparc32-espdma" +#define SPARC32_ESPDMA_DEVICE(obj) OBJECT_CHECK(ESPDMADeviceState, (obj), \ + TYPE_SPARC32_ESPDMA_DEVICE) + +typedef struct ESPDMADeviceState { + DMADeviceState parent_obj; +} ESPDMADeviceState; + +#define TYPE_SPARC32_LEDMA_DEVICE "sparc32-ledma" +#define SPARC32_LEDMA_DEVICE(obj) OBJECT_CHECK(LEDMADeviceState, (obj), \ + TYPE_SPARC32_LEDMA_DEVICE) + +typedef struct LEDMADeviceState { + DMADeviceState parent_obj; +} LEDMADeviceState; + enum { GPIO_RESET =3D 0, GPIO_DMA, @@ -285,19 +301,8 @@ static void sparc32_dma_device_init(Object *obj) qdev_init_gpio_out(dev, s->gpio, 2); } =20 -static void sparc32_dma_device_realize(DeviceState *dev, Error **errp) -{ - DMADeviceState *s =3D SPARC32_DMA_DEVICE(dev); - int reg_size; - - reg_size =3D s->is_ledma ? DMA_ETH_SIZE : DMA_SIZE; - memory_region_init_io(&s->iomem, OBJECT(dev), &dma_mem_ops, s, - "dma", reg_size); -} - static Property sparc32_dma_device_properties[] =3D { DEFINE_PROP_PTR("iommu_opaque", DMADeviceState, iommu), - DEFINE_PROP_UINT32("is_ledma", DMADeviceState, is_ledma, 0), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -308,7 +313,6 @@ static void sparc32_dma_device_class_init(ObjectClass *= klass, void *data) dc->reset =3D sparc32_dma_device_reset; dc->vmsd =3D &vmstate_sparc32_dma_device; dc->props =3D sparc32_dma_device_properties; - dc->realize =3D sparc32_dma_device_realize; /* Reason: pointer property "iommu_opaque" */ dc->user_creatable =3D false; } @@ -316,14 +320,49 @@ static void sparc32_dma_device_class_init(ObjectClass= *klass, void *data) static const TypeInfo sparc32_dma_device_info =3D { .name =3D TYPE_SPARC32_DMA_DEVICE, .parent =3D TYPE_SYS_BUS_DEVICE, + .abstract =3D true, .instance_size =3D sizeof(DMADeviceState), .instance_init =3D sparc32_dma_device_init, .class_init =3D sparc32_dma_device_class_init, }; =20 +static void sparc32_espdma_device_init(Object *obj) +{ + DMADeviceState *s =3D SPARC32_DMA_DEVICE(obj); + + memory_region_init_io(&s->iomem, OBJECT(s), &dma_mem_ops, s, + "espdma", DMA_SIZE); + s->is_ledma =3D 0; +} + +static const TypeInfo sparc32_espdma_device_info =3D { + .name =3D TYPE_SPARC32_ESPDMA_DEVICE, + .parent =3D TYPE_SPARC32_DMA_DEVICE, + .instance_size =3D sizeof(ESPDMADeviceState), + .instance_init =3D sparc32_espdma_device_init, +}; + +static void sparc32_ledma_device_init(Object *obj) +{ + DMADeviceState *s =3D SPARC32_DMA_DEVICE(obj); + + memory_region_init_io(&s->iomem, OBJECT(s), &dma_mem_ops, s, + "ledma", DMA_ETH_SIZE); + s->is_ledma =3D 1; +} + +static const TypeInfo sparc32_ledma_device_info =3D { + .name =3D TYPE_SPARC32_LEDMA_DEVICE, + .parent =3D TYPE_SPARC32_DMA_DEVICE, + .instance_size =3D sizeof(LEDMADeviceState), + .instance_init =3D sparc32_ledma_device_init, +}; + static void sparc32_dma_register_types(void) { type_register_static(&sparc32_dma_device_info); + type_register_static(&sparc32_espdma_device_info); + type_register_static(&sparc32_ledma_device_info); } =20 type_init(sparc32_dma_register_types) diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 82c553c..88a9752 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -313,9 +313,8 @@ static void *sparc32_dma_init(hwaddr daddr, qemu_irq pa= rent_irq, DeviceState *dev; SysBusDevice *s; =20 - dev =3D qdev_create(NULL, "sparc32-dma-device"); + dev =3D qdev_create(NULL, is_ledma ? "sparc32-ledma" : "sparc32-espdma= "); qdev_prop_set_ptr(dev, "iommu_opaque", iommu); - qdev_prop_set_uint32(dev, "is_ledma", is_ledma); qdev_init_nofail(dev); s =3D SYS_BUS_DEVICE(dev); sysbus_connect_irq(s, 0, parent_irq); --=20 1.7.10.4 From nobody Mon May 6 20:59:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507583530644607.7924520985174; Mon, 9 Oct 2017 14:12:10 -0700 (PDT) Received: from localhost ([::1]:59820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1fLG-0007Z4-LG for importer@patchew.org; Mon, 09 Oct 2017 17:12:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1fGv-0004Fu-HW for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1fGu-0006dT-0U for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:33 -0400 Received: from chuckie.co.uk ([82.165.15.123]:40551 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1fGt-0006ae-Pt for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:31 -0400 Received: from host109-153-37-179.range109-153.btcentralplus.com ([109.153.37.179] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1e1fGq-0003wf-Dl; Mon, 09 Oct 2017 22:07:29 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, atar4qemu@gmail.com Date: Mon, 9 Oct 2017 22:06:58 +0100 Message-Id: <1507583223-14819-4-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1507583223-14819-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1507583223-14819-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.153.37.179 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH 3/8] sparc32_dma: move type declarations from sparc32_dma.c to sparc32_dma.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mark Cave-Ayland Reviewed-by: Artyom Tarasenko --- hw/dma/sparc32_dma.c | 34 ---------------------------------- include/hw/sparc/sparc32_dma.h | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c index fbbfe57..db70192 100644 --- a/hw/dma/sparc32_dma.c +++ b/hw/dma/sparc32_dma.c @@ -40,7 +40,6 @@ * http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/DMA2.txt */ =20 -#define DMA_REGS 4 #define DMA_SIZE (4 * sizeof(uint32_t)) /* We need the mask, because one instance of the device is not page aligned (ledma, start address 0x0010) */ @@ -61,39 +60,6 @@ /* XXX SCSI and ethernet should have different read-only bit masks */ #define DMA_CSR_RO_MASK 0xfe000007 =20 -#define TYPE_SPARC32_DMA_DEVICE "sparc32-dma-device" -#define SPARC32_DMA_DEVICE(obj) OBJECT_CHECK(DMADeviceState, (obj), \ - TYPE_SPARC32_DMA_DEVICE) - -typedef struct DMADeviceState DMADeviceState; - -struct DMADeviceState { - SysBusDevice parent_obj; - - MemoryRegion iomem; - uint32_t dmaregs[DMA_REGS]; - qemu_irq irq; - void *iommu; - qemu_irq gpio[2]; - uint32_t is_ledma; -}; - -#define TYPE_SPARC32_ESPDMA_DEVICE "sparc32-espdma" -#define SPARC32_ESPDMA_DEVICE(obj) OBJECT_CHECK(ESPDMADeviceState, (obj), \ - TYPE_SPARC32_ESPDMA_DEVICE) - -typedef struct ESPDMADeviceState { - DMADeviceState parent_obj; -} ESPDMADeviceState; - -#define TYPE_SPARC32_LEDMA_DEVICE "sparc32-ledma" -#define SPARC32_LEDMA_DEVICE(obj) OBJECT_CHECK(LEDMADeviceState, (obj), \ - TYPE_SPARC32_LEDMA_DEVICE) - -typedef struct LEDMADeviceState { - DMADeviceState parent_obj; -} LEDMADeviceState; - enum { GPIO_RESET =3D 0, GPIO_DMA, diff --git a/include/hw/sparc/sparc32_dma.h b/include/hw/sparc/sparc32_dma.h index 9497b13..df7491d 100644 --- a/include/hw/sparc/sparc32_dma.h +++ b/include/hw/sparc/sparc32_dma.h @@ -1,6 +1,43 @@ #ifndef SPARC32_DMA_H #define SPARC32_DMA_H =20 +#include "hw/sysbus.h" + +#define DMA_REGS 4 + +#define TYPE_SPARC32_DMA_DEVICE "sparc32-dma-device" +#define SPARC32_DMA_DEVICE(obj) OBJECT_CHECK(DMADeviceState, (obj), \ + TYPE_SPARC32_DMA_DEVICE) + +typedef struct DMADeviceState DMADeviceState; + +struct DMADeviceState { + SysBusDevice parent_obj; + + MemoryRegion iomem; + uint32_t dmaregs[DMA_REGS]; + qemu_irq irq; + void *iommu; + qemu_irq gpio[2]; + uint32_t is_ledma; +}; + +#define TYPE_SPARC32_ESPDMA_DEVICE "sparc32-espdma" +#define SPARC32_ESPDMA_DEVICE(obj) OBJECT_CHECK(ESPDMADeviceState, (obj), \ + TYPE_SPARC32_ESPDMA_DEVICE) + +typedef struct ESPDMADeviceState { + DMADeviceState parent_obj; +} ESPDMADeviceState; + +#define TYPE_SPARC32_LEDMA_DEVICE "sparc32-ledma" +#define SPARC32_LEDMA_DEVICE(obj) OBJECT_CHECK(LEDMADeviceState, (obj), \ + TYPE_SPARC32_LEDMA_DEVICE) + +typedef struct LEDMADeviceState { + DMADeviceState parent_obj; +} LEDMADeviceState; + /* sparc32_dma.c */ void ledma_memory_read(void *opaque, hwaddr addr, uint8_t *buf, int len, int do_bswap); --=20 1.7.10.4 From nobody Mon May 6 20:59:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150758338842321.829870497216234; Mon, 9 Oct 2017 14:09:48 -0700 (PDT) Received: from localhost ([::1]:59806 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1fIs-0005RV-Od for importer@patchew.org; Mon, 09 Oct 2017 17:09:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1fGu-0004Ft-V5 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1fGt-0006dI-T1 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:32 -0400 Received: from chuckie.co.uk ([82.165.15.123]:40550 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1fGt-0006aY-Lm for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:31 -0400 Received: from host109-153-37-179.range109-153.btcentralplus.com ([109.153.37.179] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1e1fGs-0003wf-2y; Mon, 09 Oct 2017 22:07:31 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, atar4qemu@gmail.com Date: Mon, 9 Oct 2017 22:06:59 +0100 Message-Id: <1507583223-14819-5-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1507583223-14819-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1507583223-14819-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.153.37.179 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH 4/8] sun4m: move DMA device wiring from sparc32_dma_init() to sun4m_hw_init() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" By using the sysbus interface it is possible to wire up the esp/le devices to the sun4m DMA controller directly during sun4m_hw_init() instead of passing qemu_irqs into the sparc32_dma_init() function. Signed-off-by: Mark Cave-Ayland Reviewed-by: Artyom Tarasenko --- hw/sparc/sun4m.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 88a9752..4f2ed4b 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -307,8 +307,7 @@ static void *iommu_init(hwaddr addr, uint32_t version, = qemu_irq irq) return s; } =20 -static void *sparc32_dma_init(hwaddr daddr, qemu_irq parent_irq, - void *iommu, qemu_irq *dev_irq, int is_ledma) +static void *sparc32_dma_init(hwaddr daddr, void *iommu, int is_ledma) { DeviceState *dev; SysBusDevice *s; @@ -317,8 +316,6 @@ static void *sparc32_dma_init(hwaddr daddr, qemu_irq pa= rent_irq, qdev_prop_set_ptr(dev, "iommu_opaque", iommu); qdev_init_nofail(dev); s =3D SYS_BUS_DEVICE(dev); - sysbus_connect_irq(s, 0, parent_irq); - *dev_irq =3D qdev_get_gpio_in(dev, 0); sysbus_mmio_map(s, 0, daddr); =20 return s; @@ -821,9 +818,10 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hw= def, DeviceState *slavio_intctl; const char *cpu_model =3D machine->cpu_model; unsigned int i; - void *iommu, *espdma, *ledma, *nvram; - qemu_irq *cpu_irqs[MAX_CPUS], slavio_irq[32], slavio_cpu_irq[MAX_CPUS], - espdma_irq, ledma_irq; + void *iommu, *nvram; + DeviceState *espdma, *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; @@ -882,11 +880,13 @@ static void sun4m_hw_init(const struct sun4m_hwdef *h= wdef, empty_slot_init(hwdef->iommu_pad_base,hwdef->iommu_pad_len); } =20 - espdma =3D sparc32_dma_init(hwdef->dma_base, slavio_irq[18], - iommu, &espdma_irq, 0); + espdma =3D sparc32_dma_init(hwdef->dma_base, iommu, 0); + sbd =3D SYS_BUS_DEVICE(espdma); + sysbus_connect_irq(sbd, 0, slavio_irq[18]); =20 - ledma =3D sparc32_dma_init(hwdef->dma_base + 16ULL, - slavio_irq[16], iommu, &ledma_irq, 1); + ledma =3D sparc32_dma_init(hwdef->dma_base + 16ULL, iommu, 1); + sbd =3D SYS_BUS_DEVICE(ledma); + sysbus_connect_irq(sbd, 0, slavio_irq[16]); =20 if (graphic_depth !=3D 8 && graphic_depth !=3D 24) { error_report("Unsupported depth: %d", graphic_depth); @@ -939,7 +939,8 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwd= ef, empty_slot_init(hwdef->sx_base, 0x2000); } =20 - lance_init(&nd_table[0], hwdef->le_base, ledma, ledma_irq); + lance_init(&nd_table[0], hwdef->le_base, ledma, + qdev_get_gpio_in(ledma, 0)); =20 nvram =3D m48t59_init(slavio_irq[0], hwdef->nvram_base, 0, 0x2000, 196= 8, 8); =20 @@ -971,7 +972,9 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwd= ef, =20 esp_init(hwdef->esp_base, 2, espdma_memory_read, espdma_memory_write, - espdma, espdma_irq, &esp_reset, &dma_enable); + espdma, + qdev_get_gpio_in(espdma, 0), + &esp_reset, &dma_enable); =20 qdev_connect_gpio_out(espdma, 0, esp_reset); qdev_connect_gpio_out(espdma, 1, dma_enable); --=20 1.7.10.4 From nobody Mon May 6 20:59:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507583684141549.9162654012532; Mon, 9 Oct 2017 14:14:44 -0700 (PDT) Received: from localhost ([::1]:59830 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1fNl-0001K9-9I for importer@patchew.org; Mon, 09 Oct 2017 17:14:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1fGx-0004Gq-PB for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1fGw-0006fE-IY for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:35 -0400 Received: from chuckie.co.uk ([82.165.15.123]:40557 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1fGw-0006bR-Bz for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:34 -0400 Received: from host109-153-37-179.range109-153.btcentralplus.com ([109.153.37.179] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1e1fGt-0003wf-Ew; Mon, 09 Oct 2017 22:07:32 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, atar4qemu@gmail.com Date: Mon, 9 Oct 2017 22:07:00 +0100 Message-Id: <1507583223-14819-6-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1507583223-14819-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1507583223-14819-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.153.37.179 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH 5/8] sun4m_iommu: move TYPE_SUN4M_IOMMU declaration to sun4m.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is in preparation to allow the type to be used elsewhere. Signed-off-by: Mark Cave-Ayland Reviewed-by: Artyom Tarasenko --- hw/dma/sun4m_iommu.c | 14 -------------- include/hw/sparc/sun4m.h | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/hw/dma/sun4m_iommu.c b/hw/dma/sun4m_iommu.c index 335ef63..840064b 100644 --- a/hw/dma/sun4m_iommu.c +++ b/hw/dma/sun4m_iommu.c @@ -36,7 +36,6 @@ * http://mediacast.sun.com/users/Barton808/media/Sun4M_SystemArchitecture= _edited2.pdf */ =20 -#define IOMMU_NREGS (4*4096/4) #define IOMMU_CTRL (0x0000 >> 2) #define IOMMU_CTRL_IMPL 0xf0000000 /* Implementation */ #define IOMMU_CTRL_VERS 0x0f000000 /* Version */ @@ -128,19 +127,6 @@ #define IOMMU_PAGE_SIZE (1 << IOMMU_PAGE_SHIFT) #define IOMMU_PAGE_MASK ~(IOMMU_PAGE_SIZE - 1) =20 -#define TYPE_SUN4M_IOMMU "iommu" -#define SUN4M_IOMMU(obj) OBJECT_CHECK(IOMMUState, (obj), TYPE_SUN4M_IOMMU) - -typedef struct IOMMUState { - SysBusDevice parent_obj; - - MemoryRegion iomem; - uint32_t regs[IOMMU_NREGS]; - hwaddr iostart; - qemu_irq irq; - uint32_t version; -} IOMMUState; - static uint64_t iommu_mem_read(void *opaque, hwaddr addr, unsigned size) { diff --git a/include/hw/sparc/sun4m.h b/include/hw/sparc/sun4m.h index 580d87b..1f1cf91 100644 --- a/include/hw/sparc/sun4m.h +++ b/include/hw/sparc/sun4m.h @@ -4,10 +4,26 @@ #include "qemu-common.h" #include "exec/hwaddr.h" #include "qapi/qmp/types.h" +#include "hw/sysbus.h" =20 /* Devices used by sparc32 system. */ =20 /* iommu.c */ +#define TYPE_SUN4M_IOMMU "iommu" +#define SUN4M_IOMMU(obj) OBJECT_CHECK(IOMMUState, (obj), TYPE_SUN4M_IOMMU) + +#define IOMMU_NREGS (4 * 4096 / 4) + +typedef struct IOMMUState { + SysBusDevice parent_obj; + + MemoryRegion iomem; + uint32_t regs[IOMMU_NREGS]; + hwaddr iostart; + qemu_irq irq; + uint32_t version; +} IOMMUState; + void sparc_iommu_memory_rw(void *opaque, hwaddr addr, uint8_t *buf, int len, int is_write); static inline void sparc_iommu_memory_read(void *opaque, --=20 1.7.10.4 From nobody Mon May 6 20:59:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507583386132762.0405464922667; Mon, 9 Oct 2017 14:09:46 -0700 (PDT) Received: from localhost ([::1]:59805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1fIs-0005QR-4w for importer@patchew.org; Mon, 09 Oct 2017 17:09:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1fGu-0004Fo-Ox for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1fGr-0006cL-PZ for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:32 -0400 Received: from chuckie.co.uk ([82.165.15.123]:40558 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1fGr-0006bf-Ik for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:29 -0400 Received: from host109-153-37-179.range109-153.btcentralplus.com ([109.153.37.179] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1e1fGu-0003wf-KQ; Mon, 09 Oct 2017 22:07:33 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, atar4qemu@gmail.com Date: Mon, 9 Oct 2017 22:07:01 +0100 Message-Id: <1507583223-14819-7-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1507583223-14819-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1507583223-14819-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.153.37.179 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH 6/8] sparc32_dma: use object link instead of qdev property to pass IOMMU reference X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This enables us to remove the last remaining (opaque) qdev property. Whilst= we are here, also update iommu_init() to use TYPE_SUN4M_IOMMU instead of a hardcoded string. Signed-off-by: Mark Cave-Ayland Reviewed-by: Artyom Tarasenko --- hw/dma/sparc32_dma.c | 13 +++++-------- hw/sparc/sun4m.c | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c index db70192..b817472 100644 --- a/hw/dma/sparc32_dma.c +++ b/hw/dma/sparc32_dma.c @@ -263,24 +263,21 @@ static void sparc32_dma_device_init(Object *obj) =20 sysbus_init_mmio(sbd, &s->iomem); =20 + object_property_add_link(OBJECT(dev), "iommu", TYPE_SUN4M_IOMMU, + (Object **) &s->iommu, + qdev_prop_allow_set_link_before_realize, + 0, NULL); + qdev_init_gpio_in(dev, dma_set_irq, 1); qdev_init_gpio_out(dev, s->gpio, 2); } =20 -static Property sparc32_dma_device_properties[] =3D { - DEFINE_PROP_PTR("iommu_opaque", DMADeviceState, iommu), - DEFINE_PROP_END_OF_LIST(), -}; - static void sparc32_dma_device_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 dc->reset =3D sparc32_dma_device_reset; dc->vmsd =3D &vmstate_sparc32_dma_device; - dc->props =3D sparc32_dma_device_properties; - /* Reason: pointer property "iommu_opaque" */ - dc->user_creatable =3D false; } =20 static const TypeInfo sparc32_dma_device_info =3D { diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 4f2ed4b..12d36b5 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -297,7 +297,7 @@ static void *iommu_init(hwaddr addr, uint32_t version, = qemu_irq irq) DeviceState *dev; SysBusDevice *s; =20 - dev =3D qdev_create(NULL, "iommu"); + dev =3D qdev_create(NULL, TYPE_SUN4M_IOMMU); qdev_prop_set_uint32(dev, "version", version); qdev_init_nofail(dev); s =3D SYS_BUS_DEVICE(dev); @@ -313,7 +313,7 @@ static void *sparc32_dma_init(hwaddr daddr, void *iommu= , int is_ledma) SysBusDevice *s; =20 dev =3D qdev_create(NULL, is_ledma ? "sparc32-ledma" : "sparc32-espdma= "); - qdev_prop_set_ptr(dev, "iommu_opaque", iommu); + object_property_set_link(OBJECT(dev), OBJECT(iommu), "iommu", &error_a= bort); qdev_init_nofail(dev); s =3D SYS_BUS_DEVICE(dev); sysbus_mmio_map(s, 0, daddr); --=20 1.7.10.4 From nobody Mon May 6 20:59:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150758368630721.57077942816443; Mon, 9 Oct 2017 14:14:46 -0700 (PDT) Received: from localhost ([::1]:59831 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1fNp-0001Oc-CO for importer@patchew.org; Mon, 09 Oct 2017 17:14:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1fGu-0004Fq-PS for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1fGs-0006cq-Ol for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:32 -0400 Received: from chuckie.co.uk ([82.165.15.123]:40560 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1fGs-0006cR-HP for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:30 -0400 Received: from host109-153-37-179.range109-153.btcentralplus.com ([109.153.37.179] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1e1fGv-0003wf-SV; Mon, 09 Oct 2017 22:07:35 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, atar4qemu@gmail.com Date: Mon, 9 Oct 2017 22:07:02 +0100 Message-Id: <1507583223-14819-8-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1507583223-14819-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1507583223-14819-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.153.37.179 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH 7/8] sparc32_dma: introduce new SPARC32_DMA type container object X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Create a new SPARC32_DMA container object (including an appropriate contain= er memory region) and add instances of the SPARC32_ESPDMA_DEVICE and SPARC32_LEDMA_DEVICE as child objects. Also update sun4m.c to resolve the child objects accordingly. Since the sun4m IOMMU is already QOMified we can find a reference to it using object_resolve_path_type() allowing us to completely remove all ex= ternal references to the iommu pointer. Signed-off-by: Mark Cave-Ayland Reviewed-by: Artyom Tarasenko --- hw/dma/sparc32_dma.c | 56 ++++++++++++++++++++++++++++++++++++= ++++ hw/sparc/sun4m.c | 18 ++++++------- include/hw/sparc/sparc32_dma.h | 12 +++++++++ 3 files changed, 77 insertions(+), 9 deletions(-) diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c index b817472..c7aa4a4 100644 --- a/hw/dma/sparc32_dma.c +++ b/hw/dma/sparc32_dma.c @@ -30,6 +30,7 @@ #include "hw/sparc/sparc32_dma.h" #include "hw/sparc/sun4m.h" #include "hw/sysbus.h" +#include "qapi/error.h" #include "trace.h" =20 /* @@ -321,11 +322,66 @@ static const TypeInfo sparc32_ledma_device_info =3D { .instance_init =3D sparc32_ledma_device_init, }; =20 +static void sparc32_dma_init(Object *obj) +{ + SPARC32DMAState *s =3D SPARC32_DMA(obj); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); + + memory_region_init(&s->dmamem, OBJECT(s), "dma", DMA_SIZE + DMA_ETH_SI= ZE); + sysbus_init_mmio(sbd, &s->dmamem); +} + +static void sparc32_dma_realize(DeviceState *dev, Error **errp) +{ + SPARC32DMAState *s =3D SPARC32_DMA(dev); + DeviceState *d; + SysBusDevice *sbd; + Object *iommu; + + iommu =3D object_resolve_path_type("", TYPE_SUN4M_IOMMU, NULL); + if (!iommu) { + error_setg(errp, "unable to locate sun4m IOMMU device"); + return; + } + + d =3D qdev_create(NULL, TYPE_SPARC32_ESPDMA_DEVICE); + object_property_set_link(OBJECT(d), iommu, "iommu", errp); + object_property_add_child(OBJECT(s), "espdma", OBJECT(d), errp); + qdev_init_nofail(d); + sbd =3D SYS_BUS_DEVICE(d); + memory_region_add_subregion(&s->dmamem, 0x0, + sysbus_mmio_get_region(sbd, 0)); + + d =3D qdev_create(NULL, TYPE_SPARC32_LEDMA_DEVICE); + object_property_set_link(OBJECT(d), iommu, "iommu", errp); + object_property_add_child(OBJECT(s), "ledma", OBJECT(d), errp); + qdev_init_nofail(d); + sbd =3D SYS_BUS_DEVICE(d); + memory_region_add_subregion(&s->dmamem, 0x10, + sysbus_mmio_get_region(sbd, 0)); +} + +static void sparc32_dma_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->realize =3D sparc32_dma_realize; +} + +static const TypeInfo sparc32_dma_info =3D { + .name =3D TYPE_SPARC32_DMA, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(SPARC32DMAState), + .instance_init =3D sparc32_dma_init, + .class_init =3D sparc32_dma_class_init, +}; + static void sparc32_dma_register_types(void) { type_register_static(&sparc32_dma_device_info); type_register_static(&sparc32_espdma_device_info); type_register_static(&sparc32_ledma_device_info); + type_register_static(&sparc32_dma_info); } =20 type_init(sparc32_dma_register_types) diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 12d36b5..b220694 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -307,13 +307,12 @@ static void *iommu_init(hwaddr addr, uint32_t version= , qemu_irq irq) return s; } =20 -static void *sparc32_dma_init(hwaddr daddr, void *iommu, int is_ledma) +static void *sparc32_dma_init(hwaddr daddr) { DeviceState *dev; SysBusDevice *s; =20 - dev =3D qdev_create(NULL, is_ledma ? "sparc32-ledma" : "sparc32-espdma= "); - object_property_set_link(OBJECT(dev), OBJECT(iommu), "iommu", &error_a= bort); + dev =3D qdev_create(NULL, TYPE_SPARC32_DMA); qdev_init_nofail(dev); s =3D SYS_BUS_DEVICE(dev); sysbus_mmio_map(s, 0, daddr); @@ -818,8 +817,8 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwd= ef, DeviceState *slavio_intctl; const char *cpu_model =3D machine->cpu_model; unsigned int i; - void *iommu, *nvram; - DeviceState *espdma, *ledma; + void *nvram; + DeviceState *dma, *espdma, *ledma; SysBusDevice *sbd; qemu_irq *cpu_irqs[MAX_CPUS], slavio_irq[32], slavio_cpu_irq[MAX_CPUS]; qemu_irq esp_reset, dma_enable; @@ -869,8 +868,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwd= ef, afx_init(hwdef->afx_base); } =20 - iommu =3D iommu_init(hwdef->iommu_base, hwdef->iommu_version, - slavio_irq[30]); + iommu_init(hwdef->iommu_base, hwdef->iommu_version, slavio_irq[30]); =20 if (hwdef->iommu_pad_base) { /* On the real hardware (SS-5, LX) the MMU is not padded, but alia= sed. @@ -880,11 +878,13 @@ static void sun4m_hw_init(const struct sun4m_hwdef *h= wdef, empty_slot_init(hwdef->iommu_pad_base,hwdef->iommu_pad_len); } =20 - espdma =3D sparc32_dma_init(hwdef->dma_base, iommu, 0); + dma =3D sparc32_dma_init(hwdef->dma_base); + + espdma =3D DEVICE(object_resolve_path_component(OBJECT(dma), "espdma")= ); sbd =3D SYS_BUS_DEVICE(espdma); sysbus_connect_irq(sbd, 0, slavio_irq[18]); =20 - ledma =3D sparc32_dma_init(hwdef->dma_base + 16ULL, iommu, 1); + ledma =3D DEVICE(object_resolve_path_component(OBJECT(dma), "ledma")); sbd =3D SYS_BUS_DEVICE(ledma); sysbus_connect_irq(sbd, 0, slavio_irq[16]); =20 diff --git a/include/hw/sparc/sparc32_dma.h b/include/hw/sparc/sparc32_dma.h index df7491d..131d4de 100644 --- a/include/hw/sparc/sparc32_dma.h +++ b/include/hw/sparc/sparc32_dma.h @@ -38,6 +38,18 @@ typedef struct LEDMADeviceState { DMADeviceState parent_obj; } LEDMADeviceState; =20 +#define TYPE_SPARC32_DMA "sparc32-dma" +#define SPARC32_DMA(obj) OBJECT_CHECK(SPARC32DMAState, (obj), \ + TYPE_SPARC32_DMA) + +typedef struct SPARC32DMAState { + SysBusDevice parent_obj; + + MemoryRegion dmamem; + ESPDMADeviceState *espdma; + LEDMADeviceState *ledma; +} SPARC32DMAState; + /* sparc32_dma.c */ void ledma_memory_read(void *opaque, hwaddr addr, uint8_t *buf, int len, int do_bswap); --=20 1.7.10.4 From nobody Mon May 6 20:59:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150758353565836.859014225934175; Mon, 9 Oct 2017 14:12:15 -0700 (PDT) Received: from localhost ([::1]:59821 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1fLK-0007bh-RQ for importer@patchew.org; Mon, 09 Oct 2017 17:12:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1fGv-0004Fv-Nj for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1fGu-0006dd-9d for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:33 -0400 Received: from chuckie.co.uk ([82.165.15.123]:40564 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1fGu-0006d7-2X for qemu-devel@nongnu.org; Mon, 09 Oct 2017 17:07:32 -0400 Received: from host109-153-37-179.range109-153.btcentralplus.com ([109.153.37.179] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1e1fGx-0003wf-T3; Mon, 09 Oct 2017 22:07:37 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, atar4qemu@gmail.com Date: Mon, 9 Oct 2017 22:07:03 +0100 Message-Id: <1507583223-14819-9-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1507583223-14819-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1507583223-14819-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.153.37.179 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH 8/8] sparc32_dma: remove is_ledma hack and replace with memory region alias X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This hack originated from before the memory region API was introduced, and increased the size of the ledma DMA device to capture incorrect accesses beyond the end of the ledma device. A full analysis can be found on Artyom's blog at http://tyom.blogspot.co.uk/2010/10/bug-in-all-solaris-versions-afte= r-57.html. With the memory API we can now simply alias the incorrect access onto its intended destination allowing us to remove the hack. Signed-off-by: Mark Cave-Ayland Reviewed-by: Artyom Tarasenko --- hw/dma/sparc32_dma.c | 20 ++++++-------------- include/hw/sparc/sparc32_dma.h | 2 +- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c index c7aa4a4..a26bc50 100644 --- a/hw/dma/sparc32_dma.c +++ b/hw/dma/sparc32_dma.c @@ -160,12 +160,6 @@ static uint64_t dma_mem_read(void *opaque, hwaddr addr, DMADeviceState *s =3D opaque; uint32_t saddr; =20 - if (s->is_ledma && (addr > DMA_MAX_REG_OFFSET)) { - /* aliased to espdma, but we can't get there from here */ - /* buggy driver if using undocumented behavior, just return 0 */ - trace_sparc32_dma_mem_readl(addr, 0); - return 0; - } saddr =3D (addr & DMA_MASK) >> 2; trace_sparc32_dma_mem_readl(addr, s->dmaregs[saddr]); return s->dmaregs[saddr]; @@ -177,11 +171,6 @@ static void dma_mem_write(void *opaque, hwaddr addr, DMADeviceState *s =3D opaque; uint32_t saddr; =20 - if (s->is_ledma && (addr > DMA_MAX_REG_OFFSET)) { - /* aliased to espdma, but we can't get there from here */ - trace_sparc32_dma_mem_writel(addr, 0, val); - return; - } saddr =3D (addr & DMA_MASK) >> 2; trace_sparc32_dma_mem_writel(addr, s->dmaregs[saddr], val); switch (saddr) { @@ -296,7 +285,6 @@ static void sparc32_espdma_device_init(Object *obj) =20 memory_region_init_io(&s->iomem, OBJECT(s), &dma_mem_ops, s, "espdma", DMA_SIZE); - s->is_ledma =3D 0; } =20 static const TypeInfo sparc32_espdma_device_info =3D { @@ -311,8 +299,7 @@ static void sparc32_ledma_device_init(Object *obj) DMADeviceState *s =3D SPARC32_DMA_DEVICE(obj); =20 memory_region_init_io(&s->iomem, OBJECT(s), &dma_mem_ops, s, - "ledma", DMA_ETH_SIZE); - s->is_ledma =3D 1; + "ledma", DMA_SIZE); } =20 static const TypeInfo sparc32_ledma_device_info =3D { @@ -359,6 +346,11 @@ static void sparc32_dma_realize(DeviceState *dev, Erro= r **errp) sbd =3D SYS_BUS_DEVICE(d); memory_region_add_subregion(&s->dmamem, 0x10, sysbus_mmio_get_region(sbd, 0)); + + /* Add ledma alias to handle SunOS 5.7 - Solaris 9 invalid access bug = */ + memory_region_init_alias(&s->ledma_alias, OBJECT(dev), "ledma-alias", + sysbus_mmio_get_region(sbd, 0), 0x4, 0x4); + memory_region_add_subregion(&s->dmamem, 0x20, &s->ledma_alias); } =20 static void sparc32_dma_class_init(ObjectClass *klass, void *data) diff --git a/include/hw/sparc/sparc32_dma.h b/include/hw/sparc/sparc32_dma.h index 131d4de..67aa30c 100644 --- a/include/hw/sparc/sparc32_dma.h +++ b/include/hw/sparc/sparc32_dma.h @@ -19,7 +19,6 @@ struct DMADeviceState { qemu_irq irq; void *iommu; qemu_irq gpio[2]; - uint32_t is_ledma; }; =20 #define TYPE_SPARC32_ESPDMA_DEVICE "sparc32-espdma" @@ -46,6 +45,7 @@ typedef struct SPARC32DMAState { SysBusDevice parent_obj; =20 MemoryRegion dmamem; + MemoryRegion ledma_alias; ESPDMADeviceState *espdma; LEDMADeviceState *ledma; } SPARC32DMAState; --=20 1.7.10.4