Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xen support #33

Open
wants to merge 4 commits into
base: scarthgap
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions recipes-bsp/u-boot-xen-scr/files/boot.xen.its
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/dts-v1/;
/ {
description = "Configuration to load Xen/Linux";
#address-cells = <1>;
images {
default = "boot_scr";
boot_scr {
description = "default xen boot script";
data = /incbin/("boot.xen.source");
type = "script";
compression = "none";
load = <0x82000000>;
entry = <0x82000000>;
hash {
algo = "md5";
};
};
};
};
155 changes: 155 additions & 0 deletions recipes-bsp/u-boot-xen-scr/files/boot.xen.source.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
xen_name=@@XEN_IMAGE_NAME@@
kernel_name=@@XEN_KERNEL_IMAGE_NAME@@
ramdisk_name=@@XEN_RAMDISK_NAME@@

xen_addr=@@XEN_ADDRESS@@
kernel_addr=@@XEN_KERNEL_ADDRESS@@
ramdisk_addr=@@XEN_RAMDISK_ADDRESS@@

dom0less=@@XEN_BOOT_DOM0LESS@@

setenv fdtaddr @@XEN_FDT_ADDRESS@@

for boot_target in ${boot_targets};
do
# only support searching mmc for now and break if kernel is scanned
if test -z "${kernel_size}" && test "${boot_target}" = "mmc0" || test "${boot_target}" = "mmc1"; then
setenv devtype mmc
setenv bootdir /boot
setenv dtbdir ${bootdir}/dtb

if test "${boot_target}" = "mmc0"; then
setenv devnum 0
elif test "${boot_target}" = "mmc1"; then
setenv devnum 1
fi

setenv loadboot ${devtype} ${devnum}:1
setenv loadroot ${devtype} ${devnum}:2

# check xen image in boot partition then root partition
if test -e ${loadboot} ${xen_name}; then
echo "Loading ${xen_name}";
fatload ${loadboot} ${xen_addr} ${xen_name};
elif test -e ${loadroot} ${bootdir}/${xen_name}; then
echo "Loading ${xen_name}";
load ${loadroot} ${xen_addr} ${bootdir}/${xen_name};
fi

# check kernel image in boot partition then root partition
if test -e ${loadboot} ${kernel_name}; then
echo "Loading ${kernel_name}";
fatload ${loadboot} ${kernel_addr} ${kernel_name};
setenv kernel_size 0x$filesize;
elif test -e ${loadroot} ${bootdir}/$kernel_name}; then
echo "Loading ${kernel_name}";
load ${loadroot} ${kernel_addr} ${bootdir}/${kernel_name};
setenv kernel_size 0x$filesize;
fi

# load fdt from root partition
if test -e ${loadroot} ${dtbdir}/${fdtfile}; then
echo "Loading ${dtbdir}/${fdtfile}";
load ${loadroot} ${fdtaddr} ${dtbdir}/${fdtfile};
part uuid ${loadroot} rootfs_partuuid
fi

# load ramdisk for DomU from root partition
if test -n "${dom0less}" && test -e ${loadroot} ${bootdir}/${ramdisk_name}; then
echo "Loading ${bootdir}/${ramdisk_name}";
load ${loadroot} ${ramdisk_addr} ${bootdir}/${ramdisk_name};
setenv ramdisk_size 0x$filesize;
fi
fi
done

if test -z "${kernel_size}"; then
echo "No kernel image found"
exit
fi

fdt addr ${fdtaddr}
fdt resize 1024

# fdt operations
fdt set /chosen \#address-cells <0x2>
fdt set /chosen \#size-cells <0x2>
setenv xen_bootargs "console=dtuart dtuart=@@XEN_DTUART_SERIAL@@ dom0_mem=@@DOM0_MEM@@ dom0_max_vcpus=@@DOM0_MAX_VCPUS@@"
fdt set /chosen xen,xen-bootargs \"${xen_bootargs}\"

# dom0
fdt mknod /chosen dom0
fdt set /chosen/dom0 compatible "xen,linux-zimage" "xen,multiboot-module" "multiboot,module"
fdt set /chosen/dom0 reg <0x0 ${kernel_addr} 0x0 ${kernel_size}>
setenv dom0_bootargs "console=hvc0 earlyprintk=xen root=PARTUUID=${rootfs_partuuid} rw rootfstype=ext4 rootwait clk_ignore_unused"

# domU
echo outside
if test -n "${dom0less}" && test -n "${ramdisk_size}"; then
setexpr kernel_addr_u ${kernel_addr} + 0x03000000
setenv kernel_addr_u "0x${kernel_addr_u}"
cp.b ${kernel_addr} ${kernel_addr_u} ${kernel_size}
fdt mknod /chosen domU
fdt set /chosen/domU compatible "xen,domain"
fdt set /chosen/domU xen,enhanced "enabled"
fdt set /chosen/domU \#address-cells <0x2>
fdt set /chosen/domU \#size-cells <0x2>
fdt set /chosen/domU memory <0 1048576>
fdt set /chosen/domU cpus <4>
fdt set /chosen/domU vpl011
fdt mknod /chosen/domU module${kernel_addr_u}
fdt set /chosen/domU/module${kernel_addr_u} compatible "multiboot,kernel" "multiboot,module"
fdt set /chosen/domU/module${kernel_addr_u} reg <0x0 ${kernel_addr_u} 0x0 ${kernel_size} >
fdt set /chosen/domU/module${kernel_addr_u} bootargs "console=ttyAMA0"
fdt mknod /chosen/domU module${ramdisk_addr}
fdt set /chosen/domU/module${ramdisk_addr} compatible "multiboot,ramdisk" "multiboot,module"
fdt set /chosen/domU/module${ramdisk_addr} reg <0x0 ${ramdisk_addr} 0x0 ${ramdisk_size} >
fi

# shared memory
if test -n "@@XEN_SHMEM_START@@"; then
shmem_start=@@XEN_SHMEM_START@@
shmem_size=@@XEN_SHMEM_SIZE@@
shmem_node=xen_shmem@@@XEN_SHMEM_START@@
uio_node=xen_uio@@@XEN_SHMEM_START@@

# mark it as shared
fdt mknod /reserved-memory ${shmem_node}
fdt set /reserved-memory/${shmem_node} compatible "xen,shared-memory-v1"
fdt set /reserved-memory/${shmem_node} reg <0x00 ${shmem_start} 0x00 ${shmem_size}>

# expose as UIO to Dom0
fdt mknod / ${uio_node}
fdt set /${uio_node} compatible @@XEN_SHMEM_UIO_NAME@@
fdt set /${uio_node} reg <0x00 ${shmem_start} 0x00 ${shmem_size}>

# append uio to bootargs
setenv dom0_bootargs "${dom0_bootargs} uio_pdrv_genirq.of_id=@@XEN_SHMEM_UIO_NAME@@"
fi

fdt set /chosen xen,dom0-bootargs \"${dom0_bootargs}\"

fdt print /chosen

# Specify interrupts explicitly for the following instead of relying on ti,interrupt-ranges
for dev_path in @@XEN_IRQ_DEVICES@@; do
fdt get value irq_cur ${dev_path} ti,interrupt-ranges 0
fdt get value irq_num ${dev_path} ti,interrupt-ranges 2

setexpr irq_cur ${irq_cur} + 0x20
setexpr irq_end ${irq_cur} + ${irq_num}
setenv irq_prop "<"

while itest ${irq_cur} < ${irq_end}; do
setenv irq_prop "${irq_prop}0 0x${irq_cur} 4 "
setexpr irq_cur ${irq_cur} + 1
done

setenv irq_prop "${irq_prop}>"
fdt set ${dev_path} interrupts ${irq_prop}
done

setenv fdt_high 0xffffffffffffffff
echo "Booting"

booti ${xen_addr} - ${fdtaddr}
66 changes: 66 additions & 0 deletions recipes-bsp/u-boot-xen-scr/u-boot-xen-scr.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
SUMMARY = "U-Boot script to boot Xen"

LICENSE = "TI-TFL"
LIC_FILES_CHKSUM = "file://${COREBASE}/../meta-ti/meta-ti-bsp/licenses/TI-TFL;md5=a1b59cb7ba626b9dbbcbf00f3fbc438a"

PR = "r0"

SRC_URI = " \
file://boot.xen.source.in \
file://boot.xen.its \
"

DEPENDS = "u-boot-mkimage-native dtc-native"

XEN_IMAGE_NAME ??= "xen"
XEN_KERNEL_IMAGE_NAME ??= "Image"
XEN_RAMDISK_NAME ??= "${XEN_RAMFS_IMAGE}-${MACHINE}.rootfs.cpio"
XEN_FDT_ADDRESS ??= "0x80400000"
XEN_ADDRESS ??= "0x81000000"
XEN_KERNEL_ADDRESS ??= "0x83000000"
XEN_RAMDISK_ADDRESS ??= "0x89000000"
XEN_BOOT_DOM0LESS ??= ""
DOM0_MEM ??= "1G"
DOM0_MAX_VCPUS ??= "1"
XEN_SHMEM_UIO_NAME ??= "xen-uio"
XEN_SHMEM_START ??= "0x80400000"
XEN_SHMEM_SIZE ??= "0x1000"

XEN_DTUART_SERIAL ??= ""
XEN_DTUART_SERIAL:am62xx ??= "serial2"
XEN_DTUART_SERIAL:am62pxx ??= "serial2"

XEN_IRQ_DEVICES ??= ""
XEN_IRQ_DEVICES:am62xx ??= "\/bus@f0000\/bus@48000000\/interrupt-controller@48000000"
XEN_IRQ_DEVICES:am62pxx ??= "\/bus@f0000\/bus@48000000\/interrupt-controller@48000000"

S = "${WORKDIR}"

do_compile () {
sed -e 's/@@XEN_IMAGE_NAME@@/${XEN_IMAGE_NAME}/' \
-e 's/@@XEN_KERNEL_IMAGE_NAME@@/${XEN_KERNEL_IMAGE_NAME}/' \
-e 's/@@XEN_RAMDISK_NAME@@/${XEN_RAMDISK_NAME}/' \
-e 's/@@XEN_FDT_ADDRESS@@/${XEN_FDT_ADDRESS}/' \
-e 's/@@XEN_ADDRESS@@/${XEN_ADDRESS}/' \
-e 's/@@XEN_KERNEL_ADDRESS@@/${XEN_KERNEL_ADDRESS}/' \
-e 's/@@XEN_RAMDISK_ADDRESS@@/${XEN_RAMDISK_ADDRESS}/' \
-e 's/@@XEN_BOOT_DOM0LESS@@/${XEN_BOOT_DOM0LESS}/' \
-e 's/@@XEN_DTUART_SERIAL@@/${XEN_DTUART_SERIAL}/' \
-e 's/@@DOM0_MEM@@/${DOM0_MEM}/' \
-e 's/@@DOM0_MAX_VCPUS@@/${DOM0_MAX_VCPUS}/' \
-e 's/@@XEN_IRQ_DEVICES@@/${XEN_IRQ_DEVICES}/' \
-e 's/@@XEN_SHMEM_ID@@/${XEN_SHMEM_ID}/' \
-e 's/@@XEN_SHMEM_UIO_NAME@@/${XEN_SHMEM_UIO_NAME}/' \
-e 's/@@XEN_SHMEM_START@@/${XEN_SHMEM_START}/' \
-e 's/@@XEN_SHMEM_SIZE@@/${XEN_SHMEM_SIZE}/' \
"${S}/boot.xen.source.in" > "${S}/boot.xen.source"

mkimage -f ${S}/boot.xen.its ${S}/boot.xen.scr
}

inherit deploy
do_deploy () {
install -d ${DEPLOYDIR}
install -m 0644 ${S}/boot.xen.scr ${DEPLOYDIR}
}
addtask deploy before do_build after do_unpack
1 change: 1 addition & 0 deletions recipes-bsp/u-boot/files/bootmethscript.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_BOOTCOMMAND="run envboot; setenv bootmeths 'script'; bootflow scan -lb"
8 changes: 7 additions & 1 deletion recipes-bsp/u-boot/u-boot-ti-staging_%.bbappend
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
SRCREV:tie-jailhouse = "6301979bc99cd27951ee140df4b29bcfa4823fdd"

FILESEXTRAPATHS:prepend := "${THISDIR}/files:"

IPC_DM_FW = "ipc_echo_testb_mcu1_0_release_strip.xer5f"

# DM FW to be used only for AM62P tisdk-display-cluster image
Expand All @@ -11,5 +13,9 @@ TI_DM="${STAGING_DIR_HOST}${nonarch_base_libdir}/firmware/ti-dm/${PLAT_SFX}/${DM

EXTRA_OEMAKE += "TI_DM=${TI_DM}"

PR:append = "_tisdk_5"
SRC_URI:append:k3 = " \
${@bb.utils.contains('DISTRO_FEATURES', 'xen', 'file://bootmethscript.cfg', '', d)} \
"

PR:append = "_tisdk_6"

3 changes: 3 additions & 0 deletions recipes-core/images/tisdk-xen-domu.bbappend
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PR:append = "_tisdk_0"

PACKAGE_INSTALL += "xen-oob"
22 changes: 22 additions & 0 deletions recipes-core/images/tisdk-xen-image.bbappend
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
PR:append = "_tisdk_0"

IMAGE_INSTALL:append = " xen-oob u-boot-xen-scr"
IMAGE_BOOT_FILES:append = " boot.xen.scr;boot.scr"

ROOTFS_POSTINSTALL_COMMAND:append = "install_ramdisk; "
install_ramdisk () {
# Install the ramdisk which domu will use as root
if [ -n "${XEN_RAMFS_IMAGE}" ]; then
if [ -f ${DEPLOY_DIR_IMAGE}/${XEN_RAMFS_IMAGE}*-${MACHINE}.rootfs.cpio ]; then
install -m 0644 ${DEPLOY_DIR_IMAGE}/${XEN_RAMFS_IMAGE}*-${MACHINE}.rootfs.cpio ${IMAGE_ROOTFS}/boot
else
bberror "Could not find XEN_RAMFS_IMAGE (${XEN_RAMFS_IMAGE}*-${MACHINE}.rootfs.cpio)!"
bberror "Please make sure that \"cpio\" is in IMAGE_FSTYPES."
fi
fi
}

python __anonymous () {
if d.getVar('XEN_RAMFS_IMAGE', True):
d.appendVarFlag('do_rootfs', 'depends', ' ${XEN_RAMFS_IMAGE}:do_image_complete')
}
45 changes: 45 additions & 0 deletions recipes-demos/xen-oob/xen-oob.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
SUMMARY = "Out of box demo application for Xen Dom0 and DomU"

LICENSE = "TI-TFL"
LIC_FILES_CHKSUM = "file://${COREBASE}/../meta-ti/meta-ti-bsp/licenses/TI-TFL;md5=a1b59cb7ba626b9dbbcbf00f3fbc438a"

PR = "r0"

SRC_URI = " \
file://xen-oob.service.in \
file://xen-oob.sh \
"

RDEPENDS:${PN} += "bash net-tools iputils"
SYSTEMD_SERVICE:${PN} = "xen-oob.service"

inherit systemd

XEN_NET_BRIDGE ??= "xenbr0"
XEN_DOMU_IFACE ??= "enX0"
XEN_BOOT_DOM0LESS ??= ""
DOM0_IP ??= "192.168.44.1"
DOMU_IP ??= "192.168.44.2"
RAMDISK_PATH ??= "${@'\/boot\/${XEN_RAMFS_IMAGE}-${MACHINE}.rootfs.cpio' if d.getVar('XEN_RAMFS_IMAGE') else '' }"

do_install() {
sed -e 's/@@XEN_NET_BRIDGE@@/${XEN_NET_BRIDGE}/' \
-e 's/@@XEN_DOMU_IFACE@@/${XEN_DOMU_IFACE}/' \
-e 's/@@XEN_BOOT_DOM0LESS@@/${XEN_BOOT_DOM0LESS}/' \
-e 's/@@RAMDISK_PATH@@/${RAMDISK_PATH}/' \
-e 's/@@DOM0_IP@@/${DOM0_IP}/' \
-e 's/@@DOMU_IP@@/${DOMU_IP}/' \
"${WORKDIR}/xen-oob.service.in" > "${WORKDIR}/xen-oob.service"

# Install the service
install -d ${D}${systemd_system_unitdir}
install -m 0755 ${WORKDIR}/xen-oob.service ${D}${systemd_system_unitdir}

# Install the oneshot script
install -d ${D}${datadir}/demo
install -m 0755 ${WORKDIR}/xen-oob.sh ${D}${datadir}/demo
}

FILES:${PN} += " \
${datadir}/demo \
"
21 changes: 21 additions & 0 deletions recipes-demos/xen-oob/xen-oob/xen-oob.service.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This is a unit for spawning an OOB Xen DomU and pinging it

[Unit]
Description=Xen OOB
After=systemd-logind.service
Wants=systemd-logind.service

[Service]
Type=oneshot
ExecStart=/usr/share/demo/xen-oob.sh
StandardOutput=append:/var/log/xen-oob.log
StandardError=append:/var/log/xen-oob.error.log
Environment="XEN_NET_BRIDGE=@@XEN_NET_BRIDGE@@"
Environment="XEN_DOMU_IFACE=@@XEN_DOMU_IFACE@@"
Environment="XEN_BOOT_DOM0LESS=@@XEN_BOOT_DOM0LESS@@"
Environment="RAMDISK_PATH=@@RAMDISK_PATH@@"
Environment="DOM0_IP=@@DOM0_IP@@"
Environment="DOMU_IP=@@DOMU_IP@@"

[Install]
WantedBy=multi-user.target
Loading