qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Alistair Francis" <alistair@alistair23.me>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Laurent Vivier" <laurent@vivier.eu>,
	qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"David Gibson" <david@gibson.dropbear.id.au>
Subject: [RFC PATCH-for-6.1 10/10] hw/m68k/q800: Map MacIO using memory_region_add_subregion_aliased()
Date: Fri, 26 Mar 2021 01:27:28 +0100	[thread overview]
Message-ID: <20210326002728.1069834-11-f4bug@amsat.org> (raw)
In-Reply-To: <20210326002728.1069834-1-f4bug@amsat.org>

Currently the memory and flatview tree is huge, not very practical:

  $ (echo info mtree -f;echo q) \
    | qemu-system-m68k -M q800 -S -monitor stdio \
    | wc -l
  2073

Use the memory_region_add_subregion_aliased() helper to manage the
MacIO aliases under the hood.

- before:

  (qemu) info mtree
  address-space: memory
      0000000000000000-0000000007ffffff (prio 0, ram): m68k_mac.ram
      0000000040800000-00000000408fffff (prio 0, rom): m68k_mac.rom
      0000000050000000-000000005003ffff (prio 0, i/o): alias mac_m68k.io[0] @mac-io 0000000000000000-000000000003ffff
      0000000050040000-000000005007ffff (prio 0, i/o): alias mac_m68k.io[1] @mac-io 0000000000000000-000000000003ffff
      0000000050080000-00000000500bffff (prio 0, i/o): alias mac_m68k.io[2] @mac-io 0000000000000000-000000000003ffff
      ...
      0000000053f40000-0000000053f7ffff (prio 0, i/o): alias mac_m68k.io[253] @mac-io 0000000000000000-000000000003ffff
      0000000053f80000-0000000053fbffff (prio 0, i/o): alias mac_m68k.io[254] @mac-io 0000000000000000-000000000003ffff
      0000000053fc0000-0000000053ffffff (prio 0, i/o): alias mac_m68k.io[255] @mac-io 0000000000000000-000000000003ffff
      0000000060000000-00000000efffffff (prio 0, i/o): nubus-super-slots
      00000000f0000000-00000000feffffff (prio 0, i/o): nubus-slots
        00000000f9000000-00000000f9ffffff (prio 0, i/o): nubus-slot-9
          00000000f9001000-00000000f9400fff (prio 0, ram): macfb-vram
          00000000f9800000-00000000f9800fff (prio 0, i/o): macfb-ctrl
          00000000f9ffffe8-00000000f9ffffeb (prio 0, i/o): nubus-slot-9-rom
          00000000f9ffffec-00000000f9ffffff (prio 0, i/o): nubus-slot-9-format-block

- after:

  (qemu) info mtree
  address-space: memory
    0000000000000000-ffffffffffffffff (prio 0, i/o): system
      0000000000000000-0000000007ffffff (prio 0, ram): m68k_mac.ram
      0000000040800000-00000000408fffff (prio 0, rom): m68k_mac.rom
      0000000050000000-0000000053ffffff (prio 0, i/o): masked mac-io [span of 256 KiB]
      0000000060000000-00000000efffffff (prio 0, i/o): nubus-super-slots
      00000000f0000000-00000000feffffff (prio 0, i/o): nubus-slots
        00000000f9000000-00000000f9ffffff (prio 0, i/o): nubus-slot-9
          00000000f9001000-00000000f9400fff (prio 0, ram): macfb-vram
          00000000f9800000-00000000f9800fff (prio 0, i/o): macfb-ctrl
          00000000f9ffffe8-00000000f9ffffeb (prio 0, i/o): nubus-slot-9-rom
          00000000f9ffffec-00000000f9ffffff (prio 0, i/o): nubus-slot-9-format-block

  (qemu) info mtree -f
  FlatView #0
   AS "memory", root: system
   AS "cpu-memory-0", root: system
   AS "dp8393x", root: system
   Root memory region: system
    0000000000000000-0000000007ffffff (prio 0, ram): m68k_mac.ram
    0000000040800000-00000000408fffff (prio 0, rom): m68k_mac.rom
    0000000050000000-0000000053ffffff (prio 0, i/o): masked mac-io [span of 256 KiB]
    0000000060000000-00000000efffffff (prio 0, i/o): nubus-super-slots
    00000000f0000000-00000000f9000fff (prio 0, i/o): nubus-slots
    00000000f9001000-00000000f9400fff (prio 0, ram): macfb-vram
    00000000f9401000-00000000f97fffff (prio 0, i/o): nubus-slots @0000000009401000
    00000000f9800000-00000000f9800fff (prio 0, i/o): macfb-ctrl
    00000000f9801000-00000000f9ffffe7 (prio 0, i/o): nubus-slots @0000000009801000
    00000000f9ffffe8-00000000f9ffffeb (prio 0, rom): nubus-slot-9-rom
    00000000f9ffffec-00000000f9ffffff (prio 0, i/o): nubus-slot-9-format-block
    00000000fa000000-00000000feffffff (prio 0, i/o): nubus-slots @000000000a000000

  FlatView #1
   AS "mac-io", root: mac-io
   Root memory region: mac-io
    0000000000000000-0000000000001fff (prio 0, i/o): via1
    0000000000002000-0000000000003fff (prio 0, i/o): via2
    0000000000008000-0000000000008fff (prio 0, rom): dp8393x-prom
    000000000000a000-000000000000a0ff (prio 0, i/o): dp8393x-regs
    000000000000c020-000000000000c027 (prio 0, i/o): escc
    0000000000010000-00000000000100ff (prio 0, i/o): esp-regs
    0000000000010100-0000000000010103 (prio 0, i/o): esp-pdma
    000000000001e000-000000000001ffff (prio 0, i/o): swim

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/m68k/q800.c  | 15 +++------------
 hw/m68k/Kconfig |  1 +
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index 8f14e677077..4ca7e1af08e 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -40,6 +40,7 @@
 #include "standard-headers/asm-m68k/bootinfo.h"
 #include "standard-headers/asm-m68k/bootinfo-mac.h"
 #include "bootinfo.h"
+#include "hw/misc/aliased_region.h"
 #include "hw/misc/mac_via.h"
 #include "hw/input/adb.h"
 #include "hw/nubus/mac-nubus-bridge.h"
@@ -214,9 +215,6 @@ static void q800_init(MachineState *machine)
     int32_t initrd_size;
     MemoryRegion *rom;
     MemoryRegion *macio;
-    MemoryRegion *io;
-    const int io_slice_nb = (IO_SIZE / IO_SLICE);
-    int i;
     ram_addr_t ram_size = machine->ram_size;
     const char *kernel_filename = machine->kernel_filename;
     const char *initrd_filename = machine->initrd_filename;
@@ -258,15 +256,8 @@ static void q800_init(MachineState *machine)
      * Memory from IO_BASE to IO_BASE + IO_SLICE is repeated
      * from IO_BASE + IO_SLICE to IO_BASE + IO_SIZE
      */
-    io = g_new(MemoryRegion, io_slice_nb);
-    for (i = 0; i < io_slice_nb; i++) {
-        char *name = g_strdup_printf("mac_m68k.io[%d]", i);
-
-        memory_region_init_alias(&io[i], NULL, name, macio, 0, IO_SLICE);
-        memory_region_add_subregion(get_system_memory(),
-                                    IO_BASE + i * IO_SLICE, &io[i]);
-        g_free(name);
-    }
+    memory_region_add_subregion_aliased(get_system_memory(),
+                                        IO_BASE, IO_SIZE, macio, IO_SLICE);
 
     /* IRQ Glue */
     glue = qdev_new(TYPE_GLUE);
diff --git a/hw/m68k/Kconfig b/hw/m68k/Kconfig
index f839f8a0306..d2e588913b7 100644
--- a/hw/m68k/Kconfig
+++ b/hw/m68k/Kconfig
@@ -23,6 +23,7 @@ config Q800
     select ESP
     select DP8393X
     select OR_IRQ
+    select ALIASED_REGION
 
 config M68K_VIRT
     bool
-- 
2.26.2



  parent reply	other threads:[~2021-03-26  0:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-26  0:27 [RFC PATCH-for-6.1 00/10] hw/misc: Add memory_region_add_subregion_aliased() helper Philippe Mathieu-Daudé
2021-03-26  0:27 ` [RFC PATCH-for-6.1 01/10] hw/misc: Add device to help managing aliased memory regions Philippe Mathieu-Daudé
2021-03-26  0:27 ` [PATCH-for-6.1 02/10] hw/arm/musicpal: Open-code pflash_cfi02_register() call Philippe Mathieu-Daudé
2021-03-26  0:27 ` [RFC PATCH-for-6.1 03/10] hw/arm/musicpal: Map flash using memory_region_add_subregion_aliased() Philippe Mathieu-Daudé
2021-03-26 22:49   ` Philippe Mathieu-Daudé
2021-03-26  0:27 ` [PATCH-for-6.1 04/10] hw/arm/digic: Open-code pflash_cfi02_register() call Philippe Mathieu-Daudé
2021-03-26  0:27 ` [RFC PATCH-for-6.1 05/10] hw/arm/digic: Map flash using memory_region_add_subregion_aliased() Philippe Mathieu-Daudé
2021-03-26  0:27 ` [PATCH-for-6.1 06/10] hw/block/pflash_cfi02: Remove pflash_setup_mappings() Philippe Mathieu-Daudé
2021-03-29  4:11   ` David Gibson
2021-03-26  0:27 ` [PATCH-for-6.1 07/10] hw/block/pflash_cfi02: Simplify pflash_cfi02_register() prototype Philippe Mathieu-Daudé
2021-03-29  4:12   ` David Gibson
2021-03-26  0:27 ` [RFC PATCH-for-6.1 08/10] hw/misc/aliased_region: Simplify aliased I/O regions Philippe Mathieu-Daudé
2021-03-26  0:27 ` [PATCH-for-6.1 09/10] hw/m68k/q800: Add MacIO container Philippe Mathieu-Daudé
2021-03-26  0:27 ` Philippe Mathieu-Daudé [this message]
2021-03-26 12:58 ` [RFC PATCH-for-6.1 00/10] hw/misc: Add memory_region_add_subregion_aliased() helper Richard Henderson
2021-03-27 21:45 ` 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=20210326002728.1069834-11-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=alistair@alistair23.me \
    --cc=david@gibson.dropbear.id.au \
    --cc=edgar.iglesias@gmail.com \
    --cc=laurent@vivier.eu \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=richard.henderson@linaro.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).