A Xen-specific u-boot script is needed for launching Xen, and the GIC
(interrupt controller) needs to be enabled.

Since this is both Xen-specific and Raspberry Pi-specific, use a
dynamic layer to conditionally enable the recipes when both
meta-virtualization and meta-raspberrypi are in use together.

Signed-off-by: Christopher Clark <[email protected]>
---
 conf/layer.conf                               | 15 ++++++
 .../bootfiles/rpi-config_git.bbappend         |  6 +++
 .../rpi-u-boot-scr/files/boot.cmd.xen.in      | 49 +++++++++++++++++++
 .../rpi-u-boot-scr/rpi-u-boot-scr.bbappend    | 17 +++++++
 4 files changed, 87 insertions(+)
 create mode 100644 
dynamic-layers/raspberrypi/recipes-bsp/bootfiles/rpi-config_git.bbappend
 create mode 100644 
dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.xen.in
 create mode 100644 
dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bbappend

diff --git a/conf/layer.conf b/conf/layer.conf
index 142621c..1ec7a15 100644
--- a/conf/layer.conf
+++ b/conf/layer.conf
@@ -11,6 +11,21 @@ BBFILE_PRIORITY_virtualization-layer = "8"
 # Custom licenses used by some packages in this layer
 LICENSE_PATH += "${LAYERDIR}/files/custom-licenses"
 
+# The dynamic-layers directory hosts extensions and layer-specific
+# modifications.
+#
+# The .bbappend and .bb files are included if the respective layer
+# collection is available.
+BBFILES += "${@' '.join('${LAYERDIR}/dynamic-layers/%s/recipes*/*/*.bbappend' 
% layer \
+               for layer in BBFILE_COLLECTIONS.split())}"
+BBFILES += "${@' '.join('${LAYERDIR}/dynamic-layers/%s/recipes*/*/*.bb' % 
layer \
+               for layer in BBFILE_COLLECTIONS.split())}"
+
+BBFILES_DYNAMIC += " \
+    raspberrypi:${LAYERDIR}/dynamic-layers/raspberrypi/*/*/*.bb \
+    raspberrypi:${LAYERDIR}/dynamic-layers/rasbperrypi/*/*/*.bbappend \
+"
+
 # This should only be incremented on significant changes that will
 # cause compatibility issues with other layers
 LAYERVERSION_virtualization-layer = "1"
diff --git 
a/dynamic-layers/raspberrypi/recipes-bsp/bootfiles/rpi-config_git.bbappend 
b/dynamic-layers/raspberrypi/recipes-bsp/bootfiles/rpi-config_git.bbappend
new file mode 100644
index 0000000..2b9c4fb
--- /dev/null
+++ b/dynamic-layers/raspberrypi/recipes-bsp/bootfiles/rpi-config_git.bbappend
@@ -0,0 +1,6 @@
+do_deploy_append() {
+    # We need the GIC enabled for Xen to work.
+    if [ "${@bb.utils.contains('DISTRO_FEATURES', 'xen', 'yes', 'no', d)}" = 
"yes" ]; then
+        echo "enable_gic=1" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
+    fi
+}
diff --git 
a/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.xen.in 
b/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.xen.in
new file mode 100644
index 0000000..6c38d7d
--- /dev/null
+++ 
b/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.xen.in
@@ -0,0 +1,49 @@
+# Set the fdt address to what came from the GPU, so we can edit it
+fdt addr ${fdt_addr}
+
+# Pull the bootargs that the GPU has edited
+fdt get value bootargs /chosen bootargs
+
+# Set module load addresses
+setenv xen_loadaddr     "0x00200000"
+setenv kernel_loadaddr  "0x00400000"
+
+# Add some space to the fdt so we can edit it
+fdt resize 0x1000
+echo Add boot arguments for Xen
+fdt set /chosen xen,xen-bootargs "console=dtuart dtuart=/soc/serial@7e215040 
dom0_mem='@@RPI_DOM0_MEM@@' @@RPI_DEBUG_XEN_ARGS@@"
+
+echo Add boot arguments for dom0
+setenv dom0_bootargs "console=hvc0 earlyprintk=xen debug root=/dev/mmcblk0p2 
rootwait"
+fdt set /chosen xen,dom0-bootargs \"${dom0_bootargs}\"
+
+echo Add a dom0 node to chosen to put Linux boot information in
+fdt mknode /chosen dom0
+
+echo Set this for the Linux boot command
+fdt set /chosen/dom0 compatible "xen,linux-zimage", "xen,multiboot-module"
+
+# Tell Xen where PCI is
+fdt set /scb/pcie@7d500000 device_type "pci"
+
+echo Delay to allow the MMC card to be ready
+sleep 1
+
+echo Load Xen into memory
+fatload mmc 0:1 ${xen_loadaddr} xen
+echo Load Linux kernel into memory
+fatload mmc 0:1 ${kernel_loadaddr} Image
+setenv kernel_size 0x$filesize
+
+echo Set the address and size for the Linux kernel so Xen can pick it up
+fdt set /chosen/dom0 reg <${kernel_loadaddr} ${kernel_size}>
+
+# Define the size and address cells
+fdt set /chosen '#size-cells' <1>
+fdt set /chosen '#address-cells' <1>
+
+# Display the chosen fdt section - can be important for debugging
+fdt print /chosen
+
+echo Boot Xen
+booti ${xen_loadaddr} - ${fdt_addr}
diff --git 
a/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bbappend 
b/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bbappend
new file mode 100644
index 0000000..2a51116
--- /dev/null
+++ 
b/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bbappend
@@ -0,0 +1,17 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
+
+RPI_DOM0_MEM ??= "256M"
+RPI_DEBUG_XEN_ARGS ??= "sync_console bootscrub=0"
+
+SRC_URI += "file://boot.cmd.xen.in"
+
+# If the distro is Xen enabled, override the default boot.cmd.in with the
+# alternative boot.cmd.xen.in from this layer, with variables subsitution here
+do_compile_append() {
+    if [ "${@bb.utils.contains('DISTRO_FEATURES', 'xen', 'yes', 'no', d)}" = 
"yes" ]; then
+        sed -e 's/@@RPI_DOM0_MEM@@/${RPI_DOM0_MEM}/' \
+            -e 's/@@RPI_DEBUG_XEN_ARGS@@/${RPI_DEBUG_XEN_ARGS}/' \
+                "${WORKDIR}/boot.cmd.xen.in" > "${WORKDIR}/boot.cmd"
+        mkimage -A arm -T script -C none -n "Boot script" -d 
"${WORKDIR}/boot.cmd" boot.scr
+    fi
+}
-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#5501): 
https://lists.yoctoproject.org/g/meta-virtualization/message/5501
Mute This Topic: https://lists.yoctoproject.org/mt/75206225/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub  
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to