[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH] build: Build device tree source



We add support for building device tree files. An application developer
may the device tree to the SRCS variable to build the device tree.

Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
---
 Makefile                     |  1 +
 support/build/Makefile.rules | 30 ++++++++++++++++++++++++++----
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index da9b2269..19723240 100644
--- a/Makefile
+++ b/Makefile
@@ -454,6 +454,7 @@ GZIP                := gzip
 TAR            := tar
 UNZIP          := unzip -qq -u
 WGET           := wget
+DTC            := dtc
 # Time requires the full path so that subarguments are handled correctly
 TIME           := $(shell which time)
 LIFTOFF                := liftoff -e -s
diff --git a/support/build/Makefile.rules b/support/build/Makefile.rules
index d90807e0..a3111ac8 100644
--- a/support/build/Makefile.rules
+++ b/support/build/Makefile.rules
@@ -95,6 +95,12 @@ $(addprefix $(call sub_build_dir,$(1))/,$(addsuffix 
.lds,$(basename $(basename $
 )
 endef
 
+# converts paths device tree source file to the device tree binary blob
+# dts2dtb $libname,$dts
+define dts2dtb =
+$(addprefix $(call sub_build_dir,$(1))/,$(addsuffix .dtb,$(basename $(notdir 
$(2)))))
+endef
+
 
################################################################################
 #
 # Variable name prefixes
@@ -431,12 +437,24 @@ UK_DEPS-y += $(call out2dep,$(3))
 $(eval $(call vprefix_lib,$(1),CLEAN-y) += $(call build_clean,$(3)) $(call 
out2dep,$(3)))
 endef
 
+define buildrule_dts =
+$(3) : $(2) | prepare
+       $(call build_cmd,DTC,$(1),$(3),\
+              $(DTC)-I dts -O dtb -o $$(@) $$(<)\
+       )
+
+UK_SRCS-y += $(2)
+$(eval $(call vprefix_lib,$(1),DTB-y) += $(3))
+$(eval $(call vprefix_lib,$(1),CLEAN-y) += $(call build_clean,$(3)))
+endef
+
 # wrapper for buildrule_*,
 # selects appropriate buildrule depending on file extension
 #
 # buildrule $libname,$source,$target,$extraflags(optional)
 define buildrule =
 $(if $(filter %.lds.S,$(2)),$(call buildrule_lds,$(1),$(2),$(3),$(4)),\
+$(if $(filter %.dts,  $(2)),$(call buildrule_dts,$(1),$(2),$(3),$(4)),\
 $(if $(filter %.S,    $(2)),$(call buildrule_S  ,$(1),$(2),$(3),$(4)),\
 $(if $(filter %.sx,   $(2)),$(call buildrule_S  ,$(1),$(2),$(3),$(4)),\
 $(if $(filter %.s,    $(2)),$(call buildrule_s  ,$(1),$(2),$(3),$(4)),\
@@ -449,7 +467,7 @@ $(if $(filter %.CPP,  $(2)),$(call buildrule_cc 
,$(1),$(2),$(3),$(4)),\
 $(if $(filter %.c++,  $(2)),$(call buildrule_cc ,$(1),$(2),$(3),$(4)),\
 $(if $(filter %.C,    $(2)),$(call buildrule_cc ,$(1),$(2),$(3),$(4)),\
 $(error $(3): missing build rule for source type $(suffix $(2))) \
-))))))))))))
+)))))))))))))
 endef
 
 
@@ -508,8 +526,10 @@ endef
 # buildrule_libobj $libname,$source,$variant(optional)
 define buildrule_libobj =
 $(if $(filter %.lds.S,$(2)),\
-                  $(eval target=$(call src2lds,$(1),$(2))),\
-                  $(eval target=$(call src2obj,$(1),$(2),$(3))))
+               $(eval target=$(call src2lds,$(1),$(2))),\
+       $(if $(filter %.dts,$(2)),\
+               $(eval target=$(call dts2dtb,$(1),$(2))),\
+               $(eval target=$(call src2obj,$(1),$(2),$(3)))))
 $(eval $(call buildrule,$(1),$(2),$(target),\
   $($(call vprefix_src,$(1),$(2),INCLUDES))\
   $($(call vprefix_src,$(1),$(2),INCLUDES-y))\
@@ -582,7 +602,9 @@ $(if $(wildcard $($(call vprefix_lib,$(1),EXPORTS))),,\
 $(call libname2preolib,$(1)): $($(call vprefix_lib,$(1),OBJS)) \
                              $($(call vprefix_lib,$(1),OBJS-y)) \
                              $($(call vprefix_lib,$(1),ALIBS)) \
-                             $($(call vprefix_lib,$(1),ALIBS-y))
+                             $($(call vprefix_lib,$(1),ALIBS-y))\
+                             $($(call vprefix_lib,$(1),DTB)) \
+                             $($(call vprefix_lib,$(1),DTB-y))
        $(call build_cmd,LD,,$(call libname2preolib,$(1)),\
                $(LD) $(LIBLDFLAGS) $(LIBLDFLAGS-y) \
                      $($(call vprefix_lib,$(1),LDFLAGS)) \
-- 
2.20.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.