blob: 997c2da70f004f0a746a82e72f7f04a27e87495d [file] [log] [blame]
Furquan Shaikh2af76f42014-04-28 16:39:40 -07001################################################################################
2##
3## This file is part of the coreboot project.
4##
5## Copyright (C) 2014 Google Inc.
6## Copyright (C) 2012-2013 The ChromiumOS Authors
7## Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
8## Copyright (C) 2009-2010 coresystems GmbH
9## Copyright (C) 2009 Ronald G. Minnich
10##
11## This program is free software; you can redistribute it and/or modify
12## it under the terms of the GNU General Public License as published by
13## the Free Software Foundation; version 2 of the License.
14##
15## This program is distributed in the hope that it will be useful,
16## but WITHOUT ANY WARRANTY; without even the implied warranty of
17## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18## GNU General Public License for more details.
19##
Furquan Shaikh2af76f42014-04-28 16:39:40 -070020################################################################################
21
22################################################################################
23# Take care of subdirectories
24################################################################################
25
Julius Werner7dcf9d52015-10-16 13:10:02 -070026subdirs-y += armv8/
Furquan Shaikh2af76f42014-04-28 16:39:40 -070027
28################################################################################
29# ARM specific options
30################################################################################
31
Julius Wernerfffee872016-03-07 17:55:43 -080032ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM64),y)
33check-ramstage-overlap-regions += postram_cbfs_cache stack ttb
34endif
35
Furquan Shaikh2af76f42014-04-28 16:39:40 -070036################################################################################
37# bootblock
38################################################################################
39
40ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARM64),y)
41
42bootblock-y += div0.c
Furquan Shaikh2af76f42014-04-28 16:39:40 -070043bootblock-y += id.S
Nico Huber81b09f42016-01-23 00:50:00 +010044$(call src-to-obj,bootblock,$(dir)/id.S): $(obj)/build.h
Furquan Shaikh2af76f42014-04-28 16:39:40 -070045
Aaron Durbinb3847e62015-03-20 15:55:08 -050046bootblock-y += boot.c
Furquan Shaikh2af76f42014-04-28 16:39:40 -070047bootblock-y += eabi_compat.c
T Michael Turney3775f1c2018-04-24 10:15:46 -070048bootblock-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c
Furquan Shaikh668316b2014-08-30 21:59:11 -070049bootblock-y += transition.c transition_asm.S
50
Furquan Shaikh464f5ca2015-06-08 10:31:55 -070051bootblock-y += memset.S
52bootblock-y += memcpy.S
53bootblock-y += memmove.S
Furquan Shaikh2af76f42014-04-28 16:39:40 -070054
55# Build the bootblock
56
Julius Wernerec5e5e02014-08-20 15:29:56 -070057$(objcbfs)/bootblock.debug: $$(bootblock-objs) $(obj)/config.h
Furquan Shaikh2af76f42014-04-28 16:39:40 -070058 @printf " LINK $(subst $(obj)/,,$(@))\n"
Nico Huber81b09f42016-01-23 00:50:00 +010059 $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) --end-group -T $(call src-to-obj,bootblock,src/mainboard/$(MAINBOARDDIR)/memlayout.ld)
Furquan Shaikh2af76f42014-04-28 16:39:40 -070060
61endif # CONFIG_ARCH_BOOTBLOCK_ARM64
62
Furquan Shaikh6f33f0a2014-10-02 16:43:19 -070063###############################################################################
64# verification stage
65###############################################################################
66
67ifeq ($(CONFIG_ARCH_VERSTAGE_ARM64),y)
68
Julius Wernere91d1702017-03-20 15:32:15 -070069$(objcbfs)/verstage.debug: $$(verstage-objs)
Furquan Shaikh6f33f0a2014-10-02 16:43:19 -070070 @printf " LINK $(subst $(obj)/,,$(@))\n"
Julius Wernere91d1702017-03-20 15:32:15 -070071 $(LD_verstage) $(LDFLAGS_verstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(verstage-objs)) --end-group -T $(call src-to-obj,verstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld)
Furquan Shaikh6f33f0a2014-10-02 16:43:19 -070072
Aaron Durbinbc409332015-05-08 15:52:52 -050073verstage-y += boot.c
Furquan Shaikh6f33f0a2014-10-02 16:43:19 -070074verstage-y += div0.c
75verstage-y += eabi_compat.c
T Michael Turney3775f1c2018-04-24 10:15:46 -070076verstage-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c
Julius Werner2f891a02017-03-20 15:38:02 -070077verstage-y += memset.S
78verstage-y += memcpy.S
79verstage-y += memmove.S
Furquan Shaikh6f33f0a2014-10-02 16:43:19 -070080
Itamarab0df6d2015-07-31 17:10:46 +080081verstage-y += transition.c transition_asm.S
82
Furquan Shaikh6f33f0a2014-10-02 16:43:19 -070083endif # CONFIG_ARCH_VERSTAGE_ARM64
84
Furquan Shaikh2af76f42014-04-28 16:39:40 -070085################################################################################
86# romstage
87################################################################################
88
89ifeq ($(CONFIG_ARCH_ROMSTAGE_ARM64),y)
90
Aaron Durbinb3847e62015-03-20 15:55:08 -050091romstage-y += boot.c
Furquan Shaikh2af76f42014-04-28 16:39:40 -070092romstage-y += div0.c
Furquan Shaikh2af76f42014-04-28 16:39:40 -070093romstage-y += eabi_compat.c
T Michael Turney3775f1c2018-04-24 10:15:46 -070094romstage-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c
Furquan Shaikh464f5ca2015-06-08 10:31:55 -070095romstage-y += memset.S
96romstage-y += memcpy.S
97romstage-y += memmove.S
Furquan Shaikh668316b2014-08-30 21:59:11 -070098romstage-y += transition.c transition_asm.S
Furquan Shaikh2af76f42014-04-28 16:39:40 -070099
Furquan Shaikh464f5ca2015-06-08 10:31:55 -0700100rmodules_arm64-y += memset.S
101rmodules_arm64-y += memcpy.S
102rmodules_arm64-y += memmove.S
Furquan Shaikha742ef12014-07-23 11:41:59 -0700103rmodules_arm64-y += eabi_compat.c
104
Julius Wernerec5e5e02014-08-20 15:29:56 -0700105$(objcbfs)/romstage.debug: $$(romstage-objs)
Furquan Shaikh2af76f42014-04-28 16:39:40 -0700106 @printf " LINK $(subst $(obj)/,,$(@))\n"
Nico Huber81b09f42016-01-23 00:50:00 +0100107 $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group -T $(call src-to-obj,romstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld)
Furquan Shaikh2af76f42014-04-28 16:39:40 -0700108
109endif # CONFIG_ARCH_ROMSTAGE_ARM64
110
111################################################################################
112# ramstage
113################################################################################
114
115ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM64),y)
116
Furquan Shaikh2af76f42014-04-28 16:39:40 -0700117ramstage-y += div0.c
Furquan Shaikh2af76f42014-04-28 16:39:40 -0700118ramstage-y += eabi_compat.c
119ramstage-y += boot.c
120ramstage-y += tables.c
T Michael Turney3775f1c2018-04-24 10:15:46 -0700121ramstage-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c
Furquan Shaikh464f5ca2015-06-08 10:31:55 -0700122ramstage-y += memset.S
123ramstage-y += memcpy.S
124ramstage-y += memmove.S
Julius Werner745a75f2015-05-11 16:45:56 -0700125ramstage-$(CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE) += arm_tf.c
Furquan Shaikh668316b2014-08-30 21:59:11 -0700126ramstage-y += transition.c transition_asm.S
127
Furquan Shaikh464f5ca2015-06-08 10:31:55 -0700128rmodules_arm64-y += memset.S
129rmodules_arm64-y += memcpy.S
130rmodules_arm64-y += memmove.S
Furquan Shaikhfbff9082014-07-22 15:59:16 -0700131rmodules_arm64-y += eabi_compat.c
T Michael Turney3775f1c2018-04-24 10:15:46 -0700132rmodules_arm64-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c
Furquan Shaikhabde3b52014-08-26 15:39:51 -0700133
Marc Jones17b9c192015-01-16 13:45:23 -0700134ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c)
Furquan Shaikh2af76f42014-04-28 16:39:40 -0700135
136# Build the ramstage
137
Julius Wernerec5e5e02014-08-20 15:29:56 -0700138$(objcbfs)/ramstage.debug: $$(ramstage-objs)
Furquan Shaikh2af76f42014-04-28 16:39:40 -0700139 @printf " CC $(subst $(obj)/,,$(@))\n"
Nico Huber81b09f42016-01-23 00:50:00 +0100140 $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group -T $(call src-to-obj,ramstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld)
Furquan Shaikh2af76f42014-04-28 16:39:40 -0700141
Julius Werner745a75f2015-05-11 16:45:56 -0700142# Build ARM Trusted Firmware (BL31)
143
144ifeq ($(CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE),y)
145
146BL31_SOURCE := $(top)/3rdparty/arm-trusted-firmware
Julius Werner50e76702016-10-29 00:10:53 -0700147BL31_BUILD := $(abspath $(obj)/3rdparty/arm-trusted-firmware)
148BL31_TARGET := $(BL31_BUILD)/bl31/bl31.elf
Julius Werner745a75f2015-05-11 16:45:56 -0700149
Julius Werner745a75f2015-05-11 16:45:56 -0700150ifeq ($(V),1)
151BL31_MAKEARGS += V=1
152endif
153
Julius Werner91ebbfd2017-07-25 13:55:43 -0700154# Build ARM TF in debug mode (with assertions) if coreboot has hard assertions
155ifeq ($(CONFIG_FATAL_ASSERTS),y)
Julius Werner745a75f2015-05-11 16:45:56 -0700156BL31_MAKEARGS += DEBUG=1
157endif # CONFIG_CONSOLE_SERIAL
158
Julius Werner91ebbfd2017-07-25 13:55:43 -0700159# ARM TF's VERBOSE (50) is *very* spammy, so default to INFO (40)
160BL31_MAKEARGS += LOG_LEVEL=40
161
162# Always enable crash reporting, even on a release build
163BL31_MAKEARGS += CRASH_REPORTING=1
164
165# Enable coreboot-specific features like CBMEM console support
166BL31_MAKEARGS += COREBOOT=1
167
Julius Werner745a75f2015-05-11 16:45:56 -0700168# Avoid build/release|build/debug distinction by overriding BUILD_PLAT directly
Julius Werner50e76702016-10-29 00:10:53 -0700169BL31_MAKEARGS += BUILD_PLAT="$(BL31_BUILD)"
170
171# Force making .d files and output directories even though target is not 'bl31'
172BL31_MAKEARGS += IS_ANYTHING_TO_BUILD=1
Julius Werner745a75f2015-05-11 16:45:56 -0700173
Patrick Georgidcc3ecc2016-01-28 15:00:54 +0100174# Set a consistent build timestamp: the same coreboot has
175# The \# \" complications exist to satisfy both gnu make's parser and editors
176# with non-semantic quote-handling (that would assume that this line starts a
177# multi line string.
Patrick Georgi800e9642016-01-28 15:25:49 +0100178BL31_MAKEARGS += BUILD_MESSAGE_TIMESTAMP='"$(shell grep "\#define COREBOOT_BUILD\>" $(obj)/build.h |cut -d\" -f2 \# \")"'
Patrick Georgidcc3ecc2016-01-28 15:00:54 +0100179
Martin Roth76b8c0e2017-03-23 09:37:01 -0600180BL31_CFLAGS := -fno-pic -fno-stack-protector -Wno-deprecated-declarations -Wno-unused-function
Julius Werner745a75f2015-05-11 16:45:56 -0700181BL31_LDFLAGS := --emit-relocs
182
Patrick Georgi2268b3b2015-06-29 22:13:53 +0200183BL31 := $(obj)/bl31.elf
Julius Werner745a75f2015-05-11 16:45:56 -0700184
Patrick Georgidcc3ecc2016-01-28 15:00:54 +0100185$(BL31): $(obj)/build.h
Patrick Georgi78a5f222017-01-30 15:29:34 +0100186 printf " MAKE $(subst $(obj)/,,$(@))\n"
187 +CROSS_COMPILE="$(CROSS_COMPILE_arm64)" \
Julius Werner745a75f2015-05-11 16:45:56 -0700188 CFLAGS="$(BL31_CFLAGS)" \
189 LDFLAGS="$(BL31_LDFLAGS)" \
Martin Roth80c314d2016-12-29 19:55:28 -0700190 $(MAKE) -C $(BL31_SOURCE) $(BL31_MAKEARGS) $(BL31_TARGET) DISABLE_PEDANTIC=1
Julius Werner50e76702016-10-29 00:10:53 -0700191 mv $(BL31_TARGET) $@
Julius Werner745a75f2015-05-11 16:45:56 -0700192
193.PHONY: $(BL31)
194
Patrick Georgi6dc85702015-11-30 22:44:53 +0100195BL31_CBFS := $(CONFIG_CBFS_PREFIX)/bl31
Julius Werner745a75f2015-05-11 16:45:56 -0700196$(BL31_CBFS)-file := $(BL31)
Simon Glass7ae73fc2016-08-27 12:18:38 -0600197$(BL31_CBFS)-type := payload
Julius Werner745a75f2015-05-11 16:45:56 -0700198$(BL31_CBFS)-compression := $(CBFS_COMPRESS_FLAG)
199cbfs-files-y += $(BL31_CBFS)
200
Julius Wernerfffee872016-03-07 17:55:43 -0800201check-ramstage-overlap-files += $(BL31_CBFS)
202
Furquan Shaikha384c282015-05-28 12:13:51 -0700203ifeq ($(CONFIG_ARM64_USE_SECURE_OS),y)
204
205SECURE_OS_FILE := $(CONFIG_ARM64_SECURE_OS_FILE)
Patrick Georgi6dc85702015-11-30 22:44:53 +0100206SECURE_OS_FILE_CBFS := $(CONFIG_CBFS_PREFIX)/secure_os
Furquan Shaikha384c282015-05-28 12:13:51 -0700207$(SECURE_OS_FILE_CBFS)-file := $(SECURE_OS_FILE)
208$(SECURE_OS_FILE_CBFS)-type := stage
209cbfs-files-y += $(SECURE_OS_FILE_CBFS)
210
Julius Wernerfffee872016-03-07 17:55:43 -0800211check-ramstage-overlap-files += $(SECURE_OS_FILE_CBFS)
212
Furquan Shaikha384c282015-05-28 12:13:51 -0700213endif # CONFIG_ARM64_USE_SECURE_OS
214
Julius Werner745a75f2015-05-11 16:45:56 -0700215endif # CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE
216
Furquan Shaikh2af76f42014-04-28 16:39:40 -0700217endif # CONFIG_ARCH_RAMSTAGE_ARM64