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 |
Patrick Georgi | b890a12 | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 20 | ## Foundation, Inc. |
Stefan Reinauer | 3058491 | 2010-08-14 20:38:17 +0000 | [diff] [blame] | 21 | ## |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 22 | |
Patrick Georgi | 70a6b4f | 2015-03-27 14:14:58 +0100 | [diff] [blame] | 23 | ################################################################################ |
| 24 | # i386 specific tools |
| 25 | NVRAMTOOL:=$(objutil)/nvramtool/nvramtool |
| 26 | |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 27 | OPTION_TABLE_H:= |
| 28 | ifeq ($(CONFIG_HAVE_OPTION_TABLE),y) |
Patrick Georgi | 70a6b4f | 2015-03-27 14:14:58 +0100 | [diff] [blame] | 29 | |
Patrick Georgi | 5c0bca2 | 2011-01-30 16:31:15 +0000 | [diff] [blame] | 30 | cbfs-files-y += cmos_layout.bin |
| 31 | cmos_layout.bin-file = $(obj)/cmos_layout.bin |
| 32 | cmos_layout.bin-type = 0x01aa |
Patrick Georgi | 2447937 | 2011-01-18 13:56:36 +0000 | [diff] [blame] | 33 | |
Patrick Georgi | 70a6b4f | 2015-03-27 14:14:58 +0100 | [diff] [blame] | 34 | $(obj)/cmos_layout.bin: $(NVRAMTOOL) $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout |
| 35 | @printf " OPTION $(subst $(obj)/,,$(@))\n" |
| 36 | $(NVRAMTOOL) -y $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout -L $@ |
| 37 | |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 38 | OPTION_TABLE_H:=$(obj)/option_table.h |
Patrick Georgi | 70a6b4f | 2015-03-27 14:14:58 +0100 | [diff] [blame] | 39 | |
| 40 | $(OPTION_TABLE_H): $(NVRAMTOOL) $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout |
| 41 | @printf " OPTION $(subst $(obj)/,,$(@))\n" |
| 42 | $(NVRAMTOOL) -y $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout -H $@ |
| 43 | endif # CONFIG_HAVE_OPTION_TABLE |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 44 | |
Patrick Georgi | ff9d78c | 2011-01-30 16:37:39 +0000 | [diff] [blame] | 45 | stripped_vgabios_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_ID)) |
| 46 | cbfs-files-$(CONFIG_VGA_BIOS) += pci$(stripped_vgabios_id).rom |
| 47 | pci$(stripped_vgabios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_FILE)) |
| 48 | pci$(stripped_vgabios_id).rom-type := optionrom |
| 49 | |
| 50 | cbfs-files-$(CONFIG_INTEL_MBI) += mbi.bin |
| 51 | mbi.bin-file := $(call strip_quotes,$(CONFIG_MBI_FILE)) |
| 52 | mbi.bin-type := mbi |
| 53 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 54 | ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y) |
Julius Werner | f780c40 | 2014-11-10 13:11:50 -0800 | [diff] [blame] | 55 | CBFSTOOL_PRE1_OPTS = -m x86 -s $(CONFIG_ROM_SIZE) \ |
| 56 | -o $$(( $(CONFIG_ROM_SIZE) - $(CONFIG_CBFS_SIZE) )) |
Furquan Shaikh | b4ce4d4 | 2014-10-30 11:47:20 -0700 | [diff] [blame] | 57 | # Make sure that segment for .car.data is ignored while adding romstage. |
| 58 | 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] | 59 | endif |
Patrick Georgi | ff9d78c | 2011-01-30 16:37:39 +0000 | [diff] [blame] | 60 | |
Martin Roth | 16bc7e8 | 2015-06-28 13:49:16 -0600 | [diff] [blame] | 61 | ## Calculate the base address of CBFS for later comparisons |
| 62 | CBFS_BASE_ADDRESS=$(call int-add, $(call int-subtract, 0xffffffff $(CONFIG_CBFS_SIZE)) 1) |
| 63 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 64 | ############################################################################### |
| 65 | # bootblock |
| 66 | ############################################################################### |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 67 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 68 | ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32)$(CONFIG_ARCH_BOOTBLOCK_X86_64),y) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 69 | |
Aaron Durbin | 3953e39 | 2015-09-03 00:41:29 -0500 | [diff] [blame] | 70 | # Add the assembly file that pulls in the rest of the dependencies in |
| 71 | # the right order. Make sure the auto generated bootblock.inc is a proper |
| 72 | # dependency. Make the same true for the linker sript. |
| 73 | bootblock-y += bootblock.S |
| 74 | $(obj)/arch/x86/bootblock.bootblock.o: $(objgenerated)/bootblock.inc |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 75 | |
Aaron Durbin | 3953e39 | 2015-09-03 00:41:29 -0500 | [diff] [blame] | 76 | bootblock-y += bootblock.ld |
| 77 | $(obj)/arch/x86/bootblock.bootblock.ld: $(objgenerated)/bootblock.ld |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 78 | |
Patrick Georgi | 56b8309 | 2015-04-02 19:44:19 +0200 | [diff] [blame] | 79 | bootblock_romccflags := -mcpu=i386 -O2 -D__PRE_RAM__ -D__BOOTBLOCK__ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 80 | ifeq ($(CONFIG_SSE),y) |
Patrick Georgi | 56b8309 | 2015-04-02 19:44:19 +0200 | [diff] [blame] | 81 | bootblock_romccflags := -mcpu=k7 -msse -O2 -D__PRE_RAM__ -D__BOOTBLOCK__ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 82 | endif |
| 83 | |
Aaron Durbin | 3953e39 | 2015-09-03 00:41:29 -0500 | [diff] [blame] | 84 | # This is a hack in case there are no per chipset linker files. |
| 85 | $(objgenerated)/empty: |
| 86 | touch $@ |
| 87 | |
| 88 | $(objgenerated)/bootblock.ld: $$(filter-out $(obj)/arch/x86/bootblock.bootblock.ld, $$(filter %.ld,$$(bootblock-objs))) $(objgenerated)/empty |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 89 | @printf " GEN $(subst $(obj)/,,$(@))\n" |
Marc Jones | ac630f7 | 2015-06-30 15:46:49 -0600 | [diff] [blame] | 90 | cat $^ >> $@.tmp |
| 91 | mv $@.tmp $@ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 92 | |
Patrick Georgi | ef0158e | 2015-07-27 17:47:55 +0200 | [diff] [blame] | 93 | $(objgenerated)/bootblock.inc: $(src)/arch/x86/$(subst ",,$(CONFIG_BOOTBLOCK_SOURCE)) $(objutil)/romcc/romcc $(OPTION_TABLE_H) $(KCONFIG_AUTOHEADER) |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 94 | @printf " ROMCC $(subst $(obj)/,,$(@))\n" |
Patrick Georgi | 5930774 | 2014-05-19 09:23:57 +0200 | [diff] [blame] | 95 | $(CC_bootblock) $(CPPFLAGS_bootblock) -MM -MT$(objgenerated)/bootblock.inc \ |
Kyösti Mälkki | f775b8c | 2012-04-19 12:14:53 +0300 | [diff] [blame] | 96 | $< > $(objgenerated)/bootblock.inc.d |
Patrick Georgi | 5930774 | 2014-05-19 09:23:57 +0200 | [diff] [blame] | 97 | $(ROMCC) -c -S $(bootblock_romccflags) -I. $(CPPFLAGS_bootblock) $< -o $@ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 98 | |
Aaron Durbin | 3953e39 | 2015-09-03 00:41:29 -0500 | [diff] [blame] | 99 | $(objcbfs)/bootblock.debug: $(obj)/arch/x86/bootblock.bootblock.o $(obj)/arch/x86/bootblock.bootblock.ld |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 100 | @printf " LINK $(subst $(obj)/,,$(@))\n" |
Stefan Reinauer | 9874933 | 2015-06-23 12:57:06 -0700 | [diff] [blame] | 101 | ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y) |
Aaron Durbin | 3953e39 | 2015-09-03 00:41:29 -0500 | [diff] [blame] | 102 | $(LD_bootblock) -m elf_i386 --oformat elf32-i386 -static -o $@ -L$(obj) $< -T $(obj)/arch/x86/bootblock.bootblock.ld |
Stefan Reinauer | 9874933 | 2015-06-23 12:57:06 -0700 | [diff] [blame] | 103 | else |
Aaron Durbin | 3953e39 | 2015-09-03 00:41:29 -0500 | [diff] [blame] | 104 | $(LD_bootblock) -m elf_x86_64 --oformat elf64-x86-64 -static -o $@ -L$(obj) $< -T $(obj)/arch/x86/bootblock.bootblock.ld |
Stefan Reinauer | 9874933 | 2015-06-23 12:57:06 -0700 | [diff] [blame] | 105 | endif |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 106 | |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 107 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 108 | endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64 |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 109 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 110 | ############################################################################### |
| 111 | # romstage |
| 112 | ############################################################################### |
| 113 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 114 | ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 115 | |
Aaron Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 116 | romstage-y += memlayout.ld |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 117 | |
Aaron Durbin | e581b06 | 2015-09-03 11:29:28 -0500 | [diff] [blame] | 118 | # Chipset specific assembly stubs in the romstage program flow. Certain |
| 119 | # boards have more than one assembly stub so collect those and put them |
| 120 | # into a single generated file. |
| 121 | crt0s = $(cpu_incs-y) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 122 | |
Aaron Durbin | e581b06 | 2015-09-03 11:29:28 -0500 | [diff] [blame] | 123 | $(objgenerated)/romstage.inc: $$(crt0s) |
| 124 | @printf " GEN $(subst $(obj)/,,$(@))\n" |
| 125 | printf '$(foreach crt0,$(crt0s),#include "$(crt0)"\n)' > $@ |
| 126 | |
| 127 | # Add the assembly file that pulls in the rest of the dependencies in |
| 128 | # the right order. Make sure the auto generated romstage.inc is a proper |
| 129 | # dependency. |
| 130 | romstage-y += romstage.S |
| 131 | $(obj)/arch/x86/romstage.romstage.o: $(objgenerated)/romstage.inc |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 132 | |
Aaron Durbin | 85982cd | 2015-09-03 11:01:17 -0500 | [diff] [blame] | 133 | ifneq ($(CONFIG_ROMCC),y) |
| 134 | |
| 135 | romstage-srcs += $(src)/mainboard/$(MAINBOARDDIR)/romstage.c |
| 136 | |
| 137 | else # CONFIG_ROMCC == y |
| 138 | |
| 139 | # This order matters. The mainboards requiring ROMCC need their mainboard |
| 140 | # code to follow the prior crt0s files for program flow control. The |
| 141 | # romstage.inc from the MAINBOARDDIR is implicitly main() for romstage |
| 142 | # because of the instruction sequen fall-through. |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 143 | crt0s += $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc |
Stefan Reinauer | 6cb3a59 | 2015-07-13 09:39:15 +0200 | [diff] [blame] | 144 | crt0s += $(src)/arch/x86/crt0_romcc_epilogue.inc |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 145 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 146 | ifeq ($(CONFIG_MMX),y) |
| 147 | ifeq ($(CONFIG_SSE),y) |
| 148 | ROMCCFLAGS := -mcpu=p4 -O2 # MMX, SSE |
| 149 | else |
| 150 | ROMCCFLAGS := -mcpu=p2 -O2 # MMX, !SSE |
| 151 | endif |
| 152 | else |
| 153 | ROMCCFLAGS := -mcpu=i386 -O2 # !MMX, !SSE |
| 154 | endif |
| 155 | |
Patrick Georgi | 24cca75 | 2014-11-29 11:51:25 +0100 | [diff] [blame] | 156 | $(objcbfs)/romstage%.bin: $(objcbfs)/romstage%.elf |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 157 | @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" |
| 158 | $(OBJCOPY_romstage) -O binary $< $@ |
| 159 | |
Patrick Georgi | 24cca75 | 2014-11-29 11:51:25 +0100 | [diff] [blame] | 160 | $(objcbfs)/romstage%.elf: $(objcbfs)/romstage%.debug |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 161 | @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" |
| 162 | cp $< $@.tmp |
| 163 | $(OBJCOPY_romstage) --strip-debug $@.tmp |
| 164 | $(OBJCOPY_romstage) --add-gnu-debuglink=$< $@.tmp |
| 165 | mv $@.tmp $@ |
| 166 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 167 | $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(objutil)/romcc/romcc $(OPTION_TABLE_H) $(obj)/build.h $(obj)/config.h |
| 168 | printf " ROMCC romstage.inc\n" |
Patrick Georgi | 815f4bf | 2015-04-28 22:43:31 +0200 | [diff] [blame] | 169 | $(ROMCC) -c -S $(ROMCCFLAGS) -D__ROMSTAGE__ -D__PRE_RAM__ -I. $(CPPFLAGS_romstage) $< -o $@ |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 170 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 171 | endif |
| 172 | |
Alexandru Gagniuc | eb3c991 | 2014-03-29 13:01:11 -0500 | [diff] [blame] | 173 | romstage-libs ?= |
| 174 | |
Stefan Reinauer | 9874933 | 2015-06-23 12:57:06 -0700 | [diff] [blame] | 175 | ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y) |
| 176 | romstage-oformat=elf32-i386 |
| 177 | else |
| 178 | romstage-oformat=elf64-x86-64 |
| 179 | endif |
| 180 | |
Alexandru Gagniuc | eb3c991 | 2014-03-29 13:01:11 -0500 | [diff] [blame] | 181 | $(objcbfs)/romstage_null.debug: $$(romstage-objs) $(objgenerated)/romstage_null.ld $$(romstage-libs) |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 182 | @printf " LINK $(subst $(obj)/,,$(@))\n" |
Aaron Durbin | d4dd44c | 2015-09-06 10:15:17 -0500 | [diff] [blame^] | 183 | $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) $(COMPILER_RT_FLAGS_romstage) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) $(romstage-libs) --no-whole-archive $(COMPILER_RT_romstage) --end-group -T $(objgenerated)/romstage_null.ld --oformat $(romstage-oformat) |
Martin Roth | dbb50c4 | 2015-08-22 10:37:39 -0600 | [diff] [blame] | 184 | LANG=C LC_ALL= $(OBJCOPY_romstage) --only-section .illegal_globals $(@) $(objcbfs)/romstage_null.offenders 2>&1 | \ |
| 185 | grep -v "Empty loadable segment detected" && \ |
Furquan Shaikh | 3cf6aea | 2014-10-30 11:53:38 -0700 | [diff] [blame] | 186 | $(NM_romstage) $(objcbfs)/romstage_null.offenders | grep -q ""; if [ $$? -eq 0 ]; then \ |
Stefan Reinauer | b6e1237 | 2012-07-31 14:52:04 -0700 | [diff] [blame] | 187 | echo "Forbidden global variables in romstage:"; \ |
Furquan Shaikh | 3cf6aea | 2014-10-30 11:53:38 -0700 | [diff] [blame] | 188 | $(NM_romstage) $(objcbfs)/romstage_null.offenders; false; \ |
Stefan Reinauer | b6e1237 | 2012-07-31 14:52:04 -0700 | [diff] [blame] | 189 | else true; fi |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 190 | |
Patrick Georgi | 24cca75 | 2014-11-29 11:51:25 +0100 | [diff] [blame] | 191 | $(objcbfs)/romstage.debug: $$(romstage-objs) $(objgenerated)/romstage.ld $$(romstage-libs) |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 192 | @printf " LINK $(subst $(obj)/,,$(@))\n" |
Aaron Durbin | d4dd44c | 2015-09-06 10:15:17 -0500 | [diff] [blame^] | 193 | $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) $(COMPILER_RT_FLAGS_romstage) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) $(romstage-libs) --no-whole-archive $(COMPILER_RT_romstage) --end-group -T $(objgenerated)/romstage.ld --oformat $(romstage-oformat) |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 194 | |
Aaron Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 195 | $(objgenerated)/romstage_null.ld: $(obj)/arch/x86/memlayout.romstage.ld |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 196 | @printf " GEN $(subst $(obj)/,,$(@))\n" |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 197 | rm -f $@ |
| 198 | printf "ROMSTAGE_BASE = 0x0;\n" > $@.tmp |
Aaron Durbin | 14714e1 | 2015-09-04 12:06:05 -0500 | [diff] [blame] | 199 | cat $< >> $@.tmp |
Marc Jones | ac630f7 | 2015-06-30 15:46:49 -0600 | [diff] [blame] | 200 | mv $@.tmp $@ |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 201 | |
Patrick Georgi | 24cca75 | 2014-11-29 11:51:25 +0100 | [diff] [blame] | 202 | $(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] | 203 | @printf " GEN $(subst $(obj)/,,$(@))\n" |
| 204 | rm -f $@ |
Kyösti Mälkki | 1e9c1b3 | 2012-04-19 14:43:47 +0300 | [diff] [blame] | 205 | 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] | 206 | sed -e '/^ROMSTAGE_BASE/d' $(objgenerated)/romstage_null.ld >> $@.tmp |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 207 | mv $@.tmp $@ |
| 208 | |
Aaron Durbin | 4b34909 | 2015-09-07 23:05:28 -0500 | [diff] [blame] | 209 | # Use a '-a 64' option to cbfstool locate to provide a minimum alignment |
| 210 | # requirement for the overall romstage. While the first object within |
| 211 | # romstage could have a 4 byte minimum alignment that doesn't mean the linker |
| 212 | # won't decide the entire section should be aligned to a larger value. In the |
| 213 | # future cbfstool should add XIP files proper and honor the alignment |
| 214 | # requirements of the program segment. |
Kyösti Mälkki | 1e9c1b3 | 2012-04-19 14:43:47 +0300 | [diff] [blame] | 215 | $(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] | 216 | rm -f $@ |
Aaron Durbin | 4b34909 | 2015-09-07 23:05:28 -0500 | [diff] [blame] | 217 | $(CBFSTOOL) $(obj)/coreboot.pre1 locate -T -f $(objcbfs)/romstage_null.bin -n $(CONFIG_CBFS_PREFIX)/romstage -P $(CONFIG_XIP_ROM_SIZE) -a 64 > $@.tmp \ |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 218 | || { 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] | 219 | mv $@.tmp $@ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 220 | |
Patrick Georgi | d69839b | 2015-04-03 10:32:17 +0200 | [diff] [blame] | 221 | # Compiling crt0 with -g seems to trigger https://sourceware.org/bugzilla/show_bug.cgi?id=6428 |
| 222 | romstage-S-ccopts += -I. -g0 |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 223 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 224 | endif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64 |
Stefan Reinauer | f1939bb | 2010-12-30 17:39:50 +0000 | [diff] [blame] | 225 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 226 | ############################################################################### |
| 227 | # ramstage |
| 228 | ############################################################################### |
| 229 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 230 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 231 | |
Patrick Georgi | c32a52c | 2015-06-22 21:10:34 +0200 | [diff] [blame] | 232 | ifeq ($(CONFIG_COMPILE_IN_DSDT),y) |
| 233 | ramstage-srcs += $(obj)/dsdt.aml |
| 234 | |
| 235 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) |
| 236 | target-objcopy=-O elf32-i386 -B i386 |
| 237 | endif |
| 238 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_64),y) |
| 239 | target-objcopy=-O elf64-x86_64 -B x86_64 |
| 240 | endif |
| 241 | |
| 242 | define ramstage-objs_aml_template |
| 243 | $(call src-to-obj,ramstage,$(1).aml): $(1).aml |
| 244 | @printf " OBJCOPY $$(subst $$(obj)/,,$$(@))\n" |
| 245 | cd $$(dir $$@) && $$(OBJCOPY_ramstage) -I binary $$(target-objcopy) $$(notdir $$<) $$(notdir $$@) |
| 246 | endef |
| 247 | endif |
| 248 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 249 | ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c) |
| 250 | ifeq ($(CONFIG_GENERATE_MP_TABLE),y) |
| 251 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/mptable.c),) |
| 252 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mptable.c |
| 253 | endif |
| 254 | endif |
| 255 | ifeq ($(CONFIG_GENERATE_PIRQ_TABLE),y) |
| 256 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/irq_tables.c |
| 257 | endif |
| 258 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/reset.c),) |
| 259 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/reset.c |
| 260 | endif |
Vladimir Serbinenko | 822bc65 | 2014-01-03 15:55:40 +0100 | [diff] [blame] | 261 | ifeq ($(CONFIG_HAVE_ACPI_TABLES),y) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 262 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/acpi_tables.c |
Aaron Durbin | ab454c6 | 2015-07-30 12:44:58 -0500 | [diff] [blame] | 263 | ifeq ($(CONFIG_COMPILE_IN_DSDT),y) |
| 264 | $(eval $(call asl_template,dsdt,n)) |
| 265 | else |
Vladimir Serbinenko | 36f8d27 | 2015-05-31 12:31:59 +0200 | [diff] [blame] | 266 | $(eval $(call asl_template,dsdt)) |
Aaron Durbin | ab454c6 | 2015-07-30 12:44:58 -0500 | [diff] [blame] | 267 | endif |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 268 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/fadt.c),) |
| 269 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/fadt.c |
| 270 | endif |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 271 | endif # CONFIG_GENERATE_ACPI_TABLES |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 272 | ifeq ($(CONFIG_HAVE_SMI_HANDLER),y) |
| 273 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/smihandler.c),) |
| 274 | smm-srcs += src/mainboard/$(MAINBOARDDIR)/smihandler.c |
| 275 | endif |
| 276 | endif |
| 277 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/get_bus_conf.c),) |
| 278 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/get_bus_conf.c |
| 279 | endif |
| 280 | |
| 281 | ramstage-libs ?= |
| 282 | |
| 283 | ifeq ($(CONFIG_RELOCATABLE_RAMSTAGE),y) |
| 284 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 285 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) |
Furquan Shaikh | 133096b | 2014-07-31 09:28:55 -0700 | [diff] [blame] | 286 | $(eval $(call rmodule_link,$(objcbfs)/ramstage.debug, $(objgenerated)/ramstage.o, $(CONFIG_HEAP_SIZE),x86_32)) |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 287 | else |
| 288 | $(eval $(call rmodule_link,$(objcbfs)/ramstage.debug, $(objgenerated)/ramstage.o, $(CONFIG_HEAP_SIZE),x86_64)) |
| 289 | endif |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 290 | |
| 291 | # The rmodule_link defintion creates an elf file with .rmod extension. |
| 292 | $(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod |
| 293 | cp $< $@ |
| 294 | |
| 295 | else |
| 296 | |
Aaron Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 297 | ramstage-y += memlayout.ld |
Patrick Georgi | 828e0e8 | 2015-04-04 15:50:20 +0200 | [diff] [blame] | 298 | |
Aaron Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 299 | $(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(obj)/arch/x86/memlayout.ramstage.ld |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 300 | @printf " CC $(subst $(obj)/,,$(@))\n" |
Aaron Durbin | d4dd44c | 2015-09-06 10:15:17 -0500 | [diff] [blame^] | 301 | $(LD_ramstage) $(CPPFLAGS) $(LDFLAGS_ramstage) -o $@ -L$(obj) $< -T $(obj)/arch/x86/memlayout.ramstage.ld |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 302 | |
| 303 | endif |
| 304 | |
Patrick Georgi | 3ce96bd | 2014-11-22 17:42:58 +0100 | [diff] [blame] | 305 | $(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 306 | @printf " CC $(subst $(obj)/,,$(@))\n" |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 307 | ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y) |
Patrick Georgi | eec8dfb | 2015-05-07 22:24:41 +0200 | [diff] [blame] | 308 | $(LD_ramstage) -m elf_i386 -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 |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 309 | else |
| 310 | $(LD_ramstage) -m elf_x86_64 -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 |
| 311 | endif |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 312 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 313 | endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64 |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 314 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 315 | |
Stefan Reinauer | 6cb3a59 | 2015-07-13 09:39:15 +0200 | [diff] [blame] | 316 | ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y) |
| 317 | |
| 318 | romstage-y += cbmem.c |
| 319 | romstage-y += boot.c |
| 320 | |
| 321 | romstage-y += cbfs_and_run.c |
| 322 | romstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += cpu_common.c |
| 323 | romstage-y += memset.c |
| 324 | romstage-y += memcpy.c |
| 325 | romstage-y += memmove.c |
| 326 | romstage-y += mmap_boot.c |
| 327 | |
| 328 | romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c |
| 329 | |
| 330 | endif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64 |
| 331 | |
| 332 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y) |
| 333 | |
| 334 | ramstage-y += boot.c |
| 335 | ramstage-y += gdt.c |
| 336 | ramstage-y += tables.c |
| 337 | ramstage-y += cbmem.c |
| 338 | ramstage-$(CONFIG_GENERATE_MP_TABLE) += mpspec.c |
| 339 | ramstage-$(CONFIG_GENERATE_PIRQ_TABLE) += pirq_routing.c |
| 340 | ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi.c |
| 341 | ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c |
| 342 | ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpigen.c |
| 343 | ramstage-$(CONFIG_HAVE_ACPI_RESUME) += wakeup.S |
| 344 | |
| 345 | ramstage-y += c_start.S |
| 346 | ramstage-y += cpu.c |
| 347 | ramstage-y += cpu_common.c |
| 348 | ramstage-y += pci_ops_conf1.c |
| 349 | ramstage-$(CONFIG_MMCONF_SUPPORT) += pci_ops_mmconf.c |
| 350 | ramstage-y += exception.c |
| 351 | ramstage-$(CONFIG_IOAPIC) += ioapic.c |
| 352 | ramstage-y += memset.c |
| 353 | ramstage-y += memcpy.c |
| 354 | ramstage-y += memmove.c |
| 355 | ramstage-y += ebda.c |
| 356 | ramstage-y += mmap_boot.c |
| 357 | ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c |
| 358 | ramstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S |
| 359 | ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c |
| 360 | |
| 361 | smm-y += memset.c |
| 362 | smm-y += memcpy.c |
| 363 | smm-y += memmove.c |
| 364 | smm-y += mmap_boot.c |
| 365 | |
| 366 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) |
| 367 | rmodules_x86_32-y += memset.c |
| 368 | rmodules_x86_32-y += memcpy.c |
| 369 | rmodules_x86_32-y += memmove.c |
| 370 | else |
| 371 | rmodules_x86_64-y += memset.c |
| 372 | rmodules_x86_64-y += memcpy.c |
| 373 | rmodules_x86_64-y += memmove.c |
| 374 | endif |
| 375 | |
| 376 | endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64 |