qemuboot-xen-dtb.bbclass 6.86 KiB
# Enable booting Xen with qemuboot / runqemu: generate device tree
# Copyright (c) 2021 Star Lab Corp. All rights reserved.
# Author: Christopher Clark <christopher.clark@starlab.io>
# Interface variables:
# QB_DTB : defined in qemuboot.bbclass.
# If set, this class will generate the specified device tree file.
# QB_XEN_CMDLINE_EXTRA :
# A string to be appended to the default Xen hypervisor boot command line,
# for supplying Xen boot options.
# The device tree that this bbclass generates will contain Xen command
# line options to connect the Xen console to the Qemu serial port.
# QB_XEN_DOMAIN_MODULES :
# A space-separated list of colon-separated entries:
#   "<file for the module>:<load memory address>:<module compatibility string>"
# QB_XEN_DOM0_BOOTARGS :
# A string for specifying Dom0 boot options for the Xen section of the device
# tree.
# QB_XEN_DTB_TASK_DEPENDS :
# The task dependencies for the DTB generation. A default is provided.
# See also: Other QB_ variables as defined by the qemuboot.bbclass.
write_lops_xen_section() {
    cat <<EOF >"$1"
/dts-v1/;
/ {
    compatible = "system-device-tree-v1";
    lops {
        /* Connect the Xen console to Qemu dtuart */
        lop_1 {
            compatible = "system-device-tree-v1,lop,code-v1";
            code = "
                chosen = node.tree['/chosen']
                stdout_path = str(chosen['stdout-path'].value[0])
                chosen['xen,xen-bootargs'] = \
                        'console=dtuart dtuart=%s' % stdout_path
                return True
        lop_2 {
            compatible = "system-device-tree-v1,lop,modify";
            modify = "/chosen:xen,dom0-bootargs:${QB_XEN_DOM0_BOOTARGS}";
        lop_3 {
            compatible = "system-device-tree-v1,lop,modify";
            modify = "/chosen:#address-cells:<1>";
        lop_4 {
            compatible = "system-device-tree-v1,lop,modify";
            modify = "/chosen:#size-cells:<1>";
EOF
write_lop_add_to_xen_cmdline() {
    EXTRA_XEN_BOOTARGS="$2"
    cat <<EOF >"$1"
/dts-v1/;
/ {
    compatible = "system-device-tree-v1";