QEMU patches to generate device tree data
cover QEMU patches to generate device tree data
Hi Jeremy,
Here are a couple of patches to your QEMU tree that add basic support for creating device nodes at run time based on the data in the qemu device model. I'm still refining these, and the irq handling is a bit of a hack, but I wanted to get these out to you so that you could take a look and provide some initial feedback.
Cheers,
g.
---
Grant Likely (2):
arm-dt: auto-populate the device tree with qdev data
devicetree: Add 8k instead of double dtb size when reserving extra memory
device_tree.c | 4 +- hw/arm_boot.c | 3 + hw/qdev.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/qdev.h | 9 ++++ hw/sysbus.c | 84 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 225 insertions(+), 2 deletions(-)
Signature · 1 line
Signature
PATCH 1/2 qemu: devicetree: Add 8k instead of double dtb size when reserving extra memory
If a small 'seed' dtb file is loaded into qemu and then heavily modified (say for runtime population of all the device nodes), then 2x the dtb size turns out not to be very much.
This patch changes the device tree loading code to add a fixed 8k of additional space to the dtb buffer.
---
device_tree.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
device_tree.c +2 -2
@@ -41,8 +41,8 @@ void *load_device_tree(const char *filename_path, int *sizep) goto fail; } -/* Expand to 2x size to give enough room for manipulation. */ - dt_size *=2 ; +/* Expand size to give enough room for manipulation. */ + dt_size +=8 *1024 ;/* First allocate space in qemu for device tree */ fdt =qemu_mallocz (dt_size);
PATCH 2/2 qemu: arm-dt: auto-populate the device tree with qdev data
In reply to Grant LikelyThis patch adds hooks to the qemu device model to auto-generate device tree nodes from the registered qemu devices.
---
hw/arm_boot.c | 3 + hw/qdev.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/qdev.h | 9 ++++ hw/sysbus.c | 84 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 223 insertions(+), 0 deletions(-)
hw/arm_boot.c +3 -0
@@ -13,6 +13,7 @@#include "sysemu.h" #include "loader.h" #include "elf.h" +#include "qdev.h" #ifdef CONFIG_FDT #include "device_tree.h"
@@ -211,6 +212,8 @@ static int load_dtb(target_phys_addr_t addr, struct arm_boot_info *binfo) }qemu_free (filename); +qdev_fdt_populate (fdt); + rc =qemu_devtree_setprop (fdt,"/memory" ,"reg" , mem_reg_property,sizeof (mem_reg_property));if (rc <0 )
hw/qdev.c +127 -0
130 lines not on this page · raw message
hw/qdev.h +9 -0
@@ -43,10 +43,14 @@ struct DeviceState { };typedef void (*bus_dev_printfn )(Monitor *mon,DeviceState *dev,int indent); +typedef int (*fdt_populate_busfn )(void *fdt,BusState *bus,int offset); +typedef int (*fdt_populate_devicefn )(void *fdt,DeviceState *dev,int offset);struct BusInfo {const char *name;size_t size;bus_dev_printfn print_dev; +fdt_populate_devicefn fdt_populate_node; +fdt_populate_busfn fdt_populate_bus;Property *props; };
@@ -272,4 +276,9 @@ void qdev_prop_set_compat(DeviceState *dev);/* This is a nasty hack to allow passing a NULL bus to qdev_create. */ extern struct BusInfo system_bus_info; +#ifdef CONFIG_FDT +int qbus_fdt_irq_to_number (qemu_irq irq,uint32_t *phandle); +int qdev_fdt_populate (void *fdt); +#endif +#endif
hw/sysbus.c +84 -0
98 lines not on this page · raw message