Hello This is a general RFC for a framework developed at Petalogix for creating QEMU models based on a passed device tree. Machine models are dynamically constructed from parsing a Device Tree Specification (DTS) - no more hard-coded machine models, which is critical for the FPGA-based platforms (i.e. target-microblaze) but also will be very useful for forthcoming DTS-driven ARM kernels as well. Device models (including QDev models) are tagged as being associated with a "compatible" string. If a node with the registered compatible string is found when the argument dts is parsed, then the QDev model is instantiated.
For example, An ethernet controller might have a device tree node: Ethernet_MAC: ethernet@81000000 { compatible = "xlnx,xps-ethernetlite-4.00.a", "xlnx,xps-ethernetlite-1.00.a"; device_type = "network"; interrupt-parent = <&xps_intc_0>; interrupts = < 1 0 >; local-mac-address = [ 00 0a 35 00 22 01 ]; reg = < 0x81000000 0x10000 >; ... } ; Our framework registers the compatibility "xlnx,xps-ethernetlite-1.00.a" as being associated with the xilinx.ethlite qdev model (hw/xilinx_ethlite.c), and each time this compatiblity is discovered in the device tree, the qdev model is instantiated (see path 10/14 for code details on this particular example).The reg property is used to set the device base address and the interrupt properties are used to connect interrupts. Device tree (more info @ devicetree.org) provides a standarised way of specifiying such connecitons, and we use all this to create machine models. Compatibilities are registered statically from within device models as such: fdt_qdev_register_compatibility(&xilinx_ethlite_fdt_qdev_ops, "xlnx,xps-ethernetlite-1.00.a"); Where the first argument is a struct containing constant and handlers provided by the deivce model to handle device instantiation. Device instantiation is performed by the framework (not the Qdev models themselves) We have also set up a mechanism for machine models to communicate with each other by means other than bus transactions. DTS provides a means to specify arbitrary interconnections between devices, and we use this to instantiate connections such as hierarchical interrupt controllers and point to point DMA interconnections. This provides a consistent and clean way of specifying inter-device connectivity other than via the system bus. The platform is tested for Xilinx Microblaze and PPC platforms, and we have been using it both interally at PetaLogix and publishing to customers for approx. 6 months now. We have setup FDT instantiation code for all of the xilinx microbalze/PPC supported periphperals. We are currently developing support for an ARM platform. The framework itself is however independent of architecture so this could be used for creating machine models for any machine. This patch series is a minimal patch series containing support for only microblaze and a handful of peripherals. Support for a more complete range of device models and other cpu architectures will come in future patches. We would welcome any comments or questions about the approach so that we can get it merged upstream. Regards, Peter Edgar E. Iglesias (2): microblaze: Make the MSR PVR bit non writable microblaze: Add an MSR_PVR constant and use it. Peter A. G. Crosthwaite (12): qemu-coroutine: Add simple work queue support device_tree: Extended interface for fdt_generic fdt_generic: First revision xilinx_uartlite: Added fdt gen. platform support pflash_cfi01: Added fdt generic platform support qdev: Added fn for querying device property types fdt_generic_qdev: first revision xilinx_timer: Added fdt_generic platform support xilinx_intc: Added fdt generic platform support xilinx_ethlite: Added fdt generic platform support vl.c: Added hw_dtb/kern_dtb command line opts microblaze_generic_fdt: first revision Makefile.objs | 4 + Makefile.target | 1 + device_tree.c | 202 +++++++++++++++++++ device_tree.h | 30 +++ hw/fdt_generic.c | 199 +++++++++++++++++++ hw/fdt_generic.h | 92 +++++++++ hw/fdt_generic_devices.h | 8 + hw/fdt_generic_qdev.c | 75 +++++++ hw/fdt_generic_qdev.h | 46 +++++ hw/fdt_generic_util.c | 196 ++++++++++++++++++ hw/fdt_generic_util.h | 43 ++++ hw/microblaze_generic_fdt.c | 439 +++++++++++++++++++++++++++++++++++++++++ hw/pflash_cfi01.c | 37 ++++ hw/qdev-properties.c | 9 + hw/qdev.h | 1 + hw/xilinx_ethlite.c | 39 ++++- hw/xilinx_intc.c | 35 ++++- hw/xilinx_timer.c | 39 ++++- hw/xilinx_uartlite.c | 24 +++ qemu-coroutine-lock.c | 13 ++ qemu-coroutine.h | 9 + qemu-options.hx | 47 +++++ sysemu.h | 4 + target-microblaze/cpu.h | 1 + target-microblaze/translate.c | 11 +- vl.c | 19 ++ 26 files changed, 1617 insertions(+), 6 deletions(-) create mode 100644 hw/fdt_generic.c create mode 100644 hw/fdt_generic.h create mode 100644 hw/fdt_generic_devices.h create mode 100644 hw/fdt_generic_qdev.c create mode 100644 hw/fdt_generic_qdev.h create mode 100644 hw/fdt_generic_util.c create mode 100644 hw/fdt_generic_util.h create mode 100644 hw/microblaze_generic_fdt.c -- 1.7.3.2