qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <huth@tuxfamily.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, Laurent Vivier <laurent@vivier.eu>
Subject: Re: [PATCH 05/11] hw/m68k/next-cube: Make next_irq take NeXTPC* as its opaque
Date: Sat, 16 Jan 2021 09:39:38 +0100	[thread overview]
Message-ID: <20210116093938.00668b47@tuxfamily.org> (raw)
In-Reply-To: <20210115201206.17347-6-peter.maydell@linaro.org>

Am Fri, 15 Jan 2021 20:12:00 +0000
schrieb Peter Maydell <peter.maydell@linaro.org>:

> Make the next_irq function take a NeXTPC* as its opaque rather than
> the M68kCPU*.  This will make it simpler to turn the next_irq
> function into a gpio input line of the NeXTPC device in the next
> commit.
> 
> For this to work we have to pass the CPU to the NeXTPC device via a
> link property, in the same way we do in q800.c (and for the same
> reason).
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/m68k/next-cube.c | 31 +++++++++++++++++++++++--------
>  1 file changed, 23 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c
> index f5575cb43b8..a9e57304e04 100644
> --- a/hw/m68k/next-cube.c
> +++ b/hw/m68k/next-cube.c
> @@ -94,6 +94,8 @@ struct NeXTPC {
>      /* Temporary until all functionality has been moved into this
> device */ NeXTState *ns;
>  
> +    M68kCPU *cpu;
> +
>      MemoryRegion mmiomem;
>      MemoryRegion scrmem;
>  
> @@ -739,9 +741,9 @@ static const MemoryRegionOps dma_ops = {
>   */
>  static void next_irq(void *opaque, int number, int level)
>  {
> -    M68kCPU *cpu = opaque;
> +    NeXTPC *s = NEXT_PC(opaque);
> +    M68kCPU *cpu = s->cpu;
>      int shift = 0;
> -    NeXTState *ns = NEXT_MACHINE(qdev_get_machine());
>  
>      /* first switch sets interupt status */
>      /* DPRINTF("IRQ %i\n",number); */
> @@ -796,14 +798,14 @@ static void next_irq(void *opaque, int number,
> int level)
>       * this HAS to be wrong, the interrupt handlers in mach and
> together
>       * int_status and int_mask and return if there is a hit
>       */
> -    if (ns->int_mask & (1 << shift)) {
> +    if (s->ns->int_mask & (1 << shift)) {
>          DPRINTF("%x interrupt masked @ %x\n", 1 << shift,
> cpu->env.pc); /* return; */
>      }
>  
>      /* second switch triggers the correct interrupt */
>      if (level) {
> -        ns->int_status |= 1 << shift;
> +        s->ns->int_status |= 1 << shift;
>  
>          switch (number) {
>          /* level 3 - floppy, kbd/mouse, power, ether rx/tx, scsi,
> clock */ @@ -832,7 +834,7 @@ static void next_irq(void *opaque, int
> number, int level) break;
>          }
>      } else {
> -        ns->int_status &= ~(1 << shift);
> +        s->ns->int_status &= ~(1 << shift);
>          cpu_reset_interrupt(CPU(cpu), CPU_INTERRUPT_HARD);
>      }
>  }
> @@ -847,9 +849,9 @@ static void next_serial_irq(void *opaque, int n,
> int level) }
>  }
>  
> -static void next_escc_init(M68kCPU *cpu)
> +static void next_escc_init(DeviceState *pcdev)
>  {
> -    qemu_irq *ser_irq = qemu_allocate_irqs(next_serial_irq, cpu, 2);
> +    qemu_irq *ser_irq = qemu_allocate_irqs(next_serial_irq, pcdev,
> 2); DeviceState *dev;
>      SysBusDevice *s;
>  
> @@ -893,6 +895,17 @@ static void next_pc_realize(DeviceState *dev,
> Error **errp) sysbus_init_mmio(sbd, &s->scrmem);
>  }
>  
> +/*
> + * If the m68k CPU implemented its inbound irq lines as GPIO lines
> + * rather than via the m68k_set_irq_level() function we would not
> need
> + * this cpu link property and could instead provide outbound IRQ
> lines
> + * that the board could wire up to the CPU.
> + */
> +static Property next_pc_properties[] = {
> +    DEFINE_PROP_LINK("cpu", NeXTPC, cpu, TYPE_M68K_CPU, M68kCPU *),
> +    DEFINE_PROP_END_OF_LIST(),
> +};
> +
>  static void next_pc_class_init(ObjectClass *klass, void *data)
>  {
>      DeviceClass *dc = DEVICE_CLASS(klass);
> @@ -900,6 +913,7 @@ static void next_pc_class_init(ObjectClass
> *klass, void *data) dc->desc = "NeXT Peripheral Controller";
>      dc->realize = next_pc_realize;
>      dc->reset = next_pc_reset;
> +    device_class_set_props(dc, next_pc_properties);
>      /* We will add the VMState in a later commit */
>  }
>  
> @@ -938,6 +952,7 @@ static void next_cube_init(MachineState *machine)
>  
>      /* Peripheral Controller */
>      pcdev = qdev_new(TYPE_NEXT_PC);
> +    object_property_set_link(OBJECT(pcdev), "cpu", OBJECT(cpu),
> &error_abort); sysbus_realize_and_unref(SYS_BUS_DEVICE(pcdev),
> &error_fatal); /* Temporary while we refactor this code */
>      NEXT_PC(pcdev)->ns = ns;
> @@ -996,7 +1011,7 @@ static void next_cube_init(MachineState *machine)
>      }
>  
>      /* Serial */
> -    next_escc_init(cpu);
> +    next_escc_init(pcdev);
>  
>      /* TODO: */
>      /* Network */

Reviewed-by: Thomas Huth <huth@tuxfamily.org>



  reply	other threads:[~2021-01-16  8:40 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-15 20:11 [PATCH 00/11] hw/m68k/next-cube: refactor to fix Coverity issue Peter Maydell
2021-01-15 20:11 ` [PATCH 01/11] hw/m68k/next-cube: Make next_irq() function static Peter Maydell
2021-01-16  6:46   ` Thomas Huth
2021-01-15 20:11 ` [PATCH 02/11] hw/m68k/next-cube: Move register/interrupt functionality into a device Peter Maydell
2021-01-15 20:11 ` [PATCH 03/11] hw/m68k/next-cube: Move mmio_ops into NeXTPC device Peter Maydell
2021-01-16  7:09   ` Thomas Huth
2021-01-15 20:11 ` [PATCH 04/11] hw/m68k/next-cube: Move scr_ops " Peter Maydell
2021-01-16  8:18   ` Thomas Huth
2021-01-15 20:12 ` [PATCH 05/11] hw/m68k/next-cube: Make next_irq take NeXTPC* as its opaque Peter Maydell
2021-01-16  8:39   ` Thomas Huth [this message]
2021-01-15 20:12 ` [PATCH 06/11] hw/m68k/next-cube: Move int_status and int_mask to NeXTPC struct Peter Maydell
2021-01-16  8:40   ` Thomas Huth
2021-01-15 20:12 ` [PATCH 07/11] hw/m68k/next-cube: Make next_irq GPIO inputs to NEXT_PC device Peter Maydell
2021-01-16 10:24   ` Thomas Huth
2021-01-15 20:12 ` [PATCH 08/11] hw/m68k/next-cube: Move rtc into NeXTPC struct Peter Maydell
2021-01-16 10:35   ` Thomas Huth
2021-01-15 20:12 ` [PATCH 09/11] hw/m68k/next-cube: Remove unused fields from NeXTState Peter Maydell
2021-01-16 10:43   ` Thomas Huth
2021-01-15 20:12 ` [PATCH 10/11] hw/m68k/next-cube: Add vmstate for NeXTPC device Peter Maydell
2021-01-16 10:44   ` Thomas Huth
2021-01-15 20:12 ` [PATCH 11/11] hw/m68k/next-cube: Add missing header comment to next-cube.h Peter Maydell
2021-01-16  7:36   ` 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=20210116093938.00668b47@tuxfamily.org \
    --to=huth@tuxfamily.org \
    --cc=laurent@vivier.eu \
    --cc=peter.maydell@linaro.org \
    --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).