Add support for 64-bit addresses/sizes
PATCH v2 1/1 Add support for 64-bit addresses/sizes
At the moment, ImageBuilder assumes that all addresses/sizes are 32-bit max. It sets #{address,size}-cells to 0x2 and puts 0x0 as the value for the first cell. Because of that, we cannot specify MEMORY_START and MEMORY_END to be above 32-bits (e.g. to place the images in the upper memory bank).
Add support to properly handle 64-bit addresses/sizes:
- add function split_into_halves to split the value passed as a first argument into upper and lower halves. These are then set as values for variables passed respetively as the second and third argument,
- add function split_addr_size to split address and size and form a string to be passed to dt_set as data argument for reg property.
---
Changes in v2:
- redesign a patch based on master-next instead of NXP dynamic assignment patch
--- scripts/uboot-script-gen | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-)
scripts/uboot-script-gen +28 -5
@@ -22,6 +22,29 @@ function dt_mknode() fi } +# Usage: +# split_into_halves <value> <variable_to_store_upper> <variable_to_store_lower> +function split_into_halves() +{ + local value=$1 + local upper=$2 + local lower=$3 + + eval "$upper=$(printf "0x%X\n" $(($value >> 32)))" + eval "$lower=$(printf "0x%X\n" $(($value & 0xFFFFFFFF)))" +} + +function split_addr_size() +{ + local addr=$1 + local size=$2 + + split_into_halves $addr addr_upper addr_lower + split_into_halves $size size_upper size_lower + + echo "$addr_upper $addr_lower $size_upper $size_lower" +} + # data_type is either # int # hex
@@ -93,7 +116,7 @@ function add_device_tree_kernel() dt_mknode "$path" "module$addr" dt_set "$path/module$addr" "compatible" "str_a" "multiboot,kernel multiboot,module" - dt_set "$path/module$addr" "reg" "hex" "0x0 $addr 0x0 $(printf "0x%x" $size)" + dt_set "$path/module$addr" "reg" "hex" "$(split_addr_size $addr $size)" dt_set "$path/module$addr" "bootargs" "str" "$bootargs" }
@@ -106,7 +129,7 @@ function add_device_tree_ramdisk() dt_mknode "$path" "module$addr" dt_set "$path/module$addr" "compatible" "str_a" "multiboot,ramdisk multiboot,module" - dt_set "$path/module$addr" "reg" "hex" "0x0 $addr 0x0 $(printf "0x%x" $size)" + dt_set "$path/module$addr" "reg" "hex" "$(split_addr_size $addr $size)" }
@@ -118,7 +141,7 @@ function add_device_tree_passthrough() dt_mknode "$path" "module$addr" dt_set "$path/module$addr" "compatible" "str_a" "multiboot,device-tree multiboot,module" - dt_set "$path/module$addr" "reg" "hex" "0x0 $addr 0x0 $(printf "0x%x" $size)" + dt_set "$path/module$addr" "reg" "hex" "$(split_addr_size $addr $size)" } function add_device_tree_mem()
@@ -260,7 +283,7 @@ function xen_device_tree_editing() then dt_mknode "/chosen" "dom0" dt_set "/chosen/dom0" "compatible" "str_a" "xen,linux-zimage xen,multiboot-module multiboot,module" - dt_set "/chosen/dom0" "reg" "hex" "0x0 $dom0_kernel_addr 0x0 $(printf "0x%x" $dom0_kernel_size)" + dt_set "/chosen/dom0" "reg" "hex" "$(split_addr_size $dom0_kernel_addr $dom0_kernel_size)" dt_set "/chosen" "xen,dom0-bootargs" "str" "$DOM0_CMD" fi
@@ -268,7 +291,7 @@ function xen_device_tree_editing() then dt_mknode "/chosen" "dom0-ramdisk" dt_set "/chosen/dom0-ramdisk" "compatible" "str_a" "xen,linux-initrd xen,multiboot-module multiboot,module" - dt_set "/chosen/dom0-ramdisk" "reg" "hex" "0x0 $ramdisk_addr 0x0 $(printf "0x%x" $ramdisk_size)" + dt_set "/chosen/dom0-ramdisk" "reg" "hex" "$(split_addr_size $ramdisk_addr $ramdisk_size)" fi i=0
Signature · 1 line
2.25.1
On 10/10/22 10:29, Michal Orzel wrote:
Hi Michal
Quoted 10 lines
At the moment, ImageBuilder assumes that all addresses/sizes are 32-bit max. It sets #{address,size}-cells to
0x2and puts0x0as the value for the first cell. Because of that, we cannot specifyMEMORY_STARTandMEMORY_ENDto be above 32-bits (e.g. to place the images in the upper memory bank).Add support to properly handle 64-bit addresses/sizes:
- add functionsplit_into_halvesto split the value passed as a first argument into upper and lower halves. These are then set as values for variables passed respetively as the second and third argument,
s/respetively/respectively/
Quoted 29 lines
- add function
split_addr_sizeto split address and size and form a string to be passed todt_setas data argument for reg property.Signed-off-by Michal Orzel <[email protected]>---
Changes in v2:
- redesign a patch based on master-next instead of NXP dynamic assignment patch--- scripts/uboot-script-gen | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-)scripts/uboot-script-gen +10
-0@@ -22,6 +22,29 @@ function dt_mknode() fi } +# Usage: +# split_into_halves <value> <variable_to_store_upper> <variable_to_store_lower> +function split_into_halves() +{ + local value=$1 + local upper=$2 + local lower=$3 + + eval "$upper=$(printf "0x%X\n" $(($value >> 32)))" + eval "$lower=$(printf "0x%X\n" $(($value & 0xFFFFFFFF)))"
scripts/uboot-script-gen function dt_mknode() · line 44
Quoted 10 lines
scripts/uboot-script-gen +10
-0+} + +function split_addr_size() +{ + local addr=$1 + local size=$2 + + split_into_halves $addr addr_upper addr_lower + split_into_halves $size size_upper size_lower +
Just a minor observation, the variables addr_upper, addr_lower, size_upper and size_lower can be declared local.
Quoted 51 lines
scripts/uboot-script-gen +8
-5+ echo "$addr_upper $addr_lower $size_upper $size_lower" +} + # data_type is either # int # hex@@ -93,7 +116,7 @@ function add_device_tree_kernel() dt_mknode "$path" "module$addr" dt_set "$path/module$addr" "compatible" "str_a" "multiboot,kernel multiboot,module" - dt_set "$path/module$addr" "reg" "hex" "0x0 $addr 0x0 $(printf "0x%x" $size)" + dt_set "$path/module$addr" "reg" "hex" "$(split_addr_size $addr $size)" dt_set "$path/module$addr" "bootargs" "str" "$bootargs" }@@ -106,7 +129,7 @@ function add_device_tree_ramdisk() dt_mknode "$path" "module$addr" dt_set "$path/module$addr" "compatible" "str_a" "multiboot,ramdisk multiboot,module" - dt_set "$path/module$addr" "reg" "hex" "0x0 $addr 0x0 $(printf "0x%x" $size)" + dt_set "$path/module$addr" "reg" "hex" "$(split_addr_size $addr $size)" }@@ -118,7 +141,7 @@ function add_device_tree_passthrough() dt_mknode "$path" "module$addr" dt_set "$path/module$addr" "compatible" "str_a" "multiboot,device-tree multiboot,module" - dt_set "$path/module$addr" "reg" "hex" "0x0 $addr 0x0 $(printf "0x%x" $size)" + dt_set "$path/module$addr" "reg" "hex" "$(split_addr_size $addr $size)" } function add_device_tree_mem()@@ -260,7 +283,7 @@ function xen_device_tree_editing() then dt_mknode "/chosen" "dom0" dt_set "/chosen/dom0" "compatible" "str_a" "xen,linux-zimage xen,multiboot-module multiboot,module" - dt_set "/chosen/dom0" "reg" "hex" "0x0 $dom0_kernel_addr 0x0 $(printf "0x%x" $dom0_kernel_size)" + dt_set "/chosen/dom0" "reg" "hex" "$(split_addr_size $dom0_kernel_addr $dom0_kernel_size)" dt_set "/chosen" "xen,dom0-bootargs" "str" "$DOM0_CMD" fi@@ -268,7 +291,7 @@ function xen_device_tree_editing() then dt_mknode "/chosen" "dom0-ramdisk" dt_set "/chosen/dom0-ramdisk" "compatible" "str_a" "xen,linux-initrd xen,multiboot-module multiboot,module" - dt_set "/chosen/dom0-ramdisk" "reg" "hex" "0x0 $ramdisk_addr 0x0 $(printf "0x%x" $ramdisk_size)" + dt_set "/chosen/dom0-ramdisk" "reg" "hex" "$(split_addr_size $ramdisk_addr $ramdisk_size)" fi i=0
Signature · 1 line
Xenia
Hi Xenia,
Quoted 12 lines · Xenia Ragiadakou
On 10/10/22 10:29, Michal Orzel wrote:
Hi Michal
Quoted 6 lines
At the moment, ImageBuilder assumes that all addresses/sizes are 32-bit max. It sets #{address,size}-cells to
0x2and puts0x0as the value for the first cell. Because of that, we cannot specifyMEMORY_STARTandMEMORY_ENDto be above 32-bits (e.g. to place the images in the upper memory bank).
Quoted 6 lines
Quoted 4 lines
Add support to properly handle 64-bit addresses/sizes:
- add functionsplit_into_halvesto split the value passed as a first argument into upper and lower halves. These are then set as values for variables passed respetively as the second and third argument,s/respetively/respectively/
Ok.
Quoted 35 lines
Quoted 35 lines
- add function
split_addr_sizeto split address and size and form a string to be passed todt_setas data argument for reg property.Signed-off-by Michal Orzel <[email protected]>---
Changes in v2:
- redesign a patch based on master-next instead of NXP dynamic assignment patch--- scripts/uboot-script-gen | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-)scripts/uboot-script-gen +15
-0@@ -22,6 +22,29 @@ function dt_mknode() fi } +# Usage: +# split_into_halves <value> <variable_to_store_upper> <variable_to_store_lower> +function split_into_halves() +{ + local value=$1 + local upper=$2 + local lower=$3 + + eval "$upper=$(printf "0x%X\n" $(($value >> 32)))" + eval "$lower=$(printf "0x%X\n" $(($value & 0xFFFFFFFF)))" +} + +function split_addr_size() +{ + local addr=$1
Quoted 9 lines
scripts/uboot-script-gen function dt_mknode() · line 44
Quoted 5 lines
scripts/uboot-script-gen +5
-0+ local size=$2 + + split_into_halves $addr addr_upper addr_lower + split_into_halves $size size_upper size_lower +Just a minor observation, the variables
addr_upper,addr_lower,size_upperandsize_lowercan be declared local.
This function is to be called to perform substitution and as such is always executed within a subshell so no need for local.
~Michal
Quoted 67 lines · Michal Orzel
Hi Xenia,
Quoted 12 lines · Xenia Ragiadakou
On 10/10/22 10:29, Michal Orzel wrote:
Hi Michal
Quoted 6 lines
At the moment, ImageBuilder assumes that all addresses/sizes are 32-bit max. It sets #{address,size}-cells to
0x2and puts0x0as the value for the first cell. Because of that, we cannot specifyMEMORY_STARTandMEMORY_ENDto be above 32-bits (e.g. to place the images in the upper memory bank).Quoted 6 lines
Quoted 4 lines
Add support to properly handle 64-bit addresses/sizes:
- add functionsplit_into_halvesto split the value passed as a first argument into upper and lower halves. These are then set as values for variables passed respetively as the second and third argument,s/respetively/respectively/
Ok.
Quoted 35 lines
Quoted 35 lines
- add function
split_addr_sizeto split address and size and form a string to be passed todt_setas data argument for reg property.Signed-off-by Michal Orzel <[email protected]>---
Changes in v2:
- redesign a patch based on master-next instead of NXP dynamic assignment patch--- scripts/uboot-script-gen | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-)scripts/uboot-script-gen +15
-0@@ -22,6 +22,29 @@ function dt_mknode() fi } +# Usage: +# split_into_halves <value> <variable_to_store_upper> <variable_to_store_lower> +function split_into_halves() +{ + local value=$1 + local upper=$2 + local lower=$3 + + eval "$upper=$(printf "0x%X\n" $(($value >> 32)))" + eval "$lower=$(printf "0x%X\n" $(($value & 0xFFFFFFFF)))" +} + +function split_addr_size() +{ + local addr=$1Quoted 9 lines
scripts/uboot-script-gen function dt_mknode() · line 44
Quoted 5 lines
scripts/uboot-script-gen +5
-0+ local size=$2 + + split_into_halves $addr addr_upper addr_lower + split_into_halves $size size_upper size_lower +Just a minor observation, the variables
addr_upper,addr_lower,size_upperandsize_lowercan be declared local.
Quoted 2 lines
This function is to be called to perform substitution and as such is always executed within a subshell so no need for local.
So split_addr_size() is supposed to be executed only in a subshell ... Ok I did not think of that. So neither addr or size need to be declared local.
Signature · 1 line
Xenia
Quoted 70 lines · Xenia Ragiadakou
Quoted 67 lines · Michal Orzel
Hi Xenia,
Quoted 12 lines · Xenia Ragiadakou
On 10/10/22 10:29, Michal Orzel wrote:
Hi Michal
Quoted 6 lines
At the moment, ImageBuilder assumes that all addresses/sizes are 32-bit max. It sets #{address,size}-cells to
0x2and puts0x0as the value for the first cell. Because of that, we cannot specifyMEMORY_STARTandMEMORY_ENDto be above 32-bits (e.g. to place the images in the upper memory bank).Quoted 6 lines
Quoted 4 lines
Add support to properly handle 64-bit addresses/sizes:
- add functionsplit_into_halvesto split the value passed as a first argument into upper and lower halves. These are then set as values for variables passed respetively as the second and third argument,s/respetively/respectively/
Ok.
Quoted 44 lines
Quoted 30 lines
- add function
split_addr_sizeto split address and size and form a string to be passed todt_setas data argument for reg property.Signed-off-by Michal Orzel <[email protected]>---
Changes in v2:
- redesign a patch based on master-next instead of NXP dynamic assignment patch--- scripts/uboot-script-gen | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-)scripts/uboot-script-gen +10
-0@@ -22,6 +22,29 @@ function dt_mknode() fi } +# Usage: +# split_into_halves <value> <variable_to_store_upper> <variable_to_store_lower> +function split_into_halves() +{ + local value=$1 + local upper=$2 + local lower=$3 + + eval "$upper=$(printf "0x%X\n" $(($value >> 32)))" + eval "$lower=$(printf "0x%X\n" $(($value & 0xFFFFFFFF)))"scripts/uboot-script-gen function dt_mknode() · line 44
Quoted 10 lines
scripts/uboot-script-gen +10
-0+} + +function split_addr_size() +{ + local addr=$1 + local size=$2 + + split_into_halves $addr addr_upper addr_lower + split_into_halves $size size_upper size_lower +Just a minor observation, the variables
addr_upper,addr_lower,size_upperandsize_lowercan be declared local.
Quoted 6 lines
Quoted 2 lines
This function is to be called to perform substitution and as such is always executed within a subshell so no need for local.
So
split_addr_size()is supposed to be executed only in a subshell ... Ok I did not think of that. So neither addr or size need to be declared local.
Exactly, but in ImageBuilder we don't seem to use $1, $2, ... directly so that is why I added local only for the arguments passed to this function.
Quoted 3 lines
--
Xenia
~Michal
Quoted 71 lines · Michal Orzel
Quoted 70 lines · Xenia Ragiadakou
Quoted 67 lines · Michal Orzel
Hi Xenia,
Quoted 12 lines · Xenia Ragiadakou
On 10/10/22 10:29, Michal Orzel wrote:
Hi Michal
Quoted 6 lines
At the moment, ImageBuilder assumes that all addresses/sizes are 32-bit max. It sets #{address,size}-cells to
0x2and puts0x0as the value for the first cell. Because of that, we cannot specifyMEMORY_STARTandMEMORY_ENDto be above 32-bits (e.g. to place the images in the upper memory bank).Quoted 6 lines
Quoted 4 lines
Add support to properly handle 64-bit addresses/sizes:
- add functionsplit_into_halvesto split the value passed as a first argument into upper and lower halves. These are then set as values for variables passed respetively as the second and third argument,s/respetively/respectively/
Ok.
Quoted 44 lines
Quoted 30 lines
- add function
split_addr_sizeto split address and size and form a string to be passed todt_setas data argument for reg property.Signed-off-by Michal Orzel <[email protected]>---
Changes in v2:
- redesign a patch based on master-next instead of NXP dynamic assignment patch--- scripts/uboot-script-gen | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-)scripts/uboot-script-gen +10
-0@@ -22,6 +22,29 @@ function dt_mknode() fi } +# Usage: +# split_into_halves <value> <variable_to_store_upper> <variable_to_store_lower> +function split_into_halves() +{ + local value=$1 + local upper=$2 + local lower=$3 + + eval "$upper=$(printf "0x%X\n" $(($value >> 32)))" + eval "$lower=$(printf "0x%X\n" $(($value & 0xFFFFFFFF)))"scripts/uboot-script-gen function dt_mknode() · line 44
Quoted 10 lines
scripts/uboot-script-gen +10
-0+} + +function split_addr_size() +{ + local addr=$1 + local size=$2 + + split_into_halves $addr addr_upper addr_lower + split_into_halves $size size_upper size_lower +Just a minor observation, the variables
addr_upper,addr_lower,size_upperandsize_lowercan be declared local.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
This function is to be called to perform substitution and as such is always executed within a subshell so no need for local.
So
split_addr_size()is supposed to be executed only in a subshell ... Ok I did not think of that. So neither addr or size need to be declared local.Exactly, but in ImageBuilder we don't seem to use $1, $2, ... directly so that is why I added local only for the arguments passed to this function.
Thanks Michal for the patch and Xenia for the review.
I like to use local, not just because of necessity, but also just as a way to "tag" variables that we know are not going to be used outside a specific function. Almost like a naming convention.
I ended up committing a slightly modified version of split_addr_size that should be simpler and slightly more performant:
function split_value()
{
local value=$1
printf "0x%X " "$(($value >> 32))"
printf "0x%X " "$(($value & 0xFFFFFFFF))"
}function split_addr_size()
{
local addr=$1
local size=$2
split_value $addr
split_value $size
}