From 3c5326bf4a1b17ffca34bc0d2c0f290beab092a2 Mon Sep 17 00:00:00 2001 From: Rafal Jaworowski Date: Sun, 13 Jun 2010 13:02:43 +0000 Subject: [PATCH] Connect FDT infrastructure to the build system. Reviewed by: imp Sponsored by: The FreeBSD Foundation --- Makefile | 3 ++- Makefile.inc1 | 41 +++++++++++++++++++++++++++++++++++++++++ gnu/usr.bin/Makefile | 5 +++++ sys/conf/files | 24 ++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ce531244e5a3..5edb4dabda69 100644 --- a/Makefile +++ b/Makefile @@ -89,7 +89,8 @@ TGTS= all all-man buildenv buildenvvars buildkernel buildworld \ obj objlink regress rerelease showconfig tags toolchain update \ _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ _build-tools _cross-tools _includes _libraries _depend \ - build32 distribute32 install32 xdev xdev-build xdev-install + build32 builddtb distribute32 install32 xdev xdev-build xdev-install \ + TGTS+= ${SUBDIR_TARGETS} BITGTS= files includes diff --git a/Makefile.inc1 b/Makefile.inc1 index 2cbedd8aaf20..59b6629910f6 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -968,6 +968,10 @@ _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \ lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge .endif +.if ${MK_FDT} != "no" +_dtc= gnu/usr.bin/dtc +.endif + bootstrap-tools: .for _tool in \ ${_clang_tblgen} \ @@ -976,6 +980,7 @@ bootstrap-tools: ${_gperf} \ ${_groff} \ ${_ar} \ + ${_dtc} \ usr.bin/lorder \ usr.bin/makewhatis \ ${_mklocale} \ @@ -1448,3 +1453,39 @@ _xi-links: ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \ done .endif + +.if !empty(KRNLOBJDIR) && !empty(KERNCONF) +DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/ + +.if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE) +FDT_DTS_FILE!= grep "^makeoptions[[:space:]]\+FDT_DTS_FILE" \ + ${KERNCONFDIR}/${KERNCONF} 2> /dev/null | cut -d= -f2 +.endif + +.endif + +.if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH}) +DTBOUTPUTPATH= ${.CURDIR} +.endif + +# +# Build 'standalone' Device Tree Blob +# +builddtb: + @if [ "${FDT_DTS_FILE}" = "" ]; then \ + echo "ERROR: FDT_DTS_FILE must be specified!"; \ + exit 1; \ + fi; \ + if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} ]; then \ + echo "ERROR: Specified DTS file (${FDT_DTS_FILE}) does not \ + exist!"; \ + exit 1; \ + fi; \ + if [ "${DTBOUTPUTPATH}" = "${.CURDIR}" ]; then \ + echo "WARNING: DTB will be placed in the current working \ + directory"; \ + fi + @PATH=${TMPPATH} \ + dtc -O dtb -o \ + ${DTBOUTPUTPATH}/`echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb -b 0 \ + -p 1024 ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} diff --git a/gnu/usr.bin/Makefile b/gnu/usr.bin/Makefile index 17ee26ffd2fd..0a6d51fdcdf7 100644 --- a/gnu/usr.bin/Makefile +++ b/gnu/usr.bin/Makefile @@ -8,6 +8,7 @@ SUBDIR= ${_binutils} \ dialog \ diff \ diff3 \ + ${_dtc} \ ${_gdb} \ ${_gperf} \ ${_grep} \ @@ -31,6 +32,10 @@ _groff= groff _cvs= cvs .endif +.if ${MK_FDT} != "no" +_dtc= dtc +.endif + .if ${MK_GNU_GREP} != "no" _grep= grep .endif diff --git a/sys/conf/files b/sys/conf/files index 0808e7f24e06..a749e110dbfd 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -55,6 +55,18 @@ emu10k1-alsa%diked.h optional snd_emu10k1 | snd_emu10kx \ compile-with "CC='${CC}' AWK=${AWK} sh $S/tools/sound/emu10k1-mkalsa.sh $S/gnu/dev/sound/pci/emu10k1-alsa.h emu10k1-alsa%diked.h" \ no-obj no-implicit-rule before-depend \ clean "emu10k1-alsa%diked.h" +# +# The 'fdt_dtb_file' target covers an actual DTB file name, which is derived +# from the specified source (DTS) file: .dts -> .dtb +# +fdt_dtb_file optional fdt \ + compile-with "if [ -f $S/boot/fdt/dts/${FDT_DTS_FILE} ]; then dtc -O dtb -o `echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb -b 0 -p 1024 $S/boot/fdt/dts/${FDT_DTS_FILE}; fi" \ + no-obj no-implicit-rule before-depend \ + clean "`echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb" +fdt_static_dtb.h optional fdt fdt_dtb_static \ + compile-with "sh $S/tools/fdt/make_dtbh.sh ${FDT_DTS_FILE} ." \ + no-obj no-implicit-rule before-depend \ + clean "fdt_static_dtb.h" p16v-alsa%diked.h optional snd_emu10kx pci \ dependency "$S/tools/sound/emu10k1-mkalsa.sh $S/gnu/dev/sound/pci/p16v-alsa.h" \ compile-with "CC='${CC}' AWK=${AWK} sh $S/tools/sound/emu10k1-mkalsa.sh $S/gnu/dev/sound/pci/p16v-alsa.h p16v-alsa%diked.h" \ @@ -302,6 +314,12 @@ contrib/ipfilter/netinet/ip_sync.c optional ipfilter inet \ compile-with "${NORMAL_C} -I$S/contrib/ipfilter" contrib/ipfilter/netinet/mlfk_ipl.c optional ipfilter inet \ compile-with "${NORMAL_C} -I$S/contrib/ipfilter" +contrib/libfdt/fdt.c optional fdt +contrib/libfdt/fdt_ro.c optional fdt +contrib/libfdt/fdt_rw.c optional fdt +contrib/libfdt/fdt_strerror.c optional fdt +contrib/libfdt/fdt_sw.c optional fdt +contrib/libfdt/fdt_wip.c optional fdt contrib/ngatm/netnatm/api/cc_conn.c optional ngatm_ccatm \ compile-with "${NORMAL_C_NOWERROR} -I$S/contrib/ngatm" contrib/ngatm/netnatm/api/cc_data.c optional ngatm_ccatm \ @@ -961,6 +979,11 @@ dev/ex/if_ex_pccard.c optional ex pccard dev/exca/exca.c optional cbb dev/fatm/if_fatm.c optional fatm pci dev/fb/splash.c optional splash +dev/fdt/fdt_common.c optional fdt +dev/fdt/fdt_pci.c optional fdt pci +dev/fdt/fdt_static_dtb.S optional fdt fdt_dtb_static +dev/fdt/fdtbus.c optional fdt +dev/fdt/simplebus.c optional fdt dev/fe/if_fe.c optional fe dev/fe/if_fe_pccard.c optional fe pccard dev/firewire/firewire.c optional firewire @@ -1659,6 +1682,7 @@ dev/txp/if_txp.c optional txp inet dev/uart/uart_bus_acpi.c optional uart acpi #dev/uart/uart_bus_cbus.c optional uart cbus dev/uart/uart_bus_ebus.c optional uart ebus +dev/uart/uart_bus_fdt.c optional uart fdt dev/uart/uart_bus_isa.c optional uart isa dev/uart/uart_bus_pccard.c optional uart pccard dev/uart/uart_bus_pci.c optional uart pci