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 | |
Stefan Reinauer | 6cb3a59 | 2015-07-13 09:39:15 +0200 | [diff] [blame] | 70 | bootblock-srcs += $(src)/arch/x86/failover.ld |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 71 | bootblock-srcs += $(src)/cpu/x86/16bit/entry16.ld |
| 72 | bootblock-srcs += $(src)/cpu/x86/16bit/reset16.ld |
Stefan Reinauer | 6cb3a59 | 2015-07-13 09:39:15 +0200 | [diff] [blame] | 73 | bootblock-srcs += $(src)/arch/x86/id.ld |
Aaron Durbin | 6dccedd | 2012-12-03 16:17:40 -0600 | [diff] [blame] | 74 | ifeq ($(CONFIG_CPU_INTEL_FIRMWARE_INTERFACE_TABLE),y) |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 75 | bootblock-srcs += $(src)/cpu/intel/fit/fit.ld |
Aaron Durbin | 6dccedd | 2012-12-03 16:17:40 -0600 | [diff] [blame] | 76 | endif |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 77 | |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 78 | # TODO: Why can't this use the real bootblock-y += xxx.S mechanism instead? |
Stefan Reinauer | 6cb3a59 | 2015-07-13 09:39:15 +0200 | [diff] [blame] | 79 | bootblock_inc = $(src)/arch/x86/prologue.inc |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 80 | bootblock_inc += $(src)/cpu/x86/16bit/entry16.inc |
| 81 | bootblock_inc += $(src)/cpu/x86/16bit/reset16.inc |
| 82 | bootblock_inc += $(src)/cpu/x86/32bit/entry32.inc |
Stefan Reinauer | 6cb3a59 | 2015-07-13 09:39:15 +0200 | [diff] [blame] | 83 | bootblock_inc += $(src)/arch/x86/id.inc |
Aaron Durbin | 6dccedd | 2012-12-03 16:17:40 -0600 | [diff] [blame] | 84 | ifeq ($(CONFIG_CPU_INTEL_FIRMWARE_INTERFACE_TABLE),y) |
| 85 | bootblock_inc += $(src)/cpu/intel/fit/fit.inc |
| 86 | endif |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 87 | bootblock_inc += $(chipset_bootblock_inc) |
| 88 | |
| 89 | ifeq ($(CONFIG_SSE),y) |
| 90 | bootblock_inc += $(src)/cpu/x86/sse_enable.inc |
| 91 | endif |
Kyösti Mälkki | f775b8c | 2012-04-19 12:14:53 +0300 | [diff] [blame] | 92 | bootblock_inc += $(objgenerated)/bootblock.inc |
Stefan Reinauer | 6cb3a59 | 2015-07-13 09:39:15 +0200 | [diff] [blame] | 93 | bootblock_inc += $(src)/arch/x86/walkcbfs.S |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 94 | |
Patrick Georgi | 56b8309 | 2015-04-02 19:44:19 +0200 | [diff] [blame] | 95 | bootblock_romccflags := -mcpu=i386 -O2 -D__PRE_RAM__ -D__BOOTBLOCK__ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 96 | ifeq ($(CONFIG_SSE),y) |
Patrick Georgi | 56b8309 | 2015-04-02 19:44:19 +0200 | [diff] [blame] | 97 | bootblock_romccflags := -mcpu=k7 -msse -O2 -D__PRE_RAM__ -D__BOOTBLOCK__ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 98 | endif |
| 99 | |
Marc Jones | ac630f7 | 2015-06-30 15:46:49 -0600 | [diff] [blame] | 100 | $(objgenerated)/bootblock.ld: $$(filter %.ld,$$(bootblock-objs)) |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 101 | @printf " GEN $(subst $(obj)/,,$(@))\n" |
Marc Jones | ac630f7 | 2015-06-30 15:46:49 -0600 | [diff] [blame] | 102 | cat $^ >> $@.tmp |
| 103 | mv $@.tmp $@ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 104 | |
Marc Jones | 49fe74b | 2012-05-14 16:20:26 -0600 | [diff] [blame] | 105 | $(objgenerated)/bootblock_inc.S: $$(bootblock_inc) |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 106 | @printf " GEN $(subst $(obj)/,,$(@))\n" |
Patrick Georgi | 950f20a | 2012-01-17 13:13:59 +0100 | [diff] [blame] | 107 | printf '$(foreach crt0,$(bootblock_inc),#include "$(crt0)"\n)' > $@ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 108 | |
Kyösti Mälkki | f775b8c | 2012-04-19 12:14:53 +0300 | [diff] [blame] | 109 | $(objgenerated)/bootblock.o: $(objgenerated)/bootblock.s |
Daniele Forsi | 96639fb | 2014-08-02 13:45:17 +0200 | [diff] [blame] | 110 | @printf " CC $(subst $(obj)/,,$(@))\n" |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 111 | $(CC_bootblock) $(CFLAGS_bootblock) -c -o $@ $< > $(basename $@).disasm |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 112 | |
Marc Jones | 49fe74b | 2012-05-14 16:20:26 -0600 | [diff] [blame] | 113 | $(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] | 114 | @printf " CC $(subst $(obj)/,,$(@))\n" |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 115 | $(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] | 116 | |
Patrick Georgi | ef0158e | 2015-07-27 17:47:55 +0200 | [diff] [blame] | 117 | $(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] | 118 | @printf " ROMCC $(subst $(obj)/,,$(@))\n" |
Patrick Georgi | 5930774 | 2014-05-19 09:23:57 +0200 | [diff] [blame] | 119 | $(CC_bootblock) $(CPPFLAGS_bootblock) -MM -MT$(objgenerated)/bootblock.inc \ |
Kyösti Mälkki | f775b8c | 2012-04-19 12:14:53 +0300 | [diff] [blame] | 120 | $< > $(objgenerated)/bootblock.inc.d |
Patrick Georgi | 5930774 | 2014-05-19 09:23:57 +0200 | [diff] [blame] | 121 | $(ROMCC) -c -S $(bootblock_romccflags) -I. $(CPPFLAGS_bootblock) $< -o $@ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 122 | |
Kyösti Mälkki | f775b8c | 2012-04-19 12:14:53 +0300 | [diff] [blame] | 123 | $(objcbfs)/bootblock.debug: $(objgenerated)/bootblock.o $(objgenerated)/bootblock.ld |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 124 | @printf " LINK $(subst $(obj)/,,$(@))\n" |
Stefan Reinauer | 9874933 | 2015-06-23 12:57:06 -0700 | [diff] [blame] | 125 | ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y) |
| 126 | $(LD_bootblock) -m elf_i386 --oformat elf32-i386 -static -o $@ -L$(obj) $< -T $(objgenerated)/bootblock.ld |
| 127 | else |
| 128 | $(LD_bootblock) -m elf_x86_64 --oformat elf64-x86-64 -static -o $@ -L$(obj) $< -T $(objgenerated)/bootblock.ld |
| 129 | endif |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 130 | |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 131 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 132 | endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64 |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 133 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 134 | ############################################################################### |
| 135 | # romstage |
| 136 | ############################################################################### |
| 137 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 138 | ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 139 | |
Stefan Reinauer | 6cb3a59 | 2015-07-13 09:39:15 +0200 | [diff] [blame] | 140 | crt0s = $(src)/arch/x86/prologue.inc |
| 141 | romstage-srcs += $(src)/arch/x86/romstage.ld |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 142 | crt0s += $(src)/cpu/x86/32bit/entry32.inc |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 143 | romstage-srcs += $(src)/cpu/x86/32bit/entry32.ld |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 144 | |
| 145 | crt0s += $(src)/cpu/x86/fpu_enable.inc |
| 146 | ifeq ($(CONFIG_SSE),y) |
| 147 | crt0s += $(src)/cpu/x86/sse_enable.inc |
| 148 | endif |
| 149 | |
| 150 | crt0s += $(cpu_incs) |
| 151 | crt0s += $(cpu_incs-y) |
| 152 | |
| 153 | crt0s += $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc |
| 154 | |
| 155 | ifeq ($(CONFIG_ROMCC),y) |
Stefan Reinauer | 6cb3a59 | 2015-07-13 09:39:15 +0200 | [diff] [blame] | 156 | crt0s += $(src)/arch/x86/crt0_romcc_epilogue.inc |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 157 | endif |
| 158 | |
| 159 | ifeq ($(CONFIG_ROMCC),y) |
| 160 | ifeq ($(CONFIG_MMX),y) |
| 161 | ifeq ($(CONFIG_SSE),y) |
| 162 | ROMCCFLAGS := -mcpu=p4 -O2 # MMX, SSE |
| 163 | else |
| 164 | ROMCCFLAGS := -mcpu=p2 -O2 # MMX, !SSE |
| 165 | endif |
| 166 | else |
| 167 | ROMCCFLAGS := -mcpu=i386 -O2 # !MMX, !SSE |
| 168 | endif |
| 169 | |
Patrick Georgi | 24cca75 | 2014-11-29 11:51:25 +0100 | [diff] [blame] | 170 | $(objcbfs)/romstage%.bin: $(objcbfs)/romstage%.elf |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 171 | @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" |
| 172 | $(OBJCOPY_romstage) -O binary $< $@ |
| 173 | |
Patrick Georgi | 24cca75 | 2014-11-29 11:51:25 +0100 | [diff] [blame] | 174 | $(objcbfs)/romstage%.elf: $(objcbfs)/romstage%.debug |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 175 | @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" |
| 176 | cp $< $@.tmp |
| 177 | $(OBJCOPY_romstage) --strip-debug $@.tmp |
| 178 | $(OBJCOPY_romstage) --add-gnu-debuglink=$< $@.tmp |
| 179 | mv $@.tmp $@ |
| 180 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 181 | $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(objutil)/romcc/romcc $(OPTION_TABLE_H) $(obj)/build.h $(obj)/config.h |
| 182 | printf " ROMCC romstage.inc\n" |
Patrick Georgi | 815f4bf | 2015-04-28 22:43:31 +0200 | [diff] [blame] | 183 | $(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] | 184 | else |
| 185 | |
| 186 | $(obj)/mainboard/$(MAINBOARDDIR)/romstage.pre.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(OPTION_TABLE_H) $(obj)/build.h $(obj)/config.h |
| 187 | @printf " CC romstage.inc\n" |
Patrick Georgi | 815f4bf | 2015-04-28 22:43:31 +0200 | [diff] [blame] | 188 | $(CC_romstage) $(CPPFLAGS_romstage) $(CFLAGS_romstage) -MMD -D__ROMSTAGE__ -D__PRE_RAM__ -I$(src) -I. -I$(obj) -c -S $< -o $@ |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 189 | |
| 190 | $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(obj)/mainboard/$(MAINBOARDDIR)/romstage.pre.inc |
| 191 | @printf " POST romstage.inc\n" |
| 192 | sed -e 's/\.rodata/.rom.data/g' -e 's/\^\.text/.section .rom.text/g' \ |
| 193 | -e 's/\^\.section \.text/.section .rom.text/g' $^ > $@.tmp |
| 194 | mv $@.tmp $@ |
| 195 | endif |
| 196 | |
Patrick Georgi | db27306 | 2015-03-27 17:03:28 +0100 | [diff] [blame] | 197 | romstage-srcs += $(objgenerated)/crt0.S |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 198 | |
Alexandru Gagniuc | eb3c991 | 2014-03-29 13:01:11 -0500 | [diff] [blame] | 199 | romstage-libs ?= |
| 200 | |
Stefan Reinauer | 9874933 | 2015-06-23 12:57:06 -0700 | [diff] [blame] | 201 | ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y) |
| 202 | romstage-oformat=elf32-i386 |
| 203 | else |
| 204 | romstage-oformat=elf64-x86-64 |
| 205 | endif |
| 206 | |
Alexandru Gagniuc | eb3c991 | 2014-03-29 13:01:11 -0500 | [diff] [blame] | 207 | $(objcbfs)/romstage_null.debug: $$(romstage-objs) $(objgenerated)/romstage_null.ld $$(romstage-libs) |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 208 | @printf " LINK $(subst $(obj)/,,$(@))\n" |
Stefan Reinauer | 9874933 | 2015-06-23 12:57:06 -0700 | [diff] [blame] | 209 | $(LD_romstage) --gc-sections -nostdlib -nostartfiles -static -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) |
Furquan Shaikh | 3cf6aea | 2014-10-30 11:53:38 -0700 | [diff] [blame] | 210 | $(OBJCOPY_romstage) --only-section .illegal_globals $(@) $(objcbfs)/romstage_null.offenders && \ |
| 211 | $(NM_romstage) $(objcbfs)/romstage_null.offenders | grep -q ""; if [ $$? -eq 0 ]; then \ |
Stefan Reinauer | b6e1237 | 2012-07-31 14:52:04 -0700 | [diff] [blame] | 212 | echo "Forbidden global variables in romstage:"; \ |
Furquan Shaikh | 3cf6aea | 2014-10-30 11:53:38 -0700 | [diff] [blame] | 213 | $(NM_romstage) $(objcbfs)/romstage_null.offenders; false; \ |
Stefan Reinauer | b6e1237 | 2012-07-31 14:52:04 -0700 | [diff] [blame] | 214 | else true; fi |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 215 | |
Patrick Georgi | 24cca75 | 2014-11-29 11:51:25 +0100 | [diff] [blame] | 216 | $(objcbfs)/romstage.debug: $$(romstage-objs) $(objgenerated)/romstage.ld $$(romstage-libs) |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 217 | @printf " LINK $(subst $(obj)/,,$(@))\n" |
Stefan Reinauer | 9874933 | 2015-06-23 12:57:06 -0700 | [diff] [blame] | 218 | $(LD_romstage) --gc-sections -nostdlib -nostartfiles -static -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] | 219 | |
Marc Jones | ac630f7 | 2015-06-30 15:46:49 -0600 | [diff] [blame] | 220 | $(objgenerated)/romstage_null.ld: $$(filter %.ld,$$(romstage-objs)) |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 221 | @printf " GEN $(subst $(obj)/,,$(@))\n" |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 222 | rm -f $@ |
| 223 | printf "ROMSTAGE_BASE = 0x0;\n" > $@.tmp |
Marc Jones | ac630f7 | 2015-06-30 15:46:49 -0600 | [diff] [blame] | 224 | cat $^ >> $@.tmp |
| 225 | mv $@.tmp $@ |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 226 | |
Patrick Georgi | 24cca75 | 2014-11-29 11:51:25 +0100 | [diff] [blame] | 227 | $(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] | 228 | @printf " GEN $(subst $(obj)/,,$(@))\n" |
| 229 | rm -f $@ |
Kyösti Mälkki | 1e9c1b3 | 2012-04-19 14:43:47 +0300 | [diff] [blame] | 230 | 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] | 231 | sed -e '/^ROMSTAGE_BASE/d' $(objgenerated)/romstage_null.ld >> $@.tmp |
Kyösti Mälkki | a01ec14 | 2012-03-31 10:21:29 +0300 | [diff] [blame] | 232 | mv $@.tmp $@ |
| 233 | |
Kyösti Mälkki | 1e9c1b3 | 2012-04-19 14:43:47 +0300 | [diff] [blame] | 234 | $(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] | 235 | rm -f $@ |
Hung-Te Lin | e919837 | 2013-03-19 12:17:12 +0800 | [diff] [blame] | 236 | $(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] | 237 | || { 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] | 238 | mv $@.tmp $@ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 239 | |
Patrick Georgi | d69839b | 2015-04-03 10:32:17 +0200 | [diff] [blame] | 240 | $(objgenerated)/crt0.S: $$(crt0s) |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 241 | @printf " GEN $(subst $(obj)/,,$(@))\n" |
Patrick Georgi | d69839b | 2015-04-03 10:32:17 +0200 | [diff] [blame] | 242 | printf '$(foreach crt0,$(crt0s),#include "$(crt0)"\n)' > $@ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 243 | |
Patrick Georgi | d69839b | 2015-04-03 10:32:17 +0200 | [diff] [blame] | 244 | # Compiling crt0 with -g seems to trigger https://sourceware.org/bugzilla/show_bug.cgi?id=6428 |
| 245 | romstage-S-ccopts += -I. -g0 |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 246 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 247 | endif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64 |
Stefan Reinauer | f1939bb | 2010-12-30 17:39:50 +0000 | [diff] [blame] | 248 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 249 | ############################################################################### |
| 250 | # ramstage |
| 251 | ############################################################################### |
| 252 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 253 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 254 | |
Patrick Georgi | c32a52c | 2015-06-22 21:10:34 +0200 | [diff] [blame] | 255 | ifeq ($(CONFIG_COMPILE_IN_DSDT),y) |
| 256 | ramstage-srcs += $(obj)/dsdt.aml |
| 257 | |
| 258 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) |
| 259 | target-objcopy=-O elf32-i386 -B i386 |
| 260 | endif |
| 261 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_64),y) |
| 262 | target-objcopy=-O elf64-x86_64 -B x86_64 |
| 263 | endif |
| 264 | |
| 265 | define ramstage-objs_aml_template |
| 266 | $(call src-to-obj,ramstage,$(1).aml): $(1).aml |
| 267 | @printf " OBJCOPY $$(subst $$(obj)/,,$$(@))\n" |
| 268 | cd $$(dir $$@) && $$(OBJCOPY_ramstage) -I binary $$(target-objcopy) $$(notdir $$<) $$(notdir $$@) |
| 269 | endef |
| 270 | endif |
| 271 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 272 | ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c) |
| 273 | ifeq ($(CONFIG_GENERATE_MP_TABLE),y) |
| 274 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/mptable.c),) |
| 275 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mptable.c |
| 276 | endif |
| 277 | endif |
| 278 | ifeq ($(CONFIG_GENERATE_PIRQ_TABLE),y) |
| 279 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/irq_tables.c |
| 280 | endif |
| 281 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/reset.c),) |
| 282 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/reset.c |
| 283 | endif |
Vladimir Serbinenko | 822bc65 | 2014-01-03 15:55:40 +0100 | [diff] [blame] | 284 | ifeq ($(CONFIG_HAVE_ACPI_TABLES),y) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 285 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/acpi_tables.c |
Aaron Durbin | ab454c6 | 2015-07-30 12:44:58 -0500 | [diff] [blame^] | 286 | ifeq ($(CONFIG_COMPILE_IN_DSDT),y) |
| 287 | $(eval $(call asl_template,dsdt,n)) |
| 288 | else |
Vladimir Serbinenko | 36f8d27 | 2015-05-31 12:31:59 +0200 | [diff] [blame] | 289 | $(eval $(call asl_template,dsdt)) |
Aaron Durbin | ab454c6 | 2015-07-30 12:44:58 -0500 | [diff] [blame^] | 290 | endif |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 291 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/fadt.c),) |
| 292 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/fadt.c |
| 293 | endif |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 294 | endif # CONFIG_GENERATE_ACPI_TABLES |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 295 | ifeq ($(CONFIG_HAVE_SMI_HANDLER),y) |
| 296 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/smihandler.c),) |
| 297 | smm-srcs += src/mainboard/$(MAINBOARDDIR)/smihandler.c |
| 298 | endif |
| 299 | endif |
| 300 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/get_bus_conf.c),) |
| 301 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/get_bus_conf.c |
| 302 | endif |
| 303 | |
| 304 | ramstage-libs ?= |
| 305 | |
| 306 | ifeq ($(CONFIG_RELOCATABLE_RAMSTAGE),y) |
| 307 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 308 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) |
Furquan Shaikh | 133096b | 2014-07-31 09:28:55 -0700 | [diff] [blame] | 309 | $(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] | 310 | else |
| 311 | $(eval $(call rmodule_link,$(objcbfs)/ramstage.debug, $(objgenerated)/ramstage.o, $(CONFIG_HEAP_SIZE),x86_64)) |
| 312 | endif |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 313 | |
| 314 | # The rmodule_link defintion creates an elf file with .rmod extension. |
| 315 | $(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod |
| 316 | cp $< $@ |
| 317 | |
| 318 | else |
| 319 | |
Patrick Georgi | 828e0e8 | 2015-04-04 15:50:20 +0200 | [diff] [blame] | 320 | ramstage-srcs += $(src)/arch/x86/ramstage.ld |
| 321 | |
| 322 | $(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(obj)/arch/x86/ramstage.ramstage.ld |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 323 | @printf " CC $(subst $(obj)/,,$(@))\n" |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 324 | $(LD_ramstage) $(CPPFLAGS) --gc-sections -o $@ -L$(obj) $< -T $(obj)/arch/x86/ramstage.ramstage.ld |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 325 | |
| 326 | endif |
| 327 | |
Patrick Georgi | 3ce96bd | 2014-11-22 17:42:58 +0100 | [diff] [blame] | 328 | $(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 329 | @printf " CC $(subst $(obj)/,,$(@))\n" |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 330 | ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y) |
Patrick Georgi | eec8dfb | 2015-05-07 22:24:41 +0200 | [diff] [blame] | 331 | $(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] | 332 | else |
| 333 | $(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 |
| 334 | endif |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 335 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 336 | endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64 |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 337 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 338 | |
Stefan Reinauer | 6cb3a59 | 2015-07-13 09:39:15 +0200 | [diff] [blame] | 339 | ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y) |
| 340 | |
| 341 | romstage-y += cbmem.c |
| 342 | romstage-y += boot.c |
| 343 | |
| 344 | romstage-y += cbfs_and_run.c |
| 345 | romstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += cpu_common.c |
| 346 | romstage-y += memset.c |
| 347 | romstage-y += memcpy.c |
| 348 | romstage-y += memmove.c |
| 349 | romstage-y += mmap_boot.c |
| 350 | |
| 351 | romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c |
| 352 | |
| 353 | endif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64 |
| 354 | |
| 355 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y) |
| 356 | |
| 357 | ramstage-y += boot.c |
| 358 | ramstage-y += gdt.c |
| 359 | ramstage-y += tables.c |
| 360 | ramstage-y += cbmem.c |
| 361 | ramstage-$(CONFIG_GENERATE_MP_TABLE) += mpspec.c |
| 362 | ramstage-$(CONFIG_GENERATE_PIRQ_TABLE) += pirq_routing.c |
| 363 | ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi.c |
| 364 | ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c |
| 365 | ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpigen.c |
| 366 | ramstage-$(CONFIG_HAVE_ACPI_RESUME) += wakeup.S |
| 367 | |
| 368 | ramstage-y += c_start.S |
| 369 | ramstage-y += cpu.c |
| 370 | ramstage-y += cpu_common.c |
| 371 | ramstage-y += pci_ops_conf1.c |
| 372 | ramstage-$(CONFIG_MMCONF_SUPPORT) += pci_ops_mmconf.c |
| 373 | ramstage-y += exception.c |
| 374 | ramstage-$(CONFIG_IOAPIC) += ioapic.c |
| 375 | ramstage-y += memset.c |
| 376 | ramstage-y += memcpy.c |
| 377 | ramstage-y += memmove.c |
| 378 | ramstage-y += ebda.c |
| 379 | ramstage-y += mmap_boot.c |
| 380 | ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c |
| 381 | ramstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S |
| 382 | ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c |
| 383 | |
| 384 | smm-y += memset.c |
| 385 | smm-y += memcpy.c |
| 386 | smm-y += memmove.c |
| 387 | smm-y += mmap_boot.c |
| 388 | |
| 389 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) |
| 390 | rmodules_x86_32-y += memset.c |
| 391 | rmodules_x86_32-y += memcpy.c |
| 392 | rmodules_x86_32-y += memmove.c |
| 393 | else |
| 394 | rmodules_x86_64-y += memset.c |
| 395 | rmodules_x86_64-y += memcpy.c |
| 396 | rmodules_x86_64-y += memmove.c |
| 397 | endif |
| 398 | |
| 399 | endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64 |