diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index 8a1e7520aacb..308a870fe188 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -1241,6 +1241,8 @@ initarm(struct arm64_bootparams *abp) #ifdef FDT struct mem_region mem_regions[FDT_MEM_REGIONS]; int mem_regions_sz; + phandle_t root; + char dts_version[255]; #endif vm_offset_t lastaddr; caddr_t kmdp; @@ -1353,6 +1355,20 @@ initarm(struct arm64_bootparams *abp) if (env != NULL) strlcpy(kernelname, env, sizeof(kernelname)); +#ifdef FDT + root = OF_finddevice("/"); + if (OF_getprop(root, "freebsd,dts-version", dts_version, sizeof(dts_version)) > 0) { + if (strcmp(LINUX_DTS_VERSION, dts_version) != 0) + printf("WARNING: DTB version is %s while kernel expects %s, " + "please update the DTB in the ESP\n", + dts_version, + LINUX_DTS_VERSION); + } else { + printf("WARNING: Cannot find freebsd,dts-version property, " + "cannot check DTB compliance\n"); + } +#endif + if (boothowto & RB_VERBOSE) { if (efihdr != NULL) print_efi_map_entries(efihdr); diff --git a/sys/conf/Makefile.arm64 b/sys/conf/Makefile.arm64 index c7951872ca2d..2e404664708c 100644 --- a/sys/conf/Makefile.arm64 +++ b/sys/conf/Makefile.arm64 @@ -27,6 +27,9 @@ S= ../../.. INCLUDES+= -I$S/contrib/libfdt -I$S/contrib/device-tree/include +LINUX_DTS_VERSION!= awk '/freebsd,dts-version/ { sub(/;$$/,"", $$NF); print $$NF }' $S/dts/freebsd-compatible.dts +CFLAGS += -DLINUX_DTS_VERSION=\"${LINUX_DTS_VERSION}\" + # Use a custom SYSTEM_LD command to generate the elf kernel, so we can # set the text segment start address, and also strip the "arm mapping # symbols" which have names like $a.0 and $d.2; see the document