[Pdbg] [PATCH 15/18] Makefile: Add rule to generate device tree header file
Amitay Isaacs
amitay at ozlabs.org
Wed May 16 16:17:33 AEST 2018
From: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
---
Makefile.am | 8 ++++++++
generate_dt_header.sh | 24 ++++++++++++++++++++++++
2 files changed, 32 insertions(+)
create mode 100755 generate_dt_header.sh
diff --git a/Makefile.am b/Makefile.am
index cff3529..d87ab9f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,6 +13,7 @@ DT = fake.dts \
p9w-fsi.dts p9r-fsi.dts p9z-fsi.dts p9-kernel.dts p9-host.dts
DT_objects = $(DT:.dts=.dtb.o)
+DT_headers = $(DT:.dts=.dt.h)
pdbg_SOURCES = \
src/main.c src/cfam.c src/scom.c src/reg.c src/mem.c src/thread.c \
@@ -65,6 +66,10 @@ DTC_V = $(DTC_V_$(V))
DTC_V_ = $(DTC_V_$(AM_DEFAULT_VERBOSITY))
DTC_V_0 = @echo " DTC " $@;
+GEN_V = $(GEN_V_$(V))
+GEN_V_ = $(GEN_V_$(AM_DEFAULT_VERBOSITY))
+GEN_V_0 = @echo " GEN " $@;
+
%.dts: %.dts.m4
$(M4_V)$(M4) -I$(dir $<) $< > $@
@@ -78,6 +83,9 @@ p9z-fsi.dtb: p9z-fsi.dts p9-fsi.dtsi
%.dtb: %.dts
$(DTC_V)$(DTC) -q -i$(dir $@) -I dts $< -O dtb > $@
+%.dt.h: %.dtb
+ $(GEN_V)$(srcdir)/generate_dt_header.sh $< > $@
+
%.dtb.o: %.dtb
$(AM_V_CC)$(CC) -c $(srcdir)/template.S -DSYMBOL_PREFIX=$(shell echo $@ | tr '.-' '_') -DFILENAME=\"$<\" -o $@
diff --git a/generate_dt_header.sh b/generate_dt_header.sh
new file mode 100755
index 0000000..80eef17
--- /dev/null
+++ b/generate_dt_header.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+if [ $# -ne 1 ] ; then
+ echo "Usage: $0 <file.dtb>"
+ exit 1
+fi
+
+SYMBOL=$(echo "$1" | tr '.-' '_')
+SYM_START="_binary_${SYMBOL}_o_start"
+SYM_END="_biary_${SYMBOL}_o_end"
+SYM_SIZE="_biary_${SYMBOL}_o_size"
+HEADER="$f.h"
+
+cat - <<EOF
+/* This file is auto-generated from generate_dt_header.sh */
+#ifndef __${SYMBOL}_H__
+#define __${SYMBOL}_H__
+
+unsigned char ${SYM_START};
+unsigned char ${SYM_END};
+long ${SYM_SIZE};
+
+#endif /* __${SYMBOL}_H__ */
+EOF
--
2.17.0
More information about the Pdbg
mailing list