qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <huth@tuxfamily.org>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Laurent Vivier" <laurent@vivier.eu>
Subject: [Qemu-devel] [PATCH v4 5/6] m68k: Add serial controller to the NeXTcube machine
Date: Tue,  9 Jul 2019 09:32:21 +0200	[thread overview]
Message-ID: <20190709073222.26370-6-huth@tuxfamily.org> (raw)
In-Reply-To: <20190709073222.26370-1-huth@tuxfamily.org>

The NeXTcube uses a normal 8530 serial controller, so we can simply use
our normal "escc" device here.
While we're at it, also add a boot-serial-test for the next-cube machine,
now that the serial output works.

Signed-off-by: Thomas Huth <huth@tuxfamily.org>
---
 hw/m68k/Kconfig          |  1 +
 hw/m68k/next-cube.c      | 37 ++++++++++++++++++++++++++++++++++++-
 tests/boot-serial-test.c | 12 ++++++++++++
 3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/hw/m68k/Kconfig b/hw/m68k/Kconfig
index ec58a2eb06..a74fac5abd 100644
--- a/hw/m68k/Kconfig
+++ b/hw/m68k/Kconfig
@@ -11,3 +11,4 @@ config MCF5208
 config NEXTCUBE
     bool
     select FRAMEBUFFER
+    select ESCC
diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c
index 0737605417..b7f1e9106b 100644
--- a/hw/m68k/next-cube.c
+++ b/hw/m68k/next-cube.c
@@ -846,6 +846,39 @@ void next_irq(void *opaque, int number, int level)
     }
 }
 
+static void next_serial_irq(void *opaque, int n, int level)
+{
+    /* DPRINTF("SCC IRQ NUM %i\n",n); */
+    if (n) {
+        next_irq(opaque, NEXT_SCC_DMA_I, level);
+    } else {
+        next_irq(opaque, NEXT_SCC_I, level);
+    }
+}
+
+static void next_escc_init(M68kCPU *cpu)
+{
+    qemu_irq *ser_irq = qemu_allocate_irqs(next_serial_irq, cpu, 2);
+    DeviceState *dev;
+    SysBusDevice *s;
+
+    dev = qdev_create(NULL, TYPE_ESCC);
+    qdev_prop_set_uint32(dev, "disabled", 0);
+    qdev_prop_set_uint32(dev, "frequency", 9600 * 384);
+    qdev_prop_set_uint32(dev, "it_shift", 0);
+    qdev_prop_set_bit(dev, "bit_swap", true);
+    qdev_prop_set_chr(dev, "chrB", serial_hd(1));
+    qdev_prop_set_chr(dev, "chrA", serial_hd(0));
+    qdev_prop_set_uint32(dev, "chnBtype", escc_serial);
+    qdev_prop_set_uint32(dev, "chnAtype", escc_serial);
+    qdev_init_nofail(dev);
+
+    s = SYS_BUS_DEVICE(dev);
+    sysbus_connect_irq(s, 0, ser_irq[0]);
+    sysbus_connect_irq(s, 1,  ser_irq[1]);
+    sysbus_mmio_map(s, 0, 0x2118000);
+}
+
 static void next_cube_init(MachineState *machine)
 {
     M68kCPU *cpu;
@@ -937,8 +970,10 @@ static void next_cube_init(MachineState *machine)
         }
     }
 
-    /* TODO: */
     /* Serial */
+    next_escc_init(cpu);
+
+    /* TODO: */
     /* Network */
     /* SCSI */
 
diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c
index 24852d4c7d..c8ded1195e 100644
--- a/tests/boot-serial-test.c
+++ b/tests/boot-serial-test.c
@@ -24,6 +24,17 @@ static const uint8_t kernel_mcf5208[] = {
     0x60, 0xfa                              /* bra.s  loop */
 };
 
+static const uint8_t bios_nextcube[] = {
+    0x06, 0x00, 0x00, 0x00,                 /* Initial SP */
+    0x01, 0x00, 0x00, 0x08,                 /* Initial PC */
+    0x41, 0xf9, 0x02, 0x11, 0x80, 0x00,     /* lea 0x02118000,%a0 */
+    0x10, 0x3c, 0x00, 0x54,                 /* move.b #'T',%d0 */
+    0x11, 0x7c, 0x00, 0x05, 0x00, 0x01,     /* move.b #5,1(%a0)    Sel TXCTRL */
+    0x11, 0x7c, 0x00, 0x68, 0x00, 0x01,     /* move.b #0x68,1(%a0) Enable TX */
+    0x11, 0x40, 0x00, 0x03,                 /* move.b %d0,3(%a0)   Print 'T' */
+    0x60, 0xfa                              /* bra.s  loop */
+};
+
 static const uint8_t kernel_pls3adsp1800[] = {
     0xb0, 0x00, 0x84, 0x00,                 /* imm   0x8400 */
     0x30, 0x60, 0x00, 0x04,                 /* addik r3,r0,4 */
@@ -116,6 +127,7 @@ static testdef_t tests[] = {
     { "sparc64", "sun4u", "", "UltraSPARC" },
     { "s390x", "s390-ccw-virtio", "", "device" },
     { "m68k", "mcf5208evb", "", "TT", sizeof(kernel_mcf5208), kernel_mcf5208 },
+    { "m68k", "next-cube", "", "TT", sizeof(bios_nextcube), 0, bios_nextcube },
     { "microblaze", "petalogix-s3adsp1800", "", "TT",
       sizeof(kernel_pls3adsp1800), kernel_pls3adsp1800 },
     { "microblazeel", "petalogix-ml605", "", "TT",
-- 
2.21.0



  parent reply	other threads:[~2019-07-09  7:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-09  7:32 [Qemu-devel] [PATCH v4 0/6] m68k: Add basic support for the NeXTcube machine Thomas Huth
2019-07-09  7:32 ` [Qemu-devel] [PATCH v4 1/6] m68k: Add NeXTcube framebuffer device emulation Thomas Huth
2019-08-13 10:11   ` Philippe Mathieu-Daudé
2019-08-13 10:15   ` Peter Maydell
2019-07-09  7:32 ` [Qemu-devel] [PATCH v4 2/6] m68k: Add NeXTcube keyboard device Thomas Huth
2019-08-13 10:13   ` Philippe Mathieu-Daudé
2019-08-13 10:16   ` Peter Maydell
2019-08-31  5:18     ` Thomas Huth
2019-09-03  9:12       ` Peter Maydell
2019-09-03  9:21         ` Thomas Huth
2019-07-09  7:32 ` [Qemu-devel] [PATCH v4 3/6] m68k: Add NeXTcube machine Thomas Huth
2019-08-13 10:20   ` Philippe Mathieu-Daudé
2019-07-09  7:32 ` [Qemu-devel] [PATCH v4 4/6] escc: introduce a selector for the register bit Thomas Huth
2019-08-13 10:21   ` Philippe Mathieu-Daudé
2019-07-09  7:32 ` Thomas Huth [this message]
2019-08-13 10:26   ` [Qemu-devel] [PATCH v4 5/6] m68k: Add serial controller to the NeXTcube machine Philippe Mathieu-Daudé
2019-07-09  7:32 ` [Qemu-devel] [PATCH v4 6/6] m68k: Add an entry for the NeXTcube machine to the MAINTAINERS file Thomas Huth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190709073222.26370-6-huth@tuxfamily.org \
    --to=huth@tuxfamily.org \
    --cc=f4bug@amsat.org \
    --cc=laurent@vivier.eu \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).