[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH-for-6.1 10/10] hw/m68k/q800: Map MacIO using memory_region_ad
From: |
Philippe Mathieu-Daudé |
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 |
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
- Re: [RFC PATCH-for-6.1 03/10] hw/arm/musicpal: Map flash using memory_region_add_subregion_aliased(), (continued)
- [PATCH-for-6.1 02/10] hw/arm/musicpal: Open-code pflash_cfi02_register() call, Philippe Mathieu-Daudé, 2021/03/25
- [PATCH-for-6.1 04/10] hw/arm/digic: Open-code pflash_cfi02_register() call, Philippe Mathieu-Daudé, 2021/03/25
- [RFC PATCH-for-6.1 05/10] hw/arm/digic: Map flash using memory_region_add_subregion_aliased(), Philippe Mathieu-Daudé, 2021/03/25
- [PATCH-for-6.1 06/10] hw/block/pflash_cfi02: Remove pflash_setup_mappings(), Philippe Mathieu-Daudé, 2021/03/25
- [PATCH-for-6.1 07/10] hw/block/pflash_cfi02: Simplify pflash_cfi02_register() prototype, Philippe Mathieu-Daudé, 2021/03/25
- [PATCH-for-6.1 09/10] hw/m68k/q800: Add MacIO container, Philippe Mathieu-Daudé, 2021/03/25
- [RFC PATCH-for-6.1 08/10] hw/misc/aliased_region: Simplify aliased I/O regions, Philippe Mathieu-Daudé, 2021/03/25
- [RFC PATCH-for-6.1 10/10] hw/m68k/q800: Map MacIO using memory_region_add_subregion_aliased(),
Philippe Mathieu-Daudé <=
- Re: [RFC PATCH-for-6.1 00/10] hw/misc: Add memory_region_add_subregion_aliased() helper, Richard Henderson, 2021/03/26
- Re: [RFC PATCH-for-6.1 00/10] hw/misc: Add memory_region_add_subregion_aliased() helper, Mark Cave-Ayland, 2021/03/27