Add new boot.cmd.xen to u-boot-xlnx-scr bbappend to enable
Xen support for ZynqMP and Versal devices.

User can enable xen u-boot script by adding below variable from
configuration file.

BOOTMODE = "xen"

This u-boot script also supports to configure below Xen params from
configuration file

params          variable assignment
------          -------------------
duart           XEN_SERIAL_CONSOLES = "serial0"
dom0_mem        DOM0_MEM = "1500M"
dom0_max_vcpus  DOM0_MAX_VCPUS = "1"
extra params    XEN_CMDLINE_APPEND = "loglvl=all"

Signed-off-by: Sandeep Gundlupet Raju <[email protected]>
---
 .../u-boot/u-boot-xlnx-scr.bbappend           |  2 +
 .../u-boot/u-boot-xlnx-scr/boot.cmd.xen       | 80 +++++++++++++++++++
 .../recipes-bsp/u-boot/xen-boot-cmd.inc       | 38 +++++++++
 3 files changed, 120 insertions(+)
 create mode 100644 
dynamic-layers/xilinx/recipes-bsp/u-boot/u-boot-xlnx-scr.bbappend
 create mode 100644 
dynamic-layers/xilinx/recipes-bsp/u-boot/u-boot-xlnx-scr/boot.cmd.xen
 create mode 100644 dynamic-layers/xilinx/recipes-bsp/u-boot/xen-boot-cmd.inc

diff --git a/dynamic-layers/xilinx/recipes-bsp/u-boot/u-boot-xlnx-scr.bbappend 
b/dynamic-layers/xilinx/recipes-bsp/u-boot/u-boot-xlnx-scr.bbappend
new file mode 100644
index 0000000..ae847cb
--- /dev/null
+++ b/dynamic-layers/xilinx/recipes-bsp/u-boot/u-boot-xlnx-scr.bbappend
@@ -0,0 +1,2 @@
+# Include xen-boot-cmd.inc only if xen distro features is enabled.
+include ${@bb.utils.contains('DISTRO_FEATURES', 'xen', 'xen-boot-cmd.inc', '', 
d)}
diff --git 
a/dynamic-layers/xilinx/recipes-bsp/u-boot/u-boot-xlnx-scr/boot.cmd.xen 
b/dynamic-layers/xilinx/recipes-bsp/u-boot/u-boot-xlnx-scr/boot.cmd.xen
new file mode 100644
index 0000000..25e5842
--- /dev/null
+++ b/dynamic-layers/xilinx/recipes-bsp/u-boot/u-boot-xlnx-scr/boot.cmd.xen
@@ -0,0 +1,80 @@
+# This is a boot script for U-Boot with Xen parameters used by yocto machine
+# configuration file.
+# Generate boot.scr:
+# mkimage -c none -A arm -T script -d boot.cmd.xen boot.scr
+#
+################
+xen_name=@@XEN_IMAGE_NAME@@
+kernel_name=@@KERNEL_IMAGE@@
+rootfs_name=@@RAMDISK_IMAGE@@
+@@PRE_BOOTENV@@
+
+for boot_target in ${boot_targets};
+do
+       echo "Trying to load boot images from ${boot_target}"
+       if test "${boot_target}" = "jtag" ; then
+               tftpboot @@KERNEL_LOAD_ADDRESS@@ ${kernel_name}
+               setenv kernel_size 0x$filesize;
+               tftpboot @@RAMDISK_IMAGE_ADDRESS@@ ${rootfs_name}
+               setenv ramdisk_size 0x$filesize;
+               tftpboot @@XEN_LOAD_ADDRESS@@ ${xen_name}
+               tftpboot @@DEVICETREE_ADDRESS@@ system.dtb
+       fi
+       if test "${boot_target}" = "mmc0" || test "${boot_target}" = "mmc1" || 
test "${boot_target}" = "usb0" || test "${boot_target}" = "usb1"; then
+               if test "${boot_target}" = "mmc0" || test "${boot_target}" = 
"mmc1"; then
+                       setenv bootdev mmcblk${devnum}p
+               fi
+               if test "${boot_target}" = "usb0" || test "${boot_target}" = 
"usb1"; then
+                       setenv bootdev sda
+               fi
+               echo "Checking for /${xen_name}"
+               if test -e ${devtype} ${devnum}:${distro_bootpart} 
/${xen_name}; then
+                       echo "Loading ${xen_name}";
+                       fatload ${devtype} ${devnum}:${distro_bootpart} 
@@XEN_LOAD_ADDRESS@@ ${xen_name};
+               fi
+               echo "Checking for /${kernel_name}"
+               if test -e ${devtype} ${devnum}:${distro_bootpart} 
/${kernel_name}; then
+                       echo "Loading ${kernel_name}";
+                       fatload ${devtype} ${devnum}:${distro_bootpart} 
@@KERNEL_LOAD_ADDRESS@@ ${kernel_name};
+                       setenv kernel_size 0x$filesize;
+               fi
+               echo "Checking for /system.dtb"
+               if test -e ${devtype} ${devnum}:${distro_bootpart} /system.dtb; 
then
+                       echo "Loading system.dtb";
+                       fatload ${devtype} ${devnum}:${distro_bootpart} 
@@DEVICETREE_ADDRESS@@ system.dtb;
+               fi
+               echo "Checking for /${rootfs_name}"
+               if test -e ${devtype} ${devnum}:${distro_bootpart} 
/${rootfs_name} && test "${skip_ramdisk}" != "yes"; then
+                       echo "Loading ${rootfs_name}";
+                       fatload ${devtype} ${devnum}:${distro_bootpart} 
@@RAMDISK_IMAGE_ADDRESS@@ ${rootfs_name};
+                       setenv ramdisk_size 0x$filesize;
+               fi
+       fi
+       fdt addr @@DEVICETREE_ADDRESS@@
+       fdt resize 0x1000
+       fdt get value bootargs /chosen bootargs
+       fdt set /chosen \#address-cells <0x2>
+       fdt set /chosen \#size-cells <0x2>
+       setenv xen_bootargs "console=dtuart dtuart=@@XEN_SERIAL_CONSOLES@@ 
dom0_mem=@@DOM0_MEM@@ dom0_max_vcpus=@@DOM0_MAX_VCPUS@@ bootscrub=0 vwfi=native 
@@XEN_CMDLINE_APPEND@@"
+       fdt set /chosen xen,xen-bootargs \"${xen_bootargs}\"
+
+       # Check that env $ramdisk_size is 0 or not.
+       if test -n ${ramdisk_size}; then
+               fdt mknod /chosen dom0-ramdisk
+               fdt set /chosen/dom0-ramdisk compatible  "xen,linux-initrd" 
"xen,multiboot-module" "multiboot,module"
+               fdt set /chosen/dom0-ramdisk reg <0x0 @@RAMDISK_IMAGE_ADDRESS@@ 
0x0 ${ramdisk_size}>
+               setenv rootfs_param @@KERNEL_ROOT_RAMDISK@@
+       else
+               setenv rootfs_param @@KERNEL_ROOT_SD@@
+       fi
+
+       fdt mknod /chosen dom0
+       fdt set /chosen/dom0 compatible  "xen,linux-zimage" 
"xen,multiboot-module" "multiboot,module"
+       fdt set /chosen/dom0 reg <0x0 @@KERNEL_LOAD_ADDRESS@@ 0x0 
${kernel_size}>
+       setenv dom0_bootargs "console=hvc0 earlycon=xen earlyprintk=xen 
clk_ignore_unused ${rootfs_param}"
+       fdt set /chosen xen,dom0-bootargs \"${dom0_bootargs}\"
+
+       setenv fdt_high 0xffffffffffffffff
+
+       @@KERNEL_BOOTCMD@@ @@XEN_LOAD_ADDRESS@@ - @@DEVICETREE_ADDRESS@@
+done
diff --git a/dynamic-layers/xilinx/recipes-bsp/u-boot/xen-boot-cmd.inc 
b/dynamic-layers/xilinx/recipes-bsp/u-boot/xen-boot-cmd.inc
new file mode 100644
index 0000000..38f6f26
--- /dev/null
+++ b/dynamic-layers/xilinx/recipes-bsp/u-boot/xen-boot-cmd.inc
@@ -0,0 +1,38 @@
+FILESEXTRAPATHS:append := ":${THISDIR}/u-boot-xlnx-scr"
+
+SRC_URI += "file://boot.cmd.xen"
+ 
+# Image offsets for Xen boot
+KERNEL_OFFSET:zynqmp ?= "0xE00000"
+KERNEL_OFFSET:versal ?= "0xE00000"
+
+DEVICETREE_OFFSET:zynqmp ?= "0xC000000"
+DEVICETREE_OFFSET:versal ?= "0xC000000"
+
+RAMDISK_OFFSET:zynqmp ?= "0x2400000"
+RAMDISK_OFFSET:versal ?= "0x2400000"
+
+XEN_OFFSET:zynqmp ?= "0xBA00000"
+XEN_OFFSET:versal ?= "0xBA00000"
+XEN_LOAD_ADDRESS ?= "${@append_baseaddr(d,d.getVar('XEN_OFFSET'))}"
+
+# If dom0-ramdisk is used for Xen boot then set RAMDISK image to cpio.gz
+XEN_IMAGE_NAME ?= "xen"
+RAMDISK_IMAGE = "rootfs.cpio.gz"
+
+# Set the amount of memory for dom0 depending on total available memory 
size(DDR).
+DOM0_MEM ?= "1500M"
+
+# Specify which UART console Xen should use. You can sepecify the devicetree
+# alias or full path to a node in the devicetree
+# XEN_SERIAL_CONSOLES ?= "serial0" or XEN_SERIAL_CONSOLES ?= 
"/axi/serial@ff000000"
+XEN_SERIAL_CONSOLES ?= "serial0"
+
+# Specify additional Xen paramaters which will be appended to xen-bootargs
+# This can alos be used for debugging purposes.
+# Examples: XEN_CMDLINE_APPEND ?= "sched=credit loglvl=all guest_loglvl=debug"
+XEN_CMDLINE_APPEND ?= ""
+
+# Specify the max number of vcpus for dom0
+# Example usage: DOM0_MAX_VCPUS = "2" or DOM0_MAX_VCPUS = "2-4"
+DOM0_MAX_VCPUS ?= "1"
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#8144): 
https://lists.yoctoproject.org/g/meta-virtualization/message/8144
Mute This Topic: https://lists.yoctoproject.org/mt/100401328/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to