-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
recipes-bsp: u-boot: add mechanism to boot xen
This patch provides a custom CONFIG_BOOTCOMMAND when user has enabled xen under DISTRO_FEATURES. This bootcommand runs a script from boot partition, which is boot.scr by default. The script is also provided and is compiled using mkimage as a FIT image. This script loads the Xen image, the kernel image and the FDT and then modifies the FDT to allow suitable Xen configuration and other features like shared memory and UIO. Signed-off-by: Amneesh Singh <[email protected]>
- Loading branch information
Showing
5 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/dts-v1/; | ||
/ { | ||
description = "Configuration from Imagebuilder 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"; | ||
}; | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
xen_name=@@XEN_IMAGE_NAME@@ | ||
kernel_name=@@XEN_KERNEL_IMAGE_NAME@@ | ||
|
||
xen_addr=@@XEN_ADDRESS@@ | ||
kernel_addr=@@XEN_KERNEL_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 | ||
fi | ||
done | ||
|
||
if test -z "${kernel_size}"; then | ||
echo "No kernel image found" | ||
exit | ||
fi | ||
|
||
fdt addr ${fdtaddr} | ||
fdt resize 0x1000 | ||
setenv fdt_high 0xffffffffffffffff | ||
|
||
# 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@@ bootscrub=0 vwfi=native" | ||
fdt set /chosen xen,xen-bootargs \"${xen_bootargs}\" | ||
|
||
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" | ||
|
||
# shared memory | ||
if test -n "@@XEN_SHMEM_ID@@"; 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 /chosen ${shmem_node} | ||
fdt set /chosen/${shmem_node} compatible "xen,domain-shared-memory-v1" | ||
fdt set /chosen/${shmem_node} xen,shm-id "@@XEN_SHMEM_ID@@" | ||
fdt set /chosen/${shmem_node} xen,shared-mem <0x00 ${shmem_start} 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}\" | ||
|
||
# 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 | ||
|
||
echo "Booting" | ||
|
||
booti ${xen_addr} - ${fdtaddr} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CONFIG_BOOTCOMMAND="run envboot; setenv bootmeths 'script'; bootflow scan -lb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
FILESEXTRAPATHS:prepend := "${THISDIR}/scripts:" | ||
|
||
DEPENDS:append:k3 = " u-boot-mkimage-native" | ||
|
||
SRC_URI:append:k3 = " \ | ||
file://boot.xen.source.in \ | ||
file://boot.xen.its \ | ||
file://bootcommand.cfg \ | ||
" | ||
|
||
XEN_IMAGE_NAME ??= "xen" | ||
XEN_KERNEL_IMAGE_NAME ??= "Image" | ||
XEN_ADDRESS ??= "0x82040000" | ||
XEN_KERNEL_ADDRESS ??= "0x83000000" | ||
XEN_DTUART_SERIAL ??= "serial2" | ||
DOM0_MEM ??= "2G" | ||
DOM0_MAX_VCPUS ??= "1" | ||
XEN_SHMEM_ID ??= "xen-shmem" | ||
XEN_SHMEM_UIO_NAME ??= "xen-uio" | ||
XEN_SHMEM_START ??= "0x80000000" | ||
XEN_SHMEM_SIZE ??= "0x1000" | ||
|
||
XEN_IRQ_DEVICES ??= "" | ||
XEN_IRQ_DEVICES:am62pxx ??= "\/bus@f0000\/bus@48000000\/interrupt-controller@48000000" | ||
|
||
do_compile:append:k3() { | ||
sed -e 's/@@XEN_IMAGE_NAME@@/${XEN_IMAGE_NAME}/' \ | ||
-e 's/@@XEN_KERNEL_IMAGE_NAME@@/${XEN_KERNEL_IMAGE_NAME}/' \ | ||
-e 's/@@XEN_ADDRESS@@/${XEN_ADDRESS}/' \ | ||
-e 's/@@XEN_KERNEL_ADDRESS@@/${XEN_KERNEL_ADDRESS}/' \ | ||
-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}/' \ | ||
"${WORKDIR}/boot.xen.source.in" > "${WORKDIR}/boot.xen.source" | ||
|
||
mkimage -f ${WORKDIR}/boot.xen.its ${WORKDIR}/boot.xen.scr | ||
} | ||
|
||
do_deploy:append:k3() { | ||
install -d ${DEPLOYDIR} | ||
install -m 0644 ${WORKDIR}/boot.xen.scr ${DEPLOYDIR} | ||
} |