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