blob: cd920daf1ab8218189376768d06980b855631411 [file] [log] [blame]
Patrick Georgic49d7a32020-05-08 22:50:46 +02001## SPDX-License-Identifier: GPL-2.0-only
Patrick Georgi0588d192009-08-12 15:00:51 +00002
Arthur Heymans29abd042021-03-16 13:39:45 +01003ramstage-y += smm_module_loader.c
Aaron Durbinb4b9eb32014-02-13 10:26:18 -06004
Stefan Reinauer87200e22015-03-15 00:21:17 +01005ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -07006$(eval $(call create_class_compiler,smm,x86_32))
7$(eval $(call create_class_compiler,smmstub,x86_32))
Stefan Reinauer87200e22015-03-15 00:21:17 +01008else
9$(eval $(call create_class_compiler,smm,x86_64))
10$(eval $(call create_class_compiler,smmstub,x86_64))
11endif
Edward O'Callaghane9008022014-11-11 13:44:16 +110012
Patrick Georgicbe27462015-03-27 15:32:49 +010013smmstub-generic-ccopts += -D__SMM__
14smm-generic-ccopts += -D__SMM__
Furquan Shaikh2136c5a2021-01-06 23:37:47 -080015smm-c-deps+=$$(OPTION_TABLE_H)
Patrick Georgicbe27462015-03-27 15:32:49 +010016
Nico Huber98fc4262016-01-23 01:24:33 +010017$(obj)/smm/smm.o: $$(smm-objs) $(COMPILER_RT_smm)
Arthur Heymansf3d65e42020-08-09 20:18:11 +020018 $(LD_smm) -nostdlib -r -o $@ $(COMPILER_RT_FLAGS_smm) --whole-archive --start-group $(filter-out %.ld, $(smm-objs)) --no-whole-archive $(COMPILER_RT_smm) --end-group
Edward O'Callaghane9008022014-11-11 13:44:16 +110019
Kyösti Mälkki59d262c2015-05-29 10:55:59 +030020# change to the target path because objcopy will use the path name in its
21# ELF symbol names.
Nico Huber98fc4262016-01-23 01:24:33 +010022$(call src-to-obj,ramstage,$(obj)/cpu/x86/smm/smm.manual): $(obj)/smm/smm
Kyösti Mälkki59d262c2015-05-29 10:55:59 +030023 @printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
Nico Huber98fc4262016-01-23 01:24:33 +010024 cd $(dir $<); $(OBJCOPY_smm) -I binary $(notdir $<) $(target-objcopy) $(abspath $@)
Kyösti Mälkki59d262c2015-05-29 10:55:59 +030025
Kyösti Mälkki9265f892019-07-07 23:58:34 +030026ifeq ($(CONFIG_HAVE_SMI_HANDLER),y)
27ramstage-srcs += $(obj)/cpu/x86/smm/smm.manual
28endif
29
Arthur Heymans3967cf92020-08-09 21:33:19 +020030smm-y += save_state.c
31
Vladimir Serbinenko44cbe102015-05-28 21:09:31 +020032ifeq ($(CONFIG_SMM_TSEG),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070033
Kyösti Mälkki4913d8a2019-08-05 12:49:09 +030034ramstage-y += tseg_region.c
35romstage-y += tseg_region.c
36postcar-y += tseg_region.c
Kyösti Mälkki9970b612019-08-03 23:18:01 +030037
Arthur Heymansb4ba2892021-10-28 16:48:36 +020038endif
39
40ifeq ($(CONFIG_PARALLEL_MP),y)
41
Aaron Durbin50a34642013-01-03 17:38:47 -060042smmstub-y += smm_stub.S
Aaron Durbin50a34642013-01-03 17:38:47 -060043
Aaron Durbin50a34642013-01-03 17:38:47 -060044smm-y += smm_module_handler.c
45
Patrick Georgif4305462015-04-03 10:39:05 +020046ramstage-srcs += $(obj)/cpu/x86/smm/smmstub.manual
Aaron Durbin50a34642013-01-03 17:38:47 -060047
48# SMM Stub Module. The stub is used as a trampoline for relocation and normal
49# SMM handling.
Arthur Heymansbf1da4b2018-12-29 13:09:26 +010050$(obj)/smmstub/smmstub.o: $$(smmstub-objs) $(COMPILER_RT_smmstub)
51 $(LD_smmstub) -nostdlib -r -o $@ $(COMPILER_RT_FLAGS_smmstub) --whole-archive --start-group $(smmstub-objs) --no-whole-archive $(COMPILER_RT_smmstub) --end-group
Aaron Durbin50a34642013-01-03 17:38:47 -060052
53# Link the SMM stub module with a 0-byte heap.
Stefan Reinauer01327d12015-07-30 16:28:44 -070054ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
Nico Huber98fc4262016-01-23 01:24:33 +010055$(eval $(call rmodule_link,$(obj)/smmstub/smmstub.elf, $(obj)/smmstub/smmstub.o, 0,x86_32))
Stefan Reinauer01327d12015-07-30 16:28:44 -070056else
Nico Huber98fc4262016-01-23 01:24:33 +010057$(eval $(call rmodule_link,$(obj)/smmstub/smmstub.elf, $(obj)/smmstub/smmstub.o, 0,x86_64))
Stefan Reinauer01327d12015-07-30 16:28:44 -070058endif
Aaron Durbin50a34642013-01-03 17:38:47 -060059
Nico Huber98fc4262016-01-23 01:24:33 +010060$(obj)/smmstub/smmstub: $(obj)/smmstub/smmstub.elf.rmod
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070061 $(OBJCOPY_smmstub) -O binary $< $@
Aaron Durbin50a34642013-01-03 17:38:47 -060062
Nico Huber98fc4262016-01-23 01:24:33 +010063$(call src-to-obj,ramstage,$(obj)/cpu/x86/smm/smmstub.manual): $(obj)/smmstub/smmstub
Aaron Durbin50a34642013-01-03 17:38:47 -060064 @printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
Nico Huber98fc4262016-01-23 01:24:33 +010065 cd $(dir $<); $(OBJCOPY_smmstub) -I binary $(notdir $<) $(target-objcopy) $(abspath $@)
Aaron Durbin50a34642013-01-03 17:38:47 -060066
67# C-based SMM handler.
68
Stefan Reinauer87200e22015-03-15 00:21:17 +010069ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
Nico Huber98fc4262016-01-23 01:24:33 +010070$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.o, $(CONFIG_SMM_MODULE_HEAP_SIZE),x86_32))
Stefan Reinauer87200e22015-03-15 00:21:17 +010071else
Nico Huber98fc4262016-01-23 01:24:33 +010072$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.o, $(CONFIG_SMM_MODULE_HEAP_SIZE),x86_64))
Stefan Reinauer87200e22015-03-15 00:21:17 +010073endif
Aaron Durbin50a34642013-01-03 17:38:47 -060074
Nico Huber98fc4262016-01-23 01:24:33 +010075$(obj)/smm/smm: $(obj)/smm/smm.elf.rmod
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070076 $(OBJCOPY_smm) -O binary $< $@
Aaron Durbin50a34642013-01-03 17:38:47 -060077
Arthur Heymansb4ba2892021-10-28 16:48:36 +020078endif
79
80ifeq ($(CONFIG_SMM_LEGACY_ASEG),y)
Aaron Durbin50a34642013-01-03 17:38:47 -060081
Arthur Heymansf3d65e42020-08-09 20:18:11 +020082smm-y += smm.ld
83
84$(obj)/smm/smm: $(obj)/smm/smm.o $(call src-to-obj,smm,$(src)/cpu/x86/smm/smm.ld)
85 $(LD_smm) $(LDFLAGS_smm) -o $(obj)/smm/smm.elf -T $(call src-to-obj,smm,$(src)/cpu/x86/smm/smm.ld) $(obj)/smm/smm.o
Nico Huber98fc4262016-01-23 01:24:33 +010086 $(NM_smm) -n $(obj)/smm/smm.elf | sort > $(obj)/smm/smm.map
87 $(OBJCOPY_smm) -O binary $(obj)/smm/smm.elf $@
Kyösti Mälkkie2edf712015-04-10 11:52:53 +030088
Patrick Georgi8463dd92010-09-30 16:55:02 +000089smm-y += smmhandler.S
90smm-y += smihandler.c
Stefan Reinauer60fc92a2009-10-24 03:33:44 +000091
Arthur Heymansb4ba2892021-10-28 16:48:36 +020092endif # CONFIG_SMM_LEGACY_ASEG