Skip to contentSkip to conversation

Add a generic loader

RFC In review Alistair Francis 2 participants 5 messages Jan 16, 2016 – Jan 28, 2016

lore
Share & tools
lore
#0 lore raw

cover Add a generic loader

This work is based on the original work by Li Guang with extra features added by Peter C.

The idea of this loader is to allow the user to load multiple images or values into QEMU at startup.

Memory values can be loaded like this: -device loader,addr=0xfd1a0104,data=0x8000000e,data-len=4

Images can be loaded like this: -device loader,file=./images/u-boot.elf,cpu=0

This can be useful and we use it a lot in Xilinx to load multiple images into a machine at creation (ATF, Kernel and DTB for example).

It can also be used to set registers.

At the moment only LE ARM is supported. I haven't tested BE support, so I'm not sure what state it is in. The limiation for arch is based off settting the ELF_ARCH macro.

The reset patch is required otherwise the reset will never be registered and the loader can't change the PC in the case of images.

I have tested this on ARM and it works. What do people think? Is it worth pursuing to try and get accepted?

Alistair Francis (2):
qdev-monitor.c: Register reset function if the device has one
generic-loader: Add a generic loader

 default-configs/arm-softmmu.mak  |   1 +
 hw/misc/Makefile.objs            |   2 +
 hw/misc/generic-loader.c         | 121 +++++++++++++++++++++++++++++++++++++++
 include/hw/misc/generic-loader.h |  50 ++++++++++++++++
 qdev-monitor.c                   |   2 +
 5 files changed, 176 insertions(+)
 create mode 100644 hw/misc/generic-loader.c
 create mode 100644 include/hw/misc/generic-loader.h
Signature · 1 line
2.5.0
#1 lore raw

RFC 1/2 qdev-monitor.c: Register reset function if the device has one

If the device being added when running qdev_device_add() has a reset function, register it so that it can be called.

---

 qdev-monitor.c | 2 ++
 1 file changed, 2 insertions(+)
qdev-monitor.c +2 -0
index 3ce4710..8e43074 100644
@@ -560,6 +560,8 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
 
     if (bus) {
         qdev_set_parent_bus(dev, bus);
+    } else if (dc->reset) {
+        qemu_register_reset((void (*)(void *))dc->reset, dev);
     }
 
     id = qemu_opts_id(opts);
Signature · 1 line
2.5.0
#2 lore raw

RFC 2/2 generic-loader: Add a generic loader

In reply to Alistair Francis

Add a generic loader to QEMU which can be used to load images or set memory values.

---

 default-configs/arm-softmmu.mak  |   1 +
 hw/misc/Makefile.objs            |   2 +
 hw/misc/generic-loader.c         | 121 +++++++++++++++++++++++++++++++++++++++
 include/hw/misc/generic-loader.h |  50 ++++++++++++++++
 4 files changed, 174 insertions(+)
 create mode 100644 hw/misc/generic-loader.c
 create mode 100644 include/hw/misc/generic-loader.h
default-configs/arm-softmmu.mak +1 -0
index d9b90a5..0fd2df7 100644
@@ -109,3 +109,4 @@ CONFIG_IOH3420=y
 CONFIG_I82801B11=y
 CONFIG_ACPI=y
 CONFIG_SMBIOS=y
+CONFIG_LOADER=y
hw/misc/Makefile.objs +2 -0
index d4765c2..c006b70 100644
@@ -44,3 +44,5 @@ obj-$(CONFIG_STM32F2XX_SYSCFG) += stm32f2xx_syscfg.o
 obj-$(CONFIG_PVPANIC) += pvpanic.o
 obj-$(CONFIG_EDU) += edu.o
 obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o
+
+obj-$(CONFIG_LOADER) += generic-loader.o
hw/misc/generic-loader.c new file +121 -0

121 lines not on this page · raw message

include/hw/misc/generic-loader.h new file +50 -0

50 lines not on this page · raw message

Signature · 1 line
2.5.0
#3 lore raw
In reply to Alistair Francis

Hi Alistair,

Quoted 8 lines · Alistair Francis

This work is based on the original work by Li Guang with extra features added by Peter C.

The idea of this loader is to allow the user to load multiple images or values into QEMU at startup.

I have tested this on ARM and it works. What do people think? Is it worth pursuing to try and get accepted?

For what it's worth, I think this is worthwhile.

Cov

Signature · 3 lines
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#4 lore raw
Quoted 6 lines · Christopher Covington

Hi Alistair,

Quoted 3 lines · Alistair Francis

This work is based on the original work by Li Guang with extra features added by Peter C.

Quoted 7 lines
Quoted 5 lines

The idea of this loader is to allow the user to load multiple images or values into QEMU at startup.

I have tested this on ARM and it works. What do people think? Is it worth pursuing to try and get accepted?

For what it's worth, I think this is worthwhile.

Hey Chris,

That is great! Any chance you would mind commenting on the code?

I'm assuming you are looking at ARM targets, which is all that is supported at the moment.

Thanks,

Alistair

Quoted 8 lines

Cov

--
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project