From 94de3255e5b828a855bbeb93eb46042c95e234e6 Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Thu, 18 Jan 2024 10:38:15 -0700 Subject: acpi,arch,commonlib: Rename Makefiles from .inc to .mk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The .inc suffix is confusing to various tools as it's not specific to Makefiles. This means that editors don't recognize the files, and don't open them with highlighting and any other specific editor functionality. This issue is also seen in the release notes generation script where Makefiles get renamed before running cloc. Signed-off-by: Martin Roth Change-Id: Ice5dadd3eaadfa9962225520a3a75b05b44518ca Reviewed-on: https://review.coreboot.org/c/coreboot/+/80066 Reviewed-by: Maximilian Brune Tested-by: build bot (Jenkins) Reviewed-by: Michael Niewöhner Reviewed-by: Felix Singer --- src/arch/arm/Makefile.inc | 129 -------------- src/arch/arm/Makefile.mk | 129 ++++++++++++++ src/arch/arm/armv4/Makefile.inc | 54 ------ src/arch/arm/armv4/Makefile.mk | 54 ++++++ src/arch/arm/armv7/Makefile.inc | 165 ------------------ src/arch/arm/armv7/Makefile.mk | 165 ++++++++++++++++++ src/arch/arm/libgcc/Makefile.inc | 21 --- src/arch/arm/libgcc/Makefile.mk | 21 +++ src/arch/arm64/Makefile.inc | 218 ------------------------ src/arch/arm64/Makefile.mk | 218 ++++++++++++++++++++++++ src/arch/arm64/armv8/Makefile.inc | 102 ------------ src/arch/arm64/armv8/Makefile.mk | 102 ++++++++++++ src/arch/ppc64/Makefile.inc | 91 ---------- src/arch/ppc64/Makefile.mk | 91 ++++++++++ src/arch/riscv/Makefile.inc | 188 --------------------- src/arch/riscv/Makefile.mk | 188 +++++++++++++++++++++ src/arch/x86/Makefile.inc | 343 -------------------------------------- src/arch/x86/Makefile.mk | 343 ++++++++++++++++++++++++++++++++++++++ 18 files changed, 1311 insertions(+), 1311 deletions(-) delete mode 100644 src/arch/arm/Makefile.inc create mode 100644 src/arch/arm/Makefile.mk delete mode 100644 src/arch/arm/armv4/Makefile.inc create mode 100644 src/arch/arm/armv4/Makefile.mk delete mode 100644 src/arch/arm/armv7/Makefile.inc create mode 100644 src/arch/arm/armv7/Makefile.mk delete mode 100644 src/arch/arm/libgcc/Makefile.inc create mode 100644 src/arch/arm/libgcc/Makefile.mk delete mode 100644 src/arch/arm64/Makefile.inc create mode 100644 src/arch/arm64/Makefile.mk delete mode 100644 src/arch/arm64/armv8/Makefile.inc create mode 100644 src/arch/arm64/armv8/Makefile.mk delete mode 100644 src/arch/ppc64/Makefile.inc create mode 100644 src/arch/ppc64/Makefile.mk delete mode 100644 src/arch/riscv/Makefile.inc create mode 100644 src/arch/riscv/Makefile.mk delete mode 100644 src/arch/x86/Makefile.inc create mode 100644 src/arch/x86/Makefile.mk (limited to 'src/arch') diff --git a/src/arch/arm/Makefile.inc b/src/arch/arm/Makefile.inc deleted file mode 100644 index b18b137252..0000000000 --- a/src/arch/arm/Makefile.inc +++ /dev/null @@ -1,129 +0,0 @@ -## SPDX-License-Identifier: GPL-2.0-only - -############################################################################### -# ARM specific options -############################################################################### - -ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM),y) -check-ramstage-overlap-regions += postram_cbfs_cache stack ttb -endif - -ifeq ($(CONFIG_ARCH_ARM),y) -subdirs-y += libgcc/ -subdirs-y += armv4/ armv7/ - -stages_c = $(src)/arch/arm/stages.c -stages_o = $(obj)/arch/arm/stages.o - -$(stages_o): $(stages_c) $(obj)/config.h - @printf " CC $(subst $(obj)/,,$(@))\n" - $(CC_arm) -I. $(CPPFLAGS_arm) -c -o $@ $< -marm - -endif # CONFIG_ARCH_ARM - -############################################################################### -# bootblock -############################################################################### - -ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARM),y) - -decompressor-y += boot.c -bootblock-y += boot.c -decompressor-y += div0.c -bootblock-y += div0.c -decompressor-y += eabi_compat.c -bootblock-y += eabi_compat.c -decompressor-y += memset.S -bootblock-y += memset.S -decompressor-y += memcpy.S -bootblock-y += memcpy.S -decompressor-y += memmove.S -bootblock-y += memmove.S - -bootblock-y += clock.c -bootblock-y += stages.c - -$(objcbfs)/bootblock.debug: $$(bootblock-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) -T $(call src-to-obj,bootblock,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) --end-group - -$(objcbfs)/decompressor.debug: $$(decompressor-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) -T $(call src-to-obj,decompressor,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(decompressor-objs)) --end-group - -endif # CONFIG_ARCH_BOOTBLOCK_ARM - -############################################################################### -# verification stage -############################################################################### - -ifeq ($(CONFIG_ARCH_VERSTAGE_ARM),y) - -$(objcbfs)/verstage.debug: $$(verstage-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_verstage) $(LDFLAGS_verstage) -o $@ -L$(obj) -T $(call src-to-obj,verstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(verstage-objs)) --end-group - -verstage-y += boot.c -verstage-y += div0.c -verstage-y += eabi_compat.c -verstage-y += memset.S -verstage-y += memcpy.S -verstage-y += memmove.S -verstage-y += stages.c - -endif # CONFIG_ARCH_VERSTAGE_ARM - -############################################################################### -# romstage -############################################################################### - -ifeq ($(CONFIG_ARCH_ROMSTAGE_ARM),y) - -romstage-y += boot.c -romstage-y += stages.c -romstage-y += div0.c -romstage-y += eabi_compat.c -romstage-y += memset.S -romstage-y += memcpy.S -romstage-y += memmove.S -romstage-y += clock.c -rmodules_arm-y += memset.S -rmodules_arm-y += memcpy.S -rmodules_arm-y += memmove.S -rmodules_arm-y += eabi_compat.c - -$(objcbfs)/romstage.debug: $$(romstage-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) -T $(call src-to-obj,romstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group - -endif # CONFIG_ARCH_ROMSTAGE_ARM - -############################################################################### -# ramstage -############################################################################### - -ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM),y) - -ramstage-y += stages.c -ramstage-y += div0.c -ramstage-y += eabi_compat.c -ramstage-y += boot.c -ramstage-y += tables.c -ramstage-y += memset.S -ramstage-y += memcpy.S -ramstage-y += memmove.S -ramstage-y += clock.c -ramstage-y += boot_linux.S -ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit_payload.c - -rmodules_arm-y += memset.S -rmodules_arm-y += memcpy.S -rmodules_arm-y += memmove.S -rmodules_arm-y += eabi_compat.c -ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c) - -$(objcbfs)/ramstage.debug: $$(ramstage-objs) - @printf " CC $(subst $(obj)/,,$(@))\n" - $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group - -endif # CONFIG_ARCH_RAMSTAGE_ARM diff --git a/src/arch/arm/Makefile.mk b/src/arch/arm/Makefile.mk new file mode 100644 index 0000000000..b18b137252 --- /dev/null +++ b/src/arch/arm/Makefile.mk @@ -0,0 +1,129 @@ +## SPDX-License-Identifier: GPL-2.0-only + +############################################################################### +# ARM specific options +############################################################################### + +ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM),y) +check-ramstage-overlap-regions += postram_cbfs_cache stack ttb +endif + +ifeq ($(CONFIG_ARCH_ARM),y) +subdirs-y += libgcc/ +subdirs-y += armv4/ armv7/ + +stages_c = $(src)/arch/arm/stages.c +stages_o = $(obj)/arch/arm/stages.o + +$(stages_o): $(stages_c) $(obj)/config.h + @printf " CC $(subst $(obj)/,,$(@))\n" + $(CC_arm) -I. $(CPPFLAGS_arm) -c -o $@ $< -marm + +endif # CONFIG_ARCH_ARM + +############################################################################### +# bootblock +############################################################################### + +ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARM),y) + +decompressor-y += boot.c +bootblock-y += boot.c +decompressor-y += div0.c +bootblock-y += div0.c +decompressor-y += eabi_compat.c +bootblock-y += eabi_compat.c +decompressor-y += memset.S +bootblock-y += memset.S +decompressor-y += memcpy.S +bootblock-y += memcpy.S +decompressor-y += memmove.S +bootblock-y += memmove.S + +bootblock-y += clock.c +bootblock-y += stages.c + +$(objcbfs)/bootblock.debug: $$(bootblock-objs) + @printf " LINK $(subst $(obj)/,,$(@))\n" + $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) -T $(call src-to-obj,bootblock,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) --end-group + +$(objcbfs)/decompressor.debug: $$(decompressor-objs) + @printf " LINK $(subst $(obj)/,,$(@))\n" + $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) -T $(call src-to-obj,decompressor,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(decompressor-objs)) --end-group + +endif # CONFIG_ARCH_BOOTBLOCK_ARM + +############################################################################### +# verification stage +############################################################################### + +ifeq ($(CONFIG_ARCH_VERSTAGE_ARM),y) + +$(objcbfs)/verstage.debug: $$(verstage-objs) + @printf " LINK $(subst $(obj)/,,$(@))\n" + $(LD_verstage) $(LDFLAGS_verstage) -o $@ -L$(obj) -T $(call src-to-obj,verstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(verstage-objs)) --end-group + +verstage-y += boot.c +verstage-y += div0.c +verstage-y += eabi_compat.c +verstage-y += memset.S +verstage-y += memcpy.S +verstage-y += memmove.S +verstage-y += stages.c + +endif # CONFIG_ARCH_VERSTAGE_ARM + +############################################################################### +# romstage +############################################################################### + +ifeq ($(CONFIG_ARCH_ROMSTAGE_ARM),y) + +romstage-y += boot.c +romstage-y += stages.c +romstage-y += div0.c +romstage-y += eabi_compat.c +romstage-y += memset.S +romstage-y += memcpy.S +romstage-y += memmove.S +romstage-y += clock.c +rmodules_arm-y += memset.S +rmodules_arm-y += memcpy.S +rmodules_arm-y += memmove.S +rmodules_arm-y += eabi_compat.c + +$(objcbfs)/romstage.debug: $$(romstage-objs) + @printf " LINK $(subst $(obj)/,,$(@))\n" + $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) -T $(call src-to-obj,romstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group + +endif # CONFIG_ARCH_ROMSTAGE_ARM + +############################################################################### +# ramstage +############################################################################### + +ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM),y) + +ramstage-y += stages.c +ramstage-y += div0.c +ramstage-y += eabi_compat.c +ramstage-y += boot.c +ramstage-y += tables.c +ramstage-y += memset.S +ramstage-y += memcpy.S +ramstage-y += memmove.S +ramstage-y += clock.c +ramstage-y += boot_linux.S +ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit_payload.c + +rmodules_arm-y += memset.S +rmodules_arm-y += memcpy.S +rmodules_arm-y += memmove.S +rmodules_arm-y += eabi_compat.c +ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c) + +$(objcbfs)/ramstage.debug: $$(ramstage-objs) + @printf " CC $(subst $(obj)/,,$(@))\n" + $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group + +endif # CONFIG_ARCH_RAMSTAGE_ARM diff --git a/src/arch/arm/armv4/Makefile.inc b/src/arch/arm/armv4/Makefile.inc deleted file mode 100644 index f4ccaf3f91..0000000000 --- a/src/arch/arm/armv4/Makefile.inc +++ /dev/null @@ -1,54 +0,0 @@ -## SPDX-License-Identifier: GPL-2.0-only - -armv4_flags = -marm -march=armv4t -I$(src)/arch/arm/include/armv4/ \ - -D__COREBOOT_ARM_ARCH__=4 - -############################################################################### -# bootblock -############################################################################### - -ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARMV4),y) - -ifneq ($(CONFIG_BOOTBLOCK_CUSTOM),y) -bootblock-y += bootblock.S -endif - -bootblock-y += cache.c - -bootblock-generic-ccopts += $(armv4_flags) - -endif # CONFIG_ARCH_BOOTBLOCK_ARMV4 - -################################################################################ -## Verstage -################################################################################ - -ifeq ($(CONFIG_ARCH_VERSTAGE_ARMV4),y) -verstage-generic-ccopts += $(armv4_flags) - -verstage-y += cache.c -endif # CONFIG_ARCH_VERSTAGE_ARMV4 - -############################################################################### -# romstage -############################################################################### - -ifeq ($(CONFIG_ARCH_ROMSTAGE_ARMV4),y) - - -romstage-generic-ccopts += $(armv4_flags) -romstage-y += cache.c - -rmodules_arm-generic-ccopts += $(armv4_flags) - -endif # CONFIG_ARCH_ROMSTAGE_ARMV4 - -############################################################################### -# ramstage -############################################################################### - -ifeq ($(CONFIG_ARCH_RAMSTAGE_ARMV4),y) - -ramstage-generic-ccopts += $(armv4_flags) - -endif # CONFIG_ARCH_RAMSTAGE_ARMV4 diff --git a/src/arch/arm/armv4/Makefile.mk b/src/arch/arm/armv4/Makefile.mk new file mode 100644 index 0000000000..f4ccaf3f91 --- /dev/null +++ b/src/arch/arm/armv4/Makefile.mk @@ -0,0 +1,54 @@ +## SPDX-License-Identifier: GPL-2.0-only + +armv4_flags = -marm -march=armv4t -I$(src)/arch/arm/include/armv4/ \ + -D__COREBOOT_ARM_ARCH__=4 + +############################################################################### +# bootblock +############################################################################### + +ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARMV4),y) + +ifneq ($(CONFIG_BOOTBLOCK_CUSTOM),y) +bootblock-y += bootblock.S +endif + +bootblock-y += cache.c + +bootblock-generic-ccopts += $(armv4_flags) + +endif # CONFIG_ARCH_BOOTBLOCK_ARMV4 + +################################################################################ +## Verstage +################################################################################ + +ifeq ($(CONFIG_ARCH_VERSTAGE_ARMV4),y) +verstage-generic-ccopts += $(armv4_flags) + +verstage-y += cache.c +endif # CONFIG_ARCH_VERSTAGE_ARMV4 + +############################################################################### +# romstage +############################################################################### + +ifeq ($(CONFIG_ARCH_ROMSTAGE_ARMV4),y) + + +romstage-generic-ccopts += $(armv4_flags) +romstage-y += cache.c + +rmodules_arm-generic-ccopts += $(armv4_flags) + +endif # CONFIG_ARCH_ROMSTAGE_ARMV4 + +############################################################################### +# ramstage +############################################################################### + +ifeq ($(CONFIG_ARCH_RAMSTAGE_ARMV4),y) + +ramstage-generic-ccopts += $(armv4_flags) + +endif # CONFIG_ARCH_RAMSTAGE_ARMV4 diff --git a/src/arch/arm/armv7/Makefile.inc b/src/arch/arm/armv7/Makefile.inc deleted file mode 100644 index 53261eee94..0000000000 --- a/src/arch/arm/armv7/Makefile.inc +++ /dev/null @@ -1,165 +0,0 @@ -## SPDX-License-Identifier: GPL-2.0-only - -armv7_flags = -mthumb -I$(src)/arch/arm/include/armv7/ -D__COREBOOT_ARM_ARCH__=7 -armv7-a_flags = -march=armv7-a $(armv7_flags) -D__COREBOOT_ARM_V7_A__ -armv7-m_flags = -march=armv7-m $(armv7_flags) -D__COREBOOT_ARM_V7_M__ -armv7-r_flags = -march=armv7-r $(armv7_flags) -D__COREBOOT_ARM_V7_R__ - -armv7_asm_flags = -Wa,-mthumb -Wa,-mimplicit-it=always -ifeq ($(CONFIG_COMPILER_GCC),y) -armv7_asm_flags += -Wa,-mno-warn-deprecated -else # CLANG -armv7_flags += -mfpu=none -bootblock-ld-ccopts += -target arm-eabi -verstage-ld-ccopts += -target arm-eabi -romstage-ld-ccopts += -target arm-eabi -ramstage-ld-ccopts += -target arm-eabi -rmodule_arm-ld-ccopts += -target arm-eabi -endif -armv7-r_asm_flags = $(armv7-r_flags) $(armv7_asm_flags) - -############################################################################### -# bootblock -############################################################################### - -ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARMV7),y) -decompressor-generic-ccopts += $(armv7-a_flags) -decompressor-S-ccopts += $(armv7_asm_flags) -bootblock-generic-ccopts += $(armv7-a_flags) -bootblock-S-ccopts += $(armv7_asm_flags) - -ifneq ($(CONFIG_BOOTBLOCK_CUSTOM),y) -decompressor-y += bootblock.S -ifneq ($(CONFIG_COMPRESS_BOOTBLOCK),y) -bootblock-y += bootblock.S -endif -endif - -decompressor-y += cache.c -bootblock-y += cache.c -decompressor-y += cpu.S -bootblock-y += cpu.S -decompressor-y += mmu.c -bootblock-y += mmu.c - -bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += exception.c -bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += exception_asm.S - -else ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARMV7_M),y) -bootblock-generic-ccopts += $(armv7-m_flags) -bootblock-S-ccopts += $(armv7_asm_flags) - -ifneq ($(CONFIG_BOOTBLOCK_CUSTOM),y) -bootblock-y += bootblock_m.S -endif -bootblock-y += exception_mr.c -bootblock-y += cache_m.c - -else ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARMV7_R),y) -bootblock-generic-ccopts += $(armv7-r_flags) -bootblock-S-ccopts += $(armv7-r_asm_flags) - -ifneq ($(CONFIG_BOOTBLOCK_CUSTOM),y) -bootblock-y += bootblock.S -endif - -bootblock-y += cache.c -bootblock-y += cpu.S -bootblock-y += exception_mr.c -bootblock-y += mmu.c - -endif # CONFIG_ARCH_BOOTBLOCK_ARMV7 - -################################################################################ -## verification stage -################################################################################ - -ifeq ($(CONFIG_ARCH_VERSTAGE_ARMV7),y) -verstage-generic-ccopts += $(armv7-a_flags) -verstage-S-ccopts += $(armv7_asm_flags) - -verstage-y += cache.c -verstage-y += cpu.S -verstage-y += exception.c -verstage-y += exception_asm.S -verstage-y += mmu.c - -else ifeq ($(CONFIG_ARCH_VERSTAGE_ARMV7_M),y) -verstage-generic-ccopts += $(armv7-m_flags) -verstage-S-ccopts += $(armv7_asm_flags) - -else ifeq ($(CONFIG_ARCH_VERSTAGE_ARMV7_R),y) -verstage-generic-ccopts += $(armv7-r_flags) -verstage-S-ccopts += $(armv7-r_asm_flags) - -verstage-y += cache.c -verstage-y += cpu.S -verstage-y += exception_mr.c -verstage-y += mmu.c - -endif # CONFIG_ARCH_VERSTAGE_ARMV7_M - -################################################################################ -## ROM stage -################################################################################ -ifeq ($(CONFIG_ARCH_ROMSTAGE_ARMV7),y) -romstage-y += cache.c -romstage-y += cpu.S -romstage-y += exception.c -romstage-y += exception_asm.S -romstage-y += mmu.c - -romstage-generic-ccopts += $(armv7-a_flags) -romstage-S-ccopts += $(armv7_asm_flags) - -rmodules_arm-generic-ccopts += $(armv7-a_flags) -rmodules_arm-S-ccopts += $(armv7_asm_flags) - -else ifeq ($(CONFIG_ARCH_ROMSTAGE_ARMV7_R),y) -romstage-y += cache.c -romstage-y += cpu.S -romstage-y += exception_mr.c -romstage-y += mmu.c - -romstage-generic-ccopts += $(armv7-r_flags) -romstage-S-ccopts += $(armv7-r_asm_flags) - -rmodules_arm-generic-ccopts += $(armv7-r_flags) -rmodules_arm-S-ccopts += $(armv7-r_asm_flags) - -endif # CONFIG_ARCH_ROMSTAGE_ARMV7 - -############################################################################### -# ramstage -############################################################################### - -ifeq ($(CONFIG_ARCH_RAMSTAGE_ARMV7),y) - -ramstage-y += cache.c -ramstage-y += cpu.S -ramstage-y += exception.c -ramstage-y += exception_asm.S -ramstage-y += mmu.c - -ramstage-generic-ccopts += $(armv7-a_flags) -ramstage-S-ccopts += $(armv7_asm_flags) - -# All rmodule code is armv7 if ramstage is armv7. -rmodules_arm-generic-ccopts += $(armv7-a_flags) -rmodules_arm-S-ccopts += $(armv7_asm_flags) - -else ifeq ($(CONFIG_ARCH_RAMSTAGE_ARMV7_R),y) - -ramstage-y += cache.c -ramstage-y += cpu.S -ramstage-y += exception_mr.c -ramstage-y += mmu.c - -ramstage-generic-ccopts += $(armv7-r_flags) -ramstage-S-ccopts += $(armv7-r_asm_flags) - -# All rmodule code is armv7 if ramstage is armv7. -rmodules_arm-generic-ccopts += $(armv7-r_flags) -rmodules_arm-S-ccopts += $(armv7-r_asm_flags) - -endif # CONFIG_ARCH_RAMSTAGE_ARMV7 diff --git a/src/arch/arm/armv7/Makefile.mk b/src/arch/arm/armv7/Makefile.mk new file mode 100644 index 0000000000..53261eee94 --- /dev/null +++ b/src/arch/arm/armv7/Makefile.mk @@ -0,0 +1,165 @@ +## SPDX-License-Identifier: GPL-2.0-only + +armv7_flags = -mthumb -I$(src)/arch/arm/include/armv7/ -D__COREBOOT_ARM_ARCH__=7 +armv7-a_flags = -march=armv7-a $(armv7_flags) -D__COREBOOT_ARM_V7_A__ +armv7-m_flags = -march=armv7-m $(armv7_flags) -D__COREBOOT_ARM_V7_M__ +armv7-r_flags = -march=armv7-r $(armv7_flags) -D__COREBOOT_ARM_V7_R__ + +armv7_asm_flags = -Wa,-mthumb -Wa,-mimplicit-it=always +ifeq ($(CONFIG_COMPILER_GCC),y) +armv7_asm_flags += -Wa,-mno-warn-deprecated +else # CLANG +armv7_flags += -mfpu=none +bootblock-ld-ccopts += -target arm-eabi +verstage-ld-ccopts += -target arm-eabi +romstage-ld-ccopts += -target arm-eabi +ramstage-ld-ccopts += -target arm-eabi +rmodule_arm-ld-ccopts += -target arm-eabi +endif +armv7-r_asm_flags = $(armv7-r_flags) $(armv7_asm_flags) + +############################################################################### +# bootblock +############################################################################### + +ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARMV7),y) +decompressor-generic-ccopts += $(armv7-a_flags) +decompressor-S-ccopts += $(armv7_asm_flags) +bootblock-generic-ccopts += $(armv7-a_flags) +bootblock-S-ccopts += $(armv7_asm_flags) + +ifneq ($(CONFIG_BOOTBLOCK_CUSTOM),y) +decompressor-y += bootblock.S +ifneq ($(CONFIG_COMPRESS_BOOTBLOCK),y) +bootblock-y += bootblock.S +endif +endif + +decompressor-y += cache.c +bootblock-y += cache.c +decompressor-y += cpu.S +bootblock-y += cpu.S +decompressor-y += mmu.c +bootblock-y += mmu.c + +bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += exception.c +bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += exception_asm.S + +else ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARMV7_M),y) +bootblock-generic-ccopts += $(armv7-m_flags) +bootblock-S-ccopts += $(armv7_asm_flags) + +ifneq ($(CONFIG_BOOTBLOCK_CUSTOM),y) +bootblock-y += bootblock_m.S +endif +bootblock-y += exception_mr.c +bootblock-y += cache_m.c + +else ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARMV7_R),y) +bootblock-generic-ccopts += $(armv7-r_flags) +bootblock-S-ccopts += $(armv7-r_asm_flags) + +ifneq ($(CONFIG_BOOTBLOCK_CUSTOM),y) +bootblock-y += bootblock.S +endif + +bootblock-y += cache.c +bootblock-y += cpu.S +bootblock-y += exception_mr.c +bootblock-y += mmu.c + +endif # CONFIG_ARCH_BOOTBLOCK_ARMV7 + +################################################################################ +## verification stage +################################################################################ + +ifeq ($(CONFIG_ARCH_VERSTAGE_ARMV7),y) +verstage-generic-ccopts += $(armv7-a_flags) +verstage-S-ccopts += $(armv7_asm_flags) + +verstage-y += cache.c +verstage-y += cpu.S +verstage-y += exception.c +verstage-y += exception_asm.S +verstage-y += mmu.c + +else ifeq ($(CONFIG_ARCH_VERSTAGE_ARMV7_M),y) +verstage-generic-ccopts += $(armv7-m_flags) +verstage-S-ccopts += $(armv7_asm_flags) + +else ifeq ($(CONFIG_ARCH_VERSTAGE_ARMV7_R),y) +verstage-generic-ccopts += $(armv7-r_flags) +verstage-S-ccopts += $(armv7-r_asm_flags) + +verstage-y += cache.c +verstage-y += cpu.S +verstage-y += exception_mr.c +verstage-y += mmu.c + +endif # CONFIG_ARCH_VERSTAGE_ARMV7_M + +################################################################################ +## ROM stage +################################################################################ +ifeq ($(CONFIG_ARCH_ROMSTAGE_ARMV7),y) +romstage-y += cache.c +romstage-y += cpu.S +romstage-y += exception.c +romstage-y += exception_asm.S +romstage-y += mmu.c + +romstage-generic-ccopts += $(armv7-a_flags) +romstage-S-ccopts += $(armv7_asm_flags) + +rmodules_arm-generic-ccopts += $(armv7-a_flags) +rmodules_arm-S-ccopts += $(armv7_asm_flags) + +else ifeq ($(CONFIG_ARCH_ROMSTAGE_ARMV7_R),y) +romstage-y += cache.c +romstage-y += cpu.S +romstage-y += exception_mr.c +romstage-y += mmu.c + +romstage-generic-ccopts += $(armv7-r_flags) +romstage-S-ccopts += $(armv7-r_asm_flags) + +rmodules_arm-generic-ccopts += $(armv7-r_flags) +rmodules_arm-S-ccopts += $(armv7-r_asm_flags) + +endif # CONFIG_ARCH_ROMSTAGE_ARMV7 + +############################################################################### +# ramstage +############################################################################### + +ifeq ($(CONFIG_ARCH_RAMSTAGE_ARMV7),y) + +ramstage-y += cache.c +ramstage-y += cpu.S +ramstage-y += exception.c +ramstage-y += exception_asm.S +ramstage-y += mmu.c + +ramstage-generic-ccopts += $(armv7-a_flags) +ramstage-S-ccopts += $(armv7_asm_flags) + +# All rmodule code is armv7 if ramstage is armv7. +rmodules_arm-generic-ccopts += $(armv7-a_flags) +rmodules_arm-S-ccopts += $(armv7_asm_flags) + +else ifeq ($(CONFIG_ARCH_RAMSTAGE_ARMV7_R),y) + +ramstage-y += cache.c +ramstage-y += cpu.S +ramstage-y += exception_mr.c +ramstage-y += mmu.c + +ramstage-generic-ccopts += $(armv7-r_flags) +ramstage-S-ccopts += $(armv7-r_asm_flags) + +# All rmodule code is armv7 if ramstage is armv7. +rmodules_arm-generic-ccopts += $(armv7-r_flags) +rmodules_arm-S-ccopts += $(armv7-r_asm_flags) + +endif # CONFIG_ARCH_RAMSTAGE_ARMV7 diff --git a/src/arch/arm/libgcc/Makefile.inc b/src/arch/arm/libgcc/Makefile.inc deleted file mode 100644 index c6ca45e24c..0000000000 --- a/src/arch/arm/libgcc/Makefile.inc +++ /dev/null @@ -1,21 +0,0 @@ -## SPDX-License-Identifier: GPL-2.0-only - -libgcc_files = ashldi3.S lib1funcs.S lshrdi3.S muldi3.S ucmpdi2.S uldivmod.S ldivmod.S -libgcc_files += udivmoddi4.c umoddi3.c - -ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARM),y) -decompressor-y += $(libgcc_files) -bootblock-y += $(libgcc_files) -endif - -ifeq ($(CONFIG_ARCH_VERSTAGE_ARM),y) -verstage-y += $(libgcc_files) -endif - -ifeq ($(CONFIG_ARCH_ROMSTAGE_ARM),y) -romstage-y += $(libgcc_files) -endif - -ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM),y) -ramstage-y += $(libgcc_files) -endif diff --git a/src/arch/arm/libgcc/Makefile.mk b/src/arch/arm/libgcc/Makefile.mk new file mode 100644 index 0000000000..c6ca45e24c --- /dev/null +++ b/src/arch/arm/libgcc/Makefile.mk @@ -0,0 +1,21 @@ +## SPDX-License-Identifier: GPL-2.0-only + +libgcc_files = ashldi3.S lib1funcs.S lshrdi3.S muldi3.S ucmpdi2.S uldivmod.S ldivmod.S +libgcc_files += udivmoddi4.c umoddi3.c + +ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARM),y) +decompressor-y += $(libgcc_files) +bootblock-y += $(libgcc_files) +endif + +ifeq ($(CONFIG_ARCH_VERSTAGE_ARM),y) +verstage-y += $(libgcc_files) +endif + +ifeq ($(CONFIG_ARCH_ROMSTAGE_ARM),y) +romstage-y += $(libgcc_files) +endif + +ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM),y) +ramstage-y += $(libgcc_files) +endif diff --git a/src/arch/arm64/Makefile.inc b/src/arch/arm64/Makefile.inc deleted file mode 100644 index 538d254ace..0000000000 --- a/src/arch/arm64/Makefile.inc +++ /dev/null @@ -1,218 +0,0 @@ -## SPDX-License-Identifier: GPL-2.0-only - -################################################################################ -# Take care of subdirectories -################################################################################ - -subdirs-y += armv8/ - -################################################################################ -# ARM specific options -################################################################################ - -ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM64),y) -check-ramstage-overlap-regions += postram_cbfs_cache stack ttb -endif - -################################################################################ -# bootblock -################################################################################ - -ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARM64),y) - -decompressor-y += boot.c -bootblock-y += boot.c -decompressor-y += div0.c -bootblock-y += div0.c -decompressor-y += eabi_compat.c -bootblock-y += eabi_compat.c - -decompressor-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c -bootblock-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c -bootblock-y += transition.c transition_asm.S - -decompressor-y += memset.S -bootblock-y += memset.S -decompressor-y += memcpy.S -bootblock-y += memcpy.S -decompressor-y += memmove.S -bootblock-y += memmove.S - -# Build the bootblock - -$(objcbfs)/bootblock.debug: $$(bootblock-objs) $(obj)/config.h - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) --end-group -T $(call src-to-obj,bootblock,$(CONFIG_MEMLAYOUT_LD_FILE)) - -$(objcbfs)/decompressor.debug: $$(decompressor-objs) $(obj)/config.h - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(decompressor-objs)) --end-group -T $(call src-to-obj,decompressor,$(CONFIG_MEMLAYOUT_LD_FILE)) - -endif # CONFIG_ARCH_BOOTBLOCK_ARM64 - -############################################################################### -# verification stage -############################################################################### - -ifeq ($(CONFIG_ARCH_VERSTAGE_ARM64),y) - -$(objcbfs)/verstage.debug: $$(verstage-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_verstage) $(LDFLAGS_verstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(verstage-objs)) --end-group -T $(call src-to-obj,verstage,$(CONFIG_MEMLAYOUT_LD_FILE)) - -verstage-y += boot.c -verstage-y += div0.c -verstage-y += eabi_compat.c -verstage-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c -verstage-y += memset.S -verstage-y += memcpy.S -verstage-y += memmove.S - -verstage-y += transition.c transition_asm.S - -endif # CONFIG_ARCH_VERSTAGE_ARM64 - -################################################################################ -# romstage -################################################################################ - -ifeq ($(CONFIG_ARCH_ROMSTAGE_ARM64),y) - -romstage-y += boot.c -romstage-y += div0.c -romstage-y += eabi_compat.c -romstage-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c -romstage-y += memset.S -romstage-y += memcpy.S -romstage-y += memmove.S -romstage-y += ramdetect.c -romstage-y += romstage.c -romstage-y += transition.c transition_asm.S - -rmodules_arm64-y += memset.S -rmodules_arm64-y += memcpy.S -rmodules_arm64-y += memmove.S -rmodules_arm64-y += eabi_compat.c - -$(objcbfs)/romstage.debug: $$(romstage-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group -T $(call src-to-obj,romstage,$(CONFIG_MEMLAYOUT_LD_FILE)) - -endif # CONFIG_ARCH_ROMSTAGE_ARM64 - -################################################################################ -# ramstage -################################################################################ - -ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM64),y) - -ramstage-y += div0.c -ramstage-y += eabi_compat.c -ramstage-y += boot.c -ramstage-y += tables.c -ramstage-y += ramdetect.c -ramstage-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c -ramstage-y += memset.S -ramstage-y += memcpy.S -ramstage-y += memmove.S -ramstage-$(CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE) += bl31.c -ramstage-y += transition.c transition_asm.S -ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit_payload.c -ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi.c - -rmodules_arm64-y += memset.S -rmodules_arm64-y += memcpy.S -rmodules_arm64-y += memmove.S -rmodules_arm64-y += eabi_compat.c -rmodules_arm64-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c - -ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c) - -# Build the ramstage - -$(objcbfs)/ramstage.debug: $$(ramstage-objs) - @printf " CC $(subst $(obj)/,,$(@))\n" - $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) - -# Build ARM Trusted Firmware (BL31) - -ifeq ($(CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE),y) - -ifeq ($(CONFIG_ARM64_BL31_EXTERNAL_FILE),"") - -BL31_SOURCE := $(top)/3rdparty/arm-trusted-firmware -BL31_BUILD := $(abspath $(obj)/3rdparty/arm-trusted-firmware) -BL31_TARGET := $(BL31_BUILD)/bl31/bl31.elf - -ifeq ($(V),1) -BL31_MAKEARGS += V=1 -endif - -# Build ARM TF in debug mode (with assertions) if coreboot has hard assertions -ifeq ($(CONFIG_FATAL_ASSERTS),y) -BL31_MAKEARGS += DEBUG=1 -endif # CONFIG_FATAL_ASSERTS - -# ARM TF's VERBOSE (50) is *very* spammy, so default to INFO (40) -BL31_MAKEARGS += LOG_LEVEL=40 - -# Always enable crash reporting, even on a release build -BL31_MAKEARGS += CRASH_REPORTING=1 - -# Enable coreboot-specific features like CBMEM console support -BL31_MAKEARGS += COREBOOT=1 - -# Avoid build/release|build/debug distinction by overriding BUILD_PLAT directly -BL31_MAKEARGS += BUILD_PLAT="$(BL31_BUILD)" - -# Force making .d files and output directories even though target is not 'bl31' -BL31_MAKEARGS += IS_ANYTHING_TO_BUILD=1 - -# Set a consistent build timestamp: the same coreboot has -BL31_MAKEARGS += BUILD_MESSAGE_TIMESTAMP='"$(shell sed -n 's/^.define COREBOOT_BUILD\>.*"\(.*\)".*/\1/p' $(obj)/build.h)"' - -BL31_CFLAGS := -fno-pic -fno-stack-protector -Wno-deprecated-declarations -Wno-unused-function -BL31_LDFLAGS := --emit-relocs - -BL31 := $(obj)/bl31.elf - -$(BL31): $(obj)/build.h - printf " MAKE $(subst $(obj)/,,$(@))\n" - +CROSS_COMPILE="$(CROSS_COMPILE_arm64)" \ - CFLAGS="$(BL31_CFLAGS)" \ - LDFLAGS="$(BL31_LDFLAGS)" \ - $(MAKE) -C $(BL31_SOURCE) $(BL31_MAKEARGS) $(BL31_TARGET) DISABLE_PEDANTIC=1 - mv $(BL31_TARGET) $@ - -.PHONY: $(BL31) - -else - -BL31 := $(call strip_quotes,$(CONFIG_ARM64_BL31_EXTERNAL_FILE)) - -endif # CONFIG_ARM64_BUILD_ARM_TRUSTED_FIRMWARE - - -BL31_CBFS := $(CONFIG_CBFS_PREFIX)/bl31 -$(BL31_CBFS)-file := $(BL31) -$(BL31_CBFS)-type := payload -$(BL31_CBFS)-compression := $(CBFS_COMPRESS_FLAG) -cbfs-files-y += $(BL31_CBFS) - -check-ramstage-overlap-files += $(BL31_CBFS) - -ifeq ($(CONFIG_ARM64_USE_SECURE_OS),y) - -SECURE_OS_FILE := $(CONFIG_ARM64_SECURE_OS_FILE) -SECURE_OS_FILE_CBFS := $(CONFIG_CBFS_PREFIX)/secure_os -$(SECURE_OS_FILE_CBFS)-file := $(SECURE_OS_FILE) -$(SECURE_OS_FILE_CBFS)-type := stage -cbfs-files-y += $(SECURE_OS_FILE_CBFS) - -check-ramstage-overlap-files += $(SECURE_OS_FILE_CBFS) - -endif # CONFIG_ARM64_USE_SECURE_OS - -endif # CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE - -endif # CONFIG_ARCH_RAMSTAGE_ARM64 diff --git a/src/arch/arm64/Makefile.mk b/src/arch/arm64/Makefile.mk new file mode 100644 index 0000000000..538d254ace --- /dev/null +++ b/src/arch/arm64/Makefile.mk @@ -0,0 +1,218 @@ +## SPDX-License-Identifier: GPL-2.0-only + +################################################################################ +# Take care of subdirectories +################################################################################ + +subdirs-y += armv8/ + +################################################################################ +# ARM specific options +################################################################################ + +ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM64),y) +check-ramstage-overlap-regions += postram_cbfs_cache stack ttb +endif + +################################################################################ +# bootblock +################################################################################ + +ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARM64),y) + +decompressor-y += boot.c +bootblock-y += boot.c +decompressor-y += div0.c +bootblock-y += div0.c +decompressor-y += eabi_compat.c +bootblock-y += eabi_compat.c + +decompressor-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c +bootblock-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c +bootblock-y += transition.c transition_asm.S + +decompressor-y += memset.S +bootblock-y += memset.S +decompressor-y += memcpy.S +bootblock-y += memcpy.S +decompressor-y += memmove.S +bootblock-y += memmove.S + +# Build the bootblock + +$(objcbfs)/bootblock.debug: $$(bootblock-objs) $(obj)/config.h + @printf " LINK $(subst $(obj)/,,$(@))\n" + $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) --end-group -T $(call src-to-obj,bootblock,$(CONFIG_MEMLAYOUT_LD_FILE)) + +$(objcbfs)/decompressor.debug: $$(decompressor-objs) $(obj)/config.h + @printf " LINK $(subst $(obj)/,,$(@))\n" + $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(decompressor-objs)) --end-group -T $(call src-to-obj,decompressor,$(CONFIG_MEMLAYOUT_LD_FILE)) + +endif # CONFIG_ARCH_BOOTBLOCK_ARM64 + +############################################################################### +# verification stage +############################################################################### + +ifeq ($(CONFIG_ARCH_VERSTAGE_ARM64),y) + +$(objcbfs)/verstage.debug: $$(verstage-objs) + @printf " LINK $(subst $(obj)/,,$(@))\n" + $(LD_verstage) $(LDFLAGS_verstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(verstage-objs)) --end-group -T $(call src-to-obj,verstage,$(CONFIG_MEMLAYOUT_LD_FILE)) + +verstage-y += boot.c +verstage-y += div0.c +verstage-y += eabi_compat.c +verstage-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c +verstage-y += memset.S +verstage-y += memcpy.S +verstage-y += memmove.S + +verstage-y += transition.c transition_asm.S + +endif # CONFIG_ARCH_VERSTAGE_ARM64 + +################################################################################ +# romstage +################################################################################ + +ifeq ($(CONFIG_ARCH_ROMSTAGE_ARM64),y) + +romstage-y += boot.c +romstage-y += div0.c +romstage-y += eabi_compat.c +romstage-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c +romstage-y += memset.S +romstage-y += memcpy.S +romstage-y += memmove.S +romstage-y += ramdetect.c +romstage-y += romstage.c +romstage-y += transition.c transition_asm.S + +rmodules_arm64-y += memset.S +rmodules_arm64-y += memcpy.S +rmodules_arm64-y += memmove.S +rmodules_arm64-y += eabi_compat.c + +$(objcbfs)/romstage.debug: $$(romstage-objs) + @printf " LINK $(subst $(obj)/,,$(@))\n" + $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group -T $(call src-to-obj,romstage,$(CONFIG_MEMLAYOUT_LD_FILE)) + +endif # CONFIG_ARCH_ROMSTAGE_ARM64 + +################################################################################ +# ramstage +################################################################################ + +ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM64),y) + +ramstage-y += div0.c +ramstage-y += eabi_compat.c +ramstage-y += boot.c +ramstage-y += tables.c +ramstage-y += ramdetect.c +ramstage-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c +ramstage-y += memset.S +ramstage-y += memcpy.S +ramstage-y += memmove.S +ramstage-$(CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE) += bl31.c +ramstage-y += transition.c transition_asm.S +ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit_payload.c +ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi.c + +rmodules_arm64-y += memset.S +rmodules_arm64-y += memcpy.S +rmodules_arm64-y += memmove.S +rmodules_arm64-y += eabi_compat.c +rmodules_arm64-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c + +ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c) + +# Build the ramstage + +$(objcbfs)/ramstage.debug: $$(ramstage-objs) + @printf " CC $(subst $(obj)/,,$(@))\n" + $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) + +# Build ARM Trusted Firmware (BL31) + +ifeq ($(CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE),y) + +ifeq ($(CONFIG_ARM64_BL31_EXTERNAL_FILE),"") + +BL31_SOURCE := $(top)/3rdparty/arm-trusted-firmware +BL31_BUILD := $(abspath $(obj)/3rdparty/arm-trusted-firmware) +BL31_TARGET := $(BL31_BUILD)/bl31/bl31.elf + +ifeq ($(V),1) +BL31_MAKEARGS += V=1 +endif + +# Build ARM TF in debug mode (with assertions) if coreboot has hard assertions +ifeq ($(CONFIG_FATAL_ASSERTS),y) +BL31_MAKEARGS += DEBUG=1 +endif # CONFIG_FATAL_ASSERTS + +# ARM TF's VERBOSE (50) is *very* spammy, so default to INFO (40) +BL31_MAKEARGS += LOG_LEVEL=40 + +# Always enable crash reporting, even on a release build +BL31_MAKEARGS += CRASH_REPORTING=1 + +# Enable coreboot-specific features like CBMEM console support +BL31_MAKEARGS += COREBOOT=1 + +# Avoid build/release|build/debug distinction by overriding BUILD_PLAT directly +BL31_MAKEARGS += BUILD_PLAT="$(BL31_BUILD)" + +# Force making .d files and output directories even though target is not 'bl31' +BL31_MAKEARGS += IS_ANYTHING_TO_BUILD=1 + +# Set a consistent build timestamp: the same coreboot has +BL31_MAKEARGS += BUILD_MESSAGE_TIMESTAMP='"$(shell sed -n 's/^.define COREBOOT_BUILD\>.*"\(.*\)".*/\1/p' $(obj)/build.h)"' + +BL31_CFLAGS := -fno-pic -fno-stack-protector -Wno-deprecated-declarations -Wno-unused-function +BL31_LDFLAGS := --emit-relocs + +BL31 := $(obj)/bl31.elf + +$(BL31): $(obj)/build.h + printf " MAKE $(subst $(obj)/,,$(@))\n" + +CROSS_COMPILE="$(CROSS_COMPILE_arm64)" \ + CFLAGS="$(BL31_CFLAGS)" \ + LDFLAGS="$(BL31_LDFLAGS)" \ + $(MAKE) -C $(BL31_SOURCE) $(BL31_MAKEARGS) $(BL31_TARGET) DISABLE_PEDANTIC=1 + mv $(BL31_TARGET) $@ + +.PHONY: $(BL31) + +else + +BL31 := $(call strip_quotes,$(CONFIG_ARM64_BL31_EXTERNAL_FILE)) + +endif # CONFIG_ARM64_BUILD_ARM_TRUSTED_FIRMWARE + + +BL31_CBFS := $(CONFIG_CBFS_PREFIX)/bl31 +$(BL31_CBFS)-file := $(BL31) +$(BL31_CBFS)-type := payload +$(BL31_CBFS)-compression := $(CBFS_COMPRESS_FLAG) +cbfs-files-y += $(BL31_CBFS) + +check-ramstage-overlap-files += $(BL31_CBFS) + +ifeq ($(CONFIG_ARM64_USE_SECURE_OS),y) + +SECURE_OS_FILE := $(CONFIG_ARM64_SECURE_OS_FILE) +SECURE_OS_FILE_CBFS := $(CONFIG_CBFS_PREFIX)/secure_os +$(SECURE_OS_FILE_CBFS)-file := $(SECURE_OS_FILE) +$(SECURE_OS_FILE_CBFS)-type := stage +cbfs-files-y += $(SECURE_OS_FILE_CBFS) + +check-ramstage-overlap-files += $(SECURE_OS_FILE_CBFS) + +endif # CONFIG_ARM64_USE_SECURE_OS + +endif # CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE + +endif # CONFIG_ARCH_RAMSTAGE_ARM64 diff --git a/src/arch/arm64/armv8/Makefile.inc b/src/arch/arm64/armv8/Makefile.inc deleted file mode 100644 index 61961ff3d2..0000000000 --- a/src/arch/arm64/armv8/Makefile.inc +++ /dev/null @@ -1,102 +0,0 @@ -## SPDX-License-Identifier: GPL-2.0-only - -ifeq ($(CONFIG_ARCH_ARMV8_EXTENSION),0) -march = armv8-a -else -march = armv8.$(CONFIG_ARCH_ARMV8_EXTENSION)-a -endif - -armv8_flags = -march=$(march) -I$(src)/arch/arm64/include/armv8/ -D__COREBOOT_ARM_ARCH__=8 - -################################################################################ -## bootblock -################################################################################ -ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARMV8_64),y) - -ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) -decompressor-ld-ccopts += -target arm64-elf -bootblock-ld-ccopts += -target arm64-elf -endif - -ifneq ($(CONFIG_BOOTBLOCK_CUSTOM),y) -decompressor-y += bootblock.S -ifneq ($(CONFIG_COMPRESS_BOOTBLOCK),y) -bootblock-y += bootblock.S -endif -endif -decompressor-y += cpu.S -bootblock-y += cpu.S -decompressor-y += cache.c -bootblock-y += cache.c -decompressor-y += mmu.c -bootblock-y += mmu.c - -bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += exception.c - -decompressor-generic-ccopts += $(armv8_flags) -bootblock-generic-ccopts += $(armv8_flags) - -# Required to access unaligned timestamp struct members before MMU is active -# (TODO: Maybe use explicit unaligned accesses in timestamp code instead, or -# evaluate redesigning timestamp data structures to avoid misaligned members.) -decompressor-c-ccopts += -mstrict-align -bootblock-c-ccopts += -mstrict-align - -endif - -################################################################################ -## verstage -################################################################################ -ifeq ($(CONFIG_ARCH_VERSTAGE_ARMV8_64),y) - -ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) -verstage-ld-ccopts += -target arm64-elf -endif - -verstage-y += cache.c -verstage-y += cpu.S -verstage-y += exception.c - -verstage-generic-ccopts += $(armv8_flags) - -endif - -################################################################################ -## romstage -################################################################################ -ifeq ($(CONFIG_ARCH_ROMSTAGE_ARMV8_64),y) - -ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) -romstage-ld-ccopts += -target arm64-elf -endif - -romstage-y += cache.c -romstage-y += cpu.S -romstage-y += exception.c -romstage-y += mmu.c - -romstage-generic-ccopts += $(armv8_flags) - -rmodules_arm64-generic-ccopts += $(armv8_flags) - -endif - -################################################################################ -## ramstage -################################################################################ -ifeq ($(CONFIG_ARCH_RAMSTAGE_ARMV8_64),y) - -ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) -ramstage-ld-ccopts += -target arm64-elf -endif - -ramstage-y += cache.c -ramstage-y += cpu.S -ramstage-y += exception.c -ramstage-y += mmu.c - -ramstage-generic-ccopts += $(armv8_flags) - -rmodules_arm64-generic-ccopts += $(armv8_flags) - -endif diff --git a/src/arch/arm64/armv8/Makefile.mk b/src/arch/arm64/armv8/Makefile.mk new file mode 100644 index 0000000000..61961ff3d2 --- /dev/null +++ b/src/arch/arm64/armv8/Makefile.mk @@ -0,0 +1,102 @@ +## SPDX-License-Identifier: GPL-2.0-only + +ifeq ($(CONFIG_ARCH_ARMV8_EXTENSION),0) +march = armv8-a +else +march = armv8.$(CONFIG_ARCH_ARMV8_EXTENSION)-a +endif + +armv8_flags = -march=$(march) -I$(src)/arch/arm64/include/armv8/ -D__COREBOOT_ARM_ARCH__=8 + +################################################################################ +## bootblock +################################################################################ +ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARMV8_64),y) + +ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) +decompressor-ld-ccopts += -target arm64-elf +bootblock-ld-ccopts += -target arm64-elf +endif + +ifneq ($(CONFIG_BOOTBLOCK_CUSTOM),y) +decompressor-y += bootblock.S +ifneq ($(CONFIG_COMPRESS_BOOTBLOCK),y) +bootblock-y += bootblock.S +endif +endif +decompressor-y += cpu.S +bootblock-y += cpu.S +decompressor-y += cache.c +bootblock-y += cache.c +decompressor-y += mmu.c +bootblock-y += mmu.c + +bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += exception.c + +decompressor-generic-ccopts += $(armv8_flags) +bootblock-generic-ccopts += $(armv8_flags) + +# Required to access unaligned timestamp struct members before MMU is active +# (TODO: Maybe use explicit unaligned accesses in timestamp code instead, or +# evaluate redesigning timestamp data structures to avoid misaligned members.) +decompressor-c-ccopts += -mstrict-align +bootblock-c-ccopts += -mstrict-align + +endif + +################################################################################ +## verstage +################################################################################ +ifeq ($(CONFIG_ARCH_VERSTAGE_ARMV8_64),y) + +ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) +verstage-ld-ccopts += -target arm64-elf +endif + +verstage-y += cache.c +verstage-y += cpu.S +verstage-y += exception.c + +verstage-generic-ccopts += $(armv8_flags) + +endif + +################################################################################ +## romstage +################################################################################ +ifeq ($(CONFIG_ARCH_ROMSTAGE_ARMV8_64),y) + +ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) +romstage-ld-ccopts += -target arm64-elf +endif + +romstage-y += cache.c +romstage-y += cpu.S +romstage-y += exception.c +romstage-y += mmu.c + +romstage-generic-ccopts += $(armv8_flags) + +rmodules_arm64-generic-ccopts += $(armv8_flags) + +endif + +################################################################################ +## ramstage +################################################################################ +ifeq ($(CONFIG_ARCH_RAMSTAGE_ARMV8_64),y) + +ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) +ramstage-ld-ccopts += -target arm64-elf +endif + +ramstage-y += cache.c +ramstage-y += cpu.S +ramstage-y += exception.c +ramstage-y += mmu.c + +ramstage-generic-ccopts += $(armv8_flags) + +rmodules_arm64-generic-ccopts += $(armv8_flags) + +endif diff --git a/src/arch/ppc64/Makefile.inc b/src/arch/ppc64/Makefile.inc deleted file mode 100644 index 92b1e399d6..0000000000 --- a/src/arch/ppc64/Makefile.inc +++ /dev/null @@ -1,91 +0,0 @@ -## SPDX-License-Identifier: GPL-2.0-only - -ppc64_flags = -I$(src)/arch/ppc64/ -mbig-endian -mcpu=power8 -mtune=power8 - -ppc64_asm_flags = - -################################################################################ -## bootblock -################################################################################ -ifeq ($(CONFIG_ARCH_BOOTBLOCK_PPC64),y) - -bootblock-y = bootblock_crt0.S -bootblock-y += arch_timer.c -bootblock-y += boot.c -bootblock-y += \ - $(top)/src/lib/memchr.c \ - $(top)/src/lib/memcmp.c \ - $(top)/src/lib/memcpy.c \ - $(top)/src/lib/memmove.c \ - $(top)/src/lib/memset.c - -bootblock-generic-ccopts += $(ppc64_flags) - -$(objcbfs)/bootblock.debug: $$(bootblock-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) \ - -T $(call src-to-obj,bootblock,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) \ - $(LIBGCC_FILE_NAME_bootblock) --end-group $(COMPILER_RT_bootblock) - -endif - -################################################################################ -## romstage -################################################################################ -ifeq ($(CONFIG_ARCH_ROMSTAGE_PPC64),y) - -romstage-y += arch_timer.c -romstage-y += boot.c -romstage-y += stages.c -romstage-y += \ - $(top)/src/lib/memchr.c \ - $(top)/src/lib/memcmp.c \ - $(top)/src/lib/memcpy.c \ - $(top)/src/lib/memmove.c \ - $(top)/src/lib/memset.c - -romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c - -# Build the romstage - -$(objcbfs)/romstage.debug: $$(romstage-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) -T $(call src-to-obj,romstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group $(COMPILER_RT_romstage) - -romstage-c-ccopts += $(ppc64_flags) -romstage-S-ccopts += $(ppc64_asm_flags) - -endif - -################################################################################ -## ramstage -################################################################################ -ifeq ($(CONFIG_ARCH_RAMSTAGE_PPC64),y) - -ramstage-y += stages.c -ramstage-y += arch_timer.c -ramstage-y += boot.c -ramstage-y += tables.c -ramstage-y += \ - $(top)/src/lib/memchr.c \ - $(top)/src/lib/memcmp.c \ - $(top)/src/lib/memcpy.c \ - $(top)/src/lib/memmove.c \ - $(top)/src/lib/memset.c - -$(eval $(call create_class_compiler,rmodules,power8)) - -ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c - -ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mainboard.c - -# Build the ramstage - -$(objcbfs)/ramstage.debug: $$(ramstage-objs) - @printf " CC $(subst $(obj)/,,$(@))\n" - $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group $(COMPILER_RT_ramstage) - -ramstage-c-ccopts += $(ppc64_flags) -ramstage-S-ccopts += $(ppc64_asm_flags) - -endif diff --git a/src/arch/ppc64/Makefile.mk b/src/arch/ppc64/Makefile.mk new file mode 100644 index 0000000000..92b1e399d6 --- /dev/null +++ b/src/arch/ppc64/Makefile.mk @@ -0,0 +1,91 @@ +## SPDX-License-Identifier: GPL-2.0-only + +ppc64_flags = -I$(src)/arch/ppc64/ -mbig-endian -mcpu=power8 -mtune=power8 + +ppc64_asm_flags = + +################################################################################ +## bootblock +################################################################################ +ifeq ($(CONFIG_ARCH_BOOTBLOCK_PPC64),y) + +bootblock-y = bootblock_crt0.S +bootblock-y += arch_timer.c +bootblock-y += boot.c +bootblock-y += \ + $(top)/src/lib/memchr.c \ + $(top)/src/lib/memcmp.c \ + $(top)/src/lib/memcpy.c \ + $(top)/src/lib/memmove.c \ + $(top)/src/lib/memset.c + +bootblock-generic-ccopts += $(ppc64_flags) + +$(objcbfs)/bootblock.debug: $$(bootblock-objs) + @printf " LINK $(subst $(obj)/,,$(@))\n" + $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) \ + -T $(call src-to-obj,bootblock,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) \ + $(LIBGCC_FILE_NAME_bootblock) --end-group $(COMPILER_RT_bootblock) + +endif + +################################################################################ +## romstage +################################################################################ +ifeq ($(CONFIG_ARCH_ROMSTAGE_PPC64),y) + +romstage-y += arch_timer.c +romstage-y += boot.c +romstage-y += stages.c +romstage-y += \ + $(top)/src/lib/memchr.c \ + $(top)/src/lib/memcmp.c \ + $(top)/src/lib/memcpy.c \ + $(top)/src/lib/memmove.c \ + $(top)/src/lib/memset.c + +romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c + +# Build the romstage + +$(objcbfs)/romstage.debug: $$(romstage-objs) + @printf " LINK $(subst $(obj)/,,$(@))\n" + $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) -T $(call src-to-obj,romstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group $(COMPILER_RT_romstage) + +romstage-c-ccopts += $(ppc64_flags) +romstage-S-ccopts += $(ppc64_asm_flags) + +endif + +################################################################################ +## ramstage +################################################################################ +ifeq ($(CONFIG_ARCH_RAMSTAGE_PPC64),y) + +ramstage-y += stages.c +ramstage-y += arch_timer.c +ramstage-y += boot.c +ramstage-y += tables.c +ramstage-y += \ + $(top)/src/lib/memchr.c \ + $(top)/src/lib/memcmp.c \ + $(top)/src/lib/memcpy.c \ + $(top)/src/lib/memmove.c \ + $(top)/src/lib/memset.c + +$(eval $(call create_class_compiler,rmodules,power8)) + +ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c + +ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mainboard.c + +# Build the ramstage + +$(objcbfs)/ramstage.debug: $$(ramstage-objs) + @printf " CC $(subst $(obj)/,,$(@))\n" + $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group $(COMPILER_RT_ramstage) + +ramstage-c-ccopts += $(ppc64_flags) +ramstage-S-ccopts += $(ppc64_asm_flags) + +endif diff --git a/src/arch/riscv/Makefile.inc b/src/arch/riscv/Makefile.inc deleted file mode 100644 index bbd39590d2..0000000000 --- a/src/arch/riscv/Makefile.inc +++ /dev/null @@ -1,188 +0,0 @@ -## SPDX-License-Identifier: GPL-2.0-only - -################################################################################ -## RISC-V specific options -################################################################################ -ifeq ($(CONFIG_ARCH_RISCV),y) - -ifeq ($(CONFIG_ARCH_RAMSTAGE_RISCV),y) -check-ramstage-overlap-regions += stack -endif - -riscv_flags = -I$(src)/arch/riscv/ - -ifeq ($(CONFIG_ARCH_RISCV_RV64),y) -_rv_flags += -D__riscv -D__riscv_xlen=64 -D__riscv_flen=64 -else -ifeq ($(CONFIG_ARCH_RISCV_RV32),y) -_rv_flags += -D__riscv -D__riscv_xlen=32 -D__riscv_flen=32 -else -$(error "You need to select ARCH_RISCV_RV64 or ARCH_RISCV_RV32") -endif -endif - -# Needed for -print-libgcc-file-name which gets confused about all those arch -# suffixes in ARCH_SUFFIX_riscv. -simple_riscv_flags = $(riscv_flags) - -ifeq ($(CONFIG_COMPILER_GCC),y) -MARCH_SUFFIX=$(ARCH_SUFFIX_riscv) -else -MARCH_SUFFIX= -endif - -ifeq ($(CCC_ANALYZER_OUTPUT_FORMAT),) -riscv_flags += -march=$(CONFIG_RISCV_ARCH)$(MARCH_SUFFIX) -mabi=$(CONFIG_RISCV_ABI) -mcmodel=$(CONFIG_RISCV_CODEMODEL) -simple_riscv_flags += -march=$(CONFIG_RISCV_ARCH) -mabi=$(CONFIG_RISCV_ABI) -mcmodel=$(CONFIG_RISCV_CODEMODEL) -else -riscv_flags += $(_rv_flags) -simple_riscv_flags += $(_rv_flags) -endif - -riscv_asm_flags = -march=$(CONFIG_RISCV_ARCH)$(MARCH_SUFFIX) -mabi=$(CONFIG_RISCV_ABI) - -COMPILER_RT_bootblock = $(shell $(GCC_bootblock) $(simple_riscv_flags) -print-libgcc-file-name) - -COMPILER_RT_romstage = $(shell $(GCC_romstage) $(simple_riscv_flags) -print-libgcc-file-name) - -COMPILER_RT_ramstage = $(shell $(GCC_ramstage) $(simple_riscv_flags) -print-libgcc-file-name) - -## All stages - -all-y += trap_util.S -all-y += trap_handler.c -all-y += fp_asm.S -all-y += misaligned.c -all-y += sbi.c -all-y += mcall.c -all-y += virtual_memory.c -all-y += boot.c -all-y += smp.c -all-y += misc.c -all-$(ARCH_RISCV_PMP) += pmp.c -all-y += \ - $(top)/src/lib/memchr.c \ - $(top)/src/lib/memcmp.c \ - $(top)/src/lib/memcpy.c \ - $(top)/src/lib/memmove.c \ - $(top)/src/lib/memset.c -all-$(CONFIG_RISCV_USE_ARCH_TIMER) += arch_timer.c - - -################################################################################ -## bootblock -################################################################################ -ifeq ($(CONFIG_ARCH_BOOTBLOCK_RISCV),y) - -bootblock-y = bootblock.S - -$(objcbfs)/bootblock.debug: $$(bootblock-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) \ - -T $(call src-to-obj,bootblock,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) \ - $(LIBGCC_FILE_NAME_bootblock) --end-group $(COMPILER_RT_bootblock) - -bootblock-c-ccopts += $(riscv_flags) -bootblock-S-ccopts += $(riscv_asm_flags) - -ifeq ($(CONFIG_ARCH_RISCV_RV32),y) -LDFLAGS_bootblock += -m elf32lriscv -endif #CONFIG_ARCH_RISCV_RV32 - -endif #CONFIG_ARCH_BOOTBLOCK_RISCV - -################################################################################ -## romstage -################################################################################ -ifeq ($(CONFIG_ARCH_ROMSTAGE_RISCV),y) - -romstage-y += romstage.S - -# Build the romstage - -$(objcbfs)/romstage.debug: $$(romstage-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) -T $(call src-to-obj,romstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group $(COMPILER_RT_romstage) - -romstage-c-ccopts += $(riscv_flags) -romstage-S-ccopts += $(riscv_asm_flags) - -ifeq ($(CONFIG_ARCH_RISCV_RV32),y) -LDFLAGS_romstage += -m elf32lriscv -endif #CONFIG_ARCH_RISCV_RV32 - -endif #CONFIG_ARCH_ROMSTAGE_RISCV - -################################################################################ -## ramstage -################################################################################ -ifeq ($(CONFIG_ARCH_RAMSTAGE_RISCV),y) - -ramstage-y = -ramstage-y += ramstage.S -ramstage-y += tables.c -ramstage-y += payload.c -ramstage-y += fit_payload.c - -$(eval $(call create_class_compiler,rmodules,riscv)) - -ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mainboard.c - -# Build the ramstage - -$(objcbfs)/ramstage.debug: $$(ramstage-objs) - @printf " CC $(subst $(obj)/,,$(@))\n" - $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group $(COMPILER_RT_ramstage) - -ramstage-c-ccopts += $(riscv_flags) -ramstage-S-ccopts += $(riscv_asm_flags) - -ifeq ($(CONFIG_ARCH_RISCV_RV32),y) -LDFLAGS_ramstage += -m elf32lriscv -endif #CONFIG_ARCH_RISCV_RV32 - -endif #CONFIG_ARCH_RAMSTAGE_RISCV - -ifeq ($(CONFIG_RISCV_OPENSBI),y) - -OPENSBI_SOURCE := $(top)/3rdparty/opensbi -OPENSBI_BUILD := $(abspath $(obj)/3rdparty/opensbi) -OPENSBI_TARGET := $(OPENSBI_BUILD)/platform/$(CONFIG_OPENSBI_PLATFORM)/firmware/fw_dynamic.elf -OPENSBI := $(obj)/opensbi.elf - -# TODO: Building with clang has troubles finding the proper linker. -# Always use GCC for now. -$(OPENSBI_TARGET): $(obj)/config.h | $(OPENSBI_SOURCE) - printf " MAKE $(subst $(obj)/,,$(@))\n" - mkdir -p $(OPENSBI_BUILD) - $(MAKE) \ - -C "$(OPENSBI_SOURCE)" \ - CC="$(GCC_ramstage) -fno-builtin" \ - LD="$(LD_ramstage)" \ - OBJCOPY="$(OBJCOPY_ramstage)" \ - AR="$(AR_ramstage)" \ - PLATFORM=$(CONFIG_OPENSBI_PLATFORM) \ - O="$(OPENSBI_BUILD)" \ - FW_JUMP=y \ - FW_DYNAMIC=y \ - FW_PAYLOAD=n \ - FW_PAYLOAD_OFFSET=0 \ - FW_TEXT_START=$(CONFIG_OPENSBI_TEXT_START) - -$(OPENSBI): $(OPENSBI_TARGET) - cp $< $@ - -OPENSBI_CBFS := $(CONFIG_CBFS_PREFIX)/opensbi -$(OPENSBI_CBFS)-file := $(OPENSBI) -$(OPENSBI_CBFS)-type := payload -$(OPENSBI_CBFS)-compression := $(CBFS_COMPRESS_FLAG) -cbfs-files-y += $(OPENSBI_CBFS) - -check-ramstage-overlap-files += $(OPENSBI_CBFS) - -CPPFLAGS_common += -I$(OPENSBI_SOURCE)/include -ramstage-y += opensbi.c - -endif #CONFIG_RISCV_OPENSBI - -endif #CONFIG_ARCH_RISCV diff --git a/src/arch/riscv/Makefile.mk b/src/arch/riscv/Makefile.mk new file mode 100644 index 0000000000..bbd39590d2 --- /dev/null +++ b/src/arch/riscv/Makefile.mk @@ -0,0 +1,188 @@ +## SPDX-License-Identifier: GPL-2.0-only + +################################################################################ +## RISC-V specific options +################################################################################ +ifeq ($(CONFIG_ARCH_RISCV),y) + +ifeq ($(CONFIG_ARCH_RAMSTAGE_RISCV),y) +check-ramstage-overlap-regions += stack +endif + +riscv_flags = -I$(src)/arch/riscv/ + +ifeq ($(CONFIG_ARCH_RISCV_RV64),y) +_rv_flags += -D__riscv -D__riscv_xlen=64 -D__riscv_flen=64 +else +ifeq ($(CONFIG_ARCH_RISCV_RV32),y) +_rv_flags += -D__riscv -D__riscv_xlen=32 -D__riscv_flen=32 +else +$(error "You need to select ARCH_RISCV_RV64 or ARCH_RISCV_RV32") +endif +endif + +# Needed for -print-libgcc-file-name which gets confused about all those arch +# suffixes in ARCH_SUFFIX_riscv. +simple_riscv_flags = $(riscv_flags) + +ifeq ($(CONFIG_COMPILER_GCC),y) +MARCH_SUFFIX=$(ARCH_SUFFIX_riscv) +else +MARCH_SUFFIX= +endif + +ifeq ($(CCC_ANALYZER_OUTPUT_FORMAT),) +riscv_flags += -march=$(CONFIG_RISCV_ARCH)$(MARCH_SUFFIX) -mabi=$(CONFIG_RISCV_ABI) -mcmodel=$(CONFIG_RISCV_CODEMODEL) +simple_riscv_flags += -march=$(CONFIG_RISCV_ARCH) -mabi=$(CONFIG_RISCV_ABI) -mcmodel=$(CONFIG_RISCV_CODEMODEL) +else +riscv_flags += $(_rv_flags) +simple_riscv_flags += $(_rv_flags) +endif + +riscv_asm_flags = -march=$(CONFIG_RISCV_ARCH)$(MARCH_SUFFIX) -mabi=$(CONFIG_RISCV_ABI) + +COMPILER_RT_bootblock = $(shell $(GCC_bootblock) $(simple_riscv_flags) -print-libgcc-file-name) + +COMPILER_RT_romstage = $(shell $(GCC_romstage) $(simple_riscv_flags) -print-libgcc-file-name) + +COMPILER_RT_ramstage = $(shell $(GCC_ramstage) $(simple_riscv_flags) -print-libgcc-file-name) + +## All stages + +all-y += trap_util.S +all-y += trap_handler.c +all-y += fp_asm.S +all-y += misaligned.c +all-y += sbi.c +all-y += mcall.c +all-y += virtual_memory.c +all-y += boot.c +all-y += smp.c +all-y += misc.c +all-$(ARCH_RISCV_PMP) += pmp.c +all-y += \ + $(top)/src/lib/memchr.c \ + $(top)/src/lib/memcmp.c \ + $(top)/src/lib/memcpy.c \ + $(top)/src/lib/memmove.c \ + $(top)/src/lib/memset.c +all-$(CONFIG_RISCV_USE_ARCH_TIMER) += arch_timer.c + + +################################################################################ +## bootblock +################################################################################ +ifeq ($(CONFIG_ARCH_BOOTBLOCK_RISCV),y) + +bootblock-y = bootblock.S + +$(objcbfs)/bootblock.debug: $$(bootblock-objs) + @printf " LINK $(subst $(obj)/,,$(@))\n" + $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) \ + -T $(call src-to-obj,bootblock,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) \ + $(LIBGCC_FILE_NAME_bootblock) --end-group $(COMPILER_RT_bootblock) + +bootblock-c-ccopts += $(riscv_flags) +bootblock-S-ccopts += $(riscv_asm_flags) + +ifeq ($(CONFIG_ARCH_RISCV_RV32),y) +LDFLAGS_bootblock += -m elf32lriscv +endif #CONFIG_ARCH_RISCV_RV32 + +endif #CONFIG_ARCH_BOOTBLOCK_RISCV + +################################################################################ +## romstage +################################################################################ +ifeq ($(CONFIG_ARCH_ROMSTAGE_RISCV),y) + +romstage-y += romstage.S + +# Build the romstage + +$(objcbfs)/romstage.debug: $$(romstage-objs) + @printf " LINK $(subst $(obj)/,,$(@))\n" + $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) -T $(call src-to-obj,romstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group $(COMPILER_RT_romstage) + +romstage-c-ccopts += $(riscv_flags) +romstage-S-ccopts += $(riscv_asm_flags) + +ifeq ($(CONFIG_ARCH_RISCV_RV32),y) +LDFLAGS_romstage += -m elf32lriscv +endif #CONFIG_ARCH_RISCV_RV32 + +endif #CONFIG_ARCH_ROMSTAGE_RISCV + +################################################################################ +## ramstage +################################################################################ +ifeq ($(CONFIG_ARCH_RAMSTAGE_RISCV),y) + +ramstage-y = +ramstage-y += ramstage.S +ramstage-y += tables.c +ramstage-y += payload.c +ramstage-y += fit_payload.c + +$(eval $(call create_class_compiler,rmodules,riscv)) + +ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mainboard.c + +# Build the ramstage + +$(objcbfs)/ramstage.debug: $$(ramstage-objs) + @printf " CC $(subst $(obj)/,,$(@))\n" + $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group $(COMPILER_RT_ramstage) + +ramstage-c-ccopts += $(riscv_flags) +ramstage-S-ccopts += $(riscv_asm_flags) + +ifeq ($(CONFIG_ARCH_RISCV_RV32),y) +LDFLAGS_ramstage += -m elf32lriscv +endif #CONFIG_ARCH_RISCV_RV32 + +endif #CONFIG_ARCH_RAMSTAGE_RISCV + +ifeq ($(CONFIG_RISCV_OPENSBI),y) + +OPENSBI_SOURCE := $(top)/3rdparty/opensbi +OPENSBI_BUILD := $(abspath $(obj)/3rdparty/opensbi) +OPENSBI_TARGET := $(OPENSBI_BUILD)/platform/$(CONFIG_OPENSBI_PLATFORM)/firmware/fw_dynamic.elf +OPENSBI := $(obj)/opensbi.elf + +# TODO: Building with clang has troubles finding the proper linker. +# Always use GCC for now. +$(OPENSBI_TARGET): $(obj)/config.h | $(OPENSBI_SOURCE) + printf " MAKE $(subst $(obj)/,,$(@))\n" + mkdir -p $(OPENSBI_BUILD) + $(MAKE) \ + -C "$(OPENSBI_SOURCE)" \ + CC="$(GCC_ramstage) -fno-builtin" \ + LD="$(LD_ramstage)" \ + OBJCOPY="$(OBJCOPY_ramstage)" \ + AR="$(AR_ramstage)" \ + PLATFORM=$(CONFIG_OPENSBI_PLATFORM) \ + O="$(OPENSBI_BUILD)" \ + FW_JUMP=y \ + FW_DYNAMIC=y \ + FW_PAYLOAD=n \ + FW_PAYLOAD_OFFSET=0 \ + FW_TEXT_START=$(CONFIG_OPENSBI_TEXT_START) + +$(OPENSBI): $(OPENSBI_TARGET) + cp $< $@ + +OPENSBI_CBFS := $(CONFIG_CBFS_PREFIX)/opensbi +$(OPENSBI_CBFS)-file := $(OPENSBI) +$(OPENSBI_CBFS)-type := payload +$(OPENSBI_CBFS)-compression := $(CBFS_COMPRESS_FLAG) +cbfs-files-y += $(OPENSBI_CBFS) + +check-ramstage-overlap-files += $(OPENSBI_CBFS) + +CPPFLAGS_common += -I$(OPENSBI_SOURCE)/include +ramstage-y += opensbi.c + +endif #CONFIG_RISCV_OPENSBI + +endif #CONFIG_ARCH_RISCV diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc deleted file mode 100644 index 04a0e58dbf..0000000000 --- a/src/arch/x86/Makefile.inc +++ /dev/null @@ -1,343 +0,0 @@ -## SPDX-License-Identifier: GPL-2.0-only - -ifeq ($(CONFIG_POSTCAR_STAGE),y) -$(eval $(call init_standard_toolchain,postcar)) -endif - -################################################################################ -# i386 specific tools -NVRAMTOOL:=$(objutil)/nvramtool/nvramtool - -OPTION_TABLE_H:= -ifeq ($(CONFIG_HAVE_OPTION_TABLE),y) - -CMOS_LAYOUT_FILE := $(top)/$(call strip_quotes,$(CONFIG_CMOS_LAYOUT_FILE)) - -cbfs-files-y += cmos_layout.bin -cmos_layout.bin-file = $(obj)/cmos_layout.bin -cmos_layout.bin-type = cmos_layout - -$(obj)/cmos_layout.bin: $(NVRAMTOOL) $(CMOS_LAYOUT_FILE) - @printf " OPTION $(subst $(obj)/,,$(@))\n" - $(NVRAMTOOL) -y $(CMOS_LAYOUT_FILE) -L $@ - -OPTION_TABLE_H:=$(obj)/option_table.h - -$(OPTION_TABLE_H): $(NVRAMTOOL) $(CMOS_LAYOUT_FILE) - @printf " OPTION $(subst $(obj)/,,$(@))\n" - $(NVRAMTOOL) -y $(CMOS_LAYOUT_FILE) -H $@ -endif # CONFIG_HAVE_OPTION_TABLE - -stripped_vgabios_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_ID)) -cbfs-files-$(CONFIG_VGA_BIOS) += pci$(stripped_vgabios_id).rom -pci$(stripped_vgabios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_FILE)) -pci$(stripped_vgabios_id).rom-type := optionrom - -stripped_second_vbios_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_SECOND_ID)) -cbfs-files-$(CONFIG_VGA_BIOS_SECOND) += pci$(stripped_second_vbios_id).rom -pci$(stripped_second_vbios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_SECOND_FILE)) -pci$(stripped_second_vbios_id).rom-type := optionrom - -stripped_vgabios_dgpu_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_DGPU_ID)) -cbfs-files-$(CONFIG_VGA_BIOS_DGPU) += pci$(stripped_vgabios_dgpu_id).rom -pci$(stripped_vgabios_dgpu_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_DGPU_FILE)) -pci$(stripped_vgabios_dgpu_id).rom-type := optionrom - -# The AMD LPC SPI DMA controller requires source files to be 64 byte aligned. -ifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_LPC_SPI_DMA),y) -pci$(stripped_vgabios_id).rom-align := 64 -pci$(stripped_second_vbios_id).rom-align := 64 -pci$(stripped_vgabios_dgpu_id).rom-align := 64 -endif # CONFIG_SOC_AMD_COMMON_BLOCK_LPC_SPI_DMA - -############################################################################### -# common support for early assembly includes -############################################################################### - -define early_x86_stage -# $1 stage name -# $2 oformat - -# The '.' include path is needed for the generated assembly.inc file. -$(1)-S-ccopts += -I. - -$$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs) - @printf " LINK $$(subst $$(obj)/,,$$(@))\n" - $$(LD_$(1)) $$(LDFLAGS_$(1)) -o $$@ -L$$(obj) $$(COMPILER_RT_FLAGS_$(1)) --whole-archive --start-group $$(filter-out %.ld,$$($(1)-objs)) $$($(1)-libs) --no-whole-archive $$(COMPILER_RT_$(1)) --end-group -T $(call src-to-obj,$(1),$(CONFIG_MEMLAYOUT_LD_FILE)) --oformat $(2) -endef - -############################################################################### -# bootblock -############################################################################### - -ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32)$(CONFIG_ARCH_BOOTBLOCK_X86_64),y) - -bootblock-y += boot.c -bootblock-$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES) += breakpoint.c -bootblock-y += post.c -bootblock-y += cpu_common.c -bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c -bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S -bootblock-y += memcpy.c -bootblock-y += memset.c -bootblock-$(CONFIG_ARCH_BOOTBLOCK_X86_32) += memmove_32.c -bootblock-$(CONFIG_ARCH_BOOTBLOCK_X86_64) += memmove_64.S -bootblock-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c -bootblock-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c -bootblock-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES) += null_breakpoint.c -bootblock-$(CONFIG_BOOTBLOCK_NORMAL) += bootblock_normal.c -bootblock-y += gdt_init.S -bootblock-y += id.S -bootblock-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c -bootblock-y += bootblock.ld -bootblock-y += car.ld - -$(call src-to-obj,bootblock,$(dir)/id.S): $(obj)/build.h - -ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y) -$(eval $(call early_x86_stage,bootblock,elf32-i386)) -else -$(eval $(call early_x86_stage,bootblock,elf64-x86-64)) -endif - -ifeq ($(CONFIG_BOOTBLOCK_IN_CBFS),y) -add_bootblock = \ - $(CBFSTOOL) $(1) add -f $(2) -n bootblock -t bootblock $(TXTIBB) \ - -b -$(call file-size,$(2)) \ - $(cbfs-autogen-attributes) $(TS_OPTIONS) $(CBFSTOOL_ADD_CMD_OPTIONS) -endif - -ifneq ($(CONFIG_CBFS_VERIFICATION),y) -$(call src-to-obj,bootblock,$(dir)/walkcbfs.S): $(obj)/fmap_config.h -bootblock-y += walkcbfs.S -endif - -endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64 - -############################################################################### -# verstage -############################################################################### - -ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32)$(CONFIG_ARCH_VERSTAGE_X86_64),y) - -verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += assembly_entry.S -verstage-y += boot.c -verstage-$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES) += breakpoint.c -verstage-y += post.c -verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += gdt_init.S -verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c -verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S -verstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c - -verstage-y += cpu_common.c -verstage-y += memset.c -verstage-y += memcpy.c -verstage-$(CONFIG_ARCH_VERSTAGE_X86_32) += memmove_32.c -verstage-$(CONFIG_ARCH_VERSTAGE_X86_64) += memmove_64.S -verstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c -verstage-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES) += null_breakpoint.c -# If verstage is a separate stage it means there's no need -# for a chipset-specific car_stage_entry() so use the generic one -# which just calls verstage(). -verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += verstage.c - -verstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c - -verstage-y += car.ld - -verstage-libs ?= - -ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32),y) -$(eval $(call early_x86_stage,verstage,elf32-i386)) -else -$(eval $(call early_x86_stage,verstage,elf64-x86-64)) -endif - -endif # CONFIG_ARCH_VERSTAGE_X86_32 / CONFIG_ARCH_VERSTAGE_X86_64 - -############################################################################### -# romstage -############################################################################### - -ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y) - -romstage-$(CONFIG_SEPARATE_ROMSTAGE) += assembly_entry.S -romstage-$(CONFIG_SEPARATE_ROMSTAGE) += romstage.c -romstage-y += boot.c -romstage-$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES) += breakpoint.c -romstage-y += post.c -romstage-$(CONFIG_SEPARATE_ROMSTAGE) += gdt_init.S -romstage-y += cpu_common.c -romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c -romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S -romstage-y += memcpy.c -romstage-$(CONFIG_ARCH_ROMSTAGE_X86_32) += memmove_32.c -romstage-$(CONFIG_ARCH_ROMSTAGE_X86_64) += memmove_64.S -romstage-y += memset.c -romstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c -romstage-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES) += null_breakpoint.c -romstage-y += postcar_loader.c -romstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c -romstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c -romstage-$(CONFIG_COOP_MULTITASKING) += thread.c -romstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S -romstage-y += car.ld - -romstage-srcs += $(wildcard $(src)/mainboard/$(MAINBOARDDIR)/romstage.c) -romstage-libs ?= - -ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y) -$(eval $(call early_x86_stage,romstage,elf32-i386)) -else -$(eval $(call early_x86_stage,romstage,elf64-x86-64)) -endif - -# Compiling crt0 with -g seems to trigger https://sourceware.org/bugzilla/show_bug.cgi?id=6428 -romstage-S-ccopts += -g0 - -endif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64 - -############################################################################### -# postcar -############################################################################### - -ifeq ($(CONFIG_ARCH_POSTCAR_X86_32),y) -$(eval $(call create_class_compiler,postcar,x86_32)) -else -$(eval $(call create_class_compiler,postcar,x86_64)) -endif -postcar-generic-ccopts += -D__POSTCAR__ - -postcar-y += boot.c -postcar-$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES) += breakpoint.c -postcar-y += post.c -postcar-y += gdt_init.S -postcar-y += cpu_common.c -postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c -postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S -postcar-y += exit_car.S -postcar-y += memcpy.c -postcar-$(CONFIG_ARCH_POSTCAR_X86_32) += memmove_32.c -postcar-$(CONFIG_ARCH_POSTCAR_X86_64) += memmove_64.S -postcar-y += memset.c -postcar-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c -postcar-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES) += null_breakpoint.c -postcar-y += postcar.c -postcar-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c -postcar-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c - -LDFLAGS_postcar += -Map $(objcbfs)/postcar.map - -$(objcbfs)/postcar.debug: $$(postcar-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_postcar) $(LDFLAGS_postcar) -o $@ -L$(obj) $(COMPILER_RT_FLAGS_postcar) --whole-archive --start-group $(filter-out %.ld,$^) --no-whole-archive $(COMPILER_RT_postcar) --end-group -T $(call src-to-obj,postcar,$(CONFIG_MEMLAYOUT_LD_FILE)) - -$(objcbfs)/postcar.elf: $(objcbfs)/postcar.debug.rmod - cp $< $@ - -# Add postcar to CBFS -cbfs-files-$(CONFIG_POSTCAR_STAGE) += $(CONFIG_CBFS_PREFIX)/postcar -$(CONFIG_CBFS_PREFIX)/postcar-file := $(objcbfs)/postcar.elf -$(CONFIG_CBFS_PREFIX)/postcar-type := stage -$(CONFIG_CBFS_PREFIX)/postcar-compression := none - -############################################################################### -# ramstage -############################################################################### - -ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y) - -ramstage-y += acpi.c -ramstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c -ramstage-$(CONFIG_ACPI_BERT) += acpi_bert_storage.c -ramstage-y += boot.c -ramstage-y += post.c -ramstage-y += c_start.S -ramstage-y += c_exit.S -ramstage-y += cpu.c -ramstage-y += cpu_common.c -ramstage-$(CONFIG_DEBUG_HW_BREAKPOINTS) += breakpoint.c -ramstage-y += ebda.c -ramstage-y += exception.c -ramstage-y += idt.S -ramstage-$(CONFIG_IOAPIC) += ioapic.c -ramstage-y += memcpy.c -ramstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += memmove_32.c -ramstage-$(CONFIG_ARCH_RAMSTAGE_X86_64) += memmove_64.S -ramstage-y += memset.c -ramstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c -ramstage-$(CONFIG_GENERATE_MP_TABLE) += mpspec.c -ramstage-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS) += null_breakpoint.c -ramstage-$(CONFIG_GENERATE_PIRQ_TABLE) += pirq_routing.c -ramstage-y += rdrand.c -ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c -ramstage-y += tables.c -ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c -ramstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S -ramstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c -ramstage-$(CONFIG_HAVE_ACPI_RESUME) += wakeup.S -ramstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c - -rmodules_x86_32-y += memcpy.c -rmodules_x86_32-y += memmove_32.c -rmodules_x86_32-y += memset.c - -rmodules_x86_64-y += memcpy.c -rmodules_x86_64-y += memmove_64.S -rmodules_x86_64-y += memset.c - -ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) -target-objcopy=-O elf32-i386 -B i386 -LD_MACHINE =-m elf_i386 -endif -ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_64),y) -target-objcopy=-O elf64-x86-64 -B i386:x86-64 -LD_MACHINE =-m elf_x86_64 -endif - -# Make sure generated code does not use XMMx and MMx registers -CFLAGS_x86_32 += -mno-mmx -mno-sse -CFLAGS_x86_64 += -mno-mmx -mno-sse - -ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c) -ifeq ($(CONFIG_GENERATE_MP_TABLE),y) -ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/mptable.c),) -ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mptable.c -endif -endif -ifeq ($(CONFIG_GENERATE_PIRQ_TABLE),y) -ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/irq_tables.c -endif - -ramstage-libs ?= - -# The rmodule_link definition creates an elf file with .rmod extension. -$(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod - cp $< $@ - -$(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) - @printf " CC $(subst $(obj)/,,$(@))\n" - $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) $< -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) - -$(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs) - @printf " CC $(subst $(obj)/,,$(@))\n" - $(LD_ramstage) $(LD_MACHINE) -r -o $@ $(COMPILER_RT_FLAGS_ramstage) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) $(ramstage-libs) --no-whole-archive $(COMPILER_RT_ramstage) --end-group - -endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64 - -smm-$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES) += breakpoint.c -smm-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c -smm-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S -smm-y += memcpy.c -smm-$(CONFIG_ARCH_RAMSTAGE_X86_32) += memmove_32.c -smm-$(CONFIG_ARCH_RAMSTAGE_X86_64) += memmove_64.S -smm-y += memset.c -smm-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c -smm-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES) += null_breakpoint.c - -smm-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/smihandler.c) - -ifneq ($(CONFIG_HAVE_CONFIGURABLE_APMC_SMI_PORT),y) -ramstage-y += apmc_smi_port.c -smm-y += apmc_smi_port.c -endif diff --git a/src/arch/x86/Makefile.mk b/src/arch/x86/Makefile.mk new file mode 100644 index 0000000000..04a0e58dbf --- /dev/null +++ b/src/arch/x86/Makefile.mk @@ -0,0 +1,343 @@ +## SPDX-License-Identifier: GPL-2.0-only + +ifeq ($(CONFIG_POSTCAR_STAGE),y) +$(eval $(call init_standard_toolchain,postcar)) +endif + +################################################################################ +# i386 specific tools +NVRAMTOOL:=$(objutil)/nvramtool/nvramtool + +OPTION_TABLE_H:= +ifeq ($(CONFIG_HAVE_OPTION_TABLE),y) + +CMOS_LAYOUT_FILE := $(top)/$(call strip_quotes,$(CONFIG_CMOS_LAYOUT_FILE)) + +cbfs-files-y += cmos_layout.bin +cmos_layout.bin-file = $(obj)/cmos_layout.bin +cmos_layout.bin-type = cmos_layout + +$(obj)/cmos_layout.bin: $(NVRAMTOOL) $(CMOS_LAYOUT_FILE) + @printf " OPTION $(subst $(obj)/,,$(@))\n" + $(NVRAMTOOL) -y $(CMOS_LAYOUT_FILE) -L $@ + +OPTION_TABLE_H:=$(obj)/option_table.h + +$(OPTION_TABLE_H): $(NVRAMTOOL) $(CMOS_LAYOUT_FILE) + @printf " OPTION $(subst $(obj)/,,$(@))\n" + $(NVRAMTOOL) -y $(CMOS_LAYOUT_FILE) -H $@ +endif # CONFIG_HAVE_OPTION_TABLE + +stripped_vgabios_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_ID)) +cbfs-files-$(CONFIG_VGA_BIOS) += pci$(stripped_vgabios_id).rom +pci$(stripped_vgabios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_FILE)) +pci$(stripped_vgabios_id).rom-type := optionrom + +stripped_second_vbios_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_SECOND_ID)) +cbfs-files-$(CONFIG_VGA_BIOS_SECOND) += pci$(stripped_second_vbios_id).rom +pci$(stripped_second_vbios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_SECOND_FILE)) +pci$(stripped_second_vbios_id).rom-type := optionrom + +stripped_vgabios_dgpu_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_DGPU_ID)) +cbfs-files-$(CONFIG_VGA_BIOS_DGPU) += pci$(stripped_vgabios_dgpu_id).rom +pci$(stripped_vgabios_dgpu_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_DGPU_FILE)) +pci$(stripped_vgabios_dgpu_id).rom-type := optionrom + +# The AMD LPC SPI DMA controller requires source files to be 64 byte aligned. +ifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_LPC_SPI_DMA),y) +pci$(stripped_vgabios_id).rom-align := 64 +pci$(stripped_second_vbios_id).rom-align := 64 +pci$(stripped_vgabios_dgpu_id).rom-align := 64 +endif # CONFIG_SOC_AMD_COMMON_BLOCK_LPC_SPI_DMA + +############################################################################### +# common support for early assembly includes +############################################################################### + +define early_x86_stage +# $1 stage name +# $2 oformat + +# The '.' include path is needed for the generated assembly.inc file. +$(1)-S-ccopts += -I. + +$$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs) + @printf " LINK $$(subst $$(obj)/,,$$(@))\n" + $$(LD_$(1)) $$(LDFLAGS_$(1)) -o $$@ -L$$(obj) $$(COMPILER_RT_FLAGS_$(1)) --whole-archive --start-group $$(filter-out %.ld,$$($(1)-objs)) $$($(1)-libs) --no-whole-archive $$(COMPILER_RT_$(1)) --end-group -T $(call src-to-obj,$(1),$(CONFIG_MEMLAYOUT_LD_FILE)) --oformat $(2) +endef + +############################################################################### +# bootblock +############################################################################### + +ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32)$(CONFIG_ARCH_BOOTBLOCK_X86_64),y) + +bootblock-y += boot.c +bootblock-$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES) += breakpoint.c +bootblock-y += post.c +bootblock-y += cpu_common.c +bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c +bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S +bootblock-y += memcpy.c +bootblock-y += memset.c +bootblock-$(CONFIG_ARCH_BOOTBLOCK_X86_32) += memmove_32.c +bootblock-$(CONFIG_ARCH_BOOTBLOCK_X86_64) += memmove_64.S +bootblock-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c +bootblock-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c +bootblock-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES) += null_breakpoint.c +bootblock-$(CONFIG_BOOTBLOCK_NORMAL) += bootblock_normal.c +bootblock-y += gdt_init.S +bootblock-y += id.S +bootblock-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c +bootblock-y += bootblock.ld +bootblock-y += car.ld + +$(call src-to-obj,bootblock,$(dir)/id.S): $(obj)/build.h + +ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y) +$(eval $(call early_x86_stage,bootblock,elf32-i386)) +else +$(eval $(call early_x86_stage,bootblock,elf64-x86-64)) +endif + +ifeq ($(CONFIG_BOOTBLOCK_IN_CBFS),y) +add_bootblock = \ + $(CBFSTOOL) $(1) add -f $(2) -n bootblock -t bootblock $(TXTIBB) \ + -b -$(call file-size,$(2)) \ + $(cbfs-autogen-attributes) $(TS_OPTIONS) $(CBFSTOOL_ADD_CMD_OPTIONS) +endif + +ifneq ($(CONFIG_CBFS_VERIFICATION),y) +$(call src-to-obj,bootblock,$(dir)/walkcbfs.S): $(obj)/fmap_config.h +bootblock-y += walkcbfs.S +endif + +endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64 + +############################################################################### +# verstage +############################################################################### + +ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32)$(CONFIG_ARCH_VERSTAGE_X86_64),y) + +verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += assembly_entry.S +verstage-y += boot.c +verstage-$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES) += breakpoint.c +verstage-y += post.c +verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += gdt_init.S +verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c +verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S +verstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c + +verstage-y += cpu_common.c +verstage-y += memset.c +verstage-y += memcpy.c +verstage-$(CONFIG_ARCH_VERSTAGE_X86_32) += memmove_32.c +verstage-$(CONFIG_ARCH_VERSTAGE_X86_64) += memmove_64.S +verstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c +verstage-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES) += null_breakpoint.c +# If verstage is a separate stage it means there's no need +# for a chipset-specific car_stage_entry() so use the generic one +# which just calls verstage(). +verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += verstage.c + +verstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c + +verstage-y += car.ld + +verstage-libs ?= + +ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32),y) +$(eval $(call early_x86_stage,verstage,elf32-i386)) +else +$(eval $(call early_x86_stage,verstage,elf64-x86-64)) +endif + +endif # CONFIG_ARCH_VERSTAGE_X86_32 / CONFIG_ARCH_VERSTAGE_X86_64 + +############################################################################### +# romstage +############################################################################### + +ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y) + +romstage-$(CONFIG_SEPARATE_ROMSTAGE) += assembly_entry.S +romstage-$(CONFIG_SEPARATE_ROMSTAGE) += romstage.c +romstage-y += boot.c +romstage-$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES) += breakpoint.c +romstage-y += post.c +romstage-$(CONFIG_SEPARATE_ROMSTAGE) += gdt_init.S +romstage-y += cpu_common.c +romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c +romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S +romstage-y += memcpy.c +romstage-$(CONFIG_ARCH_ROMSTAGE_X86_32) += memmove_32.c +romstage-$(CONFIG_ARCH_ROMSTAGE_X86_64) += memmove_64.S +romstage-y += memset.c +romstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c +romstage-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES) += null_breakpoint.c +romstage-y += postcar_loader.c +romstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c +romstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c +romstage-$(CONFIG_COOP_MULTITASKING) += thread.c +romstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S +romstage-y += car.ld + +romstage-srcs += $(wildcard $(src)/mainboard/$(MAINBOARDDIR)/romstage.c) +romstage-libs ?= + +ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y) +$(eval $(call early_x86_stage,romstage,elf32-i386)) +else +$(eval $(call early_x86_stage,romstage,elf64-x86-64)) +endif + +# Compiling crt0 with -g seems to trigger https://sourceware.org/bugzilla/show_bug.cgi?id=6428 +romstage-S-ccopts += -g0 + +endif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64 + +############################################################################### +# postcar +############################################################################### + +ifeq ($(CONFIG_ARCH_POSTCAR_X86_32),y) +$(eval $(call create_class_compiler,postcar,x86_32)) +else +$(eval $(call create_class_compiler,postcar,x86_64)) +endif +postcar-generic-ccopts += -D__POSTCAR__ + +postcar-y += boot.c +postcar-$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES) += breakpoint.c +postcar-y += post.c +postcar-y += gdt_init.S +postcar-y += cpu_common.c +postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c +postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S +postcar-y += exit_car.S +postcar-y += memcpy.c +postcar-$(CONFIG_ARCH_POSTCAR_X86_32) += memmove_32.c +postcar-$(CONFIG_ARCH_POSTCAR_X86_64) += memmove_64.S +postcar-y += memset.c +postcar-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c +postcar-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES) += null_breakpoint.c +postcar-y += postcar.c +postcar-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c +postcar-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c + +LDFLAGS_postcar += -Map $(objcbfs)/postcar.map + +$(objcbfs)/postcar.debug: $$(postcar-objs) + @printf " LINK $(subst $(obj)/,,$(@))\n" + $(LD_postcar) $(LDFLAGS_postcar) -o $@ -L$(obj) $(COMPILER_RT_FLAGS_postcar) --whole-archive --start-group $(filter-out %.ld,$^) --no-whole-archive $(COMPILER_RT_postcar) --end-group -T $(call src-to-obj,postcar,$(CONFIG_MEMLAYOUT_LD_FILE)) + +$(objcbfs)/postcar.elf: $(objcbfs)/postcar.debug.rmod + cp $< $@ + +# Add postcar to CBFS +cbfs-files-$(CONFIG_POSTCAR_STAGE) += $(CONFIG_CBFS_PREFIX)/postcar +$(CONFIG_CBFS_PREFIX)/postcar-file := $(objcbfs)/postcar.elf +$(CONFIG_CBFS_PREFIX)/postcar-type := stage +$(CONFIG_CBFS_PREFIX)/postcar-compression := none + +############################################################################### +# ramstage +############################################################################### + +ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y) + +ramstage-y += acpi.c +ramstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c +ramstage-$(CONFIG_ACPI_BERT) += acpi_bert_storage.c +ramstage-y += boot.c +ramstage-y += post.c +ramstage-y += c_start.S +ramstage-y += c_exit.S +ramstage-y += cpu.c +ramstage-y += cpu_common.c +ramstage-$(CONFIG_DEBUG_HW_BREAKPOINTS) += breakpoint.c +ramstage-y += ebda.c +ramstage-y += exception.c +ramstage-y += idt.S +ramstage-$(CONFIG_IOAPIC) += ioapic.c +ramstage-y += memcpy.c +ramstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += memmove_32.c +ramstage-$(CONFIG_ARCH_RAMSTAGE_X86_64) += memmove_64.S +ramstage-y += memset.c +ramstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c +ramstage-$(CONFIG_GENERATE_MP_TABLE) += mpspec.c +ramstage-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS) += null_breakpoint.c +ramstage-$(CONFIG_GENERATE_PIRQ_TABLE) += pirq_routing.c +ramstage-y += rdrand.c +ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c +ramstage-y += tables.c +ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c +ramstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S +ramstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c +ramstage-$(CONFIG_HAVE_ACPI_RESUME) += wakeup.S +ramstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c + +rmodules_x86_32-y += memcpy.c +rmodules_x86_32-y += memmove_32.c +rmodules_x86_32-y += memset.c + +rmodules_x86_64-y += memcpy.c +rmodules_x86_64-y += memmove_64.S +rmodules_x86_64-y += memset.c + +ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) +target-objcopy=-O elf32-i386 -B i386 +LD_MACHINE =-m elf_i386 +endif +ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_64),y) +target-objcopy=-O elf64-x86-64 -B i386:x86-64 +LD_MACHINE =-m elf_x86_64 +endif + +# Make sure generated code does not use XMMx and MMx registers +CFLAGS_x86_32 += -mno-mmx -mno-sse +CFLAGS_x86_64 += -mno-mmx -mno-sse + +ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c) +ifeq ($(CONFIG_GENERATE_MP_TABLE),y) +ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/mptable.c),) +ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mptable.c +endif +endif +ifeq ($(CONFIG_GENERATE_PIRQ_TABLE),y) +ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/irq_tables.c +endif + +ramstage-libs ?= + +# The rmodule_link definition creates an elf file with .rmod extension. +$(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod + cp $< $@ + +$(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) + @printf " CC $(subst $(obj)/,,$(@))\n" + $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) $< -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) + +$(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs) + @printf " CC $(subst $(obj)/,,$(@))\n" + $(LD_ramstage) $(LD_MACHINE) -r -o $@ $(COMPILER_RT_FLAGS_ramstage) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) $(ramstage-libs) --no-whole-archive $(COMPILER_RT_ramstage) --end-group + +endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64 + +smm-$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES) += breakpoint.c +smm-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c +smm-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S +smm-y += memcpy.c +smm-$(CONFIG_ARCH_RAMSTAGE_X86_32) += memmove_32.c +smm-$(CONFIG_ARCH_RAMSTAGE_X86_64) += memmove_64.S +smm-y += memset.c +smm-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c +smm-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES) += null_breakpoint.c + +smm-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/smihandler.c) + +ifneq ($(CONFIG_HAVE_CONFIGURABLE_APMC_SMI_PORT),y) +ramstage-y += apmc_smi_port.c +smm-y += apmc_smi_port.c +endif -- cgit v1.2.3