Patrick Georgi | 11f0079 | 2020-03-04 15:10:45 +0100 | [diff] [blame] | 1 | ## SPDX-License-Identifier: GPL-2.0-only |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 2 | |
Patrick Georgi | 29eeece | 2018-10-31 14:24:47 +0100 | [diff] [blame] | 3 | ifeq ($(CONFIG_POSTCAR_STAGE),y) |
| 4 | $(eval $(call init_standard_toolchain,postcar)) |
| 5 | endif |
| 6 | |
Patrick Georgi | 70a6b4f | 2015-03-27 14:14:58 +0100 | [diff] [blame] | 7 | ################################################################################ |
| 8 | # i386 specific tools |
| 9 | NVRAMTOOL:=$(objutil)/nvramtool/nvramtool |
| 10 | |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 11 | OPTION_TABLE_H:= |
| 12 | ifeq ($(CONFIG_HAVE_OPTION_TABLE),y) |
Patrick Georgi | 70a6b4f | 2015-03-27 14:14:58 +0100 | [diff] [blame] | 13 | |
Angel Pons | f206cda | 2021-05-17 12:12:39 +0200 | [diff] [blame] | 14 | CMOS_LAYOUT_FILE := $(top)/$(call strip_quotes,$(CONFIG_CMOS_LAYOUT_FILE)) |
| 15 | |
Patrick Georgi | 5c0bca2 | 2011-01-30 16:31:15 +0000 | [diff] [blame] | 16 | cbfs-files-y += cmos_layout.bin |
| 17 | cmos_layout.bin-file = $(obj)/cmos_layout.bin |
Martin Roth | 8ea0651 | 2016-09-19 13:58:01 -0600 | [diff] [blame] | 18 | cmos_layout.bin-type = cmos_layout |
Patrick Georgi | 2447937 | 2011-01-18 13:56:36 +0000 | [diff] [blame] | 19 | |
Angel Pons | f206cda | 2021-05-17 12:12:39 +0200 | [diff] [blame] | 20 | $(obj)/cmos_layout.bin: $(NVRAMTOOL) $(CMOS_LAYOUT_FILE) |
Patrick Georgi | 70a6b4f | 2015-03-27 14:14:58 +0100 | [diff] [blame] | 21 | @printf " OPTION $(subst $(obj)/,,$(@))\n" |
Angel Pons | f206cda | 2021-05-17 12:12:39 +0200 | [diff] [blame] | 22 | $(NVRAMTOOL) -y $(CMOS_LAYOUT_FILE) -L $@ |
Patrick Georgi | 70a6b4f | 2015-03-27 14:14:58 +0100 | [diff] [blame] | 23 | |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 24 | OPTION_TABLE_H:=$(obj)/option_table.h |
Patrick Georgi | 70a6b4f | 2015-03-27 14:14:58 +0100 | [diff] [blame] | 25 | |
Angel Pons | f206cda | 2021-05-17 12:12:39 +0200 | [diff] [blame] | 26 | $(OPTION_TABLE_H): $(NVRAMTOOL) $(CMOS_LAYOUT_FILE) |
Patrick Georgi | 70a6b4f | 2015-03-27 14:14:58 +0100 | [diff] [blame] | 27 | @printf " OPTION $(subst $(obj)/,,$(@))\n" |
Angel Pons | f206cda | 2021-05-17 12:12:39 +0200 | [diff] [blame] | 28 | $(NVRAMTOOL) -y $(CMOS_LAYOUT_FILE) -H $@ |
Patrick Georgi | 70a6b4f | 2015-03-27 14:14:58 +0100 | [diff] [blame] | 29 | endif # CONFIG_HAVE_OPTION_TABLE |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 30 | |
Patrick Georgi | ff9d78c | 2011-01-30 16:37:39 +0000 | [diff] [blame] | 31 | stripped_vgabios_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_ID)) |
| 32 | cbfs-files-$(CONFIG_VGA_BIOS) += pci$(stripped_vgabios_id).rom |
| 33 | pci$(stripped_vgabios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_FILE)) |
| 34 | pci$(stripped_vgabios_id).rom-type := optionrom |
| 35 | |
Martin Roth | 4cc2cac | 2019-12-06 19:11:08 -0700 | [diff] [blame] | 36 | stripped_second_vbios_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_SECOND_ID)) |
| 37 | cbfs-files-$(CONFIG_VGA_BIOS_SECOND) += pci$(stripped_second_vbios_id).rom |
| 38 | pci$(stripped_second_vbios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_SECOND_FILE)) |
| 39 | pci$(stripped_second_vbios_id).rom-type := optionrom |
| 40 | |
Mike Banon | 0f8547e | 2019-02-17 19:51:53 +0300 | [diff] [blame] | 41 | stripped_vgabios_dgpu_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_DGPU_ID)) |
| 42 | cbfs-files-$(CONFIG_VGA_BIOS_DGPU) += pci$(stripped_vgabios_dgpu_id).rom |
| 43 | pci$(stripped_vgabios_dgpu_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_DGPU_FILE)) |
| 44 | pci$(stripped_vgabios_dgpu_id).rom-type := optionrom |
| 45 | |
Raul E Rangel | 90cec2d | 2021-07-23 16:43:18 -0600 | [diff] [blame] | 46 | # The AMD LPC SPI DMA controller requires source files to be 64 byte aligned. |
| 47 | ifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_LPC_SPI_DMA),y) |
| 48 | pci$(stripped_vgabios_id).rom-align := 64 |
| 49 | pci$(stripped_second_vbios_id).rom-align := 64 |
| 50 | pci$(stripped_vgabios_dgpu_id).rom-align := 64 |
| 51 | endif # CONFIG_SOC_AMD_COMMON_BLOCK_LPC_SPI_DMA |
| 52 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 53 | ############################################################################### |
Aaron Durbin | eb907b3 | 2016-01-21 00:08:17 -0600 | [diff] [blame] | 54 | # common support for early assembly includes |
| 55 | ############################################################################### |
| 56 | |
Aaron Durbin | eb907b3 | 2016-01-21 00:08:17 -0600 | [diff] [blame] | 57 | define early_x86_stage |
| 58 | # $1 stage name |
| 59 | # $2 oformat |
Aaron Durbin | eb907b3 | 2016-01-21 00:08:17 -0600 | [diff] [blame] | 60 | |
| 61 | # The '.' include path is needed for the generated assembly.inc file. |
| 62 | $(1)-S-ccopts += -I. |
| 63 | |
| 64 | $$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs) |
| 65 | @printf " LINK $$(subst $$(obj)/,,$$(@))\n" |
Furquan Shaikh | 46514c2 | 2020-06-11 11:59:07 -0700 | [diff] [blame] | 66 | $$(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),$(CONFIG_MEMLAYOUT_LD_FILE)) --oformat $(2) |
Aaron Durbin | eb907b3 | 2016-01-21 00:08:17 -0600 | [diff] [blame] | 67 | endef |
| 68 | |
| 69 | ############################################################################### |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 70 | # bootblock |
| 71 | ############################################################################### |
Patrick Georgi | 641dd71 | 2011-11-01 18:55:59 +0100 | [diff] [blame] | 72 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 73 | ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32)$(CONFIG_ARCH_BOOTBLOCK_X86_64),y) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 74 | |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 75 | bootblock-y += boot.c |
Robert Zieba | 3f01cd1 | 2022-04-14 10:36:15 -0600 | [diff] [blame] | 76 | bootblock-$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES) += breakpoint.c |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 77 | bootblock-y += post.c |
| 78 | bootblock-y += cpu_common.c |
Aaron Durbin | 4b032e4 | 2018-04-20 01:39:30 -0600 | [diff] [blame] | 79 | bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c |
| 80 | bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 81 | bootblock-y += memcpy.c |
| 82 | bootblock-y += memset.c |
Arthur Heymans | 9df0fee | 2022-11-04 20:20:14 +0100 | [diff] [blame] | 83 | bootblock-$(CONFIG_ARCH_BOOTBLOCK_X86_32) += memmove_32.c |
| 84 | bootblock-$(CONFIG_ARCH_BOOTBLOCK_X86_64) += memmove_64.S |
Aaron Durbin | f49ddb6 | 2018-01-24 17:35:58 -0700 | [diff] [blame] | 85 | bootblock-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c |
Alexandru Gagniuc | 6a62231 | 2015-10-27 10:27:30 -0700 | [diff] [blame] | 86 | bootblock-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c |
Robert Zieba | 3f01cd1 | 2022-04-14 10:36:15 -0600 | [diff] [blame] | 87 | bootblock-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES) += null_breakpoint.c |
Kyösti Mälkki | b8d575c | 2019-12-16 16:00:49 +0200 | [diff] [blame] | 88 | bootblock-$(CONFIG_BOOTBLOCK_NORMAL) += bootblock_normal.c |
Kyösti Mälkki | 97b76f7 | 2020-11-19 16:41:28 +0200 | [diff] [blame] | 89 | bootblock-y += gdt_init.S |
Alexandru Gagniuc | ee2740b | 2015-10-04 17:47:36 -0700 | [diff] [blame] | 90 | bootblock-y += id.S |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 91 | bootblock-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c |
Arthur Heymans | 28de28d | 2022-05-15 21:46:44 +0200 | [diff] [blame] | 92 | bootblock-y += bootblock.ld |
| 93 | bootblock-y += car.ld |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 94 | |
Nico Huber | 81b09f4 | 2016-01-23 00:50:00 +0100 | [diff] [blame] | 95 | $(call src-to-obj,bootblock,$(dir)/id.S): $(obj)/build.h |
Patrick Georgi | ab35575 | 2015-10-15 11:07:07 +0200 | [diff] [blame] | 96 | |
Aaron Durbin | eb907b3 | 2016-01-21 00:08:17 -0600 | [diff] [blame] | 97 | ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y) |
| 98 | $(eval $(call early_x86_stage,bootblock,elf32-i386)) |
| 99 | else |
| 100 | $(eval $(call early_x86_stage,bootblock,elf64-x86-64)) |
| 101 | endif |
| 102 | |
Arthur Heymans | e8217b1 | 2022-04-05 20:42:07 +0200 | [diff] [blame] | 103 | ifeq ($(CONFIG_BOOTBLOCK_IN_CBFS),y) |
Yu-Ping Wu | 471eda5 | 2022-05-20 17:36:46 +0800 | [diff] [blame] | 104 | add_bootblock = \ |
| 105 | $(CBFSTOOL) $(1) add -f $(2) -n bootblock -t bootblock $(TXTIBB) \ |
| 106 | -b -$(call file-size,$(2)) \ |
Arthur Heymans | 31187bb | 2022-03-30 21:31:27 +0200 | [diff] [blame] | 107 | $(cbfs-autogen-attributes) $(TS_OPTIONS) $(CBFSTOOL_ADD_CMD_OPTIONS) |
Arthur Heymans | e8217b1 | 2022-04-05 20:42:07 +0200 | [diff] [blame] | 108 | endif |
Arthur Heymans | 31187bb | 2022-03-30 21:31:27 +0200 | [diff] [blame] | 109 | |
Julius Werner | d69ccaf | 2023-04-05 16:18:32 -0700 | [diff] [blame] | 110 | ifneq ($(CONFIG_CBFS_VERIFICATION),y) |
Arthur Heymans | 50ece62 | 2021-05-04 08:46:58 +0200 | [diff] [blame] | 111 | $(call src-to-obj,bootblock,$(dir)/walkcbfs.S): $(obj)/fmap_config.h |
Arthur Heymans | a033d8c | 2021-05-05 14:20:03 +0200 | [diff] [blame] | 112 | bootblock-y += walkcbfs.S |
Julius Werner | d69ccaf | 2023-04-05 16:18:32 -0700 | [diff] [blame] | 113 | endif |
Arthur Heymans | 0eb9c57 | 2019-01-05 18:21:47 +0100 | [diff] [blame] | 114 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 115 | endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64 |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 116 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 117 | ############################################################################### |
Aaron Durbin | 75c51d9 | 2015-09-29 16:31:20 -0500 | [diff] [blame] | 118 | # verstage |
| 119 | ############################################################################### |
| 120 | |
| 121 | ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32)$(CONFIG_ARCH_VERSTAGE_X86_64),y) |
| 122 | |
Arthur Heymans | f25f095 | 2021-04-30 14:45:19 +0200 | [diff] [blame] | 123 | verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += assembly_entry.S |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 124 | verstage-y += boot.c |
Robert Zieba | 3f01cd1 | 2022-04-14 10:36:15 -0600 | [diff] [blame] | 125 | verstage-$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES) += breakpoint.c |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 126 | verstage-y += post.c |
Hannah Williams | d3c0c0c | 2018-04-27 09:09:04 -0700 | [diff] [blame] | 127 | verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += gdt_init.S |
Aaron Durbin | 4b032e4 | 2018-04-20 01:39:30 -0600 | [diff] [blame] | 128 | verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c |
| 129 | verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 130 | verstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c |
Aaron Durbin | 75c51d9 | 2015-09-29 16:31:20 -0500 | [diff] [blame] | 131 | |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 132 | verstage-y += cpu_common.c |
| 133 | verstage-y += memset.c |
| 134 | verstage-y += memcpy.c |
Arthur Heymans | 9df0fee | 2022-11-04 20:20:14 +0100 | [diff] [blame] | 135 | verstage-$(CONFIG_ARCH_VERSTAGE_X86_32) += memmove_32.c |
| 136 | verstage-$(CONFIG_ARCH_VERSTAGE_X86_64) += memmove_64.S |
Aaron Durbin | 57dbbbb | 2016-03-18 13:12:41 -0500 | [diff] [blame] | 137 | verstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c |
Robert Zieba | 3f01cd1 | 2022-04-14 10:36:15 -0600 | [diff] [blame] | 138 | verstage-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES) += null_breakpoint.c |
Arthur Heymans | 7bea084 | 2018-06-06 18:19:56 +0200 | [diff] [blame] | 139 | # If verstage is a separate stage it means there's no need |
Aaron Durbin | 10221a0 | 2016-05-26 10:55:48 -0500 | [diff] [blame] | 140 | # for a chipset-specific car_stage_entry() so use the generic one |
| 141 | # which just calls verstage(). |
Arthur Heymans | 7bea084 | 2018-06-06 18:19:56 +0200 | [diff] [blame] | 142 | verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += verstage.c |
Aaron Durbin | 75c51d9 | 2015-09-29 16:31:20 -0500 | [diff] [blame] | 143 | |
Aaron Durbin | f49ddb6 | 2018-01-24 17:35:58 -0700 | [diff] [blame] | 144 | verstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c |
Aaron Durbin | 75c51d9 | 2015-09-29 16:31:20 -0500 | [diff] [blame] | 145 | |
Arthur Heymans | 28de28d | 2022-05-15 21:46:44 +0200 | [diff] [blame] | 146 | verstage-y += car.ld |
| 147 | |
Julius Werner | e91d170 | 2017-03-20 15:32:15 -0700 | [diff] [blame] | 148 | verstage-libs ?= |
Aaron Durbin | 75c51d9 | 2015-09-29 16:31:20 -0500 | [diff] [blame] | 149 | |
| 150 | ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32),y) |
| 151 | $(eval $(call early_x86_stage,verstage,elf32-i386)) |
| 152 | else |
| 153 | $(eval $(call early_x86_stage,verstage,elf64-x86-64)) |
| 154 | endif |
| 155 | |
Aaron Durbin | 75c51d9 | 2015-09-29 16:31:20 -0500 | [diff] [blame] | 156 | endif # CONFIG_ARCH_VERSTAGE_X86_32 / CONFIG_ARCH_VERSTAGE_X86_64 |
| 157 | |
| 158 | ############################################################################### |
Aaron Durbin | 1bc6a79 | 2015-09-29 14:54:25 -0500 | [diff] [blame] | 159 | # romstage |
| 160 | ############################################################################### |
| 161 | |
| 162 | ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 163 | |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame] | 164 | romstage-$(CONFIG_SEPARATE_ROMSTAGE) += assembly_entry.S |
| 165 | romstage-$(CONFIG_SEPARATE_ROMSTAGE) += romstage.c |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 166 | romstage-y += boot.c |
Robert Zieba | 3f01cd1 | 2022-04-14 10:36:15 -0600 | [diff] [blame] | 167 | romstage-$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES) += breakpoint.c |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 168 | romstage-y += post.c |
Arthur Heymans | a2bc254 | 2021-05-29 08:10:49 +0200 | [diff] [blame] | 169 | romstage-$(CONFIG_SEPARATE_ROMSTAGE) += gdt_init.S |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 170 | romstage-y += cpu_common.c |
Aaron Durbin | 4b032e4 | 2018-04-20 01:39:30 -0600 | [diff] [blame] | 171 | romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c |
| 172 | romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 173 | romstage-y += memcpy.c |
Arthur Heymans | 9df0fee | 2022-11-04 20:20:14 +0100 | [diff] [blame] | 174 | romstage-$(CONFIG_ARCH_ROMSTAGE_X86_32) += memmove_32.c |
| 175 | romstage-$(CONFIG_ARCH_ROMSTAGE_X86_64) += memmove_64.S |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 176 | romstage-y += memset.c |
Lee Leahy | e82b505 | 2016-07-25 17:07:53 -0700 | [diff] [blame] | 177 | romstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c |
Robert Zieba | 3f01cd1 | 2022-04-14 10:36:15 -0600 | [diff] [blame] | 178 | romstage-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES) += null_breakpoint.c |
Rizwan Qureshi | b1b44d3 | 2016-08-26 21:08:50 +0530 | [diff] [blame] | 179 | romstage-y += postcar_loader.c |
Aaron Durbin | f49ddb6 | 2018-01-24 17:35:58 -0700 | [diff] [blame] | 180 | romstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 181 | romstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c |
Raul E Rangel | ca0606e | 2021-07-21 14:34:00 -0600 | [diff] [blame] | 182 | romstage-$(CONFIG_COOP_MULTITASKING) += thread.c |
| 183 | romstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S |
Arthur Heymans | 28de28d | 2022-05-15 21:46:44 +0200 | [diff] [blame] | 184 | romstage-y += car.ld |
Lee Leahy | e82b505 | 2016-07-25 17:07:53 -0700 | [diff] [blame] | 185 | |
Rizwan Qureshi | 8e8ca5c | 2018-10-01 14:35:25 +0530 | [diff] [blame] | 186 | romstage-srcs += $(wildcard $(src)/mainboard/$(MAINBOARDDIR)/romstage.c) |
Alexandru Gagniuc | eb3c991 | 2014-03-29 13:01:11 -0500 | [diff] [blame] | 187 | romstage-libs ?= |
| 188 | |
Stefan Reinauer | 9874933 | 2015-06-23 12:57:06 -0700 | [diff] [blame] | 189 | ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y) |
Aaron Durbin | 1bc6a79 | 2015-09-29 14:54:25 -0500 | [diff] [blame] | 190 | $(eval $(call early_x86_stage,romstage,elf32-i386)) |
Stefan Reinauer | 9874933 | 2015-06-23 12:57:06 -0700 | [diff] [blame] | 191 | else |
Aaron Durbin | 1bc6a79 | 2015-09-29 14:54:25 -0500 | [diff] [blame] | 192 | $(eval $(call early_x86_stage,romstage,elf64-x86-64)) |
Stefan Reinauer | 9874933 | 2015-06-23 12:57:06 -0700 | [diff] [blame] | 193 | endif |
| 194 | |
Patrick Georgi | d69839b | 2015-04-03 10:32:17 +0200 | [diff] [blame] | 195 | # 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] | 196 | romstage-S-ccopts += -g0 |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 197 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 198 | endif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64 |
Stefan Reinauer | f1939bb | 2010-12-30 17:39:50 +0000 | [diff] [blame] | 199 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 200 | ############################################################################### |
Lee Leahy | a749150 | 2016-07-24 07:43:23 -0700 | [diff] [blame] | 201 | # postcar |
| 202 | ############################################################################### |
| 203 | |
Patrick Rudolph | 8daa12f | 2018-12-26 15:12:32 +0100 | [diff] [blame] | 204 | ifeq ($(CONFIG_ARCH_POSTCAR_X86_32),y) |
Lee Leahy | a749150 | 2016-07-24 07:43:23 -0700 | [diff] [blame] | 205 | $(eval $(call create_class_compiler,postcar,x86_32)) |
Patrick Rudolph | 8daa12f | 2018-12-26 15:12:32 +0100 | [diff] [blame] | 206 | else |
| 207 | $(eval $(call create_class_compiler,postcar,x86_64)) |
| 208 | endif |
Lee Leahy | a749150 | 2016-07-24 07:43:23 -0700 | [diff] [blame] | 209 | postcar-generic-ccopts += -D__POSTCAR__ |
| 210 | |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 211 | postcar-y += boot.c |
Robert Zieba | 3f01cd1 | 2022-04-14 10:36:15 -0600 | [diff] [blame] | 212 | postcar-$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES) += breakpoint.c |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 213 | postcar-y += post.c |
Hannah Williams | d3c0c0c | 2018-04-27 09:09:04 -0700 | [diff] [blame] | 214 | postcar-y += gdt_init.S |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 215 | postcar-y += cpu_common.c |
Aaron Durbin | 4b032e4 | 2018-04-20 01:39:30 -0600 | [diff] [blame] | 216 | postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c |
| 217 | postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S |
Lee Leahy | a749150 | 2016-07-24 07:43:23 -0700 | [diff] [blame] | 218 | postcar-y += exit_car.S |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 219 | postcar-y += memcpy.c |
Arthur Heymans | 9df0fee | 2022-11-04 20:20:14 +0100 | [diff] [blame] | 220 | postcar-$(CONFIG_ARCH_POSTCAR_X86_32) += memmove_32.c |
| 221 | postcar-$(CONFIG_ARCH_POSTCAR_X86_64) += memmove_64.S |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 222 | postcar-y += memset.c |
Lee Leahy | a749150 | 2016-07-24 07:43:23 -0700 | [diff] [blame] | 223 | postcar-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c |
Robert Zieba | 3f01cd1 | 2022-04-14 10:36:15 -0600 | [diff] [blame] | 224 | postcar-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES) += null_breakpoint.c |
Aaron Durbin | 6b0cebc | 2016-09-16 16:15:14 -0500 | [diff] [blame] | 225 | postcar-y += postcar.c |
Aaron Durbin | f49ddb6 | 2018-01-24 17:35:58 -0700 | [diff] [blame] | 226 | postcar-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 227 | postcar-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c |
Lee Leahy | a749150 | 2016-07-24 07:43:23 -0700 | [diff] [blame] | 228 | |
Lee Leahy | 4cfde2a | 2016-07-24 07:51:24 -0700 | [diff] [blame] | 229 | LDFLAGS_postcar += -Map $(objcbfs)/postcar.map |
| 230 | |
Lee Leahy | a749150 | 2016-07-24 07:43:23 -0700 | [diff] [blame] | 231 | $(objcbfs)/postcar.debug: $$(postcar-objs) |
| 232 | @printf " LINK $(subst $(obj)/,,$(@))\n" |
Furquan Shaikh | 46514c2 | 2020-06-11 11:59:07 -0700 | [diff] [blame] | 233 | $(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,$(CONFIG_MEMLAYOUT_LD_FILE)) |
Lee Leahy | a749150 | 2016-07-24 07:43:23 -0700 | [diff] [blame] | 234 | |
| 235 | $(objcbfs)/postcar.elf: $(objcbfs)/postcar.debug.rmod |
| 236 | cp $< $@ |
| 237 | |
| 238 | # Add postcar to CBFS |
| 239 | cbfs-files-$(CONFIG_POSTCAR_STAGE) += $(CONFIG_CBFS_PREFIX)/postcar |
| 240 | $(CONFIG_CBFS_PREFIX)/postcar-file := $(objcbfs)/postcar.elf |
| 241 | $(CONFIG_CBFS_PREFIX)/postcar-type := stage |
| 242 | $(CONFIG_CBFS_PREFIX)/postcar-compression := none |
| 243 | |
| 244 | ############################################################################### |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 245 | # ramstage |
| 246 | ############################################################################### |
| 247 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 248 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 249 | |
Angel Pons | 79572e4 | 2020-07-13 00:17:43 +0200 | [diff] [blame] | 250 | ramstage-y += acpi.c |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 251 | ramstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c |
Marshall Dawson | 991467d | 2018-09-04 12:32:56 -0600 | [diff] [blame] | 252 | ramstage-$(CONFIG_ACPI_BERT) += acpi_bert_storage.c |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 253 | ramstage-y += boot.c |
| 254 | ramstage-y += post.c |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 255 | ramstage-y += c_start.S |
Patrick Rudolph | e563815 | 2018-12-09 10:48:59 +0100 | [diff] [blame] | 256 | ramstage-y += c_exit.S |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 257 | ramstage-y += cpu.c |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 258 | ramstage-y += cpu_common.c |
Robert Zieba | 3f01cd1 | 2022-04-14 10:36:15 -0600 | [diff] [blame] | 259 | ramstage-$(CONFIG_DEBUG_HW_BREAKPOINTS) += breakpoint.c |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 260 | ramstage-y += ebda.c |
| 261 | ramstage-y += exception.c |
Aaron Durbin | 7a7c70b | 2018-04-20 00:56:57 -0600 | [diff] [blame] | 262 | ramstage-y += idt.S |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 263 | ramstage-$(CONFIG_IOAPIC) += ioapic.c |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 264 | ramstage-y += memcpy.c |
Arthur Heymans | 9df0fee | 2022-11-04 20:20:14 +0100 | [diff] [blame] | 265 | ramstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += memmove_32.c |
| 266 | ramstage-$(CONFIG_ARCH_RAMSTAGE_X86_64) += memmove_64.S |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 267 | ramstage-y += memset.c |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 268 | ramstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c |
| 269 | ramstage-$(CONFIG_GENERATE_MP_TABLE) += mpspec.c |
Robert Zieba | 3f01cd1 | 2022-04-14 10:36:15 -0600 | [diff] [blame] | 270 | ramstage-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS) += null_breakpoint.c |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 271 | ramstage-$(CONFIG_GENERATE_PIRQ_TABLE) += pirq_routing.c |
Robbie Zhang | 1879231 | 2017-02-13 13:44:14 -0800 | [diff] [blame] | 272 | ramstage-y += rdrand.c |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 273 | ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c |
| 274 | ramstage-y += tables.c |
| 275 | ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c |
| 276 | ramstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S |
Aaron Durbin | f49ddb6 | 2018-01-24 17:35:58 -0700 | [diff] [blame] | 277 | ramstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 278 | ramstage-$(CONFIG_HAVE_ACPI_RESUME) += wakeup.S |
Martin Roth | cbf6e6b | 2020-06-06 09:45:20 -0600 | [diff] [blame] | 279 | ramstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 280 | |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 281 | rmodules_x86_32-y += memcpy.c |
Arthur Heymans | 9df0fee | 2022-11-04 20:20:14 +0100 | [diff] [blame] | 282 | rmodules_x86_32-y += memmove_32.c |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 283 | rmodules_x86_32-y += memset.c |
Kyösti Mälkki | 67a537c | 2020-06-04 09:21:40 +0300 | [diff] [blame] | 284 | |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 285 | rmodules_x86_64-y += memcpy.c |
Arthur Heymans | 9df0fee | 2022-11-04 20:20:14 +0100 | [diff] [blame] | 286 | rmodules_x86_64-y += memmove_64.S |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 287 | rmodules_x86_64-y += memset.c |
Lee Leahy | 99f1b2f | 2016-07-25 17:18:50 -0700 | [diff] [blame] | 288 | |
Patrick Georgi | c32a52c | 2015-06-22 21:10:34 +0200 | [diff] [blame] | 289 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) |
| 290 | target-objcopy=-O elf32-i386 -B i386 |
Kyösti Mälkki | 67a537c | 2020-06-04 09:21:40 +0300 | [diff] [blame] | 291 | LD_MACHINE =-m elf_i386 |
Patrick Georgi | c32a52c | 2015-06-22 21:10:34 +0200 | [diff] [blame] | 292 | endif |
| 293 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_64),y) |
Stefan Reinauer | 593f5c8 | 2015-07-30 18:03:18 -0700 | [diff] [blame] | 294 | target-objcopy=-O elf64-x86-64 -B i386:x86-64 |
Kyösti Mälkki | 67a537c | 2020-06-04 09:21:40 +0300 | [diff] [blame] | 295 | LD_MACHINE =-m elf_x86_64 |
Patrick Georgi | c32a52c | 2015-06-22 21:10:34 +0200 | [diff] [blame] | 296 | endif |
| 297 | |
Arthur Heymans | 67d9518 | 2023-05-17 17:37:17 +0200 | [diff] [blame] | 298 | # Make sure generated code does not use XMMx and MMx registers |
| 299 | CFLAGS_x86_32 += -mno-mmx -mno-sse |
| 300 | CFLAGS_x86_64 += -mno-mmx -mno-sse |
| 301 | |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 302 | ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c) |
| 303 | ifeq ($(CONFIG_GENERATE_MP_TABLE),y) |
| 304 | ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/mptable.c),) |
| 305 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mptable.c |
| 306 | endif |
| 307 | endif |
| 308 | ifeq ($(CONFIG_GENERATE_PIRQ_TABLE),y) |
| 309 | ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/irq_tables.c |
| 310 | endif |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 311 | |
| 312 | ramstage-libs ?= |
| 313 | |
Elyes HAOUAS | 2f79eb3 | 2018-08-07 12:24:42 +0200 | [diff] [blame] | 314 | # The rmodule_link definition creates an elf file with .rmod extension. |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 315 | $(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod |
| 316 | cp $< $@ |
| 317 | |
Furquan Shaikh | 46514c2 | 2020-06-11 11:59:07 -0700 | [diff] [blame] | 318 | $(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 319 | @printf " CC $(subst $(obj)/,,$(@))\n" |
Srinivas Hegde | 2d589cf | 2023-11-21 22:10:36 +0000 | [diff] [blame] | 320 | $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) $< -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 321 | |
Patrick Georgi | 3ce96bd | 2014-11-22 17:42:58 +0100 | [diff] [blame] | 322 | $(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs) |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 323 | @printf " CC $(subst $(obj)/,,$(@))\n" |
Kyösti Mälkki | 67a537c | 2020-06-04 09:21:40 +0300 | [diff] [blame] | 324 | $(LD_ramstage) $(LD_MACHINE) -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 |
Furquan Shaikh | 88ca81a | 2014-04-22 16:33:22 -0700 | [diff] [blame] | 325 | |
Stefan Reinauer | 181b773 | 2015-03-15 19:23:50 +0100 | [diff] [blame] | 326 | endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64 |
Subrata Banik | eb5b0d0 | 2019-06-04 16:46:41 +0530 | [diff] [blame] | 327 | |
Robert Zieba | 3f01cd1 | 2022-04-14 10:36:15 -0600 | [diff] [blame] | 328 | smm-$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES) += breakpoint.c |
Subrata Banik | eb5b0d0 | 2019-06-04 16:46:41 +0530 | [diff] [blame] | 329 | smm-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c |
| 330 | smm-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S |
| 331 | smm-y += memcpy.c |
Arthur Heymans | 9df0fee | 2022-11-04 20:20:14 +0100 | [diff] [blame] | 332 | smm-$(CONFIG_ARCH_RAMSTAGE_X86_32) += memmove_32.c |
| 333 | smm-$(CONFIG_ARCH_RAMSTAGE_X86_64) += memmove_64.S |
Subrata Banik | eb5b0d0 | 2019-06-04 16:46:41 +0530 | [diff] [blame] | 334 | smm-y += memset.c |
| 335 | smm-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c |
Robert Zieba | 3f01cd1 | 2022-04-14 10:36:15 -0600 | [diff] [blame] | 336 | smm-$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES) += null_breakpoint.c |
Subrata Banik | eb5b0d0 | 2019-06-04 16:46:41 +0530 | [diff] [blame] | 337 | |
Kyösti Mälkki | 0be4199 | 2021-01-08 13:58:10 +0200 | [diff] [blame] | 338 | smm-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/smihandler.c) |
Felix Held | 6759ad3 | 2023-12-14 20:49:59 +0100 | [diff] [blame] | 339 | |
| 340 | ifneq ($(CONFIG_HAVE_CONFIGURABLE_APMC_SMI_PORT),y) |
| 341 | ramstage-y += apmc_smi_port.c |
| 342 | smm-y += apmc_smi_port.c |
| 343 | endif |