aboutsummaryrefslogtreecommitdiff
path: root/scripts/uboot-script-gen
diff options
context:
space:
mode:
authorXenia Ragiadakou2022-06-16 12:56:39 +0300
committerStefano Stabellini2022-06-16 13:57:56 -0700
commit66b9bd9f5e20c168ebcad4b08ac29cf6a90b666d (patch)
tree563550c05c4f69fedce8f9b962a95acd3bd0ee89 /scripts/uboot-script-gen
parent8c7c2d0166c59754cd30e2e3ea6e21a3cb52762b (diff)
uboot-script-gen: Add DOMU_STATIC_MEM
Add a new config parameter to configure a dom0less VM with static allocation. DOMU_STATIC_MEM[number]="baseaddr1 size1 ... baseaddrN sizeN" The parameter specifies the host physical address regions to be statically allocated to the VM. Each region is defined by its start address and size. For instance, DOMU_STATIC_MEM[0]="0x30000000 0x10000000 0x50000000 0x20000000" indicates that the host memory regions [0x30000000, 0x40000000) and [0x50000000, 0x70000000) are statically allocated to the first dom0less VM. Since currently it is not possible for a VM to have a mix of both statically and non-statically allocated memory regions, when DOMU_STATIC_MEM is specified, adjust VM's memory size to equal the amount of statically allocated memory. [stefano: add check for DOMU_MEM != DOMU_STATIC_MEM] Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
Diffstat (limited to 'scripts/uboot-script-gen')
-rwxr-xr-xscripts/uboot-script-gen63
1 files changed, 61 insertions, 2 deletions
diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
index 0adf523..001f6ed 100755
--- a/scripts/uboot-script-gen
+++ b/scripts/uboot-script-gen
@@ -108,6 +108,61 @@ function add_device_tree_passthrough()
dt_set "$path/module$addr" "reg" "hex" "0x0 $addr 0x0 $(printf "0x%x" $size)"
}
+function add_device_tree_mem()
+{
+ local path=$1
+ local memory=$2
+ local regions=$3
+ local static_mem=0
+
+ # When the DOMU is configured with static allocation,
+ # the size of DOMU's memory must match the size of DOMU's static memory.
+ if test "$regions"
+ then
+ local array=($regions)
+ local index
+
+ static_mem=0
+ for (( index=1; index<${#array[@]}; index+=2 ))
+ do
+ (( static_mem += ${array[$index]} ))
+ done
+ # The property "memory" is in KB.
+ (( static_mem >>= 10 ))
+
+ if test "$memory" -ne 0 && test "$memory" -ne "$static_mem"
+ then
+ echo "$path: specified DOMU_MEM does not match DOMU_STATIC_MEM amount. Ignoring DOMU_MEM."
+ fi
+ memory=$static_mem
+ fi
+
+ if test "$memory" -eq 0
+ then
+ memory=$((512 * 1024))
+ fi
+
+ dt_set "$path" "memory" "int" "0 $memory"
+}
+
+function add_device_tree_static_mem()
+{
+ local path=$1
+ local regions=$2
+ local cells=()
+ local val
+
+ dt_set "$path" "#xen,static-mem-address-cells" "hex" "0x2"
+ dt_set "$path" "#xen,static-mem-size-cells" "hex" "0x2"
+
+ for val in ${regions[@]}
+ do
+ cells+=("$(printf "0x%x 0x%x" $(($val >> 32)) $(($val & ((1 << 32) - 1))))")
+ done
+
+ dt_set "$path" "xen,static-mem" "hex" "${cells[*]}"
+}
+
function xen_device_tree_editing()
{
dt_set "/chosen" "#address-cells" "hex" "0x2"
@@ -141,8 +196,12 @@ function xen_device_tree_editing()
dt_set "/chosen/domU$i" "compatible" "str" "xen,domain"
dt_set "/chosen/domU$i" "#address-cells" "hex" "0x2"
dt_set "/chosen/domU$i" "#size-cells" "hex" "0x2"
- dt_set "/chosen/domU$i" "memory" "int" "0 ${DOMU_MEM[$i]}"
+ add_device_tree_mem "/chosen/domU$i" ${DOMU_MEM[$i]} "${DOMU_STATIC_MEM[$i]}"
dt_set "/chosen/domU$i" "cpus" "int" "${DOMU_VCPUS[$i]}"
+ if test "${DOMU_STATIC_MEM[$i]}"
+ then
+ add_device_tree_static_mem "/chosen/domU$i" "${DOMU_STATIC_MEM[$i]}"
+ fi
dt_set "/chosen/domU$i" "vpl011" "hex" "0x1"
add_device_tree_kernel "/chosen/domU$i" ${domU_kernel_addr[$i]} ${domU_kernel_size[$i]} "${DOMU_CMD[$i]}"
if test "${domU_ramdisk_addr[$i]}"
@@ -354,7 +413,7 @@ function xen_config()
do
if test -z "${DOMU_MEM[$i]}"
then
- DOMU_MEM[$i]=512
+ DOMU_MEM[$i]=0
fi
DOMU_MEM[$i]=$((${DOMU_MEM[$i]} * 1024))
if test -z "${DOMU_VCPUS[$i]}"