From 30ee61afffd9cbfd6ee90596558e16941439a0b9 Mon Sep 17 00:00:00 2001 From: Chris Kay Date: Wed, 21 Mar 2018 12:06:37 +0000 Subject: arch: Refactor architecture library This commit splits the "architecture" concept into two, more specific concepts: the vendor, and the architecture. This allows us to refactor architecture support into more common parts, and contain architecture-specific logic more cleanly. Some architectural functions and definitions have also been renamed to better reflect their origin and to maintain naming consistency. As architectures are generally not intended to be built independently of any firmware, the CI script no longer tries to build the architecture library. Change-Id: I04430e3a5503d29247517b869e36c180d6d21eaa Signed-off-by: Chris Kay --- tools/build_system/cpu.mk | 5 +++-- tools/build_system/firmware.mk | 20 ++++++++++---------- tools/build_system/lib.mk | 4 ++++ tools/build_system/rules.mk | 20 ++++++++++++++------ 4 files changed, 31 insertions(+), 18 deletions(-) (limited to 'tools') diff --git a/tools/build_system/cpu.mk b/tools/build_system/cpu.mk index e8c50d21..51810293 100644 --- a/tools/build_system/cpu.mk +++ b/tools/build_system/cpu.mk @@ -16,8 +16,9 @@ BS_ARCH_CPU := $(BS_FIRMWARE_CPU) ARMV7M_CPUS := cortex-m3 cortex-m7 ifneq ($(findstring $(BS_FIRMWARE_CPU),$(ARMV7M_CPUS)),) + BS_ARCH_VENDOR := arm BS_ARCH_ARCH := armv7-m - BS_ARCH_ISA := thumb + BS_ARCH_MODE := thumb LDFLAGS_GCC += --specs=nano.specs LDFLAGS_ARM += --target=arm-arm-none-eabi @@ -25,8 +26,8 @@ ifneq ($(findstring $(BS_FIRMWARE_CPU),$(ARMV7M_CPUS)),) CFLAGS += -mfloat-abi=soft # No hardware floating point support else ifeq ($(BS_FIRMWARE_CPU),host) + BS_ARCH_VENDOR := none BS_ARCH_ARCH := host - else $(erro "$(BS_FIRMWARE_CPU) is not a supported CPU. Aborting...") endif diff --git a/tools/build_system/firmware.mk b/tools/build_system/firmware.mk index f1c8d9ef..a477e424 100644 --- a/tools/build_system/firmware.mk +++ b/tools/build_system/firmware.mk @@ -93,9 +93,9 @@ goal: $(TARGET_BIN) ifneq ($(BS_ARCH_CPU),host) ifeq ($(BS_LINKER),ARM) - SCATTER_SRC = $(ARCH_DIR)/src/$(BS_ARCH_ARCH)/scatter.S + SCATTER_SRC = $(ARCH_DIR)/$(BS_ARCH_VENDOR)/$(BS_ARCH_ARCH)/src/arch.scatter.S else - SCATTER_SRC = $(ARCH_DIR)/src/$(BS_ARCH_ARCH)/ld.S + SCATTER_SRC = $(ARCH_DIR)/$(BS_ARCH_VENDOR)/$(BS_ARCH_ARCH)/src/arch.ld.S endif SCATTER_PP = $(OBJ_DIR)/ld_preproc.s @@ -180,14 +180,6 @@ ifeq ($(BS_FIRMWARE_HAS_MULTITHREADING),yes) BUILD_SUFFIX := $(MULTHREADING_SUFFIX) BUILD_HAS_MULTITHREADING := yes - ifneq ($(BS_ARCH_ARCH),host) - ifeq ($(BS_COMPILER),ARM) - LIBS_y += $(OS_DIR)/RTX/Library/ARM/RTX_CM3.lib - else - LIBS_y += $(OS_DIR)/RTX/Library/GCC/libRTX_CM3.a - endif - endif - INCLUDES += $(OS_DIR)/RTX/Source INCLUDES += $(OS_DIR)/RTX/Include INCLUDES += $(OS_DIR)/../Core/Include @@ -278,6 +270,14 @@ ifeq ($(BUILD_HAS_DEBUGGER),yes) LIBS_y += $(call lib_path,debugger$(BUILD_SUFFIX)) endif +# +# Additional library dependencies +# + +include $(ARCH_DIR)/$(BS_ARCH_VENDOR)/vendor.mk + +LIBS_y += $(BS_LIB_DEPS) + SOURCES += $(BUILD_FIRMWARE_DIR)/fwk_module_list.c $(BUILD_FIRMWARE_DIR)/fwk_module_list.c: gen_module EXTRA_DEP := gen_module diff --git a/tools/build_system/lib.mk b/tools/build_system/lib.mk index 66d35bbe..f86ad372 100644 --- a/tools/build_system/lib.mk +++ b/tools/build_system/lib.mk @@ -8,6 +8,7 @@ ifndef BS_LIB_MK BS_LIB_MK := 1 +include $(BS_DIR)/cpu.mk include $(BS_DIR)/defs.mk $(info == Building $(BS_LIB_NAME) for $(BS_FIRMWARE_CPU)) @@ -59,6 +60,9 @@ goal: $(LIB) INCLUDES += $(shell pwd) INCLUDES += $(TOP_DIR)/$(LIB_BASE)/include +INCLUDES += $(ARCH_DIR)/$(BS_ARCH_VENDOR)/include +INCLUDES += $(ARCH_DIR)/$(BS_ARCH_VENDOR)/$(BS_ARCH_ARCH)/include + include $(BS_DIR)/rules.mk endif diff --git a/tools/build_system/rules.mk b/tools/build_system/rules.mk index 3a06e43a..009baa7c 100644 --- a/tools/build_system/rules.mk +++ b/tools/build_system/rules.mk @@ -81,12 +81,12 @@ else LDFLAGS_GCC += -mcpu=$(BS_ARCH_CPU) LDFLAGS_ARM += -mcpu=$(BS_ARCH_CPU) - # Optional ISA ("sub-arch") parameter - ifneq ($(BS_ARCH_ISA),) - CFLAGS += -m$(BS_ARCH_ISA) - ASFLAGS_GCC += -m$(BS_ARCH_ISA) - LDFLAGS_GCC += -m$(BS_ARCH_ISA) - LDFLAGS_ARM += -m$(BS_ARCH_ISA) + # Optional architectural mode parameter + ifneq ($(BS_ARCH_MODE),) + CFLAGS += -m$(BS_ARCH_MODE) + ASFLAGS_GCC += -m$(BS_ARCH_MODE) + LDFLAGS_GCC += -m$(BS_ARCH_MODE) + LDFLAGS_ARM += -m$(BS_ARCH_MODE) endif endif @@ -169,6 +169,14 @@ ifeq ($(BUILD_HAS_DEBUGGER),yes) DEFINES += BUILD_HAS_DEBUGGER endif +# +# Always include the architecture librarie +# + +INCLUDES += $(ARCH_DIR)/include +INCLUDES += $(ARCH_DIR)/$(BS_ARCH_VENDOR)/include +INCLUDES += $(ARCH_DIR)/$(BS_ARCH_VENDOR)/$(BS_ARCH_ARCH)/include + # # Always include the framework library # -- cgit v1.2.3