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 | 29eeece | 2018-10-31 14:24:47 +0100 | [diff] [blame] | 19 | ifeq ($(CONFIG_POSTCAR_STAGE),y) |
| 20 | $(eval $(call init_standard_toolchain,postcar)) |
| 21 | endif |
| 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 |
Martin Roth | 8ea0651 | 2016-09-19 13:58:01 -0600 | [diff] [blame] | 32 | cmos_layout.bin-type = cmos_layout |
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 | |
Mike Banon | 0f8547e | 2019-02-17 19:51:53 +0300 | [diff] [blame] | 50 | stripped_vgabios_dgpu_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_DGPU_ID)) |
| 51 | cbfs-files-$(CONFIG_VGA_BIOS_DGPU) += pci$(stripped_vgabios_dgpu_id).rom |
| 52 | pci$(stripped_vgabios_dgpu_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_DGPU_FILE)) |
| 53 | pci$(stripped_vgabios_dgpu_id).rom-type := optionrom |
| 54 | |
Nico Huber | 33fcaf9 | 2018-10-10 22:44:20 +0200 | [diff] [blame] | 55 | verstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c |
| 56 | bootblock-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c |
| 57 | romstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c |
| 58 | ramstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c |
| 59 | postcar-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c |
| 60 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 61 | ############################################################################### |
Aaron Durbin | eb907b3 | 2016-01-21 00:08:17 -0600 | [diff] [blame] | 62 | # common support for early assembly includes |
| 63 | ############################################################################### |
| 64 | |
| 65 | # Chipset specific assembly stubs in the romstage program flow. Certain |
| 66 | # boards have more than one assembly stub so collect those and put them |
| 67 | # into a single generated file. |
| 68 | crt0s = $(cpu_incs-y) |
| 69 | |
| 70 | $(objgenerated)/assembly.inc: $$(crt0s) |
| 71 | @printf " GEN $(subst $(obj)/,,$(@))\n" |
| 72 | printf '$(foreach crt0,$(crt0s),#include "$(crt0)"\n)' > $@ |
| 73 | |
| 74 | |
| 75 | define early_x86_assembly_entry_rule |
| 76 | # $1 stage name |
| 77 | # Add the assembly file that pulls in the rest of the dependencies in |
| 78 | # the right order. Make sure the auto generated assembly.inc is a proper |
| 79 | # dependency. |
| 80 | $(1)-y += assembly_entry.S |
Nico Huber | 81b09f4 | 2016-01-23 00:50:00 +0100 | [diff] [blame] | 81 | $(call src-to-obj,$(1),$(dir)/assembly_entry.S): $(objgenerated)/assembly.inc |
Aaron Durbin | eb907b3 | 2016-01-21 00:08:17 -0600 | [diff] [blame] | 82 | endef |
| 83 | |
| 84 | define early_x86_stage |
| 85 | # $1 stage name |
| 86 | # $2 oformat |
| 87 | $(1)-y += memlayout.ld |
| 88 | |
| 89 | # The '.' include path is needed for the generated assembly.inc file. |
| 90 | $(1)-S-ccopts += -I. |
| 91 | |
| 92 | $$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs) |
| 93 | @printf " LINK $$(subst $$(obj)/,,$$(@))\n" |
Nico Huber | 81b09f4 | 2016-01-23 00:50:00 +0100 | [diff] [blame] | 94 | $$(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 $(call src-to-obj,$(1),$(dir)/memlayout.ld) --oformat $(2) |
Aaron Durbin | eb907b3 | 2016-01-21 00:08:17 -0600 | [diff] [blame] | 95 | -LANG=C LC_ALL= $$(OBJCOPY_$(1)) --only-section .illegal_globals $$(@) $$(objcbfs)/$(1)_null.offenders >/dev/null 2>&1 |
| 96 | if [ -z "$$$$($$(NM_$(1)) $$(objcbfs)/$(1)_null.offenders 2>&1 | grep 'no symbols')" ];then \ |
| 97 | echo "Forbidden global variables in $(1):"; \ |
| 98 | $$(NM_$(1)) $$(objcbfs)/$(1)_null.offenders; false; \ |
| 99 | fi |
| 100 | endef |
| 101 | |
| 102 | ############################################################################### |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 103 | # bootblock |
| 104 | ############################################################################### |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 105 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 106 | ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32)$(CONFIG_ARCH_BOOTBLOCK_X86_64),y) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 107 | |
Alexandru Gagniuc | 4e153d6 | 2016-01-08 23:05:00 -0800 | [diff] [blame] | 108 | bootblock-y += boot.c |
Lee Leahy | 5f4b4c4 | 2016-07-24 08:09:40 -0700 | [diff] [blame] | 109 | bootblock-y += cpu_common.c |
Aaron Durbin | 4b032e4 | 2018-04-20 01:39:30 -0600 | [diff] [blame] | 110 | bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c |
| 111 | bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S |
Alexandru Gagniuc | 4e153d6 | 2016-01-08 23:05:00 -0800 | [diff] [blame] | 112 | bootblock-y += memcpy.c |
| 113 | bootblock-y += memset.c |
Aaron Durbin | f49ddb6 | 2018-01-24 17:35:58 -0700 | [diff] [blame] | 114 | bootblock-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c |
Alexandru Gagniuc | 6a62231 | 2015-10-27 10:27:30 -0700 | [diff] [blame] | 115 | bootblock-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c |
Alexandru Gagniuc | 4e153d6 | 2016-01-08 23:05:00 -0800 | [diff] [blame] | 116 | |
Alexandru Gagniuc | ee2740b | 2015-10-04 17:47:36 -0700 | [diff] [blame] | 117 | bootblock-y += id.S |
Nico Huber | 81b09f4 | 2016-01-23 00:50:00 +0100 | [diff] [blame] | 118 | $(call src-to-obj,bootblock,$(dir)/id.S): $(obj)/build.h |
Patrick Georgi | ab35575 | 2015-10-15 11:07:07 +0200 | [diff] [blame] | 119 | |
Aaron Durbin | eb907b3 | 2016-01-21 00:08:17 -0600 | [diff] [blame] | 120 | ifeq ($(CONFIG_C_ENVIRONMENT_BOOTBLOCK),y) |
| 121 | |
Alexandru Gagniuc | 6be6c8f | 2016-01-26 18:22:43 -0800 | [diff] [blame] | 122 | bootblock-y += bootblock_crt0.S |
Aaron Durbin | eb907b3 | 2016-01-21 00:08:17 -0600 | [diff] [blame] | 123 | |
| 124 | ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y) |
| 125 | $(eval $(call early_x86_stage,bootblock,elf32-i386)) |
| 126 | else |
| 127 | $(eval $(call early_x86_stage,bootblock,elf64-x86-64)) |
| 128 | endif |
| 129 | |
Patrick Rudolph | 4d60d96 | 2019-02-10 13:56:29 +0100 | [diff] [blame] | 130 | bootblock-$(CONFIG_ARCH_BOOTBLOCK_X86_32) += walkcbfs.S |
Arthur Heymans | 0eb9c57 | 2019-01-05 18:21:47 +0100 | [diff] [blame] | 131 | |
Aaron Durbin | eb907b3 | 2016-01-21 00:08:17 -0600 | [diff] [blame] | 132 | else # !C_ENVIRONMENT_BOOTBLOCK |
| 133 | |
| 134 | # x86-specific linker flags |
| 135 | ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y) |
| 136 | LDFLAGS_bootblock += -m elf_i386 --oformat elf32-i386 |
| 137 | else |
| 138 | LDFLAGS_bootblock += -m elf_x86_64 --oformat elf64-x86-64 |
| 139 | endif |
| 140 | |
Alexandru Gagniuc | f8e4913 | 2015-10-02 12:42:26 -0700 | [diff] [blame] | 141 | # Add the assembly file that pulls in the rest of the dependencies in |
| 142 | # the right order. Make sure the auto generated bootblock.inc is a proper |
| 143 | # dependency. Make the same true for the linker sript. |
| 144 | bootblock-y += bootblock_romcc.S |
Alexandru Gagniuc | c46a392 | 2015-10-02 16:17:41 -0700 | [diff] [blame] | 145 | bootblock-y += walkcbfs.S |
Alexandru Gagniuc | f8e4913 | 2015-10-02 12:42:26 -0700 | [diff] [blame] | 146 | $(call src-to-obj,bootblock,$(dir)/bootblock_romcc.S): $(objgenerated)/bootblock.inc |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 147 | |
Aaron Durbin | 3953e39 | 2015-09-03 00:41:29 -0500 | [diff] [blame] | 148 | bootblock-y += bootblock.ld |
Nico Huber | 81b09f4 | 2016-01-23 00:50:00 +0100 | [diff] [blame] | 149 | $(call src-to-obj,bootblock,$(dir)/bootblock.ld): $(objgenerated)/bootblock.ld |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 150 | |
Patrick Georgi | 56b8309 | 2015-04-02 19:44:19 +0200 | [diff] [blame] | 151 | bootblock_romccflags := -mcpu=i386 -O2 -D__PRE_RAM__ -D__BOOTBLOCK__ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 152 | ifeq ($(CONFIG_SSE),y) |
Kyösti Mälkki | 3ba79b3 | 2018-12-23 07:22:56 +0200 | [diff] [blame] | 153 | bootblock_romccflags := -mcpu=k7 -mno-mmx -msse -O2 -D__PRE_RAM__ -D__BOOTBLOCK__ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 154 | endif |
| 155 | |
Aaron Durbin | 3953e39 | 2015-09-03 00:41:29 -0500 | [diff] [blame] | 156 | # 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] | 157 | $(objgenerated)/empty: build-dirs |
Aaron Durbin | 3953e39 | 2015-09-03 00:41:29 -0500 | [diff] [blame] | 158 | touch $@ |
| 159 | |
Nico Huber | 81b09f4 | 2016-01-23 00:50:00 +0100 | [diff] [blame] | 160 | $(objgenerated)/bootblock.ld: $$(filter-out $(call src-to-obj,bootblock,src/arch/x86/bootblock.ld), $$(filter %.ld,$$(bootblock-objs))) $(objgenerated)/empty |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 161 | @printf " GEN $(subst $(obj)/,,$(@))\n" |
Marc Jones | ac630f7 | 2015-06-30 15:46:49 -0600 | [diff] [blame] | 162 | cat $^ >> $@.tmp |
| 163 | mv $@.tmp $@ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 164 | |
Nico Huber | 4ba7b26 | 2018-09-03 15:39:33 +0200 | [diff] [blame] | 165 | -include $(objgenerated)/bootblock.inc.d |
Patrick Georgi | ef0158e | 2015-07-27 17:47:55 +0200 | [diff] [blame] | 166 | $(objgenerated)/bootblock.inc: $(src)/arch/x86/$(subst ",,$(CONFIG_BOOTBLOCK_SOURCE)) $(objutil)/romcc/romcc $(OPTION_TABLE_H) $(KCONFIG_AUTOHEADER) |
Martin Roth | 6313bc7 | 2016-01-15 11:12:04 -0700 | [diff] [blame] | 167 | # The open quote in the subst messes with syntax highlighting. Fix it - ") |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 168 | @printf " ROMCC $(subst $(obj)/,,$(@))\n" |
Patrick Georgi | 5930774 | 2014-05-19 09:23:57 +0200 | [diff] [blame] | 169 | $(CC_bootblock) $(CPPFLAGS_bootblock) -MM -MT$(objgenerated)/bootblock.inc \ |
Kyösti Mälkki | f775b8c | 2012-04-19 12:14:53 +0300 | [diff] [blame] | 170 | $< > $(objgenerated)/bootblock.inc.d |
Patrick Georgi | 5930774 | 2014-05-19 09:23:57 +0200 | [diff] [blame] | 171 | $(ROMCC) -c -S $(bootblock_romccflags) -I. $(CPPFLAGS_bootblock) $< -o $@ |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 172 | |
Nico Huber | 81b09f4 | 2016-01-23 00:50:00 +0100 | [diff] [blame] | 173 | # bootblock.ld is part of $(bootblock-objs) |
Alexandru Gagniuc | dbeedbe | 2015-10-02 12:17:56 -0700 | [diff] [blame] | 174 | $(objcbfs)/bootblock.debug: $$(bootblock-objs) |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 175 | @printf " LINK $(subst $(obj)/,,$(@))\n" |
Alexandru Gagniuc | dbeedbe | 2015-10-02 12:17:56 -0700 | [diff] [blame] | 176 | $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) \ |
| 177 | $(filter-out %.ld,$(bootblock-objs)) \ |
Nico Huber | 81b09f4 | 2016-01-23 00:50:00 +0100 | [diff] [blame] | 178 | -T $(call src-to-obj,bootblock,src/arch/x86/bootblock.ld) |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 179 | |
Aaron Durbin | eb907b3 | 2016-01-21 00:08:17 -0600 | [diff] [blame] | 180 | endif # C_ENVIRONMENT_BOOTBLOCK |
| 181 | |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 182 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 183 | endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64 |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 184 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 185 | ############################################################################### |
Aaron Durbin | 75c51d9 | 2015-09-29 16:31:20 -0500 | [diff] [blame] | 186 | # verstage |
| 187 | ############################################################################### |
| 188 | |
| 189 | ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32)$(CONFIG_ARCH_VERSTAGE_X86_64),y) |
| 190 | |
| 191 | verstage-y += boot.c |
Hannah Williams | d3c0c0c | 2018-04-27 09:09:04 -0700 | [diff] [blame] | 192 | verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += gdt_init.S |
Aaron Durbin | 4b032e4 | 2018-04-20 01:39:30 -0600 | [diff] [blame] | 193 | verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c |
| 194 | verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S |
Aaron Durbin | 75c51d9 | 2015-09-29 16:31:20 -0500 | [diff] [blame] | 195 | |
Subrata Banik | 2761847 | 2019-05-30 18:28:59 +0530 | [diff] [blame] | 196 | verstage-y += cpu_common.c |
Aaron Durbin | 75c51d9 | 2015-09-29 16:31:20 -0500 | [diff] [blame] | 197 | verstage-y += memset.c |
| 198 | verstage-y += memcpy.c |
| 199 | verstage-y += memmove.c |
Aaron Durbin | 57dbbbb | 2016-03-18 13:12:41 -0500 | [diff] [blame] | 200 | verstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c |
Arthur Heymans | 7bea084 | 2018-06-06 18:19:56 +0200 | [diff] [blame] | 201 | # If verstage is a separate stage it means there's no need |
Aaron Durbin | 10221a0 | 2016-05-26 10:55:48 -0500 | [diff] [blame] | 202 | # for a chipset-specific car_stage_entry() so use the generic one |
| 203 | # which just calls verstage(). |
Arthur Heymans | 7bea084 | 2018-06-06 18:19:56 +0200 | [diff] [blame] | 204 | verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += verstage.c |
Aaron Durbin | 75c51d9 | 2015-09-29 16:31:20 -0500 | [diff] [blame] | 205 | |
Aaron Durbin | f49ddb6 | 2018-01-24 17:35:58 -0700 | [diff] [blame] | 206 | verstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c |
Aaron Durbin | 75c51d9 | 2015-09-29 16:31:20 -0500 | [diff] [blame] | 207 | |
Julius Werner | e91d170 | 2017-03-20 15:32:15 -0700 | [diff] [blame] | 208 | verstage-libs ?= |
Aaron Durbin | 75c51d9 | 2015-09-29 16:31:20 -0500 | [diff] [blame] | 209 | |
Aaron Durbin | eb907b3 | 2016-01-21 00:08:17 -0600 | [diff] [blame] | 210 | $(eval $(call early_x86_assembly_entry_rule,verstage)) |
| 211 | |
Aaron Durbin | 75c51d9 | 2015-09-29 16:31:20 -0500 | [diff] [blame] | 212 | ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32),y) |
| 213 | $(eval $(call early_x86_stage,verstage,elf32-i386)) |
| 214 | else |
| 215 | $(eval $(call early_x86_stage,verstage,elf64-x86-64)) |
| 216 | endif |
| 217 | |
Aaron Durbin | 75c51d9 | 2015-09-29 16:31:20 -0500 | [diff] [blame] | 218 | endif # CONFIG_ARCH_VERSTAGE_X86_32 / CONFIG_ARCH_VERSTAGE_X86_64 |
| 219 | |
| 220 | ############################################################################### |
Aaron Durbin | 1bc6a79 | 2015-09-29 14:54:25 -0500 | [diff] [blame] | 221 | # romstage |
| 222 | ############################################################################### |
| 223 | |
| 224 | ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 225 | |
Lee Leahy | e82b505 | 2016-07-25 17:07:53 -0700 | [diff] [blame] | 226 | romstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c |
| 227 | romstage-y += boot.c |
Hannah Williams | d3c0c0c | 2018-04-27 09:09:04 -0700 | [diff] [blame] | 228 | # gdt_init.S is included by entry32.inc when romstage is the first C |
| 229 | # environment. |
| 230 | romstage-$(CONFIG_C_ENVIRONMENT_BOOTBLOCK) += gdt_init.S |
Lee Leahy | e82b505 | 2016-07-25 17:07:53 -0700 | [diff] [blame] | 231 | romstage-y += cbmem.c |
| 232 | romstage-y += cbfs_and_run.c |
Subrata Banik | 2761847 | 2019-05-30 18:28:59 +0530 | [diff] [blame] | 233 | romstage-y += cpu_common.c |
Subrata Banik | c7590cd | 2017-09-04 18:44:38 +0530 | [diff] [blame] | 234 | romstage-$(CONFIG_EARLY_EBDA_INIT) += ebda.c |
Aaron Durbin | 4b032e4 | 2018-04-20 01:39:30 -0600 | [diff] [blame] | 235 | romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c |
| 236 | romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S |
Lee Leahy | e82b505 | 2016-07-25 17:07:53 -0700 | [diff] [blame] | 237 | romstage-y += memcpy.c |
| 238 | romstage-y += memmove.c |
| 239 | romstage-y += memset.c |
| 240 | romstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c |
Rizwan Qureshi | b1b44d3 | 2016-08-26 21:08:50 +0530 | [diff] [blame] | 241 | romstage-y += postcar_loader.c |
Aaron Durbin | f49ddb6 | 2018-01-24 17:35:58 -0700 | [diff] [blame] | 242 | romstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c |
Patrick Rudolph | 4d60d96 | 2019-02-10 13:56:29 +0100 | [diff] [blame] | 243 | romstage-$(CONFIG_ARCH_ROMSTAGE_X86_32) += walkcbfs.S |
Lee Leahy | e82b505 | 2016-07-25 17:07:53 -0700 | [diff] [blame] | 244 | |
Rizwan Qureshi | 8e8ca5c | 2018-10-01 14:35:25 +0530 | [diff] [blame] | 245 | romstage-srcs += $(wildcard $(src)/mainboard/$(MAINBOARDDIR)/romstage.c) |
Alexandru Gagniuc | eb3c991 | 2014-03-29 13:01:11 -0500 | [diff] [blame] | 246 | romstage-libs ?= |
| 247 | |
Aaron Durbin | eb907b3 | 2016-01-21 00:08:17 -0600 | [diff] [blame] | 248 | $(eval $(call early_x86_assembly_entry_rule,romstage)) |
| 249 | |
Stefan Reinauer | 9874933 | 2015-06-23 12:57:06 -0700 | [diff] [blame] | 250 | ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y) |
Aaron Durbin | 1bc6a79 | 2015-09-29 14:54:25 -0500 | [diff] [blame] | 251 | $(eval $(call early_x86_stage,romstage,elf32-i386)) |
Stefan Reinauer | 9874933 | 2015-06-23 12:57:06 -0700 | [diff] [blame] | 252 | else |
Aaron Durbin | 1bc6a79 | 2015-09-29 14:54:25 -0500 | [diff] [blame] | 253 | $(eval $(call early_x86_stage,romstage,elf64-x86-64)) |
Stefan Reinauer | 9874933 | 2015-06-23 12:57:06 -0700 | [diff] [blame] | 254 | endif |
| 255 | |
Patrick Georgi | d69839b | 2015-04-03 10:32:17 +0200 | [diff] [blame] | 256 | # 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] | 257 | romstage-S-ccopts += -g0 |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 258 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 259 | endif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64 |
Stefan Reinauer | f1939bb | 2010-12-30 17:39:50 +0000 | [diff] [blame] | 260 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 261 | ############################################################################### |
Lee Leahy | a749150 | 2016-07-24 07:43:23 -0700 | [diff] [blame] | 262 | # postcar |
| 263 | ############################################################################### |
| 264 | |
| 265 | $(eval $(call create_class_compiler,postcar,x86_32)) |
| 266 | postcar-generic-ccopts += -D__POSTCAR__ |
| 267 | |
Subrata Banik | 5d2928c | 2017-09-21 19:17:33 +0530 | [diff] [blame] | 268 | postcar-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c |
Lee Leahy | a749150 | 2016-07-24 07:43:23 -0700 | [diff] [blame] | 269 | postcar-y += boot.c |
Hannah Williams | d3c0c0c | 2018-04-27 09:09:04 -0700 | [diff] [blame] | 270 | postcar-y += gdt_init.S |
Lee Leahy | a749150 | 2016-07-24 07:43:23 -0700 | [diff] [blame] | 271 | postcar-y += cbfs_and_run.c |
Kyösti Mälkki | 740afc4 | 2017-09-07 08:13:19 +0300 | [diff] [blame] | 272 | postcar-y += cbmem.c |
Lee Leahy | 5f4b4c4 | 2016-07-24 08:09:40 -0700 | [diff] [blame] | 273 | postcar-y += cpu_common.c |
Subrata Banik | c7590cd | 2017-09-04 18:44:38 +0530 | [diff] [blame] | 274 | postcar-$(CONFIG_EARLY_EBDA_INIT) += ebda.c |
Aaron Durbin | 4b032e4 | 2018-04-20 01:39:30 -0600 | [diff] [blame] | 275 | postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c |
| 276 | postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S |
Lee Leahy | a749150 | 2016-07-24 07:43:23 -0700 | [diff] [blame] | 277 | postcar-y += exit_car.S |
| 278 | postcar-y += memcpy.c |
| 279 | postcar-y += memmove.c |
| 280 | postcar-y += memset.c |
| 281 | postcar-y += memlayout.ld |
| 282 | postcar-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c |
Aaron Durbin | 6b0cebc | 2016-09-16 16:15:14 -0500 | [diff] [blame] | 283 | postcar-y += postcar.c |
Aaron Durbin | f49ddb6 | 2018-01-24 17:35:58 -0700 | [diff] [blame] | 284 | postcar-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c |
Lee Leahy | a749150 | 2016-07-24 07:43:23 -0700 | [diff] [blame] | 285 | |
Lee Leahy | 4cfde2a | 2016-07-24 07:51:24 -0700 | [diff] [blame] | 286 | LDFLAGS_postcar += -Map $(objcbfs)/postcar.map |
| 287 | |
Lee Leahy | a749150 | 2016-07-24 07:43:23 -0700 | [diff] [blame] | 288 | $(objcbfs)/postcar.debug: $$(postcar-objs) |
| 289 | @printf " LINK $(subst $(obj)/,,$(@))\n" |
| 290 | $(LD_postcar) $(LDFLAGS_postcar) -o $@ -L$(obj) $(COMPILER_RT_FLAGS_postcar) --whole-archive --start-group $(filter-out %.ld,$^) --no-whole-archive $(COMPILER_RT_postcar) --end-group -T $(call src-to-obj,postcar,src/arch/x86/memlayout.ld) |
| 291 | |
| 292 | $(objcbfs)/postcar.elf: $(objcbfs)/postcar.debug.rmod |
| 293 | cp $< $@ |
| 294 | |
| 295 | # Add postcar to CBFS |
| 296 | cbfs-files-$(CONFIG_POSTCAR_STAGE) += $(CONFIG_CBFS_PREFIX)/postcar |
| 297 | $(CONFIG_CBFS_PREFIX)/postcar-file := $(objcbfs)/postcar.elf |
| 298 | $(CONFIG_CBFS_PREFIX)/postcar-type := stage |
| 299 | $(CONFIG_CBFS_PREFIX)/postcar-compression := none |
| 300 | |
| 301 | ############################################################################### |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 302 | # ramstage |
| 303 | ############################################################################### |
| 304 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 305 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 306 | |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 307 | ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi.c |
| 308 | ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpigen.c |
Furquan Shaikh | 4a2cfad | 2016-10-21 16:40:17 -0700 | [diff] [blame] | 309 | ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpigen_dsm.c |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 310 | ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi_device.c |
Duncan Laurie | 3e7197a | 2018-05-07 14:18:13 -0700 | [diff] [blame] | 311 | ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi_pld.c |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 312 | ramstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c |
Marshall Dawson | 991467d | 2018-09-04 12:32:56 -0600 | [diff] [blame] | 313 | ramstage-$(CONFIG_ACPI_BERT) += acpi_bert_storage.c |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 314 | ramstage-y += boot.c |
| 315 | ramstage-y += c_start.S |
| 316 | ramstage-y += cbmem.c |
| 317 | ramstage-y += cpu.c |
| 318 | ramstage-y += cpu_common.c |
| 319 | ramstage-y += ebda.c |
| 320 | ramstage-y += exception.c |
Aaron Durbin | 7a7c70b | 2018-04-20 00:56:57 -0600 | [diff] [blame] | 321 | ramstage-y += idt.S |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 322 | ramstage-y += gdt.c |
| 323 | ramstage-$(CONFIG_IOAPIC) += ioapic.c |
| 324 | ramstage-y += memcpy.c |
| 325 | ramstage-y += memlayout.ld |
| 326 | ramstage-y += memmove.c |
| 327 | ramstage-y += memset.c |
| 328 | ramstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c |
| 329 | ramstage-$(CONFIG_GENERATE_MP_TABLE) += mpspec.c |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 330 | ramstage-$(CONFIG_GENERATE_PIRQ_TABLE) += pirq_routing.c |
Robbie Zhang | 1879231 | 2017-02-13 13:44:14 -0800 | [diff] [blame] | 331 | ramstage-y += rdrand.c |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 332 | ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c |
| 333 | ramstage-y += tables.c |
| 334 | ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c |
| 335 | ramstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S |
Aaron Durbin | f49ddb6 | 2018-01-24 17:35:58 -0700 | [diff] [blame] | 336 | ramstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 337 | ramstage-$(CONFIG_HAVE_ACPI_RESUME) += wakeup.S |
| 338 | |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 339 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) |
| 340 | rmodules_x86_32-y += memcpy.c |
| 341 | rmodules_x86_32-y += memmove.c |
| 342 | rmodules_x86_32-y += memset.c |
| 343 | else |
| 344 | rmodules_x86_64-y += memcpy.c |
| 345 | rmodules_x86_64-y += memmove.c |
| 346 | rmodules_x86_64-y += memset.c |
| 347 | endif |
| 348 | |
Patrick Georgi | c32a52c | 2015-06-22 21:10:34 +0200 | [diff] [blame] | 349 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) |
| 350 | target-objcopy=-O elf32-i386 -B i386 |
| 351 | endif |
| 352 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_64),y) |
Stefan Reinauer | 593f5c8 | 2015-07-30 18:03:18 -0700 | [diff] [blame] | 353 | target-objcopy=-O elf64-x86-64 -B i386:x86-64 |
Patrick Georgi | c32a52c | 2015-06-22 21:10:34 +0200 | [diff] [blame] | 354 | endif |
| 355 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 356 | ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c) |
| 357 | ifeq ($(CONFIG_GENERATE_MP_TABLE),y) |
| 358 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/mptable.c),) |
| 359 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mptable.c |
| 360 | endif |
| 361 | endif |
| 362 | ifeq ($(CONFIG_GENERATE_PIRQ_TABLE),y) |
| 363 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/irq_tables.c |
| 364 | endif |
| 365 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/reset.c),) |
| 366 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/reset.c |
| 367 | endif |
Vladimir Serbinenko | 822bc65 | 2014-01-03 15:55:40 +0100 | [diff] [blame] | 368 | ifeq ($(CONFIG_HAVE_ACPI_TABLES),y) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 369 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/acpi_tables.c |
Vladimir Serbinenko | 36f8d27 | 2015-05-31 12:31:59 +0200 | [diff] [blame] | 370 | $(eval $(call asl_template,dsdt)) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 371 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/fadt.c),) |
| 372 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/fadt.c |
| 373 | endif |
Patrick Georgi | 990e7c9 | 2015-04-03 10:47:15 +0200 | [diff] [blame] | 374 | endif # CONFIG_GENERATE_ACPI_TABLES |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 375 | |
| 376 | ramstage-libs ?= |
| 377 | |
| 378 | ifeq ($(CONFIG_RELOCATABLE_RAMSTAGE),y) |
| 379 | |
Elyes HAOUAS | 2f79eb3 | 2018-08-07 12:24:42 +0200 | [diff] [blame] | 380 | # The rmodule_link definition creates an elf file with .rmod extension. |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 381 | $(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod |
| 382 | cp $< $@ |
| 383 | |
Aaron Durbin | 83bc0db | 2015-09-06 10:45:18 -0500 | [diff] [blame] | 384 | endif |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 385 | |
Nico Huber | 81b09f4 | 2016-01-23 00:50:00 +0100 | [diff] [blame] | 386 | $(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(call src-to-obj,ramstage,src/arch/x86/memlayout.ld) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 387 | @printf " CC $(subst $(obj)/,,$(@))\n" |
Nico Huber | 81b09f4 | 2016-01-23 00:50:00 +0100 | [diff] [blame] | 388 | $(LD_ramstage) $(CPPFLAGS) $(LDFLAGS_ramstage) -o $@ -L$(obj) $< -T $(call src-to-obj,ramstage,src/arch/x86/memlayout.ld) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 389 | |
Patrick Georgi | 3ce96bd | 2014-11-22 17:42:58 +0100 | [diff] [blame] | 390 | $(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 391 | @printf " CC $(subst $(obj)/,,$(@))\n" |
Patrick Rudolph | 5407e89 | 2018-11-28 07:36:55 +0100 | [diff] [blame] | 392 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) |
Patrick Georgi | eec8dfb | 2015-05-07 22:24:41 +0200 | [diff] [blame] | 393 | $(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] | 394 | else |
| 395 | $(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 |
| 396 | endif |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 397 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 398 | endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64 |
Subrata Banik | eb5b0d0 | 2019-06-04 16:46:41 +0530 | [diff] [blame] | 399 | |
| 400 | smm-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c |
| 401 | smm-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S |
| 402 | smm-y += memcpy.c |
| 403 | smm-y += memmove.c |
| 404 | smm-y += memset.c |
| 405 | smm-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c |
| 406 | |
Subrata Banik | eb5b0d0 | 2019-06-04 16:46:41 +0530 | [diff] [blame] | 407 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/smihandler.c),) |
| 408 | smm-srcs += src/mainboard/$(MAINBOARDDIR)/smihandler.c |
| 409 | endif |