1## SPDX-License-Identifier: GPL-2.0-only 2 3ramstage-y += smm_module_loader.c 4ramstage-$(CONFIG_SMM_PCI_RESOURCE_STORE) += pci_resource_store.c 5 6smm-$(CONFIG_SMM_PCI_RESOURCE_STORE) += pci_resource_store.c 7 8ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) 9$(eval $(call create_class_compiler,smm,x86_32)) 10$(eval $(call create_class_compiler,smmstub,x86_32)) 11else 12$(eval $(call create_class_compiler,smm,x86_64)) 13$(eval $(call create_class_compiler,smmstub,x86_64)) 14endif 15 16smmstub-generic-ccopts += -D__SMM__ 17smm-generic-ccopts += -D__SMM__ 18smm-c-deps+=$$(OPTION_TABLE_H) 19 20$(obj)/smm/smm.o: $$(smm-objs) $(COMPILER_RT_smm) 21 $(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 22 23# change to the target path because objcopy will use the path name in its 24# ELF symbol names. 25$(call src-to-obj,ramstage,$(obj)/cpu/x86/smm/smm.manual): $(obj)/smm/smm 26 @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" 27 cd $(dir $<); $(OBJCOPY_smm) -I binary $(notdir $<) $(target-objcopy) $(abspath $@) 28 29ifeq ($(CONFIG_HAVE_SMI_HANDLER),y) 30ramstage-srcs += $(obj)/cpu/x86/smm/smm.manual 31endif 32 33smm-y += save_state.c 34 35ramstage-y += tseg_region.c 36romstage-y += tseg_region.c 37postcar-y += tseg_region.c 38 39ifeq ($(CONFIG_PARALLEL_MP),y) 40 41smmstub-y += smm_stub.S 42 43smm-y += smm_module_handler.c 44 45ramstage-srcs += $(obj)/cpu/x86/smm/smmstub.manual 46 47# SMM Stub Module. The stub is used as a trampoline for relocation and normal 48# SMM handling. 49$(obj)/smmstub/smmstub.o: $$(smmstub-objs) $(COMPILER_RT_smmstub) 50 $(LD_smmstub) -nostdlib -r -o $@ $(COMPILER_RT_FLAGS_smmstub) --whole-archive --start-group $(smmstub-objs) --no-whole-archive $(COMPILER_RT_smmstub) --end-group 51 52ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) 53$(eval $(call rmodule_link,$(obj)/smmstub/smmstub.elf, $(obj)/smmstub/smmstub.o,x86_32)) 54else 55$(eval $(call rmodule_link,$(obj)/smmstub/smmstub.elf, $(obj)/smmstub/smmstub.o,x86_64)) 56endif 57 58$(obj)/smmstub/smmstub: $(obj)/smmstub/smmstub.elf.rmod 59 $(OBJCOPY_smmstub) -O binary $< $@ 60 61$(call src-to-obj,ramstage,$(obj)/cpu/x86/smm/smmstub.manual): $(obj)/smmstub/smmstub 62 @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" 63 cd $(dir $<); $(OBJCOPY_smmstub) -I binary $(notdir $<) $(target-objcopy) $(abspath $@) 64 65# C-based SMM handler. 66 67ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) 68$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.o,x86_32)) 69else 70$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.o,x86_64)) 71endif 72 73$(obj)/smm/smm: $(obj)/smm/smm.elf.rmod 74 $(OBJCOPY_smm) -O binary $< $@ 75 76endif 77