Alexandru Gagniuc | 00b579a | 2012-07-20 00:11:21 -0500 | [diff] [blame] | 1 | ################################################################################ |
Stefan Reinauer | 3058491 | 2010-08-14 20:38:17 +0000 | [diff] [blame] | 2 | ## |
| 3 | ## This file is part of the coreboot project. |
| 4 | ## |
Alexandru Gagniuc | 00b579a | 2012-07-20 00:11:21 -0500 | [diff] [blame] | 5 | ## Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com> |
Stefan Reinauer | 3058491 | 2010-08-14 20:38:17 +0000 | [diff] [blame] | 6 | ## Copyright (C) 2009-2010 coresystems GmbH |
| 7 | ## Copyright (C) 2009 Ronald G. Minnich |
| 8 | ## |
| 9 | ## This program is free software; you can redistribute it and/or modify |
| 10 | ## it under the terms of the GNU General Public License as published by |
| 11 | ## the Free Software Foundation; version 2 of the License. |
| 12 | ## |
| 13 | ## This program is distributed in the hope that it will be useful, |
| 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | ## GNU General Public License for more details. |
| 17 | ## |
| 18 | ## You should have received a copy of the GNU General Public License |
| 19 | ## along with this program; if not, write to the Free Software |
Paul Menzel | a46a712 | 2013-02-23 18:37:27 +0100 | [diff] [blame] | 20 | ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Stefan Reinauer | 3058491 | 2010-08-14 20:38:17 +0000 | [diff] [blame] | 21 | ## |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 22 | ############################################################################### |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 23 | # Take care of subdirectories |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 24 | ############################################################################### |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 25 | subdirs-y += boot |
Stefan Reinauer | e377857 | 2010-01-30 09:47:18 +0000 | [diff] [blame] | 26 | # subdirs-y += init |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 27 | subdirs-y += lib |
| 28 | subdirs-y += smp |
| 29 | |
Edward O'Callaghan | b0195a3 | 2014-05-23 01:32:44 +1000 | [diff] [blame] | 30 | DISASSEMBLY=-Wa,--divide |
Patrick Georgi | 327a866 | 2014-01-18 16:26:11 +0100 | [diff] [blame] | 31 | |
Patrick Georgi | 70a6b4f | 2015-03-27 14:14:58 +0100 | [diff] [blame] | 32 | ################################################################################ |
| 33 | # i386 specific tools |
| 34 | NVRAMTOOL:=$(objutil)/nvramtool/nvramtool |
| 35 | |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 36 | OPTION_TABLE_H:= |
| 37 | ifeq ($(CONFIG_HAVE_OPTION_TABLE),y) |
Patrick Georgi | 70a6b4f | 2015-03-27 14:14:58 +0100 | [diff] [blame] | 38 | |
Patrick Georgi | 5c0bca2 | 2011-01-30 16:31:15 +0000 | [diff] [blame] | 39 | cbfs-files-y += cmos_layout.bin |
| 40 | cmos_layout.bin-file = $(obj)/cmos_layout.bin |
| 41 | cmos_layout.bin-type = 0x01aa |
Patrick Georgi | 2447937 | 2011-01-18 13:56:36 +0000 | [diff] [blame] | 42 | |
Patrick Georgi | 70a6b4f | 2015-03-27 14:14:58 +0100 | [diff] [blame] | 43 | $(obj)/cmos_layout.bin: $(NVRAMTOOL) $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout |
| 44 | @printf " OPTION $(subst $(obj)/,,$(@))\n" |
| 45 | $(NVRAMTOOL) -y $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout -L $@ |
| 46 | |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 47 | OPTION_TABLE_H:=$(obj)/option_table.h |
Patrick Georgi | 70a6b4f | 2015-03-27 14:14:58 +0100 | [diff] [blame] | 48 | |
| 49 | $(OPTION_TABLE_H): $(NVRAMTOOL) $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout |
| 50 | @printf " OPTION $(subst $(obj)/,,$(@))\n" |
| 51 | $(NVRAMTOOL) -y $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout -H $@ |
| 52 | endif # CONFIG_HAVE_OPTION_TABLE |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 53 | |
Patrick Georgi | ff9d78c | 2011-01-30 16:37:39 +0000 | [diff] [blame] | 54 | stripped_vgabios_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_ID)) |
| 55 | cbfs-files-$(CONFIG_VGA_BIOS) += pci$(stripped_vgabios_id).rom |
| 56 | pci$(stripped_vgabios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_FILE)) |
| 57 | pci$(stripped_vgabios_id).rom-type := optionrom |
| 58 | |
| 59 | cbfs-files-$(CONFIG_INTEL_MBI) += mbi.bin |
| 60 | mbi.bin-file := $(call strip_quotes,$(CONFIG_MBI_FILE)) |
| 61 | mbi.bin-type := mbi |
| 62 | |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 63 | ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 64 | CBFSTOOL_PRE1_OPTS = -m x86 -o $$(( $(CONFIG_ROM_SIZE) - $(CONFIG_CBFS_SIZE) )) |
Furquan Shaikh | b4ce4d4 | 2014-10-30 11:47:20 -0700 | [diff] [blame] | 65 | # Make sure that segment for .car.data is ignored while adding romstage. |
| 66 | CBFSTOOL_PRE_OPTS = -b $(shell cat $(objcbfs)/base_xip.txt) -S ".car.data" |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 67 | endif |
Patrick Georgi | ff9d78c | 2011-01-30 16:37:39 +0000 | [diff] [blame] | 68 | |
Kyösti Mälkki | 0db2ae3a | 2012-04-19 12:00:06 +0300 | [diff] [blame] | 69 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 70 | ############################################################################### |
| 71 | # bootblock |
| 72 | ############################################################################### |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 73 | |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 74 | ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y) |
| 75 | |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 76 | bootblock-srcs += $(src)/arch/x86/init/failover.ld |
| 77 | bootblock-srcs += $(src)/cpu/x86/16bit/entry16.ld |
| 78 | bootblock-srcs += $(src)/cpu/x86/16bit/reset16.ld |
| 79 | bootblock-srcs += $(src)/arch/x86/lib/id.ld |
Aaron Durbin | 6dccedd | 2012-12-03 16:17:40 -0600 | [diff] [blame] | 80 | ifeq ($(CONFIG_CPU_INTEL_FIRMWARE_INTERFACE_TABLE),y) |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 81 | bootblock-srcs += $(src)/cpu/intel/fit/fit.ld |
Aaron Durbin | 6dccedd | 2012-12-03 16:17:40 -0600 | [diff] [blame] | 82 | endif |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 83 | |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 84 | # TODO: Why can't this use the real bootblock-y += xxx.S mechanism instead? |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 85 | bootblock_inc = $(src)/arch/x86/init/prologue.inc |
| 86 | bootblock_inc += $(src)/cpu/x86/16bit/entry16.inc |
| 87 | bootblock_inc += $(src)/cpu/x86/16bit/reset16.inc |
| 88 | bootblock_inc += $(src)/cpu/x86/32bit/entry32.inc |
| 89 | bootblock_inc += $(src)/arch/x86/lib/id.inc |
Aaron Durbin | 6dccedd | 2012-12-03 16:17:40 -0600 | [diff] [blame] | 90 | ifeq ($(CONFIG_CPU_INTEL_FIRMWARE_INTERFACE_TABLE),y) |
| 91 | bootblock_inc += $(src)/cpu/intel/fit/fit.inc |
| 92 | endif |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 93 | bootblock_inc += $(chipset_bootblock_inc) |
| 94 | |
| 95 | ifeq ($(CONFIG_SSE),y) |
| 96 | bootblock_inc += $(src)/cpu/x86/sse_enable.inc |
| 97 | endif |
Kyösti Mälkki | f775b8c | 2012-04-19 12:14:53 +0300 | [diff] [blame] | 98 | bootblock_inc += $(objgenerated)/bootblock.inc |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 99 | bootblock_inc += $(src)/arch/x86/lib/walkcbfs.S |
| 100 | |
Patrick Georgi | 56b8309 | 2015-04-02 19:44:19 +0200 | [diff] [blame] | 101 | bootblock_romccflags := -mcpu=i386 -O2 -D__PRE_RAM__ -D__BOOTBLOCK__ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 102 | ifeq ($(CONFIG_SSE),y) |
Patrick Georgi | 56b8309 | 2015-04-02 19:44:19 +0200 | [diff] [blame] | 103 | bootblock_romccflags := -mcpu=k7 -msse -O2 -D__PRE_RAM__ -D__BOOTBLOCK__ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 104 | endif |
| 105 | |
Patrick Georgi | 828e0e8 | 2015-04-04 15:50:20 +0200 | [diff] [blame^] | 106 | $(objgenerated)/bootblock.ld: $(obj)/config.h $$(filter %.ld,$$(bootblock-srcs)) |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 107 | @printf " GEN $(subst $(obj)/,,$(@))\n" |
Patrick Georgi | 828e0e8 | 2015-04-04 15:50:20 +0200 | [diff] [blame^] | 108 | printf '$(foreach ldscript,$(^),#include "$(ldscript)"\n)' | $(CC_bootblock) $(PREPROCESS_ONLY) - > $@ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 109 | |
Marc Jones | 49fe74b | 2012-05-14 16:20:26 -0600 | [diff] [blame] | 110 | $(objgenerated)/bootblock_inc.S: $$(bootblock_inc) |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 111 | @printf " GEN $(subst $(obj)/,,$(@))\n" |
Patrick Georgi | 950f20a | 2012-01-17 13:13:59 +0100 | [diff] [blame] | 112 | printf '$(foreach crt0,$(bootblock_inc),#include "$(crt0)"\n)' > $@ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 113 | |
Kyösti Mälkki | f775b8c | 2012-04-19 12:14:53 +0300 | [diff] [blame] | 114 | $(objgenerated)/bootblock.o: $(objgenerated)/bootblock.s |
Daniele Forsi | 96639fb | 2014-08-02 13:45:17 +0200 | [diff] [blame] | 115 | @printf " CC $(subst $(obj)/,,$(@))\n" |
Patrick Georgi | 5930774 | 2014-05-19 09:23:57 +0200 | [diff] [blame] | 116 | $(CC_bootblock) $(CFLAGS_x86_32) $(DISASSEMBLY) -c -o $@ $< > $(basename $@).disasm |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 117 | |
Marc Jones | 49fe74b | 2012-05-14 16:20:26 -0600 | [diff] [blame] | 118 | $(objgenerated)/bootblock.s: $(objgenerated)/bootblock_inc.S $(obj)/config.h $(obj)/build.h |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 119 | @printf " CC $(subst $(obj)/,,$(@))\n" |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 120 | $(CC_bootblock) -MMD -x assembler-with-cpp -E -I$(src)/include -I$(src)/arch/x86/include -I$(obj) -include $(obj)/build.h -include $(obj)/config.h -I. -I$(src) $< -o $@ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 121 | |
Kyösti Mälkki | f775b8c | 2012-04-19 12:14:53 +0300 | [diff] [blame] | 122 | $(objgenerated)/bootblock.inc: $(src)/arch/x86/init/$(subst ",,$(CONFIG_BOOTBLOCK_SOURCE)) $(objutil)/romcc/romcc $(OPTION_TABLE_H) |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 123 | @printf " ROMCC $(subst $(obj)/,,$(@))\n" |
Patrick Georgi | 5930774 | 2014-05-19 09:23:57 +0200 | [diff] [blame] | 124 | $(CC_bootblock) $(CPPFLAGS_bootblock) -MM -MT$(objgenerated)/bootblock.inc \ |
Kyösti Mälkki | f775b8c | 2012-04-19 12:14:53 +0300 | [diff] [blame] | 125 | $< > $(objgenerated)/bootblock.inc.d |
Patrick Georgi | 5930774 | 2014-05-19 09:23:57 +0200 | [diff] [blame] | 126 | $(ROMCC) -c -S $(bootblock_romccflags) -I. $(CPPFLAGS_bootblock) $< -o $@ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 127 | |
Kyösti Mälkki | f775b8c | 2012-04-19 12:14:53 +0300 | [diff] [blame] | 128 | $(objcbfs)/bootblock.debug: $(objgenerated)/bootblock.o $(objgenerated)/bootblock.ld |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 129 | @printf " LINK $(subst $(obj)/,,$(@))\n" |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 130 | $(LD_bootblock) -m elf_i386 -static -o $@ -L$(obj) $< -T $(objgenerated)/bootblock.ld |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 131 | |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 132 | |
| 133 | endif # CONFIG_ARCH_BOOTBLOCK_X86_32 |
| 134 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 135 | ############################################################################### |
| 136 | # romstage |
| 137 | ############################################################################### |
| 138 | |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 139 | ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y) |
| 140 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 141 | crt0s = $(src)/arch/x86/init/prologue.inc |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 142 | romstage-srcs += $(src)/arch/x86/init/romstage.ld |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 143 | crt0s += $(src)/cpu/x86/32bit/entry32.inc |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 144 | romstage-srcs += $(src)/cpu/x86/32bit/entry32.ld |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 145 | |
| 146 | crt0s += $(src)/cpu/x86/fpu_enable.inc |
| 147 | ifeq ($(CONFIG_SSE),y) |
| 148 | crt0s += $(src)/cpu/x86/sse_enable.inc |
| 149 | endif |
| 150 | |
| 151 | crt0s += $(cpu_incs) |
| 152 | crt0s += $(cpu_incs-y) |
| 153 | |
| 154 | crt0s += $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc |
| 155 | |
| 156 | ifeq ($(CONFIG_ROMCC),y) |
| 157 | crt0s += $(src)/arch/x86/init/crt0_romcc_epilogue.inc |
| 158 | endif |
| 159 | |
| 160 | ifeq ($(CONFIG_ROMCC),y) |
| 161 | ifeq ($(CONFIG_MMX),y) |
| 162 | ifeq ($(CONFIG_SSE),y) |
| 163 | ROMCCFLAGS := -mcpu=p4 -O2 # MMX, SSE |
| 164 | else |
| 165 | ROMCCFLAGS := -mcpu=p2 -O2 # MMX, !SSE |
| 166 | endif |
| 167 | else |
| 168 | ROMCCFLAGS := -mcpu=i386 -O2 # !MMX, !SSE |
| 169 | endif |
| 170 | |
Patrick Georgi | 24cca75 | 2014-11-29 11:51:25 +0100 | [diff] [blame] | 171 | $(objcbfs)/romstage%.bin: $(objcbfs)/romstage%.elf |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 172 | @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" |
| 173 | $(OBJCOPY_romstage) -O binary $< $@ |
| 174 | |
Patrick Georgi | 24cca75 | 2014-11-29 11:51:25 +0100 | [diff] [blame] | 175 | $(objcbfs)/romstage%.elf: $(objcbfs)/romstage%.debug |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 176 | @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" |
| 177 | cp $< $@.tmp |
| 178 | $(OBJCOPY_romstage) --strip-debug $@.tmp |
| 179 | $(OBJCOPY_romstage) --add-gnu-debuglink=$< $@.tmp |
| 180 | mv $@.tmp $@ |
| 181 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 182 | $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(objutil)/romcc/romcc $(OPTION_TABLE_H) $(obj)/build.h $(obj)/config.h |
| 183 | printf " ROMCC romstage.inc\n" |
Patrick Georgi | 5930774 | 2014-05-19 09:23:57 +0200 | [diff] [blame] | 184 | $(ROMCC) -c -S $(ROMCCFLAGS) -D__PRE_RAM__ -I. $(CPPFLAGS_romstage) $< -o $@ |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 185 | else |
| 186 | |
| 187 | $(obj)/mainboard/$(MAINBOARDDIR)/romstage.pre.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(OPTION_TABLE_H) $(obj)/build.h $(obj)/config.h |
| 188 | @printf " CC romstage.inc\n" |
Patrick Georgi | 5930774 | 2014-05-19 09:23:57 +0200 | [diff] [blame] | 189 | $(CC_romstage) $(CPPFLAGS_romstage) $(CFLAGS_romstage) -MMD -D__PRE_RAM__ -I$(src) -I. -I$(obj) -c -S $< -o $@ |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 190 | |
| 191 | $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(obj)/mainboard/$(MAINBOARDDIR)/romstage.pre.inc |
| 192 | @printf " POST romstage.inc\n" |
| 193 | sed -e 's/\.rodata/.rom.data/g' -e 's/\^\.text/.section .rom.text/g' \ |
| 194 | -e 's/\^\.section \.text/.section .rom.text/g' $^ > $@.tmp |
| 195 | mv $@.tmp $@ |
| 196 | endif |
| 197 | |
Patrick Georgi | db27306 | 2015-03-27 17:03:28 +0100 | [diff] [blame] | 198 | romstage-srcs += $(objgenerated)/crt0.S |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 199 | |
Alexandru Gagniuc | eb3c991 | 2014-03-29 13:01:11 -0500 | [diff] [blame] | 200 | romstage-libs ?= |
| 201 | |
| 202 | $(objcbfs)/romstage_null.debug: $$(romstage-objs) $(objgenerated)/romstage_null.ld $$(romstage-libs) |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 203 | @printf " LINK $(subst $(obj)/,,$(@))\n" |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 204 | $(LD_romstage) --gc-sections -nostdlib -nostartfiles -static -o $@ -L$(obj) $(COMPILER_RT_FLAGS_romstage) --start-group $(filter-out %.ld,$(romstage-objs)) $(romstage-libs) $(COMPILER_RT_romstage) --end-group -T $(objgenerated)/romstage_null.ld |
Furquan Shaikh | 3cf6aea | 2014-10-30 11:53:38 -0700 | [diff] [blame] | 205 | $(OBJCOPY_romstage) --only-section .illegal_globals $(@) $(objcbfs)/romstage_null.offenders && \ |
| 206 | $(NM_romstage) $(objcbfs)/romstage_null.offenders | grep -q ""; if [ $$? -eq 0 ]; then \ |
Stefan Reinauer | b6e1237 | 2012-07-31 14:52:04 -0700 | [diff] [blame] | 207 | echo "Forbidden global variables in romstage:"; \ |
Furquan Shaikh | 3cf6aea | 2014-10-30 11:53:38 -0700 | [diff] [blame] | 208 | $(NM_romstage) $(objcbfs)/romstage_null.offenders; false; \ |
Stefan Reinauer | b6e1237 | 2012-07-31 14:52:04 -0700 | [diff] [blame] | 209 | else true; fi |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 210 | |
Patrick Georgi | 24cca75 | 2014-11-29 11:51:25 +0100 | [diff] [blame] | 211 | $(objcbfs)/romstage.debug: $$(romstage-objs) $(objgenerated)/romstage.ld $$(romstage-libs) |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 212 | @printf " LINK $(subst $(obj)/,,$(@))\n" |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 213 | $(LD_romstage) --gc-sections -nostdlib -nostartfiles -static -o $@ -L$(obj) $(COMPILER_RT_FLAGS_romstage) --start-group $(filter-out %.ld,$(romstage-objs)) $(romstage-libs) $(COMPILER_RT_romstage) --end-group -T $(objgenerated)/romstage.ld |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 214 | |
Patrick Georgi | 828e0e8 | 2015-04-04 15:50:20 +0200 | [diff] [blame^] | 215 | $(objgenerated)/romstage_null.ld: $(obj)/config.h $$(filter %.ld,$$(romstage-srcs)) |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 216 | @printf " GEN $(subst $(obj)/,,$(@))\n" |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 217 | rm -f $@ |
| 218 | printf "ROMSTAGE_BASE = 0x0;\n" > $@.tmp |
Patrick Georgi | 828e0e8 | 2015-04-04 15:50:20 +0200 | [diff] [blame^] | 219 | printf '$(foreach ldscript,$(^),#include "$(ldscript)"\n)' >> $@.tmp |
| 220 | $(CC_romstage) $(PREPROCESS_ONLY) $@.tmp > $@ |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 221 | |
Patrick Georgi | 24cca75 | 2014-11-29 11:51:25 +0100 | [diff] [blame] | 222 | $(objgenerated)/romstage.ld: $(objgenerated)/romstage_null.ld $(objcbfs)/base_xip.txt |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 223 | @printf " GEN $(subst $(obj)/,,$(@))\n" |
| 224 | rm -f $@ |
Kyösti Mälkki | 1e9c1b3 | 2012-04-19 14:43:47 +0300 | [diff] [blame] | 225 | sed -e 's/^/ROMSTAGE_BASE = /g' -e 's/$$/;/g' $(objcbfs)/base_xip.txt > $@.tmp |
Patrick Georgi | 828e0e8 | 2015-04-04 15:50:20 +0200 | [diff] [blame^] | 226 | sed -e '/^ROMSTAGE_BASE/d' $(objgenerated)/romstage_null.ld >> $@.tmp |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 227 | mv $@.tmp $@ |
| 228 | |
Kyösti Mälkki | 1e9c1b3 | 2012-04-19 14:43:47 +0300 | [diff] [blame] | 229 | $(objcbfs)/base_xip.txt: $(obj)/coreboot.pre1 $(objcbfs)/romstage_null.bin |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 230 | rm -f $@ |
Hung-Te Lin | e919837 | 2013-03-19 12:17:12 +0800 | [diff] [blame] | 231 | $(CBFSTOOL) $(obj)/coreboot.pre1 locate -T -f $(objcbfs)/romstage_null.bin -n $(CONFIG_CBFS_PREFIX)/romstage -P $(CONFIG_XIP_ROM_SIZE) > $@.tmp \ |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 232 | || { echo "The romstage is larger than XIP size. Please expand the CONFIG_XIP_ROM_SIZE" ; exit 1; } |
Hung-Te Lin | 657ea6a | 2013-01-28 23:00:47 +0800 | [diff] [blame] | 233 | mv $@.tmp $@ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 234 | |
Patrick Georgi | d69839b | 2015-04-03 10:32:17 +0200 | [diff] [blame] | 235 | $(objgenerated)/crt0.S: $$(crt0s) |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 236 | @printf " GEN $(subst $(obj)/,,$(@))\n" |
Patrick Georgi | d69839b | 2015-04-03 10:32:17 +0200 | [diff] [blame] | 237 | printf '$(foreach crt0,$(crt0s),#include "$(crt0)"\n)' > $@ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 238 | |
Patrick Georgi | d69839b | 2015-04-03 10:32:17 +0200 | [diff] [blame] | 239 | # Compiling crt0 with -g seems to trigger https://sourceware.org/bugzilla/show_bug.cgi?id=6428 |
| 240 | romstage-S-ccopts += -I. -g0 |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 241 | |
| 242 | endif # CONFIG_ARCH_ROMSTAGE_X86_32 |
Stefan Reinauer | f1939bb | 2010-12-30 17:39:50 +0000 | [diff] [blame] | 243 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 244 | ############################################################################### |
| 245 | # ramstage |
| 246 | ############################################################################### |
| 247 | |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 248 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) |
| 249 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 250 | ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c) |
| 251 | ifeq ($(CONFIG_GENERATE_MP_TABLE),y) |
| 252 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/mptable.c),) |
| 253 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mptable.c |
| 254 | endif |
| 255 | endif |
| 256 | ifeq ($(CONFIG_GENERATE_PIRQ_TABLE),y) |
| 257 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/irq_tables.c |
| 258 | endif |
| 259 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/reset.c),) |
| 260 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/reset.c |
| 261 | endif |
Vladimir Serbinenko | 822bc65 | 2014-01-03 15:55:40 +0100 | [diff] [blame] | 262 | ifeq ($(CONFIG_HAVE_ACPI_TABLES),y) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 263 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/acpi_tables.c |
| 264 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/dsdt.asl |
| 265 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/ssdt2.asl),) |
| 266 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/ssdt2.asl |
| 267 | endif |
| 268 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/ssdt3.asl),) |
| 269 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/ssdt3.asl |
| 270 | endif |
| 271 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/ssdt4.asl),) |
| 272 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/ssdt4.asl |
| 273 | endif |
| 274 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/ssdt5.asl),) |
| 275 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/ssdt5.asl |
| 276 | endif |
| 277 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/fadt.c),) |
| 278 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/fadt.c |
| 279 | endif |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 280 | endif # CONFIG_GENERATE_ACPI_TABLES |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 281 | ifeq ($(CONFIG_HAVE_SMI_HANDLER),y) |
| 282 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/smihandler.c),) |
| 283 | smm-srcs += src/mainboard/$(MAINBOARDDIR)/smihandler.c |
| 284 | endif |
| 285 | endif |
| 286 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/get_bus_conf.c),) |
| 287 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/get_bus_conf.c |
| 288 | endif |
| 289 | |
| 290 | ramstage-libs ?= |
| 291 | |
| 292 | ifeq ($(CONFIG_RELOCATABLE_RAMSTAGE),y) |
| 293 | |
Furquan Shaikh | 133096b | 2014-07-31 09:28:55 -0700 | [diff] [blame] | 294 | $(eval $(call rmodule_link,$(objcbfs)/ramstage.debug, $(objgenerated)/ramstage.o, $(CONFIG_HEAP_SIZE),x86_32)) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 295 | |
| 296 | # The rmodule_link defintion creates an elf file with .rmod extension. |
| 297 | $(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod |
| 298 | cp $< $@ |
| 299 | |
| 300 | else |
| 301 | |
Patrick Georgi | 828e0e8 | 2015-04-04 15:50:20 +0200 | [diff] [blame^] | 302 | ramstage-srcs += $(src)/arch/x86/ramstage.ld |
| 303 | |
| 304 | $(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(obj)/arch/x86/ramstage.ramstage.ld |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 305 | @printf " CC $(subst $(obj)/,,$(@))\n" |
Patrick Georgi | 828e0e8 | 2015-04-04 15:50:20 +0200 | [diff] [blame^] | 306 | $(LD_ramstage) --gc-sections -o $@ -L$(obj) $< -T $(obj)/arch/x86/ramstage.ramstage.ld |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 307 | |
| 308 | endif |
| 309 | |
Patrick Georgi | 3ce96bd | 2014-11-22 17:42:58 +0100 | [diff] [blame] | 310 | $(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 311 | @printf " CC $(subst $(obj)/,,$(@))\n" |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 312 | $(LD_ramstage) -m elf_i386 -r -o $@ $(COMPILER_RT_FLAGS_ramstage) --start-group $(filter-out %.ld,$(ramstage-objs)) $(ramstage-libs) $(COMPILER_RT_ramstage) --end-group |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 313 | |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 314 | endif # CONFIG_ARCH_RAMSTAGE_X86_32 |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 315 | |
| 316 | ################################################################################ |
| 317 | |
Stefan Reinauer | f1939bb | 2010-12-30 17:39:50 +0000 | [diff] [blame] | 318 | seabios: |
| 319 | $(MAKE) -C payloads/external/SeaBIOS -f Makefile.inc \ |
Peter Stuge | b1d1c4d | 2011-02-07 20:16:40 +0000 | [diff] [blame] | 320 | HOSTCC="$(HOSTCC)" \ |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 321 | CC="$(CC_x86_32)" LD="$(LD_x86_32)" OBJDUMP="$(OBJDUMP_x86_32)" \ |
| 322 | OBJCOPY="$(OBJCOPY_x86_32)" STRIP="$(STRIP_x86_32)" \ |
Patrick Georgi | 31dbb53 | 2014-05-10 14:21:38 +0200 | [diff] [blame] | 323 | AS="$(AS_x86_32)" \ |
Stefan Reinauer | f1939bb | 2010-12-30 17:39:50 +0000 | [diff] [blame] | 324 | CONFIG_SEABIOS_MASTER=$(CONFIG_SEABIOS_MASTER) \ |
Stefan Reinauer | aff6dc2 | 2012-01-21 10:34:22 -0800 | [diff] [blame] | 325 | CONFIG_SEABIOS_STABLE=$(CONFIG_SEABIOS_STABLE) \ |
Idwer Vollering | 7c1a49b | 2014-04-01 22:47:33 +0000 | [diff] [blame] | 326 | CONFIG_SEABIOS_THREAD_OPTIONROMS=$(CONFIG_SEABIOS_THREAD_OPTIONROMS) \ |
Edward O'Callaghan | a296f9e | 2014-09-13 03:43:49 +1000 | [diff] [blame] | 327 | CONFIG_SEABIOS_VGA_COREBOOT=$(CONFIG_SEABIOS_VGA_COREBOOT) \ |
Martin Roth | 0d7f133 | 2014-07-25 14:33:49 -0600 | [diff] [blame] | 328 | CONFIG_CONSOLE_SERIAL=$(CONFIG_CONSOLE_SERIAL) \ |
| 329 | CONFIG_TTYS0_BASE=$(CONFIG_TTYS0_BASE) \ |
Martin Roth | 4d7d25f | 2014-07-25 14:39:05 -0600 | [diff] [blame] | 330 | CONFIG_SEABIOS_MALLOC_UPPERMEMORY=$(CONFIG_SEABIOS_MALLOC_UPPERMEMORY) \ |
Marc Jones | c2dff7f | 2012-05-14 21:06:10 -0600 | [diff] [blame] | 331 | OUT=$(abspath $(obj)) IASL="$(IASL)" |
Stefan Reinauer | aff6dc2 | 2012-01-21 10:34:22 -0800 | [diff] [blame] | 332 | |
Stefan Reinauer | e50952f | 2011-04-15 03:34:05 +0000 | [diff] [blame] | 333 | filo: |
| 334 | $(MAKE) -C payloads/external/FILO -f Makefile.inc \ |
| 335 | HOSTCC="$(HOSTCC)" \ |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 336 | CC="$(CC_x86_32)" LD="$(LD_x86_32)" OBJDUMP="$(OBJDUMP_x86_32)" \ |
| 337 | OBJCOPY="$(OBJCOPY_x86_32)" STRIP="$(STRIP_x86_32)" \ |
Stefan Reinauer | e50952f | 2011-04-15 03:34:05 +0000 | [diff] [blame] | 338 | CONFIG_FILO_MASTER=$(CONFIG_FILO_MASTER) \ |
| 339 | CONFIG_FILO_STABLE=$(CONFIG_FILO_STABLE) |
Stefan Reinauer | f1939bb | 2010-12-30 17:39:50 +0000 | [diff] [blame] | 340 | |
Vladimir Serbinenko | 113a366 | 2013-11-14 12:10:08 +0100 | [diff] [blame] | 341 | |
| 342 | grub2: |
| 343 | $(MAKE) -C payloads/external/GRUB2 -f Makefile.inc \ |
| 344 | HOSTCC="$(HOSTCC)" \ |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 345 | CC="$(CC_x86_32)" LD="$(LD_x86_32)" OBJDUMP="$(OBJDUMP_x86_32)" \ |
| 346 | OBJCOPY="$(OBJCOPY_x86_32)" STRIP="$(STRIP_x86_32)" \ |
Vladimir Serbinenko | 113a366 | 2013-11-14 12:10:08 +0100 | [diff] [blame] | 347 | CONFIG_GRUB2_MASTER=$(CONFIG_GRUB2_MASTER) |