summaryrefslogtreecommitdiffstats
path: root/conf/machine/include/machine-xilinx-qemu.inc
blob: 2701df20d9a00b046bd7dff808845ad2c3924d9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
EXTRA_IMAGEDEPENDS += "qemu-native qemu-helper-native"

def qemu_default_dtb(d):
    if d.getVar("IMAGE_BOOT_FILES", True):
        dtbs = d.getVar("IMAGE_BOOT_FILES", True).split(" ")
        # IMAGE_BOOT_FILES has extra renaming info in the format '<source>;<target>'
        dtbs = [f.split(";")[0] for f in dtbs]
        dtbs = [f for f in dtbs if f.endswith(".dtb")]
        if len(dtbs) != 0:
            return dtbs[0]
    if d.getVar("KERNEL_DEVICETREE", True):
        dtbs = d.getVar("KERNEL_DEVICETREE", True).split(" ")
        dtbs = [os.path.basename(d) for d in dtbs]
        if len(dtbs) != 0:
            return d.getVar("KERNEL_IMAGETYPE", True) + "-" + dtbs[0]
    return ""

def qemu_default_serial(d):
    if d.getVar("SERIAL_CONSOLE", True):
        speed, console = d.getVar("SERIAL_CONSOLE", True).split(" ", 1)
        # zynqmp uses earlycon and stdout (in dtb)
        if "zynqmp" in d.getVar("MACHINEOVERRIDES", True).split(":"):
            return ""
        return "console=%s,%s earlyprintk" % (console, speed)
    return ""

def qemu_target_binary(d):
    ta = d.getVar("TARGET_ARCH", True)
    if ta == "microblazeeb":
        ta = "microblaze"
    elif ta == "arm":
        ta = "aarch64"
    if qemuboot_xilinx_enabled(d):
        return "qemu-xilinx/qemu-system-%s" % ta
    return "qemu-system-%s" % ta

def qemuboot_xilinx_enabled(d):
    if bb.utils.contains("MACHINE_FEATURES", "qemu-system-xilinx", True, False, d):
        if d.getVar("XILINX_QEMUBOOT", True) == "1":
            return True
    return False

# For runqemu, default setup across all machines in meta-xilinx
IMAGE_CLASSES += "qemuboot"
QB_SYSTEM_NAME ?= "${@qemu_target_binary(d)}"
QB_DEFAULT_FSTYPE ?= "cpio"

XILINX_QEMUBOOT[doc] = "Set this variable to '1' to enable the generation of qemuboot.conf which uses the Xilinx QEMU."
XILINX_QEMUBOOT ??= ""

# Dependencies for native Xilinx QEMU
XILINX_QEMU_DEPENDS ?= "qemu-xilinx-native"
# If the machine supports the Xilinx QEMU, add the dependencies
EXTRA_IMAGEDEPENDS += "${@bb.utils.contains('MACHINE_FEATURES', 'qemu-system-xilinx', '${XILINX_QEMU_DEPENDS}', '', d)}"

# Add an override for when booting with the Xilinx QEMU
MACHINEOVERRIDES .= "${@':qemuboot-xilinx' if qemuboot_xilinx_enabled(d) else ''}"

# This is ignored if using Xilinx's QEMU fork
QB_DTB ?= "${@qemu_default_dtb(d)}"

# ZynqMP machines need special "-hw-dtb" device trees for the Xilinx QEMU
XILINX_QEMU_DEPENDS_append_zynqmp = " qemu-devicetrees"

QB_DEFAULT_KERNEL_qemuboot-xilinx = "none"
QB_KERNEL_CMDLINE_APPEND ?= "${@qemu_default_serial(d)}"

# Default machine targets for Xilinx QEMU (FDT Generic)
QB_MACHINE_qemuboot-xilinx_aarch64 = "-machine arm-generic-fdt"
QB_MACHINE_qemuboot-xilinx_arm = "-machine arm-generic-fdt-plnx"
QB_MACHINE_qemuboot-xilinx_microblaze = "-machine microblaze-generic-fdt"