diff options
author | Laurent Vivier <laurent@vivier.eu> | 2022-01-15 21:37:25 +0100 |
---|---|---|
committer | Laurent Vivier <laurent@vivier.eu> | 2022-01-20 09:09:37 +0100 |
commit | e48b140eef9775986cc18038c7bc68f8d2b7fe1d (patch) | |
tree | 1299636ec206ce30cbcd897bef247ed5392035c9 /hw | |
parent | b4c4c1f1129a5d9dcbcbff46b58998f6fb1410bb (diff) | |
download | qemu-e48b140eef9775986cc18038c7bc68f8d2b7fe1d.zip qemu-e48b140eef9775986cc18038c7bc68f8d2b7fe1d.tar.gz qemu-e48b140eef9775986cc18038c7bc68f8d2b7fe1d.tar.bz2 |
m68k: virt: correctly set the initial PC
According to QEMU parameter, set initial PC to the entry of
the loaded kernel.
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20220115203725.3834712-4-laurent@vivier.eu>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/m68k/virt.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/hw/m68k/virt.c b/hw/m68k/virt.c index 78e926a..bbaf630 100644 --- a/hw/m68k/virt.c +++ b/hw/m68k/virt.c @@ -85,14 +85,21 @@ #define VIRT_VIRTIO_MMIO_BASE 0xff010000 /* MMIO: 0xff010000 - 0xff01ffff */ #define VIRT_VIRTIO_IRQ_BASE PIC_IRQ(2, 1) /* PIC: 2, 3, 4, 5, IRQ: ALL */ +typedef struct { + M68kCPU *cpu; + hwaddr initial_pc; + hwaddr initial_stack; +} ResetInfo; + static void main_cpu_reset(void *opaque) { - M68kCPU *cpu = opaque; + ResetInfo *reset_info = opaque; + M68kCPU *cpu = reset_info->cpu; CPUState *cs = CPU(cpu); cpu_reset(cs); - cpu->env.aregs[7] = ldl_phys(cs->as, 0); - cpu->env.pc = ldl_phys(cs->as, 4); + cpu->env.aregs[7] = reset_info->initial_stack; + cpu->env.pc = reset_info->initial_pc; } static void virt_init(MachineState *machine) @@ -113,6 +120,7 @@ static void virt_init(MachineState *machine) SysBusDevice *sysbus; hwaddr io_base; int i; + ResetInfo *reset_info; if (ram_size > 3399672 * KiB) { /* @@ -124,9 +132,13 @@ static void virt_init(MachineState *machine) exit(1); } + reset_info = g_malloc0(sizeof(ResetInfo)); + /* init CPUs */ cpu = M68K_CPU(cpu_create(machine->cpu_type)); - qemu_register_reset(main_cpu_reset, cpu); + + reset_info->cpu = cpu; + qemu_register_reset(main_cpu_reset, reset_info); /* RAM */ memory_region_add_subregion(get_system_memory(), 0, machine->ram); @@ -206,7 +218,7 @@ static void virt_init(MachineState *machine) error_report("could not load kernel '%s'", kernel_filename); exit(1); } - stl_phys(cs->as, 4, elf_entry); /* reset initial PC */ + reset_info->initial_pc = elf_entry; parameters_base = (high + 1) & ~1; BOOTINFO1(cs->as, parameters_base, BI_MACHTYPE, MACH_VIRT); |