Skip to content

Allow specification of virt board memory size via command line #18

@abrodkin

Description

@abrodkin

As of now we allocate 2Gib of memory by default, see https://github.com/foss-for-synopsys-dwc-arc-processors/qemu/blob/master/hw/arc/virt.c#L138:

#define VIRT_RAM_SIZE 0x80000000 ... /* Init system DDR */ system_ram = g_new(MemoryRegion, 1); memory_region_init_ram(system_ram, NULL, "arc.ram", VIRT_RAM_SIZE, &error_fatal);

This allows simulated target to use the whole memory from 0x8000_0000 to the very end of 32-bit address space, which is convenient in some cases. But it also poses some limitations.

For example, even if one wants to run a simple "hello world" bare-metal application and 1 MiB of RAM is more than enough for that, you still cannot even start qemu on a machine with 2 GiB of RAM, see zephyrproject-rtos/sdk-ng#291.

And on the more powerful systems that leads to unnecessary overhead of resource usage.

The fix is as simple as:

diff --git a/hw/arc/sim-hs.c b/hw/arc/sim-hs.c index 7dbf23bd03..61f50118c0 100644 --- a/hw/arc/sim-hs.c +++ b/hw/arc/sim-hs.c @@ -25,7 +25,6 @@ #include "hw/sysbus.h" #define SIMHS_RAM_BASE 0x80000000 -#define SIMHS_RAM_SIZE 0x80000000 #define SIMHS_IO_BASE 0xf0000000 #define SIMHS_IO_SIZE 0x10000000 #define SIMHS_UART0_OFFSET 0x0 @@ -49,7 +48,7 @@ static void simhs_init(MachineState *machine) int n; boot_info.ram_start = SIMHS_RAM_BASE; - boot_info.ram_size = SIMHS_RAM_SIZE; + boot_info.ram_size = machine->ram_size; boot_info.kernel_filename = machine->kernel_filename; boot_info.kernel_cmdline = machine->kernel_cmdline; @@ -69,7 +68,7 @@ static void simhs_init(MachineState *machine) /* Init system DDR */ system_ram = g_new(MemoryRegion, 1); - memory_region_init_ram(system_ram, NULL, "arc.ram", SIMHS_RAM_SIZE, + memory_region_init_ram(system_ram, NULL, "arc.ram", machine->ram_size, &error_fatal); memory_region_add_subregion(system_memory, SIMHS_RAM_BASE, system_ram);

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions