dtc: Automatically pick a sensible boot_cpuid_phys
Currently, when in -Idts -Odtb or -Ifs -Odtb modes, dtc always
defaults to using 0 as the value for the boot_cpuid_phys header field.
That's correct quite often, but there are some systems where there is
no CPU with hardware ID of 0, or where we don't want to use the CPU
with hardware ID 0 at all (e.g. for AMP-style partitioning). The only
way to override this default currently, is with the -b command line
option.
This patch improves dtc to instead base the default boot_cpuid_phys
value on the reg property of the first listed subnode of /cpus. This
means that dtc will get boot_cpuid_phys correct by default in a
greater proportion of cases (since the boot cpu is usually listed
first, and this way at least the boot_cpuid_phys default will match
some existing cpu node). If the node doesn't exist or has an invalid
'reg' property (missing or not 4 bytes in length), then
boot_cpuid_phys is set to 0.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index c532030..ca46051 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -242,12 +242,26 @@
run_test incbin incbin.test.dtb
# Check boot_cpuid_phys handling
- run_dtc_test -I dts -O dtb -b 17 -o boot_cpuid.test.dtb empty.dts
- run_test boot-cpuid boot_cpuid.test.dtb 17
- run_dtc_test -I dtb -O dtb -b 17 -o boot_cpuid_test_tree1.test.dtb test_tree1.dtb
- run_test boot-cpuid boot_cpuid_test_tree1.test.dtb 17
- run_dtc_test -I dtb -O dtb -o boot_cpuid_preserved_test_tree1.test.dtb boot_cpuid_test_tree1.test.dtb
- run_test dtbs_equal_ordered boot_cpuid_preserved_test_tree1.test.dtb boot_cpuid_test_tree1.test.dtb
+ run_dtc_test -I dts -O dtb -o boot_cpuid.test.dtb boot-cpuid.dts
+ run_test boot-cpuid boot_cpuid.test.dtb 16
+
+ run_dtc_test -I dts -O dtb -b 17 -o boot_cpuid_17.test.dtb boot-cpuid.dts
+ run_test boot-cpuid boot_cpuid_17.test.dtb 17
+
+ run_dtc_test -I dtb -O dtb -o preserve_boot_cpuid.test.dtb boot_cpuid.test.dtb
+ run_test boot-cpuid preserve_boot_cpuid.test.dtb 16
+ run_test dtbs_equal_ordered preserve_boot_cpuid.test.dtb boot_cpuid.test.dtb
+
+ run_dtc_test -I dtb -O dtb -o preserve_boot_cpuid_17.test.dtb boot_cpuid_17.test.dtb
+ run_test boot-cpuid preserve_boot_cpuid_17.test.dtb 17
+ run_test dtbs_equal_ordered preserve_boot_cpuid_17.test.dtb boot_cpuid_17.test.dtb
+
+ run_dtc_test -I dtb -O dtb -b17 -o override17_boot_cpuid.test.dtb boot_cpuid.test.dtb
+ run_test boot-cpuid override17_boot_cpuid.test.dtb 17
+
+ run_dtc_test -I dtb -O dtb -b0 -o override0_boot_cpuid_17.test.dtb boot_cpuid_17.test.dtb
+ run_test boot-cpuid override0_boot_cpuid_17.test.dtb 0
+
# Check -Oasm mode
for tree in test_tree1.dts escapes.dts references.dts path-references.dts \