Skip to contentSkip to conversation

Zynq-7000 EPP platform model

RFC PATCH Superseded Peter A. G. Crosthwaite 11 participants 33 messages Jan 23, 2012 – Feb 1, 2012 Kbuild

v1 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

cover Zynq-7000 EPP platform model

Hi,

This is an RFC for a suite of Device models and a machine model for the Xilinx Zynq-7000 Extensible Processing Platform:

http://www.xilinx.com/products/silicon-devices/epp/zynq-7000/index.htm

This is an ARM based platform featuring embedded SoC peripherals. This patch series includes a minimal set of device models and a a machine model capable of emulating zynq platforms booting linux.

A suitable test linux image is available from:

http://www.origin.xilinx.com/member/zynq_linux/zynq_linux.tar.gz

This first 4 patches in this series are device models for IP provided by cadence for the Zynq platform. The next two are changes/additions to the qemu boot process to faciliate booting of zynq-linux. The final patch is the initial revision of the zynq machine model.

Most of this work was originally authored by Xilinx, as indicated by (c) notices in added files.

Peter A. G. Crosthwaite (7):
cadence_uart: first revision
cadence ttc: first revision
cadence_wdt: first reivison
cadence_gem: first revision
vl.c: added -kerndtb option
arm_boot: added initrd address override
xilinx_zynq: machine model first revision

 Makefile.target   |    5 +
 hw/arm-misc.h     |    2 +
 hw/arm_boot.c     |   12 +-
 hw/cadence_gem.c  | 1442 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/cadence_ttc.c  |  545 ++++++++++++++++++++
 hw/cadence_uart.c |  620 +++++++++++++++++++++++
 hw/cadence_wdt.c  |  254 ++++++++++
 qemu-options.hx   |    3 +
 vl.c              |    4 +
 9 files changed, 2883 insertions(+), 4 deletions(-)
 create mode 100644 hw/cadence_gem.c
 create mode 100644 hw/cadence_ttc.c
 create mode 100644 hw/cadence_uart.c
 create mode 100644 hw/cadence_wdt.c
Signature · 1 line
1.7.3.2
#1 lore raw

RFC PATCH 1/7 cadence_uart: first revision

Device model for Cadence UART

---
 Makefile.target   |    1 +
 hw/cadence_uart.c |  619 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 620 insertions(+), 0 deletions(-)
 create mode 100644 hw/cadence_uart.c
Makefile.target +1 -0
index bb18d72..824f6eb 100644
@@ -334,6 +334,7 @@ endif
 obj-arm-y = integratorcp.o versatilepb.o arm_pic.o arm_timer.o
 obj-arm-y += arm_boot.o pl011.o pl031.o pl050.o pl080.o pl110.o pl181.o pl190.o
 obj-arm-y += versatile_pci.o
+obj-arm-y += cadence_uart.o
 obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o
 obj-arm-y += arm_l2x0.o
 obj-arm-y += arm_mptimer.o
hw/cadence_uart.c new file +619 -0

619 lines not on this page · raw message

Signature · 1 line
1.7.3.2
#4 lore raw

RFC PATCH 2/7 cadence ttc: first revision

In reply to Peter A. G. Crosthwaite

Device model for cadence triple timer counter (TTC)

---
 Makefile.target  |    1 +
 hw/cadence_ttc.c |  545 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 546 insertions(+), 0 deletions(-)
 create mode 100644 hw/cadence_ttc.c
Makefile.target +1 -0
index 824f6eb..44ba41b 100644
@@ -335,6 +335,7 @@ obj-arm-y = integratorcp.o versatilepb.o arm_pic.o arm_timer.o
 obj-arm-y += arm_boot.o pl011.o pl031.o pl050.o pl080.o pl110.o pl181.o pl190.o
 obj-arm-y += versatile_pci.o
 obj-arm-y += cadence_uart.o
+obj-arm-y += cadence_ttc.o
 obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o
 obj-arm-y += arm_l2x0.o
 obj-arm-y += arm_mptimer.o
hw/cadence_ttc.c new file +545 -0

545 lines not on this page · raw message

Signature · 1 line
1.7.3.2
#6 lore raw

RFC PATCH 3/7 cadence_wdt: first revision

In reply to Peter A. G. Crosthwaite

Device model for cadence watchdog timer (WDT)

---
 Makefile.target  |    1 +
 hw/cadence_wdt.c |  260 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 261 insertions(+), 0 deletions(-)
 create mode 100644 hw/cadence_wdt.c
Makefile.target +1 -0
index 44ba41b..c7abcde 100644
@@ -336,6 +336,7 @@ obj-arm-y += arm_boot.o pl011.o pl031.o pl050.o pl080.o pl110.o pl181.o pl190.o
 obj-arm-y += versatile_pci.o
 obj-arm-y += cadence_uart.o
 obj-arm-y += cadence_ttc.o
+obj-arm-y += cadence_wdt.o
 obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o
 obj-arm-y += arm_l2x0.o
 obj-arm-y += arm_mptimer.o
hw/cadence_wdt.c new file +260 -0

260 lines not on this page · raw message

Signature · 1 line
1.7.3.2
#8 lore raw

RFC PATCH 4/7 cadence_gem: first revision

In reply to Peter A. G. Crosthwaite

Device mode for cadence gem ethernet controller.

---
 Makefile.target  |    1 +
 hw/cadence_gem.c | 1441 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 1442 insertions(+), 0 deletions(-)
 create mode 100644 hw/cadence_gem.c
Makefile.target +1 -0
index c7abcde..e62ff59 100644
@@ -337,6 +337,7 @@ obj-arm-y += versatile_pci.o
 obj-arm-y += cadence_uart.o
 obj-arm-y += cadence_ttc.o
 obj-arm-y += cadence_wdt.o
+obj-arm-y += cadence_gem.o
 obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o
 obj-arm-y += arm_l2x0.o
 obj-arm-y += arm_mptimer.o
hw/cadence_gem.c new file +1441 -0

1,441 lines not on this page · raw message

Signature · 1 line
1.7.3.2
#10 lore raw

RFC PATCH 5/7 vl.c: added -kerndtb option

In reply to Peter A. G. Crosthwaite

Added linux specific kernel dtb option. This option can be specified to inject an argument device tree blob (dtb) into linux.

---
 qemu-options.hx |    3 +++
 vl.c            |    4 ++++
 2 files changed, 7 insertions(+), 0 deletions(-)
qemu-options.hx +3 -0
index 6295cde..43cddff 100644
@@ -1931,6 +1931,9 @@ ETEXI
 
 DEF("kernel", HAS_ARG, QEMU_OPTION_kernel, \
     "-kernel bzImage use 'bzImage' as kernel image\n", QEMU_ARCH_ALL)
+DEF("kern-dtb", HAS_ARG, QEMU_OPTION_kerndtb, \
+    "-kern-dtb dtb device tree blob passed to kernel boot\n", QEMU_ARCH_ALL)
+
 STEXI
 @item -kernel @var{bzImage}
 @findex -kernel
vl.c +4 -0
index d5868b1..75246f8 100644
@@ -233,6 +233,7 @@ int boot_menu;
 uint8_t *boot_splash_filedata;
 int boot_splash_filedata_size;
 uint8_t qemu_extra_params_fw[2];
+const char *qemu_kerndtb = NULL;
 
 typedef struct FWBootEntry FWBootEntry;
 
@@ -2437,6 +2438,9 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_kernel:
                 kernel_filename = optarg;
                 break;
+            case QEMU_OPTION_kerndtb:
+                qemu_kerndtb = optarg;
+                break;
             case QEMU_OPTION_append:
                 kernel_cmdline = optarg;
                 break;
Signature · 1 line
1.7.3.2
#29 lore raw

RFC PATCH 6/7 arm_boot: added initrd address override

In reply to Peter A. G. Crosthwaite

parameterised the initrd load address for arm boot process. Machine models can populate the initrd field with a non-zero address to specifiy that the default value of 0x00d00000 should be overridden.

---
 hw/arm-misc.h |    2 ++
 hw/arm_boot.c |   12 ++++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)
hw/arm-misc.h +2 -0
index 6e8ae6b..89e90c9 100644
@@ -29,6 +29,8 @@ struct arm_boot_info {
     const char *kernel_filename;
     const char *kernel_cmdline;
     const char *initrd_filename;
+    /* FIXME: support initrd load address = 0  somehow */
+    target_phys_addr_t initrd_load_addr;
     target_phys_addr_t loader_start;
     target_phys_addr_t smp_loader_start;
     target_phys_addr_t smp_bootreg_addr;
hw/arm_boot.c +8 -4
index bf509a8..d63ed3f 100644
@@ -71,7 +71,8 @@ static void set_kernel_args(const struct arm_boot_info *info,
         /* ATAG_INITRD2 */
         WRITE_WORD(p, 4);
         WRITE_WORD(p, 0x54420005);
-        WRITE_WORD(p, info->loader_start + INITRD_LOAD_ADDR);
+        WRITE_WORD(p, info->loader_start + info->initrd_load_addr ?
+                info->initrd_load_addr : INITRD_LOAD_ADDR);
         WRITE_WORD(p, initrd_size);
     }
     if (info->kernel_cmdline && *info->kernel_cmdline) {
@@ -148,7 +149,8 @@ static void set_kernel_args_old(const struct arm_boot_info *info,
     WRITE_WORD(p, 0);
     /* initrd_start */
     if (initrd_size)
-        WRITE_WORD(p, info->loader_start + INITRD_LOAD_ADDR);
+        WRITE_WORD(p, info->loader_start + info->initrd_load_addr ?
+                info->initrd_load_addr : INITRD_LOAD_ADDR);
     else
         WRITE_WORD(p, 0);
     /* initrd_size */
@@ -250,11 +252,13 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info)
     }
     info->entry = entry;
     if (is_linux) {
+        target_phys_addr_t initrd_load_addr = info->initrd_load_addr ?
+                info->initrd_load_addr : INITRD_LOAD_ADDR;
         if (info->initrd_filename) {
             initrd_size = load_image_targphys(info->initrd_filename,
                                               info->loader_start
-                                              + INITRD_LOAD_ADDR,
-                                              ram_size - INITRD_LOAD_ADDR);
+                                              + initrd_load_addr,
+                                              ram_size - initrd_load_addr);
             if (initrd_size < 0) {
                 fprintf(stderr, "qemu: could not load initrd '%s'\n",
                         info->initrd_filename);
Signature · 1 line
1.7.3.2
#30 lore raw

RFC PATCH 7/7 xilinx_zynq: machine model first revision

In reply to Peter A. G. Crosthwaite

Xilinx zynq-7000 machine model. Also includes device model for the zynq-specific system level control register (SLCR) module.

---
 Makefile.target |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Makefile.target +1 -0
index e62ff59..1c89779 100644
@@ -338,6 +338,7 @@ obj-arm-y += cadence_uart.o
 obj-arm-y += cadence_ttc.o
 obj-arm-y += cadence_wdt.o
 obj-arm-y += cadence_gem.o
+obj-arm-y += xilinx_zynq.o zynq_arm_sysctl.o
 obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o
 obj-arm-y += arm_l2x0.o
 obj-arm-y += arm_mptimer.o
Signature · 1 line
1.7.3.2
#31 lore raw

Re: [Qemu-devel] [RFC PATCH 7/7] xilinx_zynq: machine model first revision

Quoted 13 lines · Peter A. G. Crosthwaite

Xilinx zynq-7000 machine model. Also includes device model for the zynq-specific system level control register (SLCR) module.

---
 Makefile.target |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Makefile.target +0 -0
index e62ff59..1c89779 100644

Makefile.target obj-arm-y += cadence_uart.o · line 344

Quoted 7 lines
Makefile.target +1 -0
@@ -338,6 +338,7 @@ obj-arm-y += cadence_uart.o
 obj-arm-y += cadence_ttc.o
 obj-arm-y += cadence_wdt.o
 obj-arm-y += cadence_gem.o
+obj-arm-y += xilinx_zynq.o zynq_arm_sysctl.o
 obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o
 obj-arm-y += arm_l2x0.o
 obj-arm-y += arm_mptimer.o

You probably forget to add that two files to this patch.

Michal

Signature · 4 lines
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian
#32 lore raw

Re: [Qemu-devel] [RFC PATCH 7/7] xilinx_zynq: machine model first revision

Regenerated and resent.

Regards,
Peter

Quoted 40 lines · Michal Simek
Quoted 20 lines · Peter A. G. Crosthwaite

Xilinx zynq-7000 machine model. Also includes device model for the zynq-specific
system level control register (SLCR) module.

Quoted 1 line
---
 Makefile.target |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Makefile.target +1 -0
index e62ff59..1c89779 100644
@@ -338,6 +338,7 @@ obj-arm-y += cadence_uart.o
 obj-arm-y += cadence_ttc.o
 obj-arm-y += cadence_wdt.o
 obj-arm-y += cadence_gem.o
+obj-arm-y += xilinx_zynq.o zynq_arm_sysctl.o
 obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o
Quoted 4 lines

a9mpcore.o
obj-arm-y += arm_l2x0.o
obj-arm-y += arm_mptimer.o

You probably forget to add that two files to this patch.

Michal

--
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux -
http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian

#2 lore raw

Re: [Qemu-devel] [RFC PATCH 1/7] cadence_uart: first revision

In reply to Peter A. G. Crosthwaite
Quoted 8 lines

-----Original Message-----
From: Peter A. G. Crosthwaite [mailto:[email protected]]
Sent: Sunday, January 22, 2012 11:20 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Duy Le; John Linn
Subject: [RFC PATCH 1/7] cadence_uart: first revision

Quoted 4 lines

Device model for Cadence UART

Signed-off-by: Peter A. G. Crosthwaite
<[email protected]>

*** My apologies, please ignore the legal footer below which I'm working on getting removed ***

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

#5 lore raw

Re: [Qemu-devel] [RFC PATCH 2/7] cadence ttc: first revision

In reply to Peter A. G. Crosthwaite
Quoted 8 lines

-----Original Message-----
From: Peter A. G. Crosthwaite [mailto:[email protected]]
Sent: Sunday, January 22, 2012 11:20 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Duy Le; John Linn
Subject: [RFC PATCH 2/7] cadence ttc: first revision

Quoted 4 lines

Device model for cadence triple timer counter (TTC)

Signed-off-by: Peter A. G. Crosthwaite
<[email protected]>

*** My apologies, please ignore the legal footer below which I'm working on getting removed ***

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

#7 lore raw

Re: [Qemu-devel] [RFC PATCH 3/7] cadence_wdt: first revision

In reply to Peter A. G. Crosthwaite
Quoted 8 lines

-----Original Message-----
From: Peter A. G. Crosthwaite [mailto:[email protected]]
Sent: Sunday, January 22, 2012 11:21 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Duy Le; John Linn
Subject: [RFC PATCH 3/7] cadence_wdt: first revision

Quoted 4 lines

Device model for cadence watchdog timer (WDT)

Signed-off-by: Peter A. G. Crosthwaite
<[email protected]>

*** My apologies, please ignore the legal footer below which I'm working on getting removed ***

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

#9 lore raw

Re: [Qemu-devel] [RFC PATCH 4/7] cadence_gem: first revision

In reply to Peter A. G. Crosthwaite
Quoted 8 lines

-----Original Message-----
From: Peter A. G. Crosthwaite [mailto:[email protected]]
Sent: Sunday, January 22, 2012 11:21 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Duy Le; John Linn
Subject: [RFC PATCH 4/7] cadence_gem: first revision

Quoted 4 lines

Device mode for cadence gem ethernet controller.

Signed-off-by: Peter A. G. Crosthwaite
<[email protected]>

*** My apologies, please ignore the legal footer below which I'm working on getting removed ***

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

#11 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

In reply to Peter A. G. Crosthwaite

Am 23.01.2012 08:20, schrieb Peter A. G. Crosthwaite:

Quoted 14 lines

Added linux specific kernel dtb option. This option can be specified to inject an argument device tree blob (dtb) into linux.

---
 qemu-options.hx |    3 +++
 vl.c            |    4 ++++
 2 files changed, 7 insertions(+), 0 deletions(-)
qemu-options.hx +0 -0
index 6295cde..43cddff 100644

qemu-options.hx ETEXI · line 1935

Quoted 5 lines
qemu-options.hx +2 -0
@@ -1931,6 +1931,9 @@ ETEXI
 
 DEF("kernel", HAS_ARG, QEMU_OPTION_kernel, \
     "-kernel bzImage use 'bzImage' as kernel image\n", QEMU_ARCH_ALL)
+DEF("kern-dtb", HAS_ARG, QEMU_OPTION_kerndtb, \
+    "-kern-dtb dtb device tree blob passed to kernel boot\n", QEMU_ARCH_ALL)

We should probably call it -kernel-dtb. If there's some strncmp() from -kernel interfering, we should fix that instead.

I don't see this variable being used anywhere in this series though. Would it have been in the missing zynq machine of 7/7?

Andreas

Quoted 26 lines
qemu-options.hx +1 -0
+
 STEXI
 @item -kernel @var{bzImage}
 @findex -kernel
vl.c +4 -0
index d5868b1..75246f8 100644
@@ -233,6 +233,7 @@ int boot_menu;
 uint8_t *boot_splash_filedata;
 int boot_splash_filedata_size;
 uint8_t qemu_extra_params_fw[2];
+const char *qemu_kerndtb = NULL;
 
 typedef struct FWBootEntry FWBootEntry;
 
@@ -2437,6 +2438,9 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_kernel:
                 kernel_filename = optarg;
                 break;
+            case QEMU_OPTION_kerndtb:
+                qemu_kerndtb = optarg;
+                break;
             case QEMU_OPTION_append:
                 kernel_cmdline = optarg;
                 break;
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#12 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

Hi Andreas,

Thanks for that, I will rename the switch to -kernel-dtb.

You are correct that 7/7 should have the usage in it, that patch was incorrectly generated, I will regenerate and resend the series tomorrow for another review cycle.

Regards.
Peter

Quoted 62 lines · Andreas Färber

Am 23.01.2012 08:20, schrieb Peter A. G. Crosthwaite:

Quoted 1 line

Added linux specific kernel dtb option. This option can be specified to

inject

Quoted 13 lines

an argument device tree blob (dtb) into linux.

---
 qemu-options.hx |    3 +++
 vl.c            |    4 ++++
 2 files changed, 7 insertions(+), 0 deletions(-)
qemu-options.hx +0 -0
index 6295cde..43cddff 100644

qemu-options.hx ETEXI · line 1935

Quoted 5 lines
qemu-options.hx +2 -0
@@ -1931,6 +1931,9 @@ ETEXI
 
 DEF("kernel", HAS_ARG, QEMU_OPTION_kernel, \
     "-kernel bzImage use 'bzImage' as kernel image\n", QEMU_ARCH_ALL)
+DEF("kern-dtb", HAS_ARG, QEMU_OPTION_kerndtb, \
+    "-kern-dtb dtb device tree blob passed to kernel boot\n",

QEMU_ARCH_ALL)

We should probably call it -kernel-dtb. If there's some strncmp() from -kernel interfering, we should fix that instead.

I don't see this variable being used anywhere in this series though. Would it have been in the missing zynq machine of 7/7?

Andreas

Quoted 17 lines
qemu-options.hx +1 -0
+
 STEXI
 @item -kernel @var{bzImage}
 @findex -kernel
vl.c +1 -0
index d5868b1..75246f8 100644
@@ -233,6 +233,7 @@ int boot_menu;
 uint8_t *boot_splash_filedata;
 int boot_splash_filedata_size;
 uint8_t qemu_extra_params_fw[2];
+const char *qemu_kerndtb = NULL;
 
 typedef struct FWBootEntry FWBootEntry;
 

vl.c int main(int argc, char **argv, char **envp) · line 2446

Quoted 9 lines
vl.c +3 -0
@@ -2437,6 +2438,9 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_kernel:
                 kernel_filename = optarg;
                 break;
+            case QEMU_OPTION_kerndtb:
+                qemu_kerndtb = optarg;
+                break;
             case QEMU_OPTION_append:
                 kernel_cmdline = optarg;
                 break;

--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

#13 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

Hi Peter,

Am 24.01.2012 08:35, schrieb Peter Crosthwaite:

Quoted 5 lines

Thanks for that, I will rename the switch to -kernel-dtb.

You are correct that 7/7 should have the usage in it, that patch was incorrectly generated, I will regenerate and resend the series tomorrow for another review cycle.

Just found it, sorry. Is it just my mail client or did something go wrong with sending? 0/7 is not threaded with the rest, and neither is the fixed-up 7/7. It would facilitate review.

When resending, please also cc our ARM maintainer, even if your Edgar might be the one to commit it in the end.
Please also don't forget to update MAINTAINERS with an entry for the new machine and devices.

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#3 lore raw

Re: [Qemu-devel] [RFC PATCH 1/7] cadence_uart: first revision

In reply to Peter A. G. Crosthwaite

Am 23.01.2012 08:20, schrieb Peter A. G. Crosthwaite:

Quoted 16 lines

Device model for Cadence UART

---
 Makefile.target   |    1 +
 hw/cadence_uart.c |  619 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 620 insertions(+), 0 deletions(-)
 create mode 100644 hw/cadence_uart.c
hw/cadence_uart.c new file +1 -0
new file mode 100644
index 0000000..931ff2c
 
+typedef struct {

[...]

Quoted 1 line

+} uart_state;

Coding Style mandates CamelCase for structs.

hw/cadence_uart.c line 616

Quoted 4 lines
hw/cadence_uart.c new file +4 -0
+static void uart_register_devices(void)
+{
+    sysbus_register_dev("cadence_uart", sizeof(uart_state),
+                        uart_init);

Please use sysbus_register_withprop() instead, for the upcoming QOM conversion.

Could you also consider adding VMState for the devices, to allow load/save? If not, they should at least be marked as unmigratable.

Quoted 1 line

+}

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#14 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

In reply to Andreas Färber

Am 24.01.2012 08:22, schrieb Andreas Färber:

Quoted 25 lines

Am 23.01.2012 08:20, schrieb Peter A. G. Crosthwaite:

Quoted 14 lines

Added linux specific kernel dtb option. This option can be specified to inject an argument device tree blob (dtb) into linux.

---
qemu-options.hx | 3 +++
vl.c | 4 ++++

2 files changed, 7 insertions(+), 0 deletions(-)
qemu-options.hx +0 -0
index 6295cde..43cddff 100644

qemu-options.hx ETEXI · line 1936

Quoted 6 lines
qemu-options.hx +2 -0
@@ -1931,6 +1931,9 @@ ETEXI
 
 DEF("kernel", HAS_ARG, QEMU_OPTION_kernel, \
 "-kernel bzImage use 'bzImage' as kernel image\n", QEMU_ARCH_ALL)
+DEF("kern-dtb", HAS_ARG, QEMU_OPTION_kerndtb, \
+ "-kern-dtb dtb device tree blob passed to kernel boot\n", 
 QEMU_ARCH_ALL)

We should probably call it -kernel-dtb. If there's some strncmp() from -kernel interfering, we should fix that instead.

Quoted 4 lines

I don't see this variable being used anywhere in this series though. Would it have been in the missing zynq machine of 7/7?

Andreas

I'd prefer a different solution. As far as I have understood, the dtb is only useful with a kernel, so it could be handled as an optional attribute to the -kernel parameter:

-kernel IMAGE[,dtb=DTB]

Of course the same applies to -append, but that's a different issue.

Regards,
Stefan

#15 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

Quoted 7 lines · Stefan Weil

I'd prefer a different solution. As far as I have understood, the dtb is only useful with a kernel, so it could be handled as an optional attribute to the -kernel parameter:

-kernel IMAGE[,dtb=DTB]

Of course the same applies to -append, but that's a different issue.

-initrd as well.

This would mean you couldn't have a comma in a filename (shouldn't come up often, but still ugly).

-Scott

#28 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

In reply to Peter A. G. Crosthwaite
Quoted 12 lines · Peter A. G. Crosthwaite
vl.c +1 -0
@@ -233,6 +233,7 @@ int boot_menu;
  uint8_t *boot_splash_filedata;
  int boot_splash_filedata_size;
  uint8_t qemu_extra_params_fw[2];
+const char *qemu_kerndtb = NULL;
 
  typedef struct FWBootEntry FWBootEntry;
 
@@ -2437,6 +2438,9 @@ int main(int argc, char **argv, char **envp)

            case QEMU_OPTION_kernel:

Quoted 8 lines

                kernel_filename = optarg;
                break;
+            case QEMU_OPTION_kerndtb:
+                qemu_kerndtb = optarg;
+                break;
            case QEMU_OPTION_append:
                kernel_cmdline = optarg;
                break;

This is inconsistent with how we handle kernel_filename and initrd_filename (throwing things around via random globals is a pretty nasty interface).

I think I like the approach Grant Likely suggested of cleaning up the machine->init function signature so we just pass it a struct instead.

Also missing the mollyguard on attempting to use -kernel-dtb but not -kernel (cf the check done for -append and -initrd).

-- PMM

#16 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

In reply to Scott Wood
Quoted 5 lines · Scott Wood
Quoted 4 lines · Stefan Weil

I'd prefer a different solution. As far as I have understood, the dtb is only useful with a kernel, so it could be handled as an optional attribute to the -kernel parameter:

Quoted 8 lines
Quoted 3 lines

-kernel IMAGE[,dtb=DTB]

Of course the same applies to -append, but that's a different issue.

-initrd as well.

This would mean you couldn't have a comma in a filename (shouldn't come up often, but still ugly).

In other instances where you use a comma to separate arguments and also want to accept commas in arbitrary file names, qemu has used the notion of a double comma as being the escape sequence for a single comma in the intended file name, rather than a separator for later arguments.

Signature · 2 lines
Eric Blake   [email protected]    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#17 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

Quoted 12 lines · Eric Blake
Quoted 11 lines · Scott Wood
Quoted 7 lines · Stefan Weil

I'd prefer a different solution. As far as I have understood, the dtb is only useful with a kernel, so it could be handled as an optional attribute to the -kernel parameter:

-kernel IMAGE[,dtb=DTB]

Of course the same applies to -append, but that's a different issue.

-initrd as well.

Quoted 7 lines
Quoted 2 lines

This would mean you couldn't have a comma in a filename (shouldn't come up often, but still ugly).

In other instances where you use a comma to separate arguments and also want to accept commas in arbitrary file names, qemu has used the notion of a double comma as being the escape sequence for a single comma in the intended file name, rather than a separator for later arguments.

Use QemuOpts for NAME=VALUE,... arguments. Common code, common syntactic conventions.

#18 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

Hi All,

So on the topic of these command line arguments for initrd, dtb and friends, another related issue we have encountered (and have hacked around in our tree) is not being able to relocate the initrd or kernel. Currently these memory locations are hardcoded in arm_boot.c:

#define KERNEL_ARGS_ADDR 0x100
#define KERNEL_LOAD_ADDR 0x00010000
#define INITRD_LOAD_ADDR 0x00d00000

If you see patch 6/7 in this same series I put in place a hack to override the initrd location in memory, but I wonder if instead this should go up to the command line interface as a parameter. Currently the machine model (or arm_boot.c) defines exactly where kernels/initrds/command-line-args line in memory, but since these are software properties should perhaps they go up to the command line as -kernel,foo=bar options? E.G:

qemu-system-arm -kernel,kernel-image=/foo/zImage,kernel-addr=0x00010000,initrd=/foo/initrd,initrd_addr=0x00d00000

It strikes me as broken that a machine model specifies where in memory a kernel has to live. Something similar would apply to the dtb argument, this patch introduces.

For the next revision of this patch series I am going to put in the mollyguard and just use -kernel-dtb foo for the moment.

So with the greater issue of linux specific command line arguments, what is the consensus here on how this is going to be handled with regards to:

-Passing all this command line stuff in a struct -nesting initrd and friends under the -kernel option.

And do either of these act as a blocker on this patch series?

Regards,
Peter

Quoted 25 lines · Markus Armbruster
Quoted 12 lines · Eric Blake
Quoted 11 lines · Scott Wood
Quoted 7 lines · Stefan Weil

I'd prefer a different solution. As far as I have understood, the dtb is only useful with a kernel, so it could be handled as an optional attribute to the -kernel parameter:

-kernel IMAGE[,dtb=DTB]

Of course the same applies to -append, but that's a different issue.

-initrd as well.

Quoted 7 lines
Quoted 2 lines

This would mean you couldn't have a comma in a filename (shouldn't come up often, but still ugly).

In other instances where you use a comma to separate arguments and also want to accept commas in arbitrary file names, qemu has used the notion of a double comma as being the escape sequence for a single comma in the intended file name, rather than a separator for later arguments.

Use QemuOpts for NAME=VALUE,... arguments. Common code, common syntactic conventions.

#19 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

Quoted 18 lines · Peter Crosthwaite

Hi All,

So on the topic of these command line arguments for initrd, dtb and friends, another related issue we have encountered (and have hacked around in our tree) is not being able to relocate the initrd or kernel. Currently these memory locations are hardcoded in arm_boot.c:

#define KERNEL_ARGS_ADDR 0x100
#define KERNEL_LOAD_ADDR 0x00010000
#define INITRD_LOAD_ADDR 0x00d00000

If you see patch 6/7 in this same series I put in place a hack to override the initrd location in memory, but I wonder if instead this should go up to the command line interface as a parameter. Currently the machine model (or arm_boot.c) defines exactly where kernels/initrds/command-line-args line in memory, but since these are software properties should perhaps they go up to the command line as -kernel,foo=bar options? E.G:

Quoted 2 lines

qemu-system-arm -kernel,kernel-image=/foo/zImage,kernel-addr=0x00010000,initrd=/foo/initrd,initrd_addr=0x00d00000

There's an opportunity here - QEMU needs the cmdline ability to load random binaries/elfs anyway, such as

--load file@address

e.g. --load image.bin@0xa4000000

-- load file.elf

(no address required)

This option or one like it would make it much easier and less hard-coded to assemble any sort of initial memory state.

Extending this, kernels, initrds and DTBs all can have machine-specific preferred addresses but can be overriden in the same way:

--kernel zImage@0x20000000 --initrd fs.img@0x40000000

and so on

The '@' symbol will need to be escaped by it's a pretty natural syntax.

John

Signature · 3 lines
John Williams, PhD, B. Eng, B. IT
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com  p: +61-7-30090663  f: +61-7-30090663
#20 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

Quoted 23 lines · John Williams
Quoted 18 lines · Peter Crosthwaite

Hi All,

So on the topic of these command line arguments for initrd, dtb and friends, another related issue we have encountered (and have hacked around in our tree) is not being able to relocate the initrd or kernel. Currently these memory locations are hardcoded in arm_boot.c:

#define KERNEL_ARGS_ADDR 0x100
#define KERNEL_LOAD_ADDR 0x00010000
#define INITRD_LOAD_ADDR 0x00d00000

If you see patch 6/7 in this same series I put in place a hack to override the initrd location in memory, but I wonder if instead this should go up to the command line interface as a parameter. Currently the machine model (or arm_boot.c) defines exactly where kernels/initrds/command-line-args line in memory, but since these are software properties should perhaps they go up to the command line as -kernel,foo=bar options? E.G:

Quoted 2 lines

qemu-system-arm -kernel,kernel-image=/foo/zImage,kernel-addr=0x00010000,initrd=/foo/initrd,initrd_addr=0x00d00000

Quoted 6 lines

There's an opportunity here - QEMU needs the cmdline ability to load random binaries/elfs anyway, such as

--load file@address

e.g. --load image.bin@0xa4000000

And while we're at it how about overriding arbitrary boot PC addresses as well?

--boot-addr 0xdeadbeef

It should be possible to boot random bootrom code in QEMU without hacking on the machine model.

qemu-system-arm -M foo --file bootrom.bin@0x000000 --boot-addr 0x00001000

We bumped into this recently - we need a cleaner way of telling QEMU if it's pretending to be just the machine with some minimal initial state as above(for running bootloaders, baremetal etc), or it's being the machine *plus* a bootloader (booting vmlinux/zimage).

Currently it's pretty hacky.

John

Quoted 23 lines

-- load file.elf

(no address required)

This option or one like it would make it much easier and less hard-coded to assemble any sort of initial memory state.

Extending this, kernels, initrds and DTBs all can have machine-specific preferred addresses but can be overriden in the same way:

--kernel zImage@0x20000000 --initrd fs.img@0x40000000

and so on

The '@' symbol will need to be escaped by it's a pretty natural syntax.

John
--
John Williams, PhD, B. Eng, B. IT
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com  p: +61-7-30090663  f: +61-7-30090663

Signature · 3 lines
John Williams, PhD, B. Eng, B. IT
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com  p: +61-7-30090663  f: +61-7-30090663
#27 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

In reply to Stefan Weil
Quoted 28 lines · Stefan Weil

Am 24.01.2012 08:22, schrieb Andreas Färber:

Quoted 27 lines

Am 23.01.2012 08:20, schrieb Peter A. G. Crosthwaite:

Quoted 14 lines

Added linux specific kernel dtb option. This option can be specified to inject an argument device tree blob (dtb) into linux.

---
qemu-options.hx | 3 +++
vl.c | 4 ++++

2 files changed, 7 insertions(+), 0 deletions(-)
qemu-options.hx +0 -0
index 6295cde..43cddff 100644

qemu-options.hx ETEXI · line 1935

Quoted 5 lines
qemu-options.hx +2 -0
@@ -1931,6 +1931,9 @@ ETEXI
 
 DEF("kernel", HAS_ARG, QEMU_OPTION_kernel, \
 "-kernel bzImage use 'bzImage' as kernel image\n", QEMU_ARCH_ALL)
+DEF("kern-dtb", HAS_ARG, QEMU_OPTION_kerndtb, \
+ "-kern-dtb dtb device tree blob passed to kernel boot\n", QEMU_ARCH_ALL)

We should probably call it -kernel-dtb. If there's some strncmp() from -kernel interfering, we should fix that instead.

I don't see this variable being used anywhere in this series though. Would it have been in the missing zynq machine of 7/7?

Quoted 7 lines
Quoted 1 line

Andreas

I'd prefer a different solution. As far as I have understood, the dtb is only useful with a kernel, so it could be handled as an optional attribute to the -kernel parameter:

-kernel IMAGE[,dtb=DTB]

If it looks like a device, acts like a device, and smells like a device...

The best thing to do here is to make an arm-kernel-loader device that hangs off of sysbus and takes four string properties.

I was going to do this shortly for PC anyway.

BTW, for unknown command line options, we should probably assume they are -device and treat accordingly. So -arm-kernel-loader dtb=DTB,kernel=/path/to/vmlinux would Just Work.

Regards,

Anthony Liguori

Quoted 7 lines

Of course the same applies to -append, but that's a different issue.

Regards,
Stefan

#21 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

In reply to John Williams
Quoted 20 lines · John Williams
Quoted 18 lines · Peter Crosthwaite

Hi All,

So on the topic of these command line arguments for initrd, dtb and friends, another related issue we have encountered (and have hacked around in our tree) is not being able to relocate the initrd or kernel. Currently these memory locations are hardcoded in arm_boot.c:

#define KERNEL_ARGS_ADDR 0x100
#define KERNEL_LOAD_ADDR 0x00010000
#define INITRD_LOAD_ADDR 0x00d00000

If you see patch 6/7 in this same series I put in place a hack to override the initrd location in memory, but I wonder if instead this should go up to the command line interface as a parameter. Currently the machine model (or arm_boot.c) defines exactly where kernels/initrds/command-line-args line in memory, but since these are software properties should perhaps they go up to the command line as -kernel,foo=bar options? E.G:

Quoted 7 lines
Quoted 2 lines

qemu-system-arm -kernel,kernel-image=/foo/zImage,kernel-addr=0x00010000,initrd=/foo/initrd,initrd_addr=0x00d00000

There's an opportunity here - QEMU needs the cmdline ability to load random binaries/elfs anyway, such as

--load file@address

Make an elf loader device if you desire this ability but I'm skeptical that it really is all that useful.

No special syntax though, we have a way to parameterize options as Markus rightly points out.

Regards,

Anthony Liguori

Quoted 21 lines

e.g. --load image.bin@0xa4000000

-- load file.elf

(no address required)

This option or one like it would make it much easier and less hard-coded to assemble any sort of initial memory state.

Extending this, kernels, initrds and DTBs all can have machine-specific preferred addresses but can be overriden in the same way:

--kernel zImage@0x20000000 --initrd fs.img@0x40000000

and so on

The '@' symbol will need to be escaped by it's a pretty natural syntax.

John

#22 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

Quoted 34 lines · Anthony Liguori
Quoted 33 lines · John Williams
Quoted 28 lines · Peter Crosthwaite

Hi All,

So on the topic of these command line arguments for initrd, dtb and friends,
another related issue we have encountered (and have hacked around in our tree) is not being able to relocate the initrd or kernel. Currently these memory locations are hardcoded in arm_boot.c:

#define KERNEL_ARGS_ADDR 0x100
#define KERNEL_LOAD_ADDR 0x00010000
#define INITRD_LOAD_ADDR 0x00d00000

If you see patch 6/7 in this same series I put in place a hack to override
the initrd location in memory, but I wonder if instead this should go up to
the command line interface as a parameter. Currently the machine model (or
arm_boot.c) defines exactly where kernels/initrds/command-line-args line in
memory, but since these are software properties should perhaps they go up to
the command line as -kernel,foo=bar options? E.G:

qemu-system-arm

-kernel,kernel-image=/foo/zImage,kernel-addr=0x00010000,initrd=/foo/initrd,initrd_addr=0x00d00000

Quoted 8 lines
Quoted 4 lines

There's an opportunity here - QEMU needs the cmdline ability to load random binaries/elfs anyway, such as

--load file@address

Make an elf loader device if you desire this ability but I'm skeptical that it really is all that useful.

It is useful for non-Linux use-cases, of which there are many!

Can you explain how you'd see such a 'loader device' in practice? How does it get bound into the machine model? How do we pass arguments to it?

Thanks,

John

Signature · 3 lines
John Williams, PhD, B. Eng, B. IT
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com  p: +61-7-30090663  f: +61-7-30090663
#23 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

Quoted 38 lines · John Williams
Quoted 37 lines · Anthony Liguori
Quoted 36 lines · John Williams
Quoted 25 lines · Peter Crosthwaite

Hi All,

So on the topic of these command line arguments for initrd, dtb and friends,
another related issue we have encountered (and have hacked around in our tree) is not being able to relocate the initrd or kernel. Currently these memory locations are hardcoded in arm_boot.c:

#define KERNEL_ARGS_ADDR 0x100
#define KERNEL_LOAD_ADDR 0x00010000
#define INITRD_LOAD_ADDR 0x00d00000

If you see patch 6/7 in this same series I put in place a hack to override
the initrd location in memory, but I wonder if instead this should go up to
the command line interface as a parameter. Currently the machine model (or
arm_boot.c) defines exactly where kernels/initrds/command-line-args line in
memory, but since these are software properties should perhaps they go up to
the command line as -kernel,foo=bar options? E.G:

Quoted 3 lines

qemu-system-arm

-kernel,kernel-image=/foo/zImage,kernel-addr=0x00010000,initrd=/foo/initrd,initrd_addr=0x00d00000

There's an opportunity here - QEMU needs the cmdline ability to load random binaries/elfs anyway, such as

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

--load file@address

Make an elf loader device if you desire this ability but I'm skeptical that it really is all that useful.

It is useful for non-Linux use-cases, of which there are many!

It's not just a matter of loading an elf binary in memory. You probably need to have a specific register state set in order to run non-Linux elf binaries which means you'll need binary specific logic.

If all of these binaries you want to run have a well known register state, they you can just use fw_cfg and a piece of firmware to read the binary (which is basically how -kernel works on target-i386).

Quoted 4 lines

Can you explain how you'd see such a 'loader device' in practice? How does it get bound into the machine model? How do we pass arguments to it?

You create a device via qdev (now QOM) that takes whatever properties you need.
You then do:

-device elf-loader,base=0xa00000,file=my-elf-binary

No different than adding a network card.

As I mentioned in the previous note, we probably should short cut unknown options as just assume they're meant for -device such that you could also do:

-elf-loader base=0xa00000,file=my-elf-binary

Regards,

Anthony Liguori

Quoted 4 lines

Thanks,

John

#24 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

Quoted 12 lines
Quoted 12 lines
Quoted 10 lines
Quoted 4 lines

There's an opportunity here - QEMU needs the cmdline ability to load random binaries/elfs anyway, such as

--load file@address

Make an elf loader device if you desire this ability but I'm skeptical that
it really is all that useful.

Quoted 6 lines
Quoted 1 line

It is useful for non-Linux use-cases, of which there are many!

It's not just a matter of loading an elf binary in memory.  You probably need to have a specific register state set in order to run non-Linux elf binaries which means you'll need binary specific logic.

The machine state at bootup is very well defined - it's whatever the TRM says!

An example may help. We are working on the Xilinx Zynq model, dual core Cortex A-9. We currently are able to use QEMU for the entire flow from

cold reset ->
bootrom ->
u-boot ->
Linux

In this flow, we don't want any magic initial state, we want QEMU to model the CPU just like the real hardware.

Equivalently, we might like to kick directly into the kernel, SMP==2 and so on.

It makes no sense to me that we should somehow use a different machine model just to model a different boot flow on the same hardware.

Another example, we are working on remoteproc/rpmsg support so that we can run Linux on one core, and firmware on another. We have this working in QEMU today, except we had to hack around the ARM boot code's assumptions that we always want the 2nd CPU to run an WFE/WIQ loop. This is only true if you are running Linux *and* you want QEMU to fake the actions of a bootloader.

If you are modelling a cold start you want those two CPUs to race until one of them reads the CPUID register puts itself to sleep, ie just run the bootrom.

All of these use cases are not about virtualisation, but about system modeling and emulation, which really is where QEMU is valuable in the embedded space.

Quoted 11 lines

If all of these binaries you want to run have a well known register state, they you can just use fw_cfg and a piece of firmware to read the binary (which is basically how -kernel works on target-i386).

Quoted 4 lines

Can you explain how you'd see such a 'loader device' in practice?  How does it get bound into the machine model?  How do we pass arguments to it?

Quoted 6 lines

You create a device via qdev (now QOM) that takes whatever properties you need.  You then do:

-device elf-loader,base=0xa00000,file=my-elf-binary

No different than adding a network card.

A network card is a tangible object, it can be present in the system. The ELF loader is just emulator cruft, a necessary evil to get the initial state of the machine. Should it really be on a level footing with actual devices?

Rgds,

John

Signature · 3 lines
John Williams, PhD, B. Eng, B. IT
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com  p: +61-7-30090663  f: +61-7-30090663
#25 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

Quoted 13 lines · John Williams
Quoted 13 lines
Quoted 13 lines
Quoted 11 lines
Quoted 5 lines

There's an opportunity here - QEMU needs the cmdline ability to load random binaries/elfs anyway, such as

--load file@address

Make an elf loader device if you desire this ability but I'm skeptical that
it really is all that useful.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

It is useful for non-Linux use-cases, of which there are many!

It's not just a matter of loading an elf binary in memory. You probably need to have a specific register state set in order to run non-Linux elf binaries which means you'll need binary specific logic.

The machine state at bootup is very well defined - it's whatever the TRM

says!

Quoted 10 lines

An example may help. We are working on the Xilinx Zynq model, dual core Cortex A-9. We currently are able to use QEMU for the entire flow from

cold reset ->
bootrom ->
u-boot ->
Linux

Quoted 4 lines

In this flow, we don't want any magic initial state, we want QEMU to model the CPU just like the real hardware.

Equivalently, we might like to kick directly into the kernel, SMP==2 and

so on.

Quoted 11 lines

It makes no sense to me that we should somehow use a different machine model just to model a different boot flow on the same hardware.

Another example, we are working on remoteproc/rpmsg support so that we can run Linux on one core, and firmware on another. We have this working in QEMU today, except we had to hack around the ARM boot code's assumptions that we always want the 2nd CPU to run an WFE/WIQ loop. This is only true if you are running Linux *and* you want QEMU to fake the actions of a bootloader.

Quoted 7 lines

If you are modelling a cold start you want those two CPUs to race until one of them reads the CPUID register puts itself to sleep, ie just run the bootrom.

All of these use cases are not about virtualisation, but about system modeling and emulation, which really is where QEMU is valuable in the embedded space.

I don't see how any of this is relevant. Presumably, on real hardware, you have a rom bank wired to a specific physical address with ip fixed to an address which happens to be in that space?

Why not just use an emulated flash chip?

Quoted 2 lines
Quoted 2 lines

If all of these binaries you want to run have a well known register

state,

Quoted 11 lines
Quoted 11 lines

they you can just use fw_cfg and a piece of firmware to read the binary (which is basically how -kernel works on target-i386).

Quoted 4 lines

Can you explain how you'd see such a 'loader device' in practice? How does it get bound into the machine model? How do we pass arguments to it?

You create a device via qdev (now QOM) that takes whatever properties

you

Quoted 10 lines
Quoted 5 lines

need. You then do:

-device elf-loader,base=0xa00000,file=my-elf-binary

No different than adding a network card.

A network card is a tangible object, it can be present in the system. The ELF loader is just emulator cruft, a necessary evil to get the initial state of the machine. Should it really be on a level footing with actual devices?

All systems have to bootstrap software some how. Some device is reasonable for this. This isn't emulated magic :-)

Regards,

Anthony Liguori

Quoted 8 lines

Rgds,

John
--
John Williams, PhD, B. Eng, B. IT
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com p: +61-7-30090663 f: +61-7-30090663

#26 lore raw

Re: [Qemu-devel] [RFC PATCH 5/7] vl.c: added -kerndtb option

Quoted 55 lines · Anthony Liguori
Quoted 52 lines · John Williams
Quoted 13 lines
Quoted 13 lines
Quoted 11 lines
Quoted 5 lines

There's an opportunity here - QEMU needs the cmdline ability to load random binaries/elfs anyway, such as

--load file@address

Make an elf loader device if you desire this ability but I'm skeptical that
it really is all that useful.

Quoted 6 lines
Quoted 1 line

It is useful for non-Linux use-cases, of which there are many!

It's not just a matter of loading an elf binary in memory.  You probably need to have a specific register state set in order to run non-Linux elf binaries which means you'll need binary specific logic.

The machine state at bootup is very well defined - it's whatever the TRM says!

An example may help.  We are working on the Xilinx Zynq model, dual core Cortex A-9.  We currently are able to use QEMU for the entire flow from

cold reset ->
bootrom ->
u-boot ->
Linux

In this flow, we don't want any magic initial state, we want QEMU to model the CPU just like the real hardware.

Equivalently, we might like to kick directly into the kernel, SMP==2 and so on.

It makes no sense to me that we should somehow use a different machine model just to model a different boot flow on the same hardware.

Another example, we are working on remoteproc/rpmsg support so that we can run Linux on one core, and firmware on another.  We have this working in QEMU today, except we had to hack around the ARM boot code's assumptions that we always want the 2nd CPU to run an WFE/WIQ loop.  This is only true if you are running Linux *and* you want QEMU to fake the actions of a bootloader.

If you are modelling a cold start you want those two CPUs to race until one of them reads the CPUID register puts itself to sleep, ie just run the bootrom.

Quoted 7 lines
Quoted 3 lines

All of these use cases are not about virtualisation, but about system modeling and emulation, which really is where QEMU is valuable in the embedded space.

I don't see how any of this is relevant.  Presumably, on real hardware, you have a rom bank wired to a specific physical address with ip fixed to an address which happens to be in that space?

Certainly a ROM makes sense to model as a device - there is a physical equivalent. I'm just not so sure about a virtual device whos job is to bus master stuffing contents into some other memory. For example, with such an 'ELF loader' device - when ecaxtly should it do the load?
Do you end up with a race at system init time?

Quoted 1 line

Why not just use an emulated flash chip?

If there is a bus addressable memory with fixed contents then that can be modelled with a device. I'm talking about an intermediate mode where we would like to be able to prepopulate memory with arbitrary contents. Half way between 'model a ROM device with the bootrom', and the hacky 'QEMU is also sometimes a Linux bootloader' approach taken for booting VMLinux images.

Quoted 20 lines
Quoted 20 lines
Quoted 19 lines

If all of these binaries you want to run have a well known register state,
they you can just use fw_cfg and a piece of firmware to read the binary (which is basically how -kernel works on target-i386).

Quoted 4 lines

Can you explain how you'd see such a 'loader device' in practice?  How does it get bound into the machine model?  How do we pass arguments to it?

You create a device via qdev (now QOM) that takes whatever properties you
need.  You then do:

-device elf-loader,base=0xa00000,file=my-elf-binary

No different than adding a network card.

Quoted 7 lines
Quoted 4 lines

A network card is a tangible object, it can be present in the system. The ELF loader is just emulator cruft, a necessary evil to get the initial state of the machine.  Should it really be on a level footing with actual devices?

All systems have to bootstrap software some how.  Some device is reasonable for this.  This isn't emulated magic :-)

Sure. I just have some questions about the behavioural semantics of an ELF/binary loader device, vs recognising this loading function as a role for a 'deus ex machina'

John

Signature · 3 lines
John Williams, PhD, B. Eng, B. IT
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com  p: +61-7-30090663  f: +61-7-30090663