From: Fabien Chouteau <chouteau@adacore.com>
To: qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, agraf@suse.de
Subject: [Qemu-devel] [PATCH 2/3] PPC PReP: Use kernel entry to set nip at reset
Date: Wed, 3 Apr 2013 18:40:12 +0200 [thread overview]
Message-ID: <1365007213-27603-3-git-send-email-chouteau@adacore.com> (raw)
In-Reply-To: <1365007213-27603-1-git-send-email-chouteau@adacore.com>
When we load an ELF kernel we can start the board at the entry point.
Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
---
hw/ppc/prep.c | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index a2730c8..12198ff 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -56,6 +56,12 @@
#define KERNEL_LOAD_ADDR 0x01000000
#define INITRD_LOAD_ADDR 0x01800000
+typedef struct ResetData {
+ PowerPCCPU *cpu;
+ bool use_entry;
+ target_ulong entry; /* save kernel entry in case of reset */
+} ResetData;
+
#if defined (HARD_DEBUG_PPC_IO) && !defined (DEBUG_PPC_IO)
#define DEBUG_PPC_IO
#endif
@@ -425,8 +431,13 @@ static void cpu_request_exit(void *opaque, int irq, int level)
static void ppc_prep_reset(void *opaque)
{
- PowerPCCPU *cpu = opaque;
+ ResetData *s = (ResetData *)opaque;
+ PowerPCCPU *cpu = s->cpu;
+
+ if (s->use_entry) {
+ cpu->env.nip = s->entry;
+ }
cpu_reset(CPU(cpu));
}
@@ -463,11 +474,14 @@ static void ppc_prep_init(QEMUMachineInitArgs *args)
qemu_irq *cpu_exit_irq;
int ppc_boot_device;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
+ ResetData *reset_data;
sysctrl = g_malloc0(sizeof(sysctrl_t));
linux_boot = (kernel_filename != NULL);
+ reset_data = g_malloc0(sizeof(ResetData) * smp_cpus);
+
/* init CPUs */
if (cpu_model == NULL)
cpu_model = "602";
@@ -486,7 +500,11 @@ static void ppc_prep_init(QEMUMachineInitArgs *args)
/* Set time-base frequency to 100 Mhz */
cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
}
- qemu_register_reset(ppc_prep_reset, cpu);
+
+ /* Reset data */
+ reset_data[i].cpu = cpu;
+ reset_data[i].use_entry = false;
+ qemu_register_reset(ppc_prep_reset, &reset_data[i]);
}
/* allocate RAM */
@@ -521,19 +539,27 @@ static void ppc_prep_init(QEMUMachineInitArgs *args)
}
if (linux_boot) {
+ uint64_t entry;
+
kernel_base = KERNEL_LOAD_ADDR;
/* Try to load the kernel as an ELF file */
- kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, NULL, NULL,
+ kernel_size = load_elf(kernel_filename, NULL, NULL, &entry, NULL, NULL,
1, ELF_MACHINE, 0);
- if (kernel_size < 0) {
+ if (kernel_size > 0) {
+ /* Entry point for CPU #0 */
+ reset_data[0].entry = entry;
+ reset_data[0].use_entry = true;
+ } else {
/* Try to load the kernel as an binary file */
kernel_size = load_image_targphys(kernel_filename, kernel_base,
ram_size - kernel_base);
}
+
if (kernel_size < 0) {
hw_error("qemu: could not load kernel '%s'\n", kernel_filename);
}
+
/* load initrd */
if (initrd_filename) {
initrd_base = INITRD_LOAD_ADDR;
--
1.7.9.5
next prev parent reply other threads:[~2013-04-03 16:40 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-03 16:40 [Qemu-devel] [PATCH 0/3] PPC PReP: Use ElF kernel on PReP Fabien Chouteau
2013-04-03 16:40 ` [Qemu-devel] [PATCH 1/3] PPC PReP: Load ELF kernel Fabien Chouteau
2013-04-03 16:40 ` Fabien Chouteau [this message]
2013-04-03 16:40 ` [Qemu-devel] [PATCH 3/3] PPC PReP: can run without bios image Fabien Chouteau
2013-04-03 16:59 ` Alexander Graf
2013-04-04 8:37 ` Fabien Chouteau
2013-04-04 9:26 ` Alexander Graf
2013-04-04 16:19 ` Fabien Chouteau
2013-04-04 9:46 ` Artyom Tarasenko
2013-04-04 9:50 ` Alexander Graf
2013-04-04 9:57 ` Artyom Tarasenko
2013-04-04 11:53 ` Andreas Färber
2013-04-04 11:59 ` Alexander Graf
2013-04-05 23:00 ` Scott Wood
2013-04-06 9:01 ` Alexander Graf
2013-04-08 17:52 ` Scott Wood
2013-07-04 8:35 ` Julio Guerra
2013-07-10 9:16 ` Julio Guerra
2013-04-06 9:07 ` Alexander Graf
2013-04-06 11:27 ` Peter Maydell
2013-04-06 11:38 ` Alexander Graf
2013-04-06 13:08 ` Peter Maydell
2013-04-06 20:07 ` [Qemu-devel] [Qemu-ppc] " Edgar E. Iglesias
2013-04-06 20:12 ` Alexander Graf
2013-04-07 0:52 ` Edgar E. Iglesias
2013-04-04 12:43 ` [Qemu-devel] " Peter Maydell
2013-04-04 16:17 ` Fabien Chouteau
2013-04-04 16:20 ` Peter Maydell
2013-04-04 16:26 ` Artyom Tarasenko
2013-04-04 16:30 ` Peter Maydell
2013-04-04 16:34 ` Alexander Graf
2013-04-04 16:41 ` Peter Maydell
2013-04-04 16:51 ` Alexander Graf
2013-04-04 16:52 ` Peter Maydell
2013-04-04 22:32 ` Alexander Graf
2013-04-04 22:35 ` Peter Maydell
2013-04-04 16:46 ` Artyom Tarasenko
2013-04-04 16:51 ` Peter Maydell
2013-04-04 17:08 ` Artyom Tarasenko
2013-04-04 17:22 ` Andreas Färber
2013-04-05 9:19 ` Fabien Chouteau
2013-04-05 9:30 ` Peter Maydell
2013-04-04 17:05 ` Andreas Färber
2013-04-05 2:32 ` Rob Landley
2013-04-04 11:16 ` Andreas Färber
2013-04-04 16:18 ` Fabien Chouteau
2013-04-03 16:47 ` [Qemu-devel] [PATCH 0/3] PPC PReP: Use ElF kernel on PReP Alexander Graf
2013-04-03 17:32 ` Andreas Färber
2013-04-04 8:17 ` Fabien Chouteau
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=1365007213-27603-3-git-send-email-chouteau@adacore.com \
--to=chouteau@adacore.com \
--cc=agraf@suse.de \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).