Skip to contentSkip to conversation

Add mach-virt platform

PATCH Superseded John Rigby 1 participant 3 messages Apr 30, 2013

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

John Rigby

author
#0 lore raw

cover Add mach-virt platform

First modify arm fdt handling so boards can provide a blob rather than requiring one on command line.

Next add mach-virt platform that creates fdt blob from scratch describing its minimal hw which is a pl011 uart and a sp804 timer.

Tested on amd64 host with full system emulation and also using kvm on an arndale board

John Rigby (2):
ARM: Allow boards to provide an fdt blob
ARM: Add mach-virt platform

 hw/arm/Makefile.objs |    2 +-
 hw/arm/boot.c        |   31 +++--
 hw/arm/mach-virt.c   |  339 ++++++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/arm/arm.h |    6 +
 4 files changed, 366 insertions(+), 12 deletions(-)
 create mode 100644 hw/arm/mach-virt.c
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/2 ARM: Allow boards to provide an fdt blob

If no fdt is provided on command line and the new field get_dtb in struct arm_boot_info is set then call it to get a device tree blob.

Also allow dumping of device tree by calling qemu_devtree_dumpdtb near the end of load_dtb.

---
 hw/arm/boot.c        |   31 ++++++++++++++++++++-----------
 include/hw/arm/arm.h |    6 ++++++
 2 files changed, 26 insertions(+), 11 deletions(-)
hw/arm/boot.c +20 -11
index f451529..de71edf 100644
@@ -235,19 +235,27 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo)
     int size, rc;
     uint32_t acells, scells, hival;
 
-    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename);
-    if (!filename) {
-        fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename);
-        return -1;
-    }
+    if (binfo->dtb_filename) {
+        filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename);
+        if (!filename) {
+            fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename);
+            return -1;
+        }
 
-    fdt = load_device_tree(filename, &size);
-    if (!fdt) {
-        fprintf(stderr, "Couldn't open dtb file %s\n", filename);
+        fdt = load_device_tree(filename, &size);
+        if (!fdt) {
+            fprintf(stderr, "Couldn't open dtb file %s\n", filename);
+            g_free(filename);
+            return -1;
+        }
         g_free(filename);
-        return -1;
+    } else if (binfo->get_dtb) {
+        fdt = binfo->get_dtb(addr, binfo, &size);
+        if (!fdt) {
+            fprintf(stderr, "Couldn't get dtb blob from board func\n");
+            return -1;
+        }
     }
-    g_free(filename);
 
     acells = qemu_devtree_getprop_cell(fdt, "/", "#address-cells");
     scells = qemu_devtree_getprop_cell(fdt, "/", "#size-cells");
@@ -304,6 +312,7 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo)
             fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n");
         }
     }
+    qemu_devtree_dumpdtb(fdt, size);
 
     cpu_physical_memory_write(addr, fdt, size);
 
@@ -440,7 +449,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
         /* for device tree boot, we pass the DTB directly in r2. Otherwise
          * we point to the kernel args.
          */
-        if (info->dtb_filename) {
+        if (info->dtb_filename || info->get_dtb) {
             /* Place the DTB after the initrd in memory. Note that some
              * kernels will trash anything in the 4K page the initrd
              * ends in, so make sure the DTB isn't caught up in that.
include/hw/arm/arm.h +6 -0
index 7b2b02d..4c56a1b 100644
@@ -31,6 +31,10 @@ struct arm_boot_info {
     const char *kernel_cmdline;
     const char *initrd_filename;
     const char *dtb_filename;
+    /* if a board is able to create a dtb without a dtb file then it
+     * sets get_dtb.  This will only be used if no dtb file is provided.
+     */
+    void *(*get_dtb)(hwaddr addr, const struct arm_boot_info *binfo, int *size);
     hwaddr loader_start;
     /* multicore boards that use the default secondary core boot functions
      * need to put the address of the secondary boot code, the boot reg,
@@ -59,6 +63,8 @@ struct arm_boot_info {
     int is_linux;
     hwaddr initrd_start;
     hwaddr initrd_size;
+    void *dtb_blob;
+    int dtb_blob_size;
     hwaddr entry;
 };
 void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info);
Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH 2/2 ARM: Add mach-virt platform

In reply to John Rigby

Add mach-virt platform support cooresponding to /arch/arm/mach-virt in kernel tree.

For now it is not virtual but instantiates a pl011 uart and and sp804 timer. The uart is need for a console the timer is needed when running without kvm and there is no arch timer.

---
 hw/arm/Makefile.objs |    2 +-
 hw/arm/mach-virt.c   |  339 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 340 insertions(+), 1 deletion(-)
 create mode 100644 hw/arm/mach-virt.c
hw/arm/Makefile.objs +1 -1
index 9e3a06f..0789352 100644
@@ -1,5 +1,5 @@
 obj-y += boot.o collie.o exynos4_boards.o gumstix.o highbank.o
-obj-y += integratorcp.o kzm.o mainstone.o musicpal.o nseries.o
+obj-y += integratorcp.o kzm.o mach-virt.o mainstone.o musicpal.o nseries.o
 obj-y += omap_sx1.o palm.o pic_cpu.o realview.o spitz.o stellaris.o
 obj-y += tosa.o versatilepb.o vexpress.o xilinx_zynq.o z2.o
 
hw/arm/mach-virt.c new file +339 -0

339 lines not on this page · raw message

Signature · 1 line
1.7.9.5