[PATCH 2/8] hw/loongarch/virt: Add field ram_end in LoongArchVirtMachineState

Bibo Mao posted 8 patches 1 week, 6 days ago
Maintainers: Song Gao <gaosong@loongson.cn>, Bibo Mao <maobibo@loongson.cn>, Jiaxun Yang <jiaxun.yang@flygoat.com>
[PATCH 2/8] hw/loongarch/virt: Add field ram_end in LoongArchVirtMachineState
Posted by Bibo Mao 1 week, 6 days ago
DRAM region is dynamically set and the last valid physical address
region with LoongArch Virt Machine. To record the last valid physical
address, field ram_end is added in structure LoongArchVirtMachineState.
In future PCIE 64-bit MMIO region will start next from DRAM memory
region.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
 hw/loongarch/virt.c         | 2 ++
 include/hw/loongarch/virt.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index 31215b7785..76e43c5f71 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -755,8 +755,10 @@ static void virt_init(MachineState *machine)
             exit(EXIT_FAILURE);
         }
         machine_memory_devices_init(machine, base, device_mem_size);
+        base += device_mem_size;
     }
 
+    lvms->ram_end = base;
     /* load the BIOS image. */
     virt_firmware_init(lvms);
 
diff --git a/include/hw/loongarch/virt.h b/include/hw/loongarch/virt.h
index 602feab0f0..8b970d1753 100644
--- a/include/hw/loongarch/virt.h
+++ b/include/hw/loongarch/virt.h
@@ -65,6 +65,7 @@ struct LoongArchVirtMachineState {
     DeviceState *extioi;
     struct memmap_entry *memmap_table;
     unsigned int memmap_entries;
+    hwaddr ram_end;
 };
 
 #define TYPE_LOONGARCH_VIRT_MACHINE  MACHINE_TYPE_NAME("virt")
-- 
2.39.3