qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <huth@tuxfamily.org>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 03/36] next-cube: remove overlap between next.dma and next.mmio memory regions
Date: Sun, 27 Oct 2024 12:24:29 +0100	[thread overview]
Message-ID: <20241027122429.50163254@tpx1> (raw)
In-Reply-To: <80f404f7-a8e7-4fcc-8e7d-d82d285113e5@ilande.co.uk>

Am Sat, 26 Oct 2024 22:13:25 +0100
schrieb Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>:

> On 26/10/2024 08:56, Thomas Huth wrote:
> 
> > Am Wed, 23 Oct 2024 09:58:19 +0100
> > schrieb Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>:
> >   
> >> Change the start of the next.mmio memory region so that it follows on directly
> >> after the next.dma memory region, adjusting the address offsets in
> >> next_mmio_read() and next_mmio_write() accordingly.
> >>
> >> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> >> ---
> >>   hw/m68k/next-cube.c | 28 ++++++++++++++--------------
> >>   1 file changed, 14 insertions(+), 14 deletions(-)
> >>
> >> diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c
> >> index 4e8e55a8bd..e1d94c1ce0 100644
> >> --- a/hw/m68k/next-cube.c
> >> +++ b/hw/m68k/next-cube.c
> >> @@ -266,23 +266,23 @@ static uint64_t next_mmio_read(void *opaque, hwaddr addr, unsigned size)
> >>       uint64_t val;
> >>   
> >>       switch (addr) {
> >> -    case 0x7000:
> >> +    case 0x2000:
> >>           /* DPRINTF("Read INT status: %x\n", s->int_status); */
> >>           val = s->int_status;
> >>           break;
> >>   
> >> -    case 0x7800:
> >> +    case 0x2800:
> >>           DPRINTF("MMIO Read INT mask: %x\n", s->int_mask);
> >>           val = s->int_mask;
> >>           break;
> >>   
> >> -    case 0xc000 ... 0xc003:
> >> -        val = extract32(s->scr1, (4 - (addr - 0xc000) - size) << 3,
> >> +    case 0x7000 ... 0x7003:
> >> +        val = extract32(s->scr1, (4 - (addr - 0x7000) - size) << 3,
> >>                           size << 3);
> >>           break;
> >>   
> >> -    case 0xd000 ... 0xd003:
> >> -        val = extract32(s->scr2, (4 - (addr - 0xd000) - size) << 3,
> >> +    case 0x8000 ... 0x8003:
> >> +        val = extract32(s->scr2, (4 - (addr - 0x8000) - size) << 3,
> >>                           size << 3);
> >>           break;
> >>   
> >> @@ -301,25 +301,25 @@ static void next_mmio_write(void *opaque, hwaddr addr, uint64_t val,
> >>       NeXTPC *s = NEXT_PC(opaque);
> >>   
> >>       switch (addr) {
> >> -    case 0x7000:
> >> +    case 0x2000:
> >>           DPRINTF("INT Status old: %x new: %x\n", s->int_status,
> >>                   (unsigned int)val);
> >>           s->int_status = val;
> >>           break;
> >>   
> >> -    case 0x7800:
> >> +    case 0x2800:
> >>           DPRINTF("INT Mask old: %x new: %x\n", s->int_mask, (unsigned int)val);
> >>           s->int_mask  = val;
> >>           break;  
> > 
> > Could you please add comments at the end of the "case" lines, stating which
> > mmio addresses are handled in each case? Otherwise, it's harder to grep for
> > certain addresses later. E.g:
> > 
> >      case 0x2800:     /* 0x2007800 */  
> 
> If you think it will help? Presumably this is to aid with comparing with other source 
> code/documentation?

Yes, it will help with 1) debugging code that is running in the guest (so
you can find IO addresses that it is accessing more easily) and 2) help
when comparing the code with "Previous":

 https://sourceforge.net/p/previous/code/HEAD/tree/trunk/src/ioMemTabNEXT.c#l36

> >> @@ -1000,7 +1000,7 @@ static void next_cube_init(MachineState *machine)
> >>       sysbus_create_simple(TYPE_NEXTFB, 0x0B000000, NULL);
> >>   
> >>       /* MMIO */
> >> -    sysbus_mmio_map(SYS_BUS_DEVICE(pcdev), 0, 0x02000000);
> >> +    sysbus_mmio_map(SYS_BUS_DEVICE(pcdev), 0, 0x02005000);  
> > 
> > Why 0x02005000 and not directly 0x02007000 ?  
> 
> Before this patch the output of "info mtree" shows as follows:
> 
> (qemu) info mtree
> address-space: cpu-memory-0
> address-space: memory
>    0000000000000000-ffffffffffffffff (prio 0, i/o): system
>      0000000000000000-000000000001ffff (prio 0, rom): alias next.rom2 @next.rom 
> 0000000000000000-000000000001ffff
>      0000000001000000-000000000101ffff (prio 0, rom): next.rom
>      0000000002000000-0000000002004fff (prio 0, i/o): next.dma
>      0000000002000000-00000000020cffff (prio 0, i/o): next.mmio
>      000000000200e000-000000000200efff (prio 0, i/o): next.kbd
>      00000000020c0000-00000000020c003f (prio 0, ram): next.bmapmem
>      0000000002100000-000000000211ffff (prio 0, i/o): next.scr
>      0000000002114000-000000000211400f (prio 0, i/o): esp-regs
>      0000000002118000-0000000002118003 (prio 0, i/o): escc
>      0000000004000000-0000000007ffffff (prio 0, ram): next.ram
>      000000000b000000-000000000b1cb0ff (prio 0, ram): next-video
>      00000000820c0000-00000000820c003f (prio 0, ram): alias next.bmapmem2 
> @next.bmapmem 0000000000000000-000000000000003f
> 
> All this patch does is move the start of next.mmio to 0x2005000 to avoid the overlap.
> 
> > I think there is another range at 0x02006000 related to the ethernet
> > controller, so directly going with 0x02007000 might cause less friction
> > later when we add the NIC?  
> 
> By the end of the series, everything except the "global" registers in next.mmio have 
> their own memory region (or empty-slot if the target is unknown) so that "info mtree" 
> output looks like this:
> 
> (qemu) info mtree
> address-space: cpu-memory-0
> address-space: memory
>    0000000000000000-ffffffffffffffff (prio 0, i/o): system
>      0000000000000000-000000000001ffff (prio 0, rom): alias next.rom2 @next.rom 
> 0000000000000000-000000000001ffff
>      0000000001000000-000000000101ffff (prio 0, rom): next.rom
>      0000000002000000-0000000002004fff (prio 0, i/o): next.dma
>      0000000002005000-000000000200dfff (prio 0, i/o): next.mmio
>      000000000200e000-000000000200efff (prio 0, i/o): next.kbd
>      00000000020c0000-00000000020c003f (prio 0, ram): next.bmapmem
>      0000000002106000-000000000210601f (prio 0, i/o): next.en
>      0000000002110000-000000000211000f (prio -10000, i/o): empty-slot
>      0000000002112000-000000000211200f (prio -10000, i/o): empty-slot
>      0000000002114000-000000000211403f (prio 0, i/o): next.scsi
>        0000000002114000-000000000211400f (prio 0, i/o): esp-regs
>        0000000002114020-0000000002114021 (prio 0, i/o): csrs
>      0000000002114108-000000000211410b (prio 0, i/o): next.floppy
>      0000000002118000-0000000002118003 (prio 0, i/o): escc
>      0000000002118004-0000000002118013 (prio -10000, i/o): empty-slot
>      000000000211a000-000000000211a003 (prio 0, i/o): next.timer
>      0000000004000000-0000000007ffffff (prio 0, ram): next.ram
>      000000000b000000-000000000b1cb0ff (prio 0, ram): next-video
>      00000000820c0000-00000000820c003f (prio 0, ram): alias next.bmapmem2 
> @next.bmapmem 0000000000000000-000000000000003f
> 
> In this case next.en is a dummy memory region which can easily be replaced with a 
> proper device implementation: see the final version of next-cube.c after the series 
> at https://gitlab.com/mcayland/qemu/-/blob/next-cube-improvements/hw/m68k/next-cube.c.

If I get it right, the IO memory is mirrored at 0x2000000 and 0x2100000,
so the ethernet region should show up in both, 0x2006000 and 0x2106000 in
the end? ... those memory regions on the NeXT are very confusing, but at
least this is what I get from 
 https://sourceforge.net/p/previous/code/HEAD/tree/trunk/src/cpu/memory.c#l1167
(IO_bank is mapped twice, unless it's the 030 Cube)

So I think we should make sure that we can mirror the ethernet registers at
0x2006000, too?

 Thomas


  reply	other threads:[~2024-10-27 11:25 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-23  8:58 [PATCH 00/36] next-cube: more tidy-ups and improvements Mark Cave-Ayland
2024-10-23  8:58 ` [PATCH 01/36] next-cube: fix up compilation when DEBUG_NEXT is enabled Mark Cave-Ayland
2024-10-26  6:30   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 02/36] next-cube: remove 0x14020 dummy value from next_mmio_read() Mark Cave-Ayland
2024-10-26  7:44   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 03/36] next-cube: remove overlap between next.dma and next.mmio memory regions Mark Cave-Ayland
2024-10-24  2:42   ` Philippe Mathieu-Daudé
2024-10-24  8:31     ` Mark Cave-Ayland
2024-10-26  7:56   ` Thomas Huth
2024-10-26 21:13     ` Mark Cave-Ayland
2024-10-27 11:24       ` Thomas Huth [this message]
2024-10-28 22:06         ` Mark Cave-Ayland
2024-10-23  8:58 ` [PATCH 04/36] next-cube: remove cpu parameter from next_scsi_init() Mark Cave-Ayland
2024-10-26  7:59   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 05/36] next-cube: create new next.scsi container memory region Mark Cave-Ayland
2024-10-23  8:58 ` [PATCH 06/36] next-cube: move next_scsi_init() to next_pc_realize() Mark Cave-Ayland
2024-10-27 10:07   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 07/36] next-cube: introduce next_pc_init() object init function Mark Cave-Ayland
2024-10-27 10:25   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 08/36] next-cube: introduce next-scsi device Mark Cave-Ayland
2024-10-27 11:58   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 09/36] next-cube: move SCSI CSRs from next-pc to the " Mark Cave-Ayland
2024-10-28 16:21   ` Thomas Huth
2024-10-28 22:21     ` Mark Cave-Ayland
2024-11-01 16:37       ` Thomas Huth
2024-10-23  8:58 ` [PATCH 10/36] next-cube: move SCSI 4020 logic from next-pc device to " Mark Cave-Ayland
2024-10-28 16:22   ` Thomas Huth
2024-10-28 22:23     ` Mark Cave-Ayland
2024-10-23  8:58 ` [PATCH 11/36] next-cube: move floppy disk MMIO to separate memory region in next-pc Mark Cave-Ayland
2024-10-28 16:31   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 12/36] next-cube: map ESCC registers as a subregion of the next.scr memory region Mark Cave-Ayland
2024-10-28 16:36   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 13/36] next-cube: move ESCC to be QOM child of next-pc device Mark Cave-Ayland
2024-10-28 16:39   ` Thomas Huth
2024-10-28 22:28     ` Mark Cave-Ayland
2024-11-01 16:34       ` Thomas Huth
2024-10-23  8:58 ` [PATCH 14/36] next-cube: move timer MMIO to separate memory region on " Mark Cave-Ayland
2024-11-01 16:46   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 15/36] next-cube: move en ethernet " Mark Cave-Ayland
2024-11-02  7:26   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 16/36] next-cube: add empty slots for unknown accesses to next.scr memory region Mark Cave-Ayland
2024-10-23  8:58 ` [PATCH 17/36] next-cube: remove unused " Mark Cave-Ayland
2024-11-02  9:40   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 18/36] next-cube: rearrange NeXTState declarations to improve readability Mark Cave-Ayland
2024-11-02  9:41   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 19/36] next-cube: convert next-pc device to use Resettable interface Mark Cave-Ayland
2024-11-02  9:48   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 20/36] next-cube: rename typedef struct NextRtc to NeXTRTC Mark Cave-Ayland
2024-11-02  9:49   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 21/36] next-cube: use qemu_irq to drive int_status in next_scr2_rtc_update() Mark Cave-Ayland
2024-11-03 18:31   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 22/36] next-cube: separate rtc read and write shift logic Mark Cave-Ayland
2024-11-03 18:52   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 23/36] next-cube: always use retval to return rtc read values Mark Cave-Ayland
2024-10-23  8:58 ` [PATCH 24/36] next-cube: use named gpio to set RTC data bit in scr2 Mark Cave-Ayland
2024-11-09  7:51   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 25/36] next-cube: use named gpio to read " Mark Cave-Ayland
2024-11-09  7:55   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 26/36] next-cube: don't use rtc phase value of -1 Mark Cave-Ayland
2024-10-23 10:37   ` BALATON Zoltan
2024-10-24  8:28     ` Mark Cave-Ayland
2024-11-09  7:57   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 27/36] next-cube: QOMify NeXTRTC Mark Cave-Ayland
2024-10-24  2:44   ` Philippe Mathieu-Daudé
2024-10-24  8:41     ` Mark Cave-Ayland
2024-11-09  8:14   ` Thomas Huth
2024-11-11 21:30     ` Mark Cave-Ayland
2024-10-23  8:58 ` [PATCH 28/36] next-cube: move reset of next-rtc fields from next-pc to next-rtc Mark Cave-Ayland
2024-11-09  8:19   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 29/36] next-cube: move rtc-data-in gpio from next-pc to next-rtc device Mark Cave-Ayland
2024-11-09  8:21   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 30/36] next-cube: use named gpio output for next-rtc data Mark Cave-Ayland
2024-10-23  8:58 ` [PATCH 31/36] next-cube: add rtc-cmd-reset named gpio to reset the rtc state machine Mark Cave-Ayland
2024-11-09  8:24   ` Thomas Huth
2024-11-11 21:37     ` Mark Cave-Ayland
2024-10-23  8:58 ` [PATCH 32/36] next-cube: add rtc-power-out " Mark Cave-Ayland
2024-10-24  8:45   ` Mark Cave-Ayland
2024-10-23  8:58 ` [PATCH 33/36] next-cube: move next_rtc_cmd_is_write() and next_rtc_data_in_irq() functions Mark Cave-Ayland
2024-11-09  8:25   ` Thomas Huth
2024-11-11 21:39     ` Mark Cave-Ayland
2024-10-23  8:58 ` [PATCH 34/36] next-cube: rename old_scr2 and scr2_2 in next_scr2_rtc_update() Mark Cave-Ayland
2024-11-09  8:25   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 35/36] next-cube: add my copyright to the top of the file Mark Cave-Ayland
2024-11-09  8:26   ` Thomas Huth
2024-10-23  8:58 ` [PATCH 36/36] next-cube: replace boiler-plate GPL 2.0 or later license text with SPDX identifier Mark Cave-Ayland
2024-10-23  9:30   ` Daniel P. Berrangé
2024-10-23  9:42     ` Mark Cave-Ayland
2024-10-29 11:22 ` [PATCH 00/36] next-cube: more tidy-ups and improvements Peter Maydell
2024-10-29 12:51   ` Mark Cave-Ayland

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=20241027122429.50163254@tpx1 \
    --to=huth@tuxfamily.org \
    --cc=mark.cave-ayland@ilande.co.uk \
    --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).