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>
6 files changed