From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"David Hildenbrand" <david@redhat.com>,
"Laurent Vivier" <laurent@vivier.eu>,
"Peter Xu" <peterx@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: [PATCH 3/3] m68k: virt: correctly set the initial PC
Date: Sat, 15 Jan 2022 21:37:25 +0100 [thread overview]
Message-ID: <20220115203725.3834712-4-laurent@vivier.eu> (raw)
In-Reply-To: <20220115203725.3834712-1-laurent@vivier.eu>
According to QEMU parameter, set initial PC to the entry of
the loaded kernel.
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
hw/m68k/virt.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/hw/m68k/virt.c b/hw/m68k/virt.c
index 78e926a55457..bbaf630bbf20 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);
--
2.34.1
next prev parent reply other threads:[~2022-01-15 20:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-15 20:37 [PATCH 0/3] m68k: virt: fix reboot Laurent Vivier
2022-01-15 20:37 ` [PATCH 1/3] exec/memory: Extract address_space_set() from dma_memory_set() Laurent Vivier
2022-01-17 8:23 ` David Hildenbrand
2022-01-17 8:57 ` Peter Xu
2022-01-15 20:37 ` [PATCH 2/3] hw/elf_ops: clear uninitialized segment space Laurent Vivier
2022-01-15 20:37 ` Laurent Vivier [this message]
2022-01-20 8:11 ` [PATCH 0/3] m68k: virt: fix reboot Laurent Vivier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220115203725.3834712-4-laurent@vivier.eu \
--to=laurent@vivier.eu \
--cc=david@redhat.com \
--cc=f4bug@amsat.org \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).