Patrick Georgi | c49d7a3 | 2020-05-08 22:50:46 +0200 | [diff] [blame] | 1 | ## SPDX-License-Identifier: GPL-2.0-only |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 2 | |
Arthur Heymans | 29abd04 | 2021-03-16 13:39:45 +0100 | [diff] [blame] | 3 | ramstage-y += smm_module_loader.c |
Aaron Durbin | b4b9eb3 | 2014-02-13 10:26:18 -0600 | [diff] [blame] | 4 | |
Stefan Reinauer | 87200e2 | 2015-03-15 00:21:17 +0100 | [diff] [blame] | 5 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 6 | $(eval $(call create_class_compiler,smm,x86_32)) |
| 7 | $(eval $(call create_class_compiler,smmstub,x86_32)) |
Stefan Reinauer | 87200e2 | 2015-03-15 00:21:17 +0100 | [diff] [blame] | 8 | else |
| 9 | $(eval $(call create_class_compiler,smm,x86_64)) |
| 10 | $(eval $(call create_class_compiler,smmstub,x86_64)) |
| 11 | endif |
Edward O'Callaghan | e900802 | 2014-11-11 13:44:16 +1100 | [diff] [blame] | 12 | |
Patrick Georgi | cbe2746 | 2015-03-27 15:32:49 +0100 | [diff] [blame] | 13 | smmstub-generic-ccopts += -D__SMM__ |
| 14 | smm-generic-ccopts += -D__SMM__ |
Furquan Shaikh | 2136c5a | 2021-01-06 23:37:47 -0800 | [diff] [blame] | 15 | smm-c-deps+=$$(OPTION_TABLE_H) |
Patrick Georgi | cbe2746 | 2015-03-27 15:32:49 +0100 | [diff] [blame] | 16 | |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 17 | $(obj)/smm/smm.o: $$(smm-objs) $(COMPILER_RT_smm) |
Arthur Heymans | f3d65e4 | 2020-08-09 20:18:11 +0200 | [diff] [blame] | 18 | $(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'Callaghan | e900802 | 2014-11-11 13:44:16 +1100 | [diff] [blame] | 19 | |
Kyösti Mälkki | 59d262c | 2015-05-29 10:55:59 +0300 | [diff] [blame] | 20 | # change to the target path because objcopy will use the path name in its |
| 21 | # ELF symbol names. |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 22 | $(call src-to-obj,ramstage,$(obj)/cpu/x86/smm/smm.manual): $(obj)/smm/smm |
Kyösti Mälkki | 59d262c | 2015-05-29 10:55:59 +0300 | [diff] [blame] | 23 | @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 24 | cd $(dir $<); $(OBJCOPY_smm) -I binary $(notdir $<) $(target-objcopy) $(abspath $@) |
Kyösti Mälkki | 59d262c | 2015-05-29 10:55:59 +0300 | [diff] [blame] | 25 | |
Kyösti Mälkki | 9265f89 | 2019-07-07 23:58:34 +0300 | [diff] [blame] | 26 | ifeq ($(CONFIG_HAVE_SMI_HANDLER),y) |
| 27 | ramstage-srcs += $(obj)/cpu/x86/smm/smm.manual |
| 28 | endif |
| 29 | |
Arthur Heymans | 3967cf9 | 2020-08-09 21:33:19 +0200 | [diff] [blame] | 30 | smm-y += save_state.c |
| 31 | |
Vladimir Serbinenko | 44cbe10 | 2015-05-28 21:09:31 +0200 | [diff] [blame] | 32 | ifeq ($(CONFIG_SMM_TSEG),y) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 33 | |
Kyösti Mälkki | 4913d8a | 2019-08-05 12:49:09 +0300 | [diff] [blame] | 34 | ramstage-y += tseg_region.c |
| 35 | romstage-y += tseg_region.c |
| 36 | postcar-y += tseg_region.c |
Kyösti Mälkki | 9970b61 | 2019-08-03 23:18:01 +0300 | [diff] [blame] | 37 | |
Arthur Heymans | b4ba289 | 2021-10-28 16:48:36 +0200 | [diff] [blame^] | 38 | endif |
| 39 | |
| 40 | ifeq ($(CONFIG_PARALLEL_MP),y) |
| 41 | |
Aaron Durbin | 50a3464 | 2013-01-03 17:38:47 -0600 | [diff] [blame] | 42 | smmstub-y += smm_stub.S |
Aaron Durbin | 50a3464 | 2013-01-03 17:38:47 -0600 | [diff] [blame] | 43 | |
Aaron Durbin | 50a3464 | 2013-01-03 17:38:47 -0600 | [diff] [blame] | 44 | smm-y += smm_module_handler.c |
| 45 | |
Patrick Georgi | f430546 | 2015-04-03 10:39:05 +0200 | [diff] [blame] | 46 | ramstage-srcs += $(obj)/cpu/x86/smm/smmstub.manual |
Aaron Durbin | 50a3464 | 2013-01-03 17:38:47 -0600 | [diff] [blame] | 47 | |
| 48 | # SMM Stub Module. The stub is used as a trampoline for relocation and normal |
| 49 | # SMM handling. |
Arthur Heymans | bf1da4b | 2018-12-29 13:09:26 +0100 | [diff] [blame] | 50 | $(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 Durbin | 50a3464 | 2013-01-03 17:38:47 -0600 | [diff] [blame] | 52 | |
| 53 | # Link the SMM stub module with a 0-byte heap. |
Stefan Reinauer | 01327d1 | 2015-07-30 16:28:44 -0700 | [diff] [blame] | 54 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 55 | $(eval $(call rmodule_link,$(obj)/smmstub/smmstub.elf, $(obj)/smmstub/smmstub.o, 0,x86_32)) |
Stefan Reinauer | 01327d1 | 2015-07-30 16:28:44 -0700 | [diff] [blame] | 56 | else |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 57 | $(eval $(call rmodule_link,$(obj)/smmstub/smmstub.elf, $(obj)/smmstub/smmstub.o, 0,x86_64)) |
Stefan Reinauer | 01327d1 | 2015-07-30 16:28:44 -0700 | [diff] [blame] | 58 | endif |
Aaron Durbin | 50a3464 | 2013-01-03 17:38:47 -0600 | [diff] [blame] | 59 | |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 60 | $(obj)/smmstub/smmstub: $(obj)/smmstub/smmstub.elf.rmod |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 61 | $(OBJCOPY_smmstub) -O binary $< $@ |
Aaron Durbin | 50a3464 | 2013-01-03 17:38:47 -0600 | [diff] [blame] | 62 | |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 63 | $(call src-to-obj,ramstage,$(obj)/cpu/x86/smm/smmstub.manual): $(obj)/smmstub/smmstub |
Aaron Durbin | 50a3464 | 2013-01-03 17:38:47 -0600 | [diff] [blame] | 64 | @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 65 | cd $(dir $<); $(OBJCOPY_smmstub) -I binary $(notdir $<) $(target-objcopy) $(abspath $@) |
Aaron Durbin | 50a3464 | 2013-01-03 17:38:47 -0600 | [diff] [blame] | 66 | |
| 67 | # C-based SMM handler. |
| 68 | |
Stefan Reinauer | 87200e2 | 2015-03-15 00:21:17 +0100 | [diff] [blame] | 69 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 70 | $(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.o, $(CONFIG_SMM_MODULE_HEAP_SIZE),x86_32)) |
Stefan Reinauer | 87200e2 | 2015-03-15 00:21:17 +0100 | [diff] [blame] | 71 | else |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 72 | $(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.o, $(CONFIG_SMM_MODULE_HEAP_SIZE),x86_64)) |
Stefan Reinauer | 87200e2 | 2015-03-15 00:21:17 +0100 | [diff] [blame] | 73 | endif |
Aaron Durbin | 50a3464 | 2013-01-03 17:38:47 -0600 | [diff] [blame] | 74 | |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 75 | $(obj)/smm/smm: $(obj)/smm/smm.elf.rmod |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 76 | $(OBJCOPY_smm) -O binary $< $@ |
Aaron Durbin | 50a3464 | 2013-01-03 17:38:47 -0600 | [diff] [blame] | 77 | |
Arthur Heymans | b4ba289 | 2021-10-28 16:48:36 +0200 | [diff] [blame^] | 78 | endif |
| 79 | |
| 80 | ifeq ($(CONFIG_SMM_LEGACY_ASEG),y) |
Aaron Durbin | 50a3464 | 2013-01-03 17:38:47 -0600 | [diff] [blame] | 81 | |
Arthur Heymans | f3d65e4 | 2020-08-09 20:18:11 +0200 | [diff] [blame] | 82 | smm-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 Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 86 | $(NM_smm) -n $(obj)/smm/smm.elf | sort > $(obj)/smm/smm.map |
| 87 | $(OBJCOPY_smm) -O binary $(obj)/smm/smm.elf $@ |
Kyösti Mälkki | e2edf71 | 2015-04-10 11:52:53 +0300 | [diff] [blame] | 88 | |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 89 | smm-y += smmhandler.S |
| 90 | smm-y += smihandler.c |
Stefan Reinauer | 60fc92a | 2009-10-24 03:33:44 +0000 | [diff] [blame] | 91 | |
Arthur Heymans | b4ba289 | 2021-10-28 16:48:36 +0200 | [diff] [blame^] | 92 | endif # CONFIG_SMM_LEGACY_ASEG |