From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYudX-0003OJ-Vq for qemu-devel@nongnu.org; Thu, 25 Feb 2016 07:03:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYudU-0007jG-3W for qemu-devel@nongnu.org; Thu, 25 Feb 2016 07:03:15 -0500 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Thu, 25 Feb 2016 13:02:11 +0100 Message-Id: <1456401731-10672-1-git-send-email-hpoussin@reactos.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH] dbdma: warn when using unassigned channel List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "open list:Old World" , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Alexander Graf With this, it's easier to know if a guest uses an invalid and/or unimplem= ented DMA channel. Signed-off-by: Herv=C3=A9 Poussineau --- hw/misc/macio/mac_dbdma.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c index d81dea7..6051f17 100644 --- a/hw/misc/macio/mac_dbdma.c +++ b/hw/misc/macio/mac_dbdma.c @@ -557,11 +557,13 @@ void DBDMA_register_channel(void *dbdma, int nchan,= qemu_irq irq, =20 DBDMA_DPRINTF("DBDMA_register_channel 0x%x\n", nchan); =20 + assert(rw); + assert(flush); + ch->irq =3D irq; ch->rw =3D rw; ch->flush =3D flush; ch->io.opaque =3D opaque; - ch->io.channel =3D ch; } =20 static void @@ -775,6 +777,20 @@ static void dbdma_reset(void *opaque) memset(s->channels[i].regs, 0, DBDMA_SIZE); } =20 +static void dbdma_unassigned_rw(DBDMA_io *io) +{ + DBDMA_channel *ch =3D io->channel; + qemu_log_mask(LOG_GUEST_ERROR, "%s: use of unassigned channel %d\n", + __func__, ch->channel); +} + +static void dbdma_unassigned_flush(DBDMA_io *io) +{ + DBDMA_channel *ch =3D io->channel; + qemu_log_mask(LOG_GUEST_ERROR, "%s: use of unassigned channel %d\n", + __func__, ch->channel); +} + void* DBDMA_init (MemoryRegion **dbdma_mem) { DBDMAState *s; @@ -784,8 +800,13 @@ void* DBDMA_init (MemoryRegion **dbdma_mem) =20 for (i =3D 0; i < DBDMA_CHANNELS; i++) { DBDMA_io *io =3D &s->channels[i].io; + DBDMA_channel *ch =3D &s->channels[i]; qemu_iovec_init(&io->iov, 1); - s->channels[i].channel =3D i; + + ch->rw =3D dbdma_unassigned_rw; + ch->flush =3D dbdma_unassigned_flush; + ch->channel =3D i; + ch->io.channel =3D ch; } =20 memory_region_init_io(&s->mem, NULL, &dbdma_ops, s, "dbdma", 0x1000)= ; --=20 2.1.4