From 5054d0c76bbbd6c45e660f9b5d3a3c6dc13dee5c Mon Sep 17 00:00:00 2001 From: bigmagic Date: Fri, 28 Jun 2024 23:07:06 +0800 Subject: [PATCH] hw/riscv: Adjust the memory allocation size of evalsoc to resolve the issue of insufficient memory allocation in QEMU. xip:32MB ddr:64MB ilm:8MB dlm:8MB sram:512MB If -m size is configured, the size is used as the size of the DDR. Otherwise, the size of the DDR is determined by parsing the json script, and the default size is 64MB. --- hw/riscv/nuclei_evalsoc.c | 7 +++++++ include/hw/riscv/nuclei_evalsoc.h | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/hw/riscv/nuclei_evalsoc.c b/hw/riscv/nuclei_evalsoc.c index bcc2989ed5eb..41f1fcbe6b21 100644 --- a/hw/riscv/nuclei_evalsoc.c +++ b/hw/riscv/nuclei_evalsoc.c @@ -865,6 +865,13 @@ static void evalsoc_machine_init(MachineState *machine) memory_region_add_subregion(system_memory, s->sram.addr_base, &s->soc.sram); + // ddr + //if -m 128M or no -m,s->ddr.addr_size is first json,then EVALSOC_DDR_SIZE + if(machine->ram_size != 128 * MiB) + { + s->ddr.addr_size = machine->ram_size; + } + memory_region_init_ram(&s->soc.ddr, NULL, "riscv.evalsoc.ram.ddr", s->ddr.addr_size, &error_fatal); memory_region_add_subregion(system_memory, s->ddr.addr_base, diff --git a/include/hw/riscv/nuclei_evalsoc.h b/include/hw/riscv/nuclei_evalsoc.h index f4f5df0eeca1..1eee0dccf070 100644 --- a/include/hw/riscv/nuclei_evalsoc.h +++ b/include/hw/riscv/nuclei_evalsoc.h @@ -250,15 +250,15 @@ enum #define EVALSOC_QSPI2_SIZE (0x1000) #define EVALSOC_XIP_BASE (0x20000000) -#define EVALSOC_XIP_SIZE (0x20000000) +#define EVALSOC_XIP_SIZE (0x02000000)//32MB #define EVALSOC_DDR_BASE (0x80000000) -#define EVALSOC_DDR_SIZE (0x80000000) +#define EVALSOC_DDR_SIZE (0x04000000)//64MB #define EVALSOC_ILM_BASE (0x80000000) -#define EVALSOC_ILM_SIZE (0x80000000) +#define EVALSOC_ILM_SIZE (0x00800000)//8MB #define EVALSOC_DLM_BASE (0x90000000) -#define EVALSOC_DLM_SIZE (0x70000000) +#define EVALSOC_DLM_SIZE (0x00800000)//8MB #define EVALSOC_SRAM_BASE (0xA0000000) -#define EVALSOC_SRAM_SIZE (0x60000000) +#define EVALSOC_SRAM_SIZE (0x20000000)//512MB /* IREGION Offsets */ #define IREGION_IINFO_OFS (0x0)