From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: jusual@mail.ru, "Joel Stanley" <joel@jms.id.au>,
jim@groklearning.com, qemu-arm@nongnu.org,
"Peter Maydell" <peter.maydell@linaro.org>,
"Steffen Gortz" <qemu.ml@steffen-goertz.de>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Stefan Hajnoczi" <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH] microbit: make -kernel optional
Date: Fri, 14 Dec 2018 14:51:52 +0000 [thread overview]
Message-ID: <20181214145152.27250-1-stefanha@redhat.com> (raw)
ARMv7M machine types support -kernel for ELF and raw image files.
Microbit programs are typically in Intel HEX (.hex) format. The generic
loader supports .hex files but it doesn't work as expected:
$ qemu-system-arm -M microbit -device loader,file=microbit.hex
Guest image must be specified (using -kernel)
This error comes from armv7m_load_kernel() but we don't have -kernel in
this case.
This patch makes -kernel optional since most of the time we'll want to
use -device loader instead.
Note that we need to register the reset handler that
armv7m_load_kernel() used to register for us.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/arm/microbit.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/hw/arm/microbit.c b/hw/arm/microbit.c
index a734e7f650..638f638792 100644
--- a/hw/arm/microbit.c
+++ b/hw/arm/microbit.c
@@ -14,6 +14,7 @@
#include "hw/arm/arm.h"
#include "sysemu/sysemu.h"
#include "exec/address-spaces.h"
+#include "qemu/error-report.h"
#include "hw/arm/nrf51_soc.h"
@@ -28,6 +29,13 @@ typedef struct {
#define MICROBIT_MACHINE(obj) \
OBJECT_CHECK(MicrobitMachineState, obj, TYPE_MICROBIT_MACHINE)
+static void microbit_cpu_reset(void *opaque)
+{
+ ARMCPU *cpu = opaque;
+
+ cpu_reset(CPU(cpu));
+}
+
static void microbit_init(MachineState *machine)
{
MicrobitMachineState *s = MICROBIT_MACHINE(machine);
@@ -41,8 +49,13 @@ static void microbit_init(MachineState *machine)
&error_fatal);
object_property_set_bool(soc, true, "realized", &error_fatal);
- armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
- NRF51_SOC(soc)->flash_size);
+ if (machine->kernel_filename) {
+ armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
+ NRF51_SOC(soc)->flash_size);
+ } else {
+ /* armv7m_load_kernel() does this, we need to do it manually here */
+ qemu_register_reset(microbit_cpu_reset, ARM_CPU(first_cpu));
+ }
}
static void microbit_machine_class_init(ObjectClass *oc, void *data)
--
2.19.2
next reply other threads:[~2018-12-14 14:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-14 14:51 Stefan Hajnoczi [this message]
2019-01-03 7:56 ` [Qemu-devel] [PATCH] microbit: make -kernel optional Stefan Hajnoczi
2019-01-03 13:06 ` Peter Maydell
2019-01-03 14:18 ` Stefan Hajnoczi
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=20181214145152.27250-1-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=jim@groklearning.com \
--cc=joel@jms.id.au \
--cc=jusual@mail.ru \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu.ml@steffen-goertz.de \
/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).