diff --git a/Makefile b/Makefile index 4e883082c..ee778e9c0 100644 --- a/Makefile +++ b/Makefile @@ -51,37 +51,57 @@ else endif BL_COMMON_OBJS := misc_helpers.o cache_helpers.o tlb_helpers.o \ - semihosting_call.o mmio.o pl011.o semihosting.o \ - std.o bl_common.o platform_helpers.o sysreg_helpers.o - -ARCH := aarch64 -PLAT := fvp - -BUILD_BASE:=./build -BUILD:=${BUILD_BASE}/${PLAT}/${BUILD_TYPE} -BUILD_BL1:=${BUILD}/bl1 -BUILD_BL2:=${BUILD}/bl2 -BUILD_BL31:=${BUILD}/bl31 -BUILD_DIRS:=${BUILD_BL1} ${BUILD_BL2} ${BUILD_BL31} - -all: bl1 bl2 bl31 - -$(info Including bl1.mk) -include bl1/bl1.mk + std.o bl_common.o platform_helpers.o +ARCH ?= aarch64 + +# By default, build all platforms available +PLAT ?= all + +BUILD_BASE := ./build +BUILD_PLAT := ${BUILD_BASE}/${PLAT}/${BUILD_TYPE} +BUILD_BL1 := ${BUILD_PLAT}/bl1 +BUILD_BL2 := ${BUILD_PLAT}/bl2 +BUILD_BL31 := ${BUILD_PLAT}/bl31 +BUILD_DIRS := ${BUILD_BL1} ${BUILD_BL2} ${BUILD_BL31} + +PLATFORMS := $(shell ls -I common plat/) +ifeq (${PLAT},) + $(error "Error: Unknown platform. Please use PLAT= to specify the platform.") +endif +ifeq ($(findstring ${PLAT},${PLATFORMS} all),) + $(error "Error: Invalid platform. The following platforms are available: ${PLATFORMS}") +endif -$(info Including bl2.mk) -include bl2/bl2.mk +ifeq (${PLAT},all) +all: ${PLATFORMS} +else +all: msg_start bl1 bl2 bl31 +endif -$(info Including bl31.mk) -include bl31/bl31.mk +msg_start: + @echo "Building ${PLAT}" + +${PLATFORMS}: + ${MAKE} PLAT=$@ all + +ifneq (${PLAT},all) + $(info Including ${PLAT}/platform.mk) + include plat/${PLAT}/platform.mk + $(info Including bl1.mk) + include bl1/bl1.mk + $(info Including bl2.mk) + include bl2/bl2.mk + $(info Including bl31.mk) + include bl31/bl31.mk +endif -.PHONY: dump clean realclean distclean bl1 bl2 bl31 +.PHONY: all msg_start ${PLATFORMS} dump clean realclean distclean bl1 bl2 bl31 .SUFFIXES: -BL1_OBJS := $(addprefix ${BUILD_BL1}/,${BL1_OBJS} ${BL_COMMON_OBJS}) -BL2_OBJS := $(addprefix ${BUILD_BL2}/,${BL2_OBJS} ${BL_COMMON_OBJS}) -BL31_OBJS := $(addprefix ${BUILD_BL31}/,${BL31_OBJS} ${BL_COMMON_OBJS}) +BL1_OBJS := $(addprefix ${BUILD_BL1}/,${BL1_OBJS} ${BL_COMMON_OBJS} ${PLAT_BL_COMMON_OBJS}) +BL2_OBJS := $(addprefix ${BUILD_BL2}/,${BL2_OBJS} ${BL_COMMON_OBJS} ${PLAT_BL_COMMON_OBJS}) +BL31_OBJS := $(addprefix ${BUILD_BL31}/,${BL31_OBJS} ${BL_COMMON_OBJS} ${PLAT_BL_COMMON_OBJS}) BL1_MAPFILE := $(addprefix ${BUILD_BL1}/,${BL1_MAPFILE}) BL2_MAPFILE := $(addprefix ${BUILD_BL2}/,${BL2_MAPFILE}) BL31_MAPFILE := $(addprefix ${BUILD_BL31}/,${BL31_MAPFILE}) @@ -89,12 +109,10 @@ BL1_LINKERFILE := $(addprefix ${BUILD_BL1}/,${BL1_LINKERFILE}) BL2_LINKERFILE := $(addprefix ${BUILD_BL2}/,${BL2_LINKERFILE}) BL31_LINKERFILE := $(addprefix ${BUILD_BL31}/,${BL31_LINKERFILE}) -INCLUDES += -Ilib/include/ -Iinclude/aarch64/ -Iinclude/ \ - -Idrivers/arm/interconnect/cci-400/ \ - -Idrivers/arm/peripherals/pl011/ \ - -Iplat/fvp -Idrivers/power \ +INCLUDES += -Ilib/include/ -Iinclude/${ARCH}/ -Iinclude/ \ -Iarch/system/gic -Icommon/psci \ - -Iinclude/stdlib -Iinclude/stdlib/sys + -Iinclude/stdlib -Iinclude/stdlib/sys \ + -Iplat/${PLAT} ${PLAT_INCLUDES} ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \ -mgeneral-regs-only -D__ASSEMBLY__ ${INCLUDES} @@ -133,13 +151,18 @@ NM := ${CROSS_COMPILE}nm PP := ${CROSS_COMPILE}gcc -E ${CFLAGS} -bl1: ${BUILD_BL1} ${BUILD}/bl1.bin -bl2: ${BUILD_BL2} ${BUILD}/bl2.bin -bl31: ${BUILD_BL31} ${BUILD}/bl31.bin +bl1: ${BUILD_BL1} ${BUILD_PLAT}/bl1.bin +bl2: ${BUILD_BL2} ${BUILD_PLAT}/bl2.bin +bl31: ${BUILD_BL31} ${BUILD_PLAT}/bl31.bin +ifeq (${PLAT},all) + ifeq (${MAKECMDGOALS},clean) + $(error "Please select a platform with PLAT=. You can use 'make distclean' to clean up all platform builds") + endif +endif clean: @echo " CLEAN" - ${Q}rm -rf ${BUILD} + ${Q}rm -rf ${BUILD_PLAT} realclean distclean: @echo " REALCLEAN" @@ -180,15 +203,15 @@ ${BUILD_BL31}/%.o: %.c ${Q}${CC} ${CFLAGS} -c $< -o $@ ${BUILD_BL1}/%.ld: %.ld.S - @echo " LDS $<" + @echo " PP $<" ${Q}${AS} ${ASFLAGS} -P -E $< -o $@ ${BUILD_BL2}/%.ld: %.ld.S - @echo " LDS $<" + @echo " PP $<" ${Q}${AS} ${ASFLAGS} -P -E $< -o $@ ${BUILD_BL31}/%.ld: %.ld.S - @echo " LDS $<" + @echo " PP $<" ${Q}${AS} ${ASFLAGS} -P -E $< -o $@ @@ -204,19 +227,22 @@ ${BUILD_BL31}/bl31.elf: ${BL31_OBJS} ${BL31_LINKERFILE} @echo " LD $@" ${Q}${LD} -o $@ ${LDFLAGS} ${BL31_LDFLAGS} ${BL31_OBJS} -${BUILD}/bl1.bin: ${BUILD_BL1}/bl1.elf +${BUILD_PLAT}/bl1.bin: ${BUILD_BL1}/bl1.elf + @echo " BIN $@" ${Q}${OC} -O binary $< $@ @echo @echo "Built $@ successfully" @echo -${BUILD}/bl2.bin: ${BUILD_BL2}/bl2.elf +${BUILD_PLAT}/bl2.bin: ${BUILD_BL2}/bl2.elf + @echo " BIN $@" ${Q}${OC} -O binary $< $@ @echo @echo "Built $@ successfully" @echo -${BUILD}/bl31.bin: ${BUILD_BL31}/bl31.elf +${BUILD_PLAT}/bl31.bin: ${BUILD_BL31}/bl31.elf + @echo " BIN $@" ${Q}${OC} -O binary $< $@ @echo @echo "Built $@ successfully" diff --git a/acknowledgements.md b/acknowledgements.md index ef49ca336..a428f2f9d 100644 --- a/acknowledgements.md +++ b/acknowledgements.md @@ -3,7 +3,7 @@ Contributor Acknowledgements Companies --------- - +Linaro Limited Individuals ----------- diff --git a/bl1/bl1.mk b/bl1/bl1.mk index 68a7ef72a..012967a90 100644 --- a/bl1/bl1.mk +++ b/bl1/bl1.mk @@ -28,19 +28,21 @@ # POSSIBILITY OF SUCH DAMAGE. # -vpath %.c drivers/arm/interconnect/cci-400/ plat/fvp \ - plat/fvp/${ARCH} drivers/arm/peripherals/pl011 common/ lib/ \ - lib/semihosting arch/aarch64/ lib/stdlib +vpath %.c plat/${PLAT} plat/${PLAT}/${ARCH} \ + common/ lib/ arch/${ARCH} \ + ${PLAT_BL1_C_VPATH} -vpath %.S arch/${ARCH}/cpu plat/common/aarch64 \ - plat/fvp/${ARCH} lib/semihosting/aarch64 \ - include/ lib/arch/aarch64 +vpath %.S arch/${ARCH}/cpu plat/common/${ARCH} \ + plat/${PLAT}/${ARCH} \ + include/ lib/arch/${ARCH} \ + ${PLAT_BL1_S_VPATH} + +BL1_OBJS += bl1_arch_setup.o \ + bl1_entrypoint.o \ + early_exceptions.o \ + bl1_main.o \ + cpu_helpers.o -BL1_ASM_OBJS := bl1_entrypoint.o bl1_plat_helpers.o cpu_helpers.o -BL1_C_OBJS := bl1_main.o cci400.o bl1_plat_setup.o bl1_arch_setup.o \ - fvp_common.o fvp_helpers.o early_exceptions.o BL1_ENTRY_POINT := reset_handler BL1_MAPFILE := bl1.map BL1_LINKERFILE := bl1.ld - -BL1_OBJS := $(BL1_C_OBJS) $(BL1_ASM_OBJS) diff --git a/bl2/bl2.mk b/bl2/bl2.mk index daa893041..9c43e88c2 100644 --- a/bl2/bl2.mk +++ b/bl2/bl2.mk @@ -28,21 +28,22 @@ # POSSIBILITY OF SUCH DAMAGE. # -vpath %.c common/ drivers/arm/interconnect/cci-400/ \ - drivers/arm/peripherals/pl011 common/ lib/ \ - plat/fvp plat/fvp/${ARCH} lib/semihosting arch/aarch64/ \ - lib/stdlib +vpath %.c common/ lib/ \ + plat/${PLAT} plat/${PLAT}/${ARCH} arch/${ARCH} \ + ${PLAT_BL2_C_VPATH} -vpath %.S lib/arch/aarch64 \ - lib/semihosting/aarch64 \ - include lib/sync/locks/exclusive +vpath %.S lib/arch/${ARCH} \ + include lib/sync/locks/exclusive \ + ${PLAT_BL2_S_VPATH} -BL2_ASM_OBJS := bl2_entrypoint.o spinlock.o -BL2_C_OBJS := bl2_main.o bl2_plat_setup.o bl2_arch_setup.o fvp_common.o \ +BL2_OBJS += bl2_entrypoint.o \ + bl2_arch_setup.o \ + bl2_main.o \ + spinlock.o \ early_exceptions.o + BL2_ENTRY_POINT := bl2_entrypoint BL2_MAPFILE := bl2.map BL2_LINKERFILE := bl2.ld -BL2_OBJS := $(BL2_C_OBJS) $(BL2_ASM_OBJS) CFLAGS += $(DEFINES) diff --git a/bl31/bl31.mk b/bl31/bl31.mk index 228e5307d..e5bacd7b9 100644 --- a/bl31/bl31.mk +++ b/bl31/bl31.mk @@ -28,27 +28,34 @@ # POSSIBILITY OF SUCH DAMAGE. # -vpath %.c drivers/arm/interconnect/cci-400/ common/ lib/ \ - drivers/arm/peripherals/pl011 plat/fvp common/psci \ - lib/semihosting arch/aarch64/ lib/stdlib lib/sync/locks/bakery/ \ - drivers/power/ arch/system/gic/ plat/fvp/aarch64/ +vpath %.c common/ lib/ arch/system/gic \ + plat/${PLAT} arch/${ARCH} common/psci \ + lib/sync/locks/bakery/ \ + plat/${PLAT}/${ARCH} ${PLAT_BL31_C_VPATH} -vpath %.S lib/arch/aarch64 common/psci \ - lib/semihosting/aarch64 include/ plat/fvp/${ARCH} \ - lib/sync/locks/exclusive plat/common/aarch64/ \ - arch/system/gic/${ARCH} +vpath %.S lib/arch/${ARCH} common/psci \ + include/ plat/${PLAT}/${ARCH} \ + lib/sync/locks/exclusive plat/common/${ARCH} \ + arch/system/gic/${ARCH} \ + ${PLAT_BL31_S_VPATH} -BL31_ASM_OBJS := bl31_entrypoint.o runtime_exceptions.o psci_entry.o \ - spinlock.o gic_v3_sysregs.o fvp_helpers.o -BL31_C_OBJS := bl31_main.o bl31_plat_setup.o bl31_arch_setup.o \ - exception_handlers.o bakery_lock.o cci400.o \ - fvp_common.o fvp_pm.o fvp_pwrc.o fvp_topology.o \ - runtime_svc.o fvp_gic.o gic_v2.o gic_v3.o psci_setup.o \ - psci_common.o psci_afflvl_on.o psci_main.o \ - psci_afflvl_off.o psci_afflvl_suspend.o +BL31_OBJS += bl31_arch_setup.o \ + bl31_entrypoint.o \ + exception_handlers.o \ + runtime_exceptions.o \ + bl31_main.o \ + psci_entry.o \ + psci_setup.o \ + psci_common.o \ + psci_afflvl_on.o \ + psci_main.o \ + psci_afflvl_off.o \ + psci_afflvl_suspend.o \ + spinlock.o \ + gic_v3_sysregs.o \ + bakery_lock.o \ + runtime_svc.o BL31_ENTRY_POINT := bl31_entrypoint BL31_MAPFILE := bl31.map BL31_LINKERFILE := bl31.ld - -BL31_OBJS := $(BL31_C_OBJS) $(BL31_ASM_OBJS) diff --git a/docs/change-log.md b/docs/change-log.md index 7d6d8f6b1..50e111113 100644 --- a/docs/change-log.md +++ b/docs/change-log.md @@ -98,6 +98,11 @@ Detailed changes since last release system. The GICv3 re-distributors are probed to work out which re-distributor should be used with which CPU. +* Add multi-platform support to the build system. The user may now specify + which platform to build using PLAT= as part of the make command + line. Default behaviour is to make all platforms. New platforms are + automatically detected by the make file when they are added to the plat + directory. ARM Trusted Firmware - version 0.2 ================================== diff --git a/docs/user-guide.md b/docs/user-guide.md index bc4597f18..0358e074a 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -82,7 +82,7 @@ To build the software for the FVPs, follow these steps: 3. Set the compiler path and build: - CROSS_COMPILE=/bin/aarch64-none-elf- make + CROSS_COMPILE=/bin/aarch64-none-elf- make PLAT=fvp By default this produces a release version of the build. To produce a debug version instead, refer to the "Debugging options" section below. @@ -104,7 +104,7 @@ To build the software for the FVPs, follow these steps: 5. (Optional) Build products for a specific build variant can be removed using: - make DEBUG= clean + make DEBUG= PLAT=fvp clean ... where `` is `0` or `1`, as specified when building. @@ -117,7 +117,7 @@ To build the software for the FVPs, follow these steps: To compile a debug version and make the build more verbose use - CROSS_COMPILE=/bin/aarch64-none-elf- make DEBUG=1 V=1 + CROSS_COMPILE=/bin/aarch64-none-elf- make PLAT=fvp DEBUG=1 V=1 AArch64 GCC uses DWARF version 4 debugging symbols by default. Some tools (for example DS-5) might not support this and may need an older version of DWARF @@ -135,7 +135,7 @@ Extra debug options can be passed to the build system by setting `CFLAGS`: CFLAGS='-O0 -gdwarf-2' \ CROSS_COMPILE=/bin/aarch64-none-elf- \ - make DEBUG=1 V=1 + make PLAT=fvp DEBUG=1 V=1 NOTE: The Foundation FVP does not provide a debugger interface. diff --git a/plat/fvp/platform.mk b/plat/fvp/platform.mk new file mode 100644 index 000000000..94942f5a4 --- /dev/null +++ b/plat/fvp/platform.mk @@ -0,0 +1,81 @@ +# +# Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# Neither the name of ARM nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific +# prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +PLAT_INCLUDES := -Idrivers/arm/interconnect/cci-400/ \ + -Idrivers/arm/peripherals/pl011/ \ + -Idrivers/power + +PLAT_BL1_C_VPATH := drivers/arm/interconnect/cci-400/ \ + drivers/arm/peripherals/pl011 \ + lib/semihosting \ + lib/stdlib + +PLAT_BL1_S_VPATH := lib/semihosting/${ARCH} + +PLAT_BL2_C_VPATH := drivers/arm/interconnect/cci-400 \ + drivers/arm/peripherals/pl011 \ + lib/stdlib \ + lib/semihosting + +PLAT_BL2_S_VPATH := lib/semihosting/${ARCH} + +PLAT_BL31_C_VPATH := drivers/arm/interconnect/cci-400 \ + drivers/arm/peripherals/pl011 \ + lib/semihosting \ + lib/stdlib \ + drivers/power + +PLAT_BL31_S_VPATH := lib/semihosting/${ARCH} + +PLAT_BL_COMMON_OBJS := semihosting_call.o \ + mmio.o \ + pl011.o \ + semihosting.o \ + sysreg_helpers.o + +BL1_OBJS += bl1_plat_setup.o \ + bl1_plat_helpers.o \ + fvp_helpers.o \ + fvp_common.o \ + cci400.o + +BL2_OBJS += bl2_plat_setup.o \ + fvp_common.o + +BL31_OBJS += bl31_plat_setup.o \ + fvp_helpers.o \ + fvp_common.o \ + fvp_pm.o \ + fvp_pwrc.o \ + fvp_topology.o \ + fvp_gic.o \ + cci400.o \ + gic_v2.o \ + gic_v3.o