blob: 048d3647c4526615d4b39748ae12998a522dd5de [file] [log] [blame]
Stefan Reinauer52db0b92012-12-07 17:15:04 -08001################################################################################
2##
3## This file is part of the coreboot project.
4##
5## Copyright (C) 2012 The ChromiumOS Authors
6## Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
7## Copyright (C) 2009-2010 coresystems GmbH
8## Copyright (C) 2009 Ronald G. Minnich
9##
10## This program is free software; you can redistribute it and/or modify
11## it under the terms of the GNU General Public License as published by
12## the Free Software Foundation; version 2 of the License.
13##
14## This program is distributed in the hope that it will be useful,
15## but WITHOUT ANY WARRANTY; without even the implied warranty of
16## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17## GNU General Public License for more details.
18##
19## You should have received a copy of the GNU General Public License
20## along with this program; if not, write to the Free Software
Paul Menzela46a7122013-02-23 18:37:27 +010021## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Stefan Reinauer52db0b92012-12-07 17:15:04 -080022##
Furquan Shaikh88ca81a2014-04-22 16:33:22 -070023###############################################################################
Stefan Reinauer52db0b92012-12-07 17:15:04 -080024# Take care of subdirectories
Furquan Shaikh88ca81a2014-04-22 16:33:22 -070025###############################################################################
Stefan Reinauer52db0b92012-12-07 17:15:04 -080026subdirs-y += boot/
27subdirs-y += lib/
Stefan Reinauer52db0b92012-12-07 17:15:04 -080028
Furquan Shaikh88ca81a2014-04-22 16:33:22 -070029###############################################################################
30# ARM specific options
31###############################################################################
Stefan Reinauer52db0b92012-12-07 17:15:04 -080032
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070033ifeq ($(CONFIG_ARCH_ROMSTAGE_ARMV7),y)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -070034CBFSTOOL_PRE1_OPTS = -m armv7 -b $(CONFIG_BOOTBLOCK_ROM_OFFSET) -H $(CONFIG_CBFS_HEADER_ROM_OFFSET) -o $(CONFIG_CBFS_ROM_OFFSET)
35CBFSTOOL_PRE_OPTS = -b 0
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070036endif
Stefan Reinauer52db0b92012-12-07 17:15:04 -080037
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070038ifeq ($(CONFIG_ARCH_ARMV7),y)
Ronald G. Minnich27bd64a2013-02-28 17:47:00 +010039stages_c = $(src)/arch/armv7/stages.c
40stages_o = $(obj)/arch/armv7/stages.o
41
Gabe Black4938a322013-09-15 20:53:57 -070042$(stages_o): $(stages_c) $(obj)/config.h
Ronald G. Minnich27bd64a2013-02-28 17:47:00 +010043 @printf " CC $(subst $(obj)/,,$(@))\n"
Patrick Georgi91d6fc82014-05-25 00:05:20 +020044 $(CC_armv7) -I. $(CPPFLAGS_armv7) -c -o $@ $< -marm
Ronald G. Minnich27bd64a2013-02-28 17:47:00 +010045
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070046endif # CONFIG_ARCH_ARMV7
David Hendricks10c90d32012-12-27 13:30:55 -080047
Furquan Shaikh88ca81a2014-04-22 16:33:22 -070048###############################################################################
49# bootblock
50###############################################################################
Ronald G. Minnichb21eaa72013-03-07 15:23:45 -080051
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070052ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARMV7),y)
53
Stefan Reinauer93ce3b32013-05-24 14:38:48 -070054bootblock-y += cache.c
Stefan Reinauer93ce3b32013-05-24 14:38:48 -070055bootblock-y += eabi_compat.c
Stefan Reinauerff7c8e82013-05-29 13:12:20 -070056bootblock-y += memset.S
Stefan Reinauerff7c8e82013-05-29 13:12:20 -070057bootblock-y += memcpy.S
Gabe Black7a6651c2013-07-07 14:15:22 -070058bootblock-y += memmove.S
Gabe Blackee4bfbf2013-08-13 21:05:43 -070059bootblock-y += mmu.c
Stefan Reinauerff7c8e82013-05-29 13:12:20 -070060
David Hendricks3d7344a2013-01-08 21:05:06 -080061bootblock_lds = $(src)/arch/armv7/bootblock.lds
Stefan Reinauer52db0b92012-12-07 17:15:04 -080062bootblock_lds += $(chipset_bootblock_lds)
63
David Hendricks3d7344a2013-01-08 21:05:06 -080064bootblock_inc += $(src)/arch/armv7/bootblock.inc
Stefan Reinauer93ce3b32013-05-24 14:38:48 -070065bootblock_inc += $(src)/arch/armv7/id.inc
Stefan Reinauer52db0b92012-12-07 17:15:04 -080066bootblock_inc += $(chipset_bootblock_inc)
David Hendricks3d7344a2013-01-08 21:05:06 -080067bootblock_inc += $(objgenerated)/bootblock.inc
Stefan Reinauer52db0b92012-12-07 17:15:04 -080068
Hung-Te Linfe187922013-02-01 01:09:24 +080069bootblock_custom = $(src)/$(call strip_quotes,$(CONFIG_BOOTBLOCK_CPU_INIT))
70bootblock_custom += $(src)/$(call strip_quotes,$(CONFIG_BOOTBLOCK_MAINBOARD_INIT))
71
Stefan Reinauer52db0b92012-12-07 17:15:04 -080072$(objgenerated)/bootblock.ld: $$(bootblock_lds) $(obj)/ldoptions
73 @printf " GEN $(subst $(obj)/,,$(@))\n"
74 printf '$(foreach ldscript,ldoptions $(bootblock_lds),INCLUDE "$(ldscript)"\n)' > $@
75
76$(objgenerated)/bootblock_inc.S: $$(bootblock_inc)
77 @printf " GEN $(subst $(obj)/,,$(@))\n"
78 printf '$(foreach crt0,$(bootblock_inc),#include "$(crt0)"\n)' > $@
79
80$(objgenerated)/bootblock.o: $(objgenerated)/bootblock.s
81 @printf " CC $(subst $(obj)/,,$(@))\n"
Patrick Georgi25b56c32014-05-25 00:11:35 +020082 $(CC_bootblock) $(CPPFLAGS_bootblock) -Wa,-acdlns -c -o $@ $< > $(basename $@).disasm
Stefan Reinauer52db0b92012-12-07 17:15:04 -080083
84$(objgenerated)/bootblock.s: $(objgenerated)/bootblock_inc.S $(obj)/config.h $(obj)/build.h
85 @printf " CC $(subst $(obj)/,,$(@))\n"
Patrick Georgi25b56c32014-05-25 00:11:35 +020086 $(CC_bootblock) $(CPPFLAGS_bootblock) -MMD -x assembler-with-cpp -E -I$(src)/include -I$(src)/arch/armv7/include -I$(obj) -include $(obj)/build.h -include $(obj)/config.h -I. -I$(src) $< -o $@
Stefan Reinauer52db0b92012-12-07 17:15:04 -080087
Gabe Black4938a322013-09-15 20:53:57 -070088$(objgenerated)/bootblock.inc: $(src)/arch/armv7/$(subst ",,$(CONFIG_BOOTBLOCK_SOURCE)) $(bootblock_custom) $(OPTION_TABLE_H) $(obj)/config.h
Daniele Forsi21fbc082014-08-10 15:18:42 +020089 @printf " CC $(subst $(obj)/,,$(@))\n"
Patrick Georgi25b56c32014-05-25 00:11:35 +020090 $(CC_bootblock) $(CFLAGS_bootblock) $(CPPFLAGS_bootblock) -MM \
Hung-Te Linb868d402013-02-06 22:01:18 +080091 -MT$(objgenerated)/bootblock.inc \
David Hendricks3d7344a2013-01-08 21:05:06 -080092 $< > $(objgenerated)/bootblock.inc.d
Patrick Georgi25b56c32014-05-25 00:11:35 +020093 $(CC_bootblock) -c -S $(CFLAGS_bootblock) -I. $(CPPFLAGS_bootblock) $< -o $@
Stefan Reinauer52db0b92012-12-07 17:15:04 -080094
Gabe Black4938a322013-09-15 20:53:57 -070095$(objcbfs)/bootblock.debug: $(objgenerated)/bootblock.o $(objgenerated)/bootblock.ld $$(bootblock-objs) $(stages) $(obj)/config.h
Stefan Reinauer52db0b92012-12-07 17:15:04 -080096 @printf " LINK $(subst $(obj)/,,$(@))\n"
97ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070098 $(LD_bootblock) -m armelf_linux_eabi -include $(obj)/config.h -static -o $@.tmp -L$(obj) $< -T $(objgenerated)/bootblock.ld
Stefan Reinauer52db0b92012-12-07 17:15:04 -080099else
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700100 $(CC_bootblock) -nostdlib -nostartfiles -include $(obj)/config.h -static -o $@ -L$(obj) -T $(objgenerated)/bootblock.ld -Wl,--start-group $(objgenerated)/bootblock.o $(bootblock-objs) $(stages) $(LIBGCC_FILE_NAME_bootblock) -Wl,--end-group
Stefan Reinauer52db0b92012-12-07 17:15:04 -0800101endif
102
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700103endif # CONFIG_ARCH_BOOTBLOCK_ARMV7
104
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700105###############################################################################
106# romstage
107###############################################################################
108
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700109ifeq ($(CONFIG_ARCH_ROMSTAGE_ARMV7),y)
110
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700111romstage-y += cache.c
112romstage-y += div0.c
113romstage-y += eabi_compat.c
114romstage-y += memset.S
115romstage-y += memcpy.S
116romstage-y += memmove.S
117romstage-srcs += $(objgenerated)/crt0.s
118
119ldscripts =
120ldscripts += $(src)/arch/armv7/romstage.ld
121
122#crt0s += $(src)/cpu/arm/fpu_enable.inc
123# FIXME: CONFIG_NEON or something similar for ARM?
124#ifeq ($(CONFIG_SSE),y)
125#crt0s += $(src)/cpu/arm/sse_enable.inc
126#endif
127
128crt0s += $(cpu_incs)
129crt0s += $(cpu_incs-y)
Stefan Reinauer52db0b92012-12-07 17:15:04 -0800130
Stefan Reinauer7f86c052013-03-25 17:50:17 -0700131$(objcbfs)/romstage.debug: $$(romstage-objs) $(stages_o) $(objgenerated)/romstage.ld
Stefan Reinauer52db0b92012-12-07 17:15:04 -0800132 @printf " LINK $(subst $(obj)/,,$(@))\n"
133ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700134 $(LD_romstage) -nostdlib -nostartfiles -static -o $@ -L$(obj) $(romstage-objs) -T $(objgenerated)/romstage.ld
Stefan Reinauer52db0b92012-12-07 17:15:04 -0800135else
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700136 $(CC_romstage) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(objgenerated)/romstage.ld -Wl,--start-group $(romstage-objs) $(stages_o) $(LIBGCC_FILE_NAME_romstage) -Wl,--end-group
Stefan Reinauer52db0b92012-12-07 17:15:04 -0800137endif
138
Stefan Reinauer7f86c052013-03-25 17:50:17 -0700139$(objgenerated)/romstage.ld: $$(ldscripts) $(obj)/ldoptions
Stefan Reinauer52db0b92012-12-07 17:15:04 -0800140 @printf " GEN $(subst $(obj)/,,$(@))\n"
141 rm -f $@
Stefan Reinauer52db0b92012-12-07 17:15:04 -0800142 printf '$(foreach ldscript,ldoptions $(ldscripts),INCLUDE "$(ldscript:$(obj)/%=%)"\n)' >> $@.tmp
143 mv $@.tmp $@
144
Stefan Reinauer52db0b92012-12-07 17:15:04 -0800145$(objgenerated)/crt0.romstage.S: $$(crt0s)
146 @printf " GEN $(subst $(obj)/,,$(@))\n"
147 printf '$(foreach crt0,$(crt0s),#include "$(crt0:$(obj)/%=%)"\n)' > $@
148
149$(objgenerated)/crt0.romstage.o: $(objgenerated)/crt0.s
150 @printf " CC $(subst $(obj)/,,$(@))\n"
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700151 $(CC_romstage) -Wa,-acdlns -c -o $@ $< > $(basename $@).disasm
Stefan Reinauer52db0b92012-12-07 17:15:04 -0800152
153$(objgenerated)/crt0.s: $(objgenerated)/crt0.romstage.S $(obj)/config.h $(obj)/build.h
154 @printf " CC $(subst $(obj)/,,$(@))\n"
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700155 $(CC_romstage) -MMD -x assembler-with-cpp -E -I$(src)/include -I$(src)/arch/armv7/include -I$(obj) -include $(obj)/config.h -include $(obj)/build.h -I. -I$(src) $< -o $@
Stefan Reinauer52db0b92012-12-07 17:15:04 -0800156
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700157$(obj)/mainboard/$(MAINBOARDDIR)/romstage.pre.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(OPTION_TABLE_H) $(obj)/build.h $(obj)/config.h
158 @printf " CC romstage.inc\n"
Patrick Georgi58f73a62014-05-17 14:00:12 +0200159 $(CC_romstage) -MMD $(CFLAGS_romstage) $(CPPFLAGS_romstage) -D__PRE_RAM__ -I$(src) -I. -I$(obj) -c -S $< -o $@
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700160
161endif # CONFIG_ARCH_ROMSTAGE_ARMV7
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700162
163###############################################################################
164# ramstage
165###############################################################################
166
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700167ifeq ($(CONFIG_ARCH_RAMSTAGE_ARMV7),y)
168
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700169ramstage-y += exception.c
170ramstage-y += exception_asm.S
171ramstage-y += div0.c
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700172ramstage-y += cache.c
Ronald G. Minnichd6b16f52013-08-16 15:57:56 -0700173ramstage-y += cpu.c
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700174ramstage-y += mmu.c
175ramstage-y += eabi_compat.c
176ramstage-y += boot.c
177ramstage-y += tables.c
178ramstage-y += memset.S
179ramstage-y += memcpy.S
180ramstage-y += memmove.S
181ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c)
182
183$(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(src)/arch/armv7/ramstage.ld
184 @printf " CC $(subst $(obj)/,,$(@))\n"
185ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700186 $(LD_ramstage) -m armelf_linux_eabi -o $@ -L$(obj) $< -T $(src)/arch/armv7/ramstage.ld
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700187else
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700188 $(CC_ramstage) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(src)/arch/armv7/ramstage.ld $<
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700189endif
190
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700191$(objgenerated)/ramstage.o: $(stages_o) $$(ramstage-objs) $(LIBGCC_FILE_NAME_ramstage)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700192 @printf " CC $(subst $(obj)/,,$(@))\n"
193ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700194 $(LD_ramstage) -m -m armelf_linux_eabi -r -o $@ --wrap __divdi3 --wrap __udivdi3 --wrap __moddi3 --wrap __umoddi3 --wrap __uidiv --start-group $(ramstage-objs) $(LIBGCC_FILE_NAME_ramstage) --end-group
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700195else
Patrick Georgi58f73a62014-05-17 14:00:12 +0200196 $(CC_ramstage) $(CFLAGS_ramstage) $(CPPFLAGS_ramstage) -nostdlib -r -o $@ -Wl,--start-group $(stages_o) $(ramstage-objs) $(LIBGCC_FILE_NAME_ramstage) -Wl,--end-group
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700197endif
198
199ifeq ($(CONFIG_GENERATE_PIRQ_TABLE),y)
200ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/irq_tables.c
201endif
202ifeq ($(CONFIG_BOARD_HAS_HARD_RESET),y)
203ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/reset.c
204endif
205ifeq ($(CONFIG_GENERATE_ACPI_TABLES),y)
206ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/acpi_tables.c
207ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/dsdt.asl
208# make doesn't have arithmetic operators or greater-than comparisons
209ifeq ($(subst 5,4,$(CONFIG_ACPI_SSDTX_NUM)),4)
210ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/ssdt2.asl
211ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/ssdt3.asl
212ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/ssdt4.asl
213endif
214ifeq ($(CONFIG_ACPI_SSDTX_NUM),5)
215ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/ssdt5.asl
216endif
217endif
218
219ifeq ($(CONFIG_HAVE_BUS_CONFIG),y)
220ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/get_bus_conf.c
221endif
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700222
223endif # CONFIG_ARCH_RAMSTAGE_ARMV7