Commit 4a84032a26 for qemu.org
commit 4a84032a26811e4f7404625b09c66b468534fdfe
Author: Helge Deller <deller@gmx.de>
Date: Mon Mar 30 00:11:12 2026 +0200
hw/hppa: Implement memory ranges
All 64-bit PA-RISC machines split the memory into (up to 3) different
memory ranges, which are mapped at specific addresses. This patch
mimics the mapping as it's done on physical machines, which includes the
3.75 GB split for C3700, and 1 GB split for newer 64-bit PAT machines
like the A400.
SeaBIOS-hppa needs to know how the memory split is done, so add a new
memsplit_addr variable which stores the specific split address and hand
this over to SeaBIOS-hppa via fwcfg.
Signed-off-by: Helge Deller <deller@gmx.de>
diff --git a/hw/hppa/hppa_hardware.h b/hw/hppa/hppa_hardware.h
index 006aae63b9..e2b2faa4a3 100644
--- a/hw/hppa/hppa_hardware.h
+++ b/hw/hppa/hppa_hardware.h
@@ -8,7 +8,8 @@
#define FIRMWARE_END 0xf0100000
#define FIRMWARE_HIGH 0xfffffff0 /* upper 32-bits of 64-bit firmware address */
-#define RAM_MAP_HIGH 0x0100000000 /* memory above 3.75 GB is mapped here */
+#define RAM_MAP_HIGH1 0x0100000000 /* memory above 4 GB */
+#define RAM_MAP_HIGH2 0x4040000000 /* memory between 1 G and 3.75 GB */
#define MEM_PDC_ENTRY 0x4800 /* PDC entry address */
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 3663bac53b..abd75dfe7d 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -43,6 +43,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(HppaMachineState, HPPA_COMMON_MACHINE)
struct HppaMachineState {
MachineState parent_obj;
+
+ uint64_t memsplit_addr;
};
#define MIN_SEABIOS_HPPA_VERSION 22 /* require at least this fw version */
@@ -208,6 +210,7 @@ static FWCfgState *create_fw_cfg(MachineState *ms, PCIBus *pci_bus,
const char qemu_version[] = QEMU_VERSION;
MachineClass *mc = MACHINE_GET_CLASS(ms);
int btlb_entries = HPPA_BTLB_ENTRIES(&cpu[0]->env);
+ struct HppaMachineState *hpm = HPPA_COMMON_MACHINE(ms);
int len;
fw_cfg = fw_cfg_init_mem_nodma(addr, addr + 4, 1);
@@ -231,6 +234,10 @@ static FWCfgState *create_fw_cfg(MachineState *ms, PCIBus *pci_bus,
fw_cfg_add_file(fw_cfg, "/etc/hppa/machine",
g_memdup2(mc->name, len), len);
+ val = cpu_to_le64(hpm->memsplit_addr);
+ fw_cfg_add_file(fw_cfg, "/etc/hppa/memsplit-addr",
+ g_memdup2(&val, sizeof(val)), sizeof(val));
+
val = cpu_to_le64(soft_power_reg);
fw_cfg_add_file(fw_cfg, "/etc/hppa/power-button-addr",
g_memdup2(&val, sizeof(val)), sizeof(val));
@@ -287,6 +294,8 @@ static TranslateFn *machine_HP_common_init_cpus(MachineState *machine)
TranslateFn *translate;
MemoryRegion *cpu_region;
uint64_t ram_max;
+ struct HppaMachineState *hpm;
+ hwaddr splitaddr;
/* Create CPUs. */
for (unsigned int i = 0; i < smp_cpus; i++) {
@@ -347,21 +356,36 @@ static TranslateFn *machine_HP_common_init_cpus(MachineState *machine)
info_report("Max RAM size limited to %" PRIu64 " MB", ram_max / MiB);
machine->ram_size = ram_max;
}
- if (machine->ram_size <= FIRMWARE_START) {
- /* contiguous memory up to 3.75 GB RAM */
- memory_region_add_subregion_overlap(addr_space, 0, machine->ram, -1);
- } else {
+
+ hpm = HPPA_COMMON_MACHINE(machine);
+ if (!hpm->memsplit_addr) {
/* non-contiguous: Memory above 3.75 GB is mapped at RAM_MAP_HIGH */
- MemoryRegion *mem_region;
- mem_region = g_new(MemoryRegion, 2);
- memory_region_init_alias(&mem_region[0], &addr_space->parent_obj,
- "LowMem", machine->ram, 0, FIRMWARE_START);
- memory_region_init_alias(&mem_region[1], &addr_space->parent_obj,
- "HighMem", machine->ram, FIRMWARE_START,
- machine->ram_size - FIRMWARE_START);
- memory_region_add_subregion_overlap(addr_space, 0, &mem_region[0], -1);
- memory_region_add_subregion_overlap(addr_space, RAM_MAP_HIGH,
- &mem_region[1], -1);
+ hpm->memsplit_addr = FIRMWARE_START;
+ }
+ splitaddr = hpm->memsplit_addr;
+
+ MemoryRegion *mem_region;
+ mem_region = g_new(MemoryRegion, 1);
+ memory_region_init_alias(&mem_region[0], &addr_space->parent_obj,
+ "memory0", machine->ram, 0, splitaddr);
+ memory_region_add_subregion_overlap(addr_space, 0, &mem_region[0], -1);
+ if (hppa_is_pa20(&cpu[0]->env)) {
+ if (machine->ram_size > 4 * GiB) {
+ mem_region = g_new(MemoryRegion, 1);
+ memory_region_init_alias(&mem_region[0], &addr_space->parent_obj,
+ "memory1", machine->ram, 4 * GiB,
+ machine->ram_size - 4 * GiB);
+ memory_region_add_subregion_overlap(addr_space, RAM_MAP_HIGH1,
+ &mem_region[0], -1);
+ }
+ if (machine->ram_size > splitaddr) {
+ mem_region = g_new(MemoryRegion, 1);
+ memory_region_init_alias(&mem_region[0], &addr_space->parent_obj,
+ "memory2", machine->ram, splitaddr,
+ 4 * GiB - splitaddr);
+ memory_region_add_subregion_overlap(addr_space, RAM_MAP_HIGH2,
+ &mem_region[0], -1);
+ }
}
return translate;
@@ -756,6 +780,10 @@ static void machine_HP_C3700_init(MachineState *machine)
*/
static void machine_HP_A400_init(MachineState *machine)
{
+ struct HppaMachineState *hpm;
+
+ hpm = HPPA_COMMON_MACHINE(machine);
+ hpm->memsplit_addr = 1 * GiB;
machine_HP_C3700_init(machine);
}
@@ -814,7 +842,7 @@ static void hppa_machine_common_class_init(ObjectClass *oc, const void *data)
mc->default_cpus = 1;
mc->max_cpus = HPPA_MAX_CPUS;
mc->default_boot_order = "cd";
- mc->default_ram_id = "ram";
+ mc->default_ram_id = "hppa.ram";
mc->default_nic = "tulip";
nc->nmi_monitor_handler = hppa_nmi;