1 ## SPDX-License-Identifier: GPL-2.0-only
3 ifeq ($(CONFIG_POSTCAR_STAGE
),y
)
4 $(eval
$(call init_standard_toolchain
,postcar
))
7 ################################################################################
9 NVRAMTOOL
:=$(objutil
)/nvramtool
/nvramtool
12 ifeq ($(CONFIG_HAVE_OPTION_TABLE
),y
)
14 CMOS_LAYOUT_FILE
:= $(top
)/$(call strip_quotes
,$(CONFIG_CMOS_LAYOUT_FILE
))
16 cbfs-files-y
+= cmos_layout.bin
17 cmos_layout.bin-file
= $(obj
)/cmos_layout.bin
18 cmos_layout.bin-type
= cmos_layout
20 $(obj
)/cmos_layout.bin
: $(NVRAMTOOL
) $(CMOS_LAYOUT_FILE
)
21 @printf
" OPTION $(subst $(obj)/,,$(@))\n"
22 $(NVRAMTOOL
) -y
$(CMOS_LAYOUT_FILE
) -L
$@
24 OPTION_TABLE_H
:=$(obj
)/option_table.h
26 $(OPTION_TABLE_H
): $(NVRAMTOOL
) $(CMOS_LAYOUT_FILE
)
27 @printf
" OPTION $(subst $(obj)/,,$(@))\n"
28 $(NVRAMTOOL
) -y
$(CMOS_LAYOUT_FILE
) -H
$@
29 endif # CONFIG_HAVE_OPTION_TABLE
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
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
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
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
53 ###############################################################################
55 ###############################################################################
57 ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32
)$(CONFIG_ARCH_BOOTBLOCK_X86_64
),y
)
60 bootblock-
$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES
) += breakpoint.c
62 bootblock-y
+= cpu_common.c
63 bootblock-
$(CONFIG_IDT_IN_EVERY_STAGE
) += exception.c
64 bootblock-
$(CONFIG_IDT_IN_EVERY_STAGE
) += idt.S
65 bootblock-y
+= memcpy.c
66 bootblock-y
+= memset.c
67 bootblock-
$(CONFIG_ARCH_BOOTBLOCK_X86_32
) += memmove_32.c
68 bootblock-
$(CONFIG_ARCH_BOOTBLOCK_X86_64
) += memmove_64.S
69 bootblock-
$(CONFIG_COLLECT_TIMESTAMPS_TSC
) += timestamp.c
70 bootblock-
$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP
) += mmap_boot.c
71 bootblock-
$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES
) += null_breakpoint.c
72 bootblock-
$(CONFIG_DEBUG_STACK_OVERFLOW_BREAKPOINTS_IN_ALL_STAGES
) += stack_canary_breakpoint.c
73 bootblock-
$(CONFIG_BOOTBLOCK_NORMAL
) += bootblock_normal.c
74 bootblock-y
+= gdt_init.S
76 bootblock-
$(CONFIG_HAVE_CF9_RESET
) += cf9_reset.c
77 bootblock-y
+= bootblock.
ld
80 $(call src-to-obj
,bootblock
,$(dir)/id.S
): $(obj
)/build.h
82 $(eval
$(call link_stage
,bootblock
))
84 ifeq ($(CONFIG_BOOTBLOCK_IN_CBFS
),y
)
86 $(CBFSTOOL
) $(1) add
-f
$(2) -n bootblock
-t bootblock
$(TXTIBB
) \
87 -b
-$(call file-size
,$(2)) \
88 $(cbfs-autogen-attributes
) $(TS_OPTIONS
) $(CBFSTOOL_ADD_CMD_OPTIONS
)
91 ifneq ($(CONFIG_CBFS_VERIFICATION
),y
)
92 $(call src-to-obj
,bootblock
,$(dir)/walkcbfs.S
): $(obj
)/fmap_config.h
93 bootblock-y
+= walkcbfs.S
96 endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64
98 ###############################################################################
100 ###############################################################################
102 ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32
)$(CONFIG_ARCH_VERSTAGE_X86_64
),y
)
104 verstage-
$(CONFIG_VBOOT_SEPARATE_VERSTAGE
) += assembly_entry.S
106 verstage-
$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES
) += breakpoint.c
108 verstage-
$(CONFIG_VBOOT_SEPARATE_VERSTAGE
) += gdt_init.S
109 verstage-
$(CONFIG_IDT_IN_EVERY_STAGE
) += exception.c
110 verstage-
$(CONFIG_IDT_IN_EVERY_STAGE
) += idt.S
111 verstage-
$(CONFIG_HAVE_CF9_RESET
) += cf9_reset.c
113 verstage-y
+= cpu_common.c
114 verstage-y
+= memset.c
115 verstage-y
+= memcpy.c
116 verstage-
$(CONFIG_ARCH_VERSTAGE_X86_32
) += memmove_32.c
117 verstage-
$(CONFIG_ARCH_VERSTAGE_X86_64
) += memmove_64.S
118 verstage-
$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP
) += mmap_boot.c
119 verstage-
$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES
) += null_breakpoint.c
120 verstage-
$(CONFIG_DEBUG_STACK_OVERFLOW_BREAKPOINTS_IN_ALL_STAGES
) += stack_canary_breakpoint.c
121 # If verstage is a separate stage it means there's no need
122 # for a chipset-specific car_stage_entry() so use the generic one
123 # which just calls verstage().
124 verstage-
$(CONFIG_VBOOT_SEPARATE_VERSTAGE
) += verstage.c
126 verstage-
$(CONFIG_COLLECT_TIMESTAMPS_TSC
) += timestamp.c
132 $(eval
$(call link_stage
,verstage
))
134 endif # CONFIG_ARCH_VERSTAGE_X86_32 / CONFIG_ARCH_VERSTAGE_X86_64
136 ###############################################################################
138 ###############################################################################
140 ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32
)$(CONFIG_ARCH_ROMSTAGE_X86_64
),y
)
142 romstage-
$(CONFIG_SEPARATE_ROMSTAGE
) += assembly_entry.S
143 romstage-
$(CONFIG_SEPARATE_ROMSTAGE
) += romstage.c
145 romstage-
$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES
) += breakpoint.c
147 romstage-
$(CONFIG_SEPARATE_ROMSTAGE
) += gdt_init.S
148 romstage-y
+= cpu_common.c
149 romstage-
$(CONFIG_IDT_IN_EVERY_STAGE
) += exception.c
150 romstage-
$(CONFIG_IDT_IN_EVERY_STAGE
) += idt.S
151 romstage-y
+= memcpy.c
152 romstage-
$(CONFIG_ARCH_ROMSTAGE_X86_32
) += memmove_32.c
153 romstage-
$(CONFIG_ARCH_ROMSTAGE_X86_64
) += memmove_64.S
154 romstage-y
+= memset.c
155 romstage-
$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP
) += mmap_boot.c
156 romstage-
$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES
) += null_breakpoint.c
157 romstage-
$(CONFIG_DEBUG_STACK_OVERFLOW_BREAKPOINTS_IN_ALL_STAGES
) += stack_canary_breakpoint.c
158 romstage-y
+= postcar_loader.c
159 romstage-
$(CONFIG_COLLECT_TIMESTAMPS_TSC
) += timestamp.c
160 romstage-
$(CONFIG_HAVE_CF9_RESET
) += cf9_reset.c
161 romstage-
$(CONFIG_COOP_MULTITASKING
) += thread.c
162 romstage-
$(CONFIG_COOP_MULTITASKING
) += thread_switch.S
165 romstage-srcs
+= $(wildcard $(src
)/mainboard
/$(MAINBOARDDIR
)/romstage.c
)
168 $(eval
$(call link_stage
,romstage
))
170 # Compiling crt0 with -g seems to trigger https://sourceware.org/bugzilla/show_bug.cgi?id=6428
171 romstage-S-ccopts
+= -g0
173 endif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64
175 ###############################################################################
177 ###############################################################################
179 ifeq ($(CONFIG_ARCH_POSTCAR_X86_32
),y
)
180 $(eval
$(call create_class_compiler
,postcar
,x86_32
))
182 $(eval
$(call create_class_compiler
,postcar
,x86_64
))
184 postcar-generic-ccopts
+= -D__POSTCAR__
187 postcar-
$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES
) += breakpoint.c
189 postcar-y
+= gdt_init.S
190 postcar-y
+= cpu_common.c
191 postcar-
$(CONFIG_IDT_IN_EVERY_STAGE
) += exception.c
192 postcar-
$(CONFIG_IDT_IN_EVERY_STAGE
) += idt.S
193 postcar-y
+= exit_car.S
194 postcar-y
+= memcpy.c
195 postcar-
$(CONFIG_ARCH_POSTCAR_X86_32
) += memmove_32.c
196 postcar-
$(CONFIG_ARCH_POSTCAR_X86_64
) += memmove_64.S
197 postcar-y
+= memset.c
198 postcar-
$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP
) += mmap_boot.c
199 postcar-
$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES
) += null_breakpoint.c
200 postcar-
$(CONFIG_DEBUG_STACK_OVERFLOW_BREAKPOINTS_IN_ALL_STAGES
) += stack_canary_breakpoint.c
201 postcar-y
+= postcar.c
202 postcar-
$(CONFIG_COLLECT_TIMESTAMPS_TSC
) += timestamp.c
203 postcar-
$(CONFIG_HAVE_CF9_RESET
) += cf9_reset.c
205 LDFLAGS_postcar
+= -Map
$(objcbfs
)/postcar.map
207 $(eval
$(call link_stage
,postcar
))
209 $(objcbfs
)/postcar.elf
: $(objcbfs
)/postcar.debug.rmod
212 # Add postcar to CBFS
213 cbfs-files-
$(CONFIG_POSTCAR_STAGE
) += $(CONFIG_CBFS_PREFIX
)/postcar
214 $(CONFIG_CBFS_PREFIX
)/postcar-file
:= $(objcbfs
)/postcar.elf
215 $(CONFIG_CBFS_PREFIX
)/postcar-type
:= stage
216 $(CONFIG_CBFS_PREFIX
)/postcar-compression
:= none
218 ###############################################################################
220 ###############################################################################
222 ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32
)$(CONFIG_ARCH_RAMSTAGE_X86_64
),y
)
225 ramstage-
$(CONFIG_HAVE_ACPI_RESUME
) += acpi_s3.c
226 ramstage-
$(CONFIG_ACPI_BERT
) += acpi_bert_storage.c
229 ramstage-y
+= c_start.S
231 ramstage-y
+= cpu_common.c
232 ramstage-
$(CONFIG_DEBUG_HW_BREAKPOINTS
) += breakpoint.c
234 ramstage-y
+= exception.c
236 ramstage-
$(CONFIG_IOAPIC
) += ioapic.c
238 ramstage-y
+= memcpy.c
239 ramstage-
$(CONFIG_ARCH_RAMSTAGE_X86_32
) += memmove_32.c
240 ramstage-
$(CONFIG_ARCH_RAMSTAGE_X86_64
) += memmove_64.S
241 ramstage-y
+= memset.c
242 ramstage-
$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP
) += mmap_boot.c
243 ramstage-
$(CONFIG_GENERATE_MP_TABLE
) += mpspec.c
244 ramstage-
$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS
) += null_breakpoint.c
245 ramstage-
$(CONFIG_DEBUG_STACK_OVERFLOW_BREAKPOINTS
) += stack_canary_breakpoint.c
246 ramstage-
$(CONFIG_GENERATE_PIRQ_TABLE
) += pirq_routing.c
247 ramstage-y
+= rdrand.c
248 ramstage-
$(CONFIG_GENERATE_SMBIOS_TABLES
) += smbios.c
249 ramstage-y
+= tables.c
250 ramstage-
$(CONFIG_COOP_MULTITASKING
) += thread.c
251 ramstage-
$(CONFIG_COOP_MULTITASKING
) += thread_switch.S
252 ramstage-
$(CONFIG_COLLECT_TIMESTAMPS_TSC
) += timestamp.c
253 ramstage-
$(CONFIG_HAVE_ACPI_RESUME
) += wakeup.S
254 ramstage-
$(CONFIG_HAVE_CF9_RESET
) += cf9_reset.c
256 rmodules_x86_32-y
+= memcpy.c
257 rmodules_x86_32-y
+= memmove_32.c
258 rmodules_x86_32-y
+= memset.c
260 rmodules_x86_64-y
+= memcpy.c
261 rmodules_x86_64-y
+= memmove_64.S
262 rmodules_x86_64-y
+= memset.c
264 ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32
),y
)
265 target-objcopy
=-O elf32-i386
-B i386
267 ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_64
),y
)
268 target-objcopy
=-O elf64-x86-64
-B i386
:x86-64
271 # Make sure generated code does not use XMMx and MMx registers
272 CFLAGS_x86_32
+= -mno-mmx
-mno-sse
273 CFLAGS_x86_64
+= -mno-mmx
-mno-sse
275 ramstage-srcs
+= $(wildcard src
/mainboard
/$(MAINBOARDDIR
)/mainboard.c
)
276 ifeq ($(CONFIG_GENERATE_MP_TABLE
),y
)
277 ifneq ($(wildcard src
/mainboard
/$(MAINBOARDDIR
)/mptable.c
),)
278 ramstage-srcs
+= src
/mainboard
/$(MAINBOARDDIR
)/mptable.c
281 ifeq ($(CONFIG_GENERATE_PIRQ_TABLE
),y
)
282 ramstage-srcs
+= src
/mainboard
/$(MAINBOARDDIR
)/irq_tables.c
287 $(eval
$(call link_stage
,ramstage
))
289 $(objcbfs
)/ramstage.elf
: $(objcbfs
)/ramstage.debug.rmod
292 endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64
294 smm-
$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES
) += breakpoint.c
295 smm-
$(CONFIG_IDT_IN_EVERY_STAGE
) += exception.c
296 smm-
$(CONFIG_IDT_IN_EVERY_STAGE
) += idt.S
298 smm-
$(CONFIG_ARCH_RAMSTAGE_X86_32
) += memmove_32.c
299 smm-
$(CONFIG_ARCH_RAMSTAGE_X86_64
) += memmove_64.S
301 smm-
$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP
) += mmap_boot.c
302 smm-
$(CONFIG_DEBUG_NULL_DEREF_BREAKPOINTS_IN_ALL_STAGES
) += null_breakpoint.c
304 smm-srcs
+= $(wildcard src
/mainboard
/$(MAINBOARDDIR
)/smihandler.c
)
306 ifneq ($(CONFIG_HAVE_CONFIGURABLE_APMC_SMI_PORT
),y
)
307 ramstage-y
+= apmc_smi_port.c
308 smm-y
+= apmc_smi_port.c