* [PATCH-for-11.0 00/13] hw/sh4/r2d: Raise amount of RAM from 64 to 192 MB
@ 2025-11-24 9:50 Philippe Mathieu-Daudé
2025-11-24 9:50 ` [PATCH-for-11.0 01/13] hw/sh4/r2d: Bail out early if user request invalid RAM size Philippe Mathieu-Daudé
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-24 9:50 UTC (permalink / raw)
To: John Paul Adrian Glaubitz, qemu-devel
Cc: Rob Landley, Thorsten Glaser, Yoshinori Sato, Magnus Damm,
Philippe Mathieu-Daudé
It is possible to add more RAM on the R2D board:
- 1 real 64MB SDRAM
- 1 virtual 64MB SRAM (virtual because back then such
SRAM size wouldn't exist).
Memory tree change with this series applied:
$ diff -uw a b
--- a 2025-11-24 10:48:58
+++ b 2025-11-24 10:49:30
@@ -1,4 +1,4 @@
-QEMU 10.0.0 monitor - type 'help' for more information
+QEMU 10.1.91 monitor - type 'help' for more information
(qemu) info mtree -f
FlatView #0
AS "memory", root: system
@@ -6,7 +6,7 @@
Root memory region: system
0000000000000000-0000000000ffffff (prio 0, romd): r2d.flash
0000000004000000-000000000400003f (prio 0, i/o): r2d-fpga
- 000000000c000000-000000000fffffff (prio 0, ram): r2d.sdram
+ 0000000008000000-000000000fffffff (prio 0, ram): ram
0000000010000000-00000000107fffff (prio 0, ram): sm501.local
0000000013e00000-0000000013e0006b (prio 0, i/o): sm501-system-config
0000000013e10040-0000000013e10053 (prio 0, i/o): sm501-i2c
@@ -16,6 +16,7 @@
0000000013f00000-0000000013f00053 (prio 0, i/o): sm501-2d-engine
000000001400080c-000000001400080f (prio 0, i/o): ide-mmio.2
0000000014001000-000000001400101f (prio 0, i/o): ide-mmio.1
+ 0000000018000000-000000001bffffff (prio 0, ram): ram @0000000008000000
000000001e080000-000000001e080003 (prio 0, i/o): intc @000000001e080000
000000001e080040-000000001e080043 (prio 0, i/o): intc @000000001e080040
000000001e080060-000000001e080063 (prio 0, i/o): intc @000000001e080060
Philippe Mathieu-Daudé (13):
hw/sh4/r2d: Bail out early if user request invalid RAM size
hw/sh4/r2d: Define BOOT_PARAMS_BASE
hw/sh4/r2d: Introduce sdram_base and sdram_size variables
hw/sh4/r2d: Use memdev allocation for RAM
hw/sh4/r2d: Reword SH7750_BCR1 and SH7750_BCR2 initialization comments
hw/sh4/r2d: Configure flash (CS#0) as 16-bit accessible
hw/sh4/r2d: Introduce EXT_CS_BASE() macro and use it for SDRAM
hw/sh4/r2d: Use EXT_CS_BASE() macro for boot flash device
hw/sh4/r2d: Use EXT_CS_BASE() macro for FPGA device
hw/sh4/r2d: Use EXT_CS_BASE() macro for display controller
hw/sh4/r2d: Use EXT_CS_BASE() macro for pseudo ISA bus
hw/sh4/r2d: Add 64MB of SDRAM in CS#2
hw/sh4/r2d: Add 64MB of SRAM in CS#6
hw/sh4/r2d.c | 76 ++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 56 insertions(+), 20 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH-for-11.0 01/13] hw/sh4/r2d: Bail out early if user request invalid RAM size
2025-11-24 9:50 [PATCH-for-11.0 00/13] hw/sh4/r2d: Raise amount of RAM from 64 to 192 MB Philippe Mathieu-Daudé
@ 2025-11-24 9:50 ` Philippe Mathieu-Daudé
2025-11-24 9:50 ` [PATCH-for-11.0 02/13] hw/sh4/r2d: Define BOOT_PARAMS_BASE Philippe Mathieu-Daudé
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-24 9:50 UTC (permalink / raw)
To: John Paul Adrian Glaubitz, qemu-devel
Cc: Rob Landley, Thorsten Glaser, Yoshinori Sato, Magnus Damm,
Philippe Mathieu-Daudé
Do not give false expectations, as this machine only
uses 64MB of RAM.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sh4/r2d.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index 010be6d5394..56da48f64cb 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -251,6 +251,14 @@ static void r2d_init(MachineState *machine)
USBBus *usb_bus;
r2d_fpga_t *fpga;
+ switch (machine->ram_size) {
+ case 64 * MiB:
+ break;
+ default:
+ error_report("This machine can only use 64M of memory");
+ exit(EXIT_FAILURE);
+ }
+
cpu = SUPERH_CPU(cpu_create(machine->cpu_type));
env = &cpu->env;
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH-for-11.0 02/13] hw/sh4/r2d: Define BOOT_PARAMS_BASE
2025-11-24 9:50 [PATCH-for-11.0 00/13] hw/sh4/r2d: Raise amount of RAM from 64 to 192 MB Philippe Mathieu-Daudé
2025-11-24 9:50 ` [PATCH-for-11.0 01/13] hw/sh4/r2d: Bail out early if user request invalid RAM size Philippe Mathieu-Daudé
@ 2025-11-24 9:50 ` Philippe Mathieu-Daudé
2025-11-24 9:50 ` [PATCH-for-11.0 03/13] hw/sh4/r2d: Introduce sdram_base and sdram_size variables Philippe Mathieu-Daudé
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-24 9:50 UTC (permalink / raw)
To: John Paul Adrian Glaubitz, qemu-devel
Cc: Rob Landley, Thorsten Glaser, Yoshinori Sato, Magnus Damm,
Philippe Mathieu-Daudé
Linux expects the boot_params structure at a fixed location.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sh4/r2d.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index 56da48f64cb..5f8c034e1af 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -53,6 +53,7 @@
#define SM501_VRAM_SIZE 0x800000
+#define BOOT_PARAMS_BASE 0x0c000000
#define BOOT_PARAMS_OFFSET 0x0010000
/* CONFIG_BOOT_LINK_OFFSET of Linux kernel */
#define LINUX_LOAD_OFFSET 0x0800000
@@ -383,7 +384,7 @@ static void r2d_init(MachineState *machine)
}
rom_add_blob_fixed("boot_params", &boot_params, sizeof(boot_params),
- SDRAM_BASE + BOOT_PARAMS_OFFSET);
+ BOOT_PARAMS_BASE + BOOT_PARAMS_OFFSET);
}
static void r2d_machine_init(MachineClass *mc)
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH-for-11.0 03/13] hw/sh4/r2d: Introduce sdram_base and sdram_size variables
2025-11-24 9:50 [PATCH-for-11.0 00/13] hw/sh4/r2d: Raise amount of RAM from 64 to 192 MB Philippe Mathieu-Daudé
2025-11-24 9:50 ` [PATCH-for-11.0 01/13] hw/sh4/r2d: Bail out early if user request invalid RAM size Philippe Mathieu-Daudé
2025-11-24 9:50 ` [PATCH-for-11.0 02/13] hw/sh4/r2d: Define BOOT_PARAMS_BASE Philippe Mathieu-Daudé
@ 2025-11-24 9:50 ` Philippe Mathieu-Daudé
2025-11-24 9:50 ` [PATCH-for-11.0 04/13] hw/sh4/r2d: Use memdev allocation for RAM Philippe Mathieu-Daudé
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-24 9:50 UTC (permalink / raw)
To: John Paul Adrian Glaubitz, qemu-devel
Cc: Rob Landley, Thorsten Glaser, Yoshinori Sato, Magnus Damm,
Philippe Mathieu-Daudé
Soon RAM base / size won't be fixed, so introduce local
variables for them.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sh4/r2d.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index 5f8c034e1af..51c7c3e2e07 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -251,9 +251,12 @@ static void r2d_init(MachineState *machine)
PCIBus *pci_bus;
USBBus *usb_bus;
r2d_fpga_t *fpga;
+ hwaddr sdram_base;
+ uint64_t sdram_size = SDRAM_SIZE;
switch (machine->ram_size) {
case 64 * MiB:
+ sdram_base = SDRAM_BASE;
break;
default:
error_report("This machine can only use 64M of memory");
@@ -269,8 +272,8 @@ static void r2d_init(MachineState *machine)
qemu_register_reset(main_cpu_reset, reset_info);
/* Allocate memory space */
- memory_region_init_ram(sdram, NULL, "r2d.sdram", SDRAM_SIZE, &error_fatal);
- memory_region_add_subregion(address_space_mem, SDRAM_BASE, sdram);
+ memory_region_init_ram(sdram, NULL, "r2d.sdram", sdram_size, &error_fatal);
+ memory_region_add_subregion(address_space_mem, sdram_base, sdram);
/* Register peripherals */
s = sh7750_init(cpu, address_space_mem);
fpga = r2d_fpga_init(address_space_mem, 0x04000000, sh7750_irl(s));
@@ -338,7 +341,7 @@ static void r2d_init(MachineState *machine)
int kernel_size;
kernel_size = load_image_targphys(kernel_filename,
- SDRAM_BASE + LINUX_LOAD_OFFSET,
+ sdram_base + LINUX_LOAD_OFFSET,
INITRD_LOAD_OFFSET - LINUX_LOAD_OFFSET,
NULL);
if (kernel_size < 0) {
@@ -352,15 +355,15 @@ static void r2d_init(MachineState *machine)
address_space_stw(&address_space_memory, SH7750_BCR2, 3 << (3 * 2),
MEMTXATTRS_UNSPECIFIED, NULL); /* cs3 32bit */
/* Start from P2 area */
- reset_info->vector = (SDRAM_BASE + LINUX_LOAD_OFFSET) | 0xa0000000;
+ reset_info->vector = (sdram_base + LINUX_LOAD_OFFSET) | 0xa0000000;
}
if (initrd_filename) {
int initrd_size;
initrd_size = load_image_targphys(initrd_filename,
- SDRAM_BASE + INITRD_LOAD_OFFSET,
- SDRAM_SIZE - INITRD_LOAD_OFFSET,
+ sdram_base + INITRD_LOAD_OFFSET,
+ sdram_size - INITRD_LOAD_OFFSET,
NULL);
if (initrd_size < 0) {
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH-for-11.0 04/13] hw/sh4/r2d: Use memdev allocation for RAM
2025-11-24 9:50 [PATCH-for-11.0 00/13] hw/sh4/r2d: Raise amount of RAM from 64 to 192 MB Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-11-24 9:50 ` [PATCH-for-11.0 03/13] hw/sh4/r2d: Introduce sdram_base and sdram_size variables Philippe Mathieu-Daudé
@ 2025-11-24 9:50 ` Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 05/13] hw/sh4/r2d: Reword SH7750_BCR1 and SH7750_BCR2 initialization comments Philippe Mathieu-Daudé
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-24 9:50 UTC (permalink / raw)
To: John Paul Adrian Glaubitz, qemu-devel
Cc: Rob Landley, Thorsten Glaser, Yoshinori Sato, Magnus Damm,
Philippe Mathieu-Daudé
Memdev allocated MemoryRegion is initialized by generic code,
so board only needs to opt in to memdev scheme by providing
MachineClass::default_ram_id and using MachineState::ram
instead of manually initializing RAM memory region.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sh4/r2d.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index 51c7c3e2e07..5fd06b3b731 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -252,7 +252,7 @@ static void r2d_init(MachineState *machine)
USBBus *usb_bus;
r2d_fpga_t *fpga;
hwaddr sdram_base;
- uint64_t sdram_size = SDRAM_SIZE;
+ uint64_t sdram_size = machine->ram_size;
switch (machine->ram_size) {
case 64 * MiB:
@@ -272,7 +272,7 @@ static void r2d_init(MachineState *machine)
qemu_register_reset(main_cpu_reset, reset_info);
/* Allocate memory space */
- memory_region_init_ram(sdram, NULL, "r2d.sdram", sdram_size, &error_fatal);
+ memory_region_init_alias(sdram, NULL, "sdram", machine->ram, 0, sdram_size);
memory_region_add_subregion(address_space_mem, sdram_base, sdram);
/* Register peripherals */
s = sh7750_init(cpu, address_space_mem);
@@ -396,6 +396,8 @@ static void r2d_machine_init(MachineClass *mc)
mc->init = r2d_init;
mc->block_default_type = IF_IDE;
mc->default_cpu_type = TYPE_SH7751R_CPU;
+ mc->default_ram_size = 64 * MiB;
+ mc->default_ram_id = "ram";
mc->default_nic = "rtl8139";
}
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH-for-11.0 05/13] hw/sh4/r2d: Reword SH7750_BCR1 and SH7750_BCR2 initialization comments
2025-11-24 9:50 [PATCH-for-11.0 00/13] hw/sh4/r2d: Raise amount of RAM from 64 to 192 MB Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2025-11-24 9:50 ` [PATCH-for-11.0 04/13] hw/sh4/r2d: Use memdev allocation for RAM Philippe Mathieu-Daudé
@ 2025-11-24 9:51 ` Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 06/13] hw/sh4/r2d: Configure flash (CS#0) as 16-bit accessible Philippe Mathieu-Daudé
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-24 9:51 UTC (permalink / raw)
To: John Paul Adrian Glaubitz, qemu-devel
Cc: Rob Landley, Thorsten Glaser, Yoshinori Sato, Magnus Damm,
Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sh4/r2d.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index 5fd06b3b731..9de4944ecee 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -350,10 +350,12 @@ static void r2d_init(MachineState *machine)
}
/* initialization which should be done by firmware */
- address_space_stl(&address_space_memory, SH7750_BCR1, 1 << 3,
- MEMTXATTRS_UNSPECIFIED, NULL); /* cs3 SDRAM */
- address_space_stw(&address_space_memory, SH7750_BCR2, 3 << (3 * 2),
- MEMTXATTRS_UNSPECIFIED, NULL); /* cs3 32bit */
+ address_space_stl(&address_space_memory, SH7750_BCR1,
+ (1 << 3) | /* Areas 3 accessed as SDRAM */
+ 0, MEMTXATTRS_UNSPECIFIED, NULL);
+ address_space_stw(&address_space_memory, SH7750_BCR2,
+ (0b11 << 2 * 3) | /* Area 3 Bus width is 32 bits */
+ 0, MEMTXATTRS_UNSPECIFIED, NULL);
/* Start from P2 area */
reset_info->vector = (sdram_base + LINUX_LOAD_OFFSET) | 0xa0000000;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH-for-11.0 06/13] hw/sh4/r2d: Configure flash (CS#0) as 16-bit accessible
2025-11-24 9:50 [PATCH-for-11.0 00/13] hw/sh4/r2d: Raise amount of RAM from 64 to 192 MB Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2025-11-24 9:51 ` [PATCH-for-11.0 05/13] hw/sh4/r2d: Reword SH7750_BCR1 and SH7750_BCR2 initialization comments Philippe Mathieu-Daudé
@ 2025-11-24 9:51 ` Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 07/13] hw/sh4/r2d: Introduce EXT_CS_BASE() macro and use it for SDRAM Philippe Mathieu-Daudé
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-24 9:51 UTC (permalink / raw)
To: John Paul Adrian Glaubitz, qemu-devel
Cc: Rob Landley, Thorsten Glaser, Yoshinori Sato, Magnus Damm,
Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sh4/r2d.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index 9de4944ecee..12232fabbdf 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -355,6 +355,7 @@ static void r2d_init(MachineState *machine)
0, MEMTXATTRS_UNSPECIFIED, NULL);
address_space_stw(&address_space_memory, SH7750_BCR2,
(0b11 << 2 * 3) | /* Area 3 Bus width is 32 bits */
+ (0b10 << 14) | /* Area 0 Bus Width is 16 bits */
0, MEMTXATTRS_UNSPECIFIED, NULL);
/* Start from P2 area */
reset_info->vector = (sdram_base + LINUX_LOAD_OFFSET) | 0xa0000000;
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH-for-11.0 07/13] hw/sh4/r2d: Introduce EXT_CS_BASE() macro and use it for SDRAM
2025-11-24 9:50 [PATCH-for-11.0 00/13] hw/sh4/r2d: Raise amount of RAM from 64 to 192 MB Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2025-11-24 9:51 ` [PATCH-for-11.0 06/13] hw/sh4/r2d: Configure flash (CS#0) as 16-bit accessible Philippe Mathieu-Daudé
@ 2025-11-24 9:51 ` Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 08/13] hw/sh4/r2d: Use EXT_CS_BASE() macro for boot flash device Philippe Mathieu-Daudé
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-24 9:51 UTC (permalink / raw)
To: John Paul Adrian Glaubitz, qemu-devel
Cc: Rob Landley, Thorsten Glaser, Yoshinori Sato, Magnus Damm,
Philippe Mathieu-Daudé
The SH7751 memory controller can access 7 external banks.
The 64MB of SDRAM is on bank #3. Introduce the EXT_CS_BASE()
macro and use it for SDRAM.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sh4/r2d.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index 12232fabbdf..ecbc1ec2a98 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -45,10 +45,11 @@
#include "hw/block/flash.h"
#include "exec/tswap.h"
-#define FLASH_BASE 0x00000000
+#define EXT_CS_SIZE (64 * MiB)
+#define EXT_CS_BASE(cs_index) ((cs_index) * EXT_CS_SIZE)
+
#define FLASH_SIZE (16 * MiB)
-#define SDRAM_BASE 0x0c000000 /* Physical location of SDRAM: Area 3 */
#define SDRAM_SIZE 0x04000000
#define SM501_VRAM_SIZE 0x800000
@@ -256,7 +257,7 @@ static void r2d_init(MachineState *machine)
switch (machine->ram_size) {
case 64 * MiB:
- sdram_base = SDRAM_BASE;
+ sdram_base = EXT_CS_BASE(3); /* 64M @CS3 */
break;
default:
error_report("This machine can only use 64M of memory");
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH-for-11.0 08/13] hw/sh4/r2d: Use EXT_CS_BASE() macro for boot flash device
2025-11-24 9:50 [PATCH-for-11.0 00/13] hw/sh4/r2d: Raise amount of RAM from 64 to 192 MB Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2025-11-24 9:51 ` [PATCH-for-11.0 07/13] hw/sh4/r2d: Introduce EXT_CS_BASE() macro and use it for SDRAM Philippe Mathieu-Daudé
@ 2025-11-24 9:51 ` Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 09/13] hw/sh4/r2d: Use EXT_CS_BASE() macro for FPGA device Philippe Mathieu-Daudé
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-24 9:51 UTC (permalink / raw)
To: John Paul Adrian Glaubitz, qemu-devel
Cc: Rob Landley, Thorsten Glaser, Yoshinori Sato, Magnus Damm,
Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sh4/r2d.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index ecbc1ec2a98..26edcabf2c0 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -252,6 +252,7 @@ static void r2d_init(MachineState *machine)
PCIBus *pci_bus;
USBBus *usb_bus;
r2d_fpga_t *fpga;
+ const hwaddr flash_base = EXT_CS_BASE(0);
hwaddr sdram_base;
uint64_t sdram_size = machine->ram_size;
@@ -321,7 +322,7 @@ static void r2d_init(MachineState *machine)
* addressable in words of 16bit.
*/
dinfo = drive_get(IF_PFLASH, 0, 0);
- pflash_cfi02_register(0x0, "r2d.flash", FLASH_SIZE,
+ pflash_cfi02_register(flash_base, "r2d.flash", FLASH_SIZE,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
64 * KiB, 1, 2, 0x0001, 0x227e, 0x2220, 0x2200,
0x555, 0x2aa, 0);
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH-for-11.0 09/13] hw/sh4/r2d: Use EXT_CS_BASE() macro for FPGA device
2025-11-24 9:50 [PATCH-for-11.0 00/13] hw/sh4/r2d: Raise amount of RAM from 64 to 192 MB Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2025-11-24 9:51 ` [PATCH-for-11.0 08/13] hw/sh4/r2d: Use EXT_CS_BASE() macro for boot flash device Philippe Mathieu-Daudé
@ 2025-11-24 9:51 ` Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 10/13] hw/sh4/r2d: Use EXT_CS_BASE() macro for display controller Philippe Mathieu-Daudé
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-24 9:51 UTC (permalink / raw)
To: John Paul Adrian Glaubitz, qemu-devel
Cc: Rob Landley, Thorsten Glaser, Yoshinori Sato, Magnus Damm,
Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sh4/r2d.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index 26edcabf2c0..2229cc6fe66 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -253,6 +253,7 @@ static void r2d_init(MachineState *machine)
USBBus *usb_bus;
r2d_fpga_t *fpga;
const hwaddr flash_base = EXT_CS_BASE(0);
+ const hwaddr fpga_base = EXT_CS_BASE(1);
hwaddr sdram_base;
uint64_t sdram_size = machine->ram_size;
@@ -278,7 +279,7 @@ static void r2d_init(MachineState *machine)
memory_region_add_subregion(address_space_mem, sdram_base, sdram);
/* Register peripherals */
s = sh7750_init(cpu, address_space_mem);
- fpga = r2d_fpga_init(address_space_mem, 0x04000000, sh7750_irl(s));
+ fpga = r2d_fpga_init(address_space_mem, fpga_base, sh7750_irl(s));
dev = qdev_new("sh_pci");
busdev = SYS_BUS_DEVICE(dev);
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH-for-11.0 10/13] hw/sh4/r2d: Use EXT_CS_BASE() macro for display controller
2025-11-24 9:50 [PATCH-for-11.0 00/13] hw/sh4/r2d: Raise amount of RAM from 64 to 192 MB Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2025-11-24 9:51 ` [PATCH-for-11.0 09/13] hw/sh4/r2d: Use EXT_CS_BASE() macro for FPGA device Philippe Mathieu-Daudé
@ 2025-11-24 9:51 ` Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 11/13] hw/sh4/r2d: Use EXT_CS_BASE() macro for pseudo ISA bus Philippe Mathieu-Daudé
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-24 9:51 UTC (permalink / raw)
To: John Paul Adrian Glaubitz, qemu-devel
Cc: Rob Landley, Thorsten Glaser, Yoshinori Sato, Magnus Damm,
Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sh4/r2d.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index 2229cc6fe66..75878abe946 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -254,6 +254,7 @@ static void r2d_init(MachineState *machine)
r2d_fpga_t *fpga;
const hwaddr flash_base = EXT_CS_BASE(0);
const hwaddr fpga_base = EXT_CS_BASE(1);
+ const hwaddr sm501_base = EXT_CS_BASE(4);
hwaddr sdram_base;
uint64_t sdram_size = machine->ram_size;
@@ -295,11 +296,11 @@ static void r2d_init(MachineState *machine)
dev = qdev_new("sysbus-sm501");
busdev = SYS_BUS_DEVICE(dev);
qdev_prop_set_uint32(dev, "vram-size", SM501_VRAM_SIZE);
- qdev_prop_set_uint64(dev, "dma-offset", 0x10000000);
+ qdev_prop_set_uint64(dev, "dma-offset", sm501_base);
qdev_prop_set_chr(dev, "chardev", serial_hd(2));
sysbus_realize_and_unref(busdev, &error_fatal);
- sysbus_mmio_map(busdev, 0, 0x10000000);
- sysbus_mmio_map(busdev, 1, 0x13e00000);
+ sysbus_mmio_map(busdev, 0, sm501_base);
+ sysbus_mmio_map(busdev, 1, sm501_base + 0x3e00000);
sysbus_connect_irq(busdev, 0, &fpga->irq[SM501]);
/* onboard CF (True IDE mode, Master only). */
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH-for-11.0 11/13] hw/sh4/r2d: Use EXT_CS_BASE() macro for pseudo ISA bus
2025-11-24 9:50 [PATCH-for-11.0 00/13] hw/sh4/r2d: Raise amount of RAM from 64 to 192 MB Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2025-11-24 9:51 ` [PATCH-for-11.0 10/13] hw/sh4/r2d: Use EXT_CS_BASE() macro for display controller Philippe Mathieu-Daudé
@ 2025-11-24 9:51 ` Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 12/13] hw/sh4/r2d: Add 64MB of SDRAM in CS#2 Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 13/13] hw/sh4/r2d: Add 64MB of SRAM in CS#6 Philippe Mathieu-Daudé
12 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-24 9:51 UTC (permalink / raw)
To: John Paul Adrian Glaubitz, qemu-devel
Cc: Rob Landley, Thorsten Glaser, Yoshinori Sato, Magnus Damm,
Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sh4/r2d.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index 75878abe946..df62f7a48a9 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -255,6 +255,7 @@ static void r2d_init(MachineState *machine)
const hwaddr flash_base = EXT_CS_BASE(0);
const hwaddr fpga_base = EXT_CS_BASE(1);
const hwaddr sm501_base = EXT_CS_BASE(4);
+ const hwaddr isa_base = EXT_CS_BASE(5);
hwaddr sdram_base;
uint64_t sdram_size = machine->ram_size;
@@ -310,8 +311,8 @@ static void r2d_init(MachineState *machine)
sysbus_connect_irq(busdev, 0, &fpga->irq[CF_IDE]);
qdev_prop_set_uint32(dev, "shift", 1);
sysbus_realize_and_unref(busdev, &error_fatal);
- sysbus_mmio_map(busdev, 0, 0x14001000);
- sysbus_mmio_map(busdev, 1, 0x1400080c);
+ sysbus_mmio_map(busdev, 0, isa_base + 0x1000);
+ sysbus_mmio_map(busdev, 1, isa_base + 0x080c);
mmio_ide_init_drives(dev, dinfo, NULL);
/*
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH-for-11.0 12/13] hw/sh4/r2d: Add 64MB of SDRAM in CS#2
2025-11-24 9:50 [PATCH-for-11.0 00/13] hw/sh4/r2d: Raise amount of RAM from 64 to 192 MB Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2025-11-24 9:51 ` [PATCH-for-11.0 11/13] hw/sh4/r2d: Use EXT_CS_BASE() macro for pseudo ISA bus Philippe Mathieu-Daudé
@ 2025-11-24 9:51 ` Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 13/13] hw/sh4/r2d: Add 64MB of SRAM in CS#6 Philippe Mathieu-Daudé
12 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-24 9:51 UTC (permalink / raw)
To: John Paul Adrian Glaubitz, qemu-devel
Cc: Rob Landley, Thorsten Glaser, Yoshinori Sato, Magnus Damm,
Philippe Mathieu-Daudé
Expand maximum memory from 64MB to 128MB.
Inspired-by: Rob Landley <rob@landley.net>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sh4/r2d.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index df62f7a48a9..f5bc7c46965 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -263,8 +263,11 @@ static void r2d_init(MachineState *machine)
case 64 * MiB:
sdram_base = EXT_CS_BASE(3); /* 64M @CS3 */
break;
+ case 128 * MiB:
+ sdram_base = EXT_CS_BASE(2); /* 64M @CS2, 64M@CS3 */
+ break;
default:
- error_report("This machine can only use 64M of memory");
+ error_report("This machine can only use 64M or 128M of memory");
exit(EXIT_FAILURE);
}
@@ -356,9 +359,11 @@ static void r2d_init(MachineState *machine)
/* initialization which should be done by firmware */
address_space_stl(&address_space_memory, SH7750_BCR1,
+ (1 << 2) | /* Areas 2 accessed as SDRAM */
(1 << 3) | /* Areas 3 accessed as SDRAM */
0, MEMTXATTRS_UNSPECIFIED, NULL);
address_space_stw(&address_space_memory, SH7750_BCR2,
+ (0b11 << 2 * 2) | /* Area 2 Bus width is 32 bits */
(0b11 << 2 * 3) | /* Area 3 Bus width is 32 bits */
(0b10 << 14) | /* Area 0 Bus Width is 16 bits */
0, MEMTXATTRS_UNSPECIFIED, NULL);
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH-for-11.0 13/13] hw/sh4/r2d: Add 64MB of SRAM in CS#6
2025-11-24 9:50 [PATCH-for-11.0 00/13] hw/sh4/r2d: Raise amount of RAM from 64 to 192 MB Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2025-11-24 9:51 ` [PATCH-for-11.0 12/13] hw/sh4/r2d: Add 64MB of SDRAM in CS#2 Philippe Mathieu-Daudé
@ 2025-11-24 9:51 ` Philippe Mathieu-Daudé
12 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-24 9:51 UTC (permalink / raw)
To: John Paul Adrian Glaubitz, qemu-devel
Cc: Rob Landley, Thorsten Glaser, Yoshinori Sato, Magnus Damm,
Philippe Mathieu-Daudé
Expand maximum memory from 128MB to 192MB.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sh4/r2d.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index f5bc7c46965..445cc9a246d 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -245,6 +245,7 @@ static void r2d_init(MachineState *machine)
ResetData *reset_info;
struct SH7750State *s;
MemoryRegion *sdram = g_new(MemoryRegion, 1);
+ MemoryRegion *sram = g_new(MemoryRegion, 1);
DriveInfo *dinfo;
DeviceState *dev;
SysBusDevice *busdev;
@@ -266,8 +267,15 @@ static void r2d_init(MachineState *machine)
case 128 * MiB:
sdram_base = EXT_CS_BASE(2); /* 64M @CS2, 64M@CS3 */
break;
+ case 192 * MiB:
+ sdram_base = EXT_CS_BASE(2); /* 64M @CS2, 64M@CS3, 64M@CS6 */
+ sdram_size = 128 * MiB;
+ memory_region_init_alias(sram, NULL,
+ "sram", machine->ram, 128 * MiB, 64 * MiB);
+ memory_region_add_subregion(address_space_mem, EXT_CS_BASE(6), sram);
+ break;
default:
- error_report("This machine can only use 64M or 128M of memory");
+ error_report("This machine can only use 64M, 128M or 192M of memory");
exit(EXIT_FAILURE);
}
@@ -365,6 +373,7 @@ static void r2d_init(MachineState *machine)
address_space_stw(&address_space_memory, SH7750_BCR2,
(0b11 << 2 * 2) | /* Area 2 Bus width is 32 bits */
(0b11 << 2 * 3) | /* Area 3 Bus width is 32 bits */
+ (0b11 << 2 * 6) | /* Area 6 Bus width is 32 bits */
(0b10 << 14) | /* Area 0 Bus Width is 16 bits */
0, MEMTXATTRS_UNSPECIFIED, NULL);
/* Start from P2 area */
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2025-11-24 9:57 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-24 9:50 [PATCH-for-11.0 00/13] hw/sh4/r2d: Raise amount of RAM from 64 to 192 MB Philippe Mathieu-Daudé
2025-11-24 9:50 ` [PATCH-for-11.0 01/13] hw/sh4/r2d: Bail out early if user request invalid RAM size Philippe Mathieu-Daudé
2025-11-24 9:50 ` [PATCH-for-11.0 02/13] hw/sh4/r2d: Define BOOT_PARAMS_BASE Philippe Mathieu-Daudé
2025-11-24 9:50 ` [PATCH-for-11.0 03/13] hw/sh4/r2d: Introduce sdram_base and sdram_size variables Philippe Mathieu-Daudé
2025-11-24 9:50 ` [PATCH-for-11.0 04/13] hw/sh4/r2d: Use memdev allocation for RAM Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 05/13] hw/sh4/r2d: Reword SH7750_BCR1 and SH7750_BCR2 initialization comments Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 06/13] hw/sh4/r2d: Configure flash (CS#0) as 16-bit accessible Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 07/13] hw/sh4/r2d: Introduce EXT_CS_BASE() macro and use it for SDRAM Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 08/13] hw/sh4/r2d: Use EXT_CS_BASE() macro for boot flash device Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 09/13] hw/sh4/r2d: Use EXT_CS_BASE() macro for FPGA device Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 10/13] hw/sh4/r2d: Use EXT_CS_BASE() macro for display controller Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 11/13] hw/sh4/r2d: Use EXT_CS_BASE() macro for pseudo ISA bus Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 12/13] hw/sh4/r2d: Add 64MB of SDRAM in CS#2 Philippe Mathieu-Daudé
2025-11-24 9:51 ` [PATCH-for-11.0 13/13] hw/sh4/r2d: Add 64MB of SRAM in CS#6 Philippe Mathieu-Daudé
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).