Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 1 | ## |
| 2 | ## This file is part of the coreboot project. |
| 3 | ## |
Stefan Reinauer | b987f7b | 2010-05-30 13:44:32 +0000 | [diff] [blame] | 4 | ## Copyright (C) 2008-2010 coresystems GmbH |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 5 | ## |
| 6 | ## This program is free software; you can redistribute it and/or modify |
| 7 | ## it under the terms of the GNU General Public License as published by |
Stefan Reinauer | b987f7b | 2010-05-30 13:44:32 +0000 | [diff] [blame] | 8 | ## the Free Software Foundation; version 2 of the License. |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 9 | ## |
| 10 | ## This program is distributed in the hope that it will be useful, |
| 11 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | ## GNU General Public License for more details. |
| 14 | ## |
Patrick Georgi | 0588d19 | 2009-08-12 15:00:51 +0000 | [diff] [blame] | 15 | |
Aaron Durbin | a41e030 | 2016-04-30 14:56:20 -0500 | [diff] [blame] | 16 | ramstage-y += smm_module_loader.c |
Aaron Durbin | b4b9eb3 | 2014-02-13 10:26:18 -0600 | [diff] [blame] | 17 | |
Stefan Reinauer | 87200e2 | 2015-03-15 00:21:17 +0100 | [diff] [blame] | 18 | ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 19 | $(eval $(call create_class_compiler,smm,x86_32)) |
| 20 | $(eval $(call create_class_compiler,smmstub,x86_32)) |
Stefan Reinauer | 87200e2 | 2015-03-15 00:21:17 +0100 | [diff] [blame] | 21 | else |
| 22 | $(eval $(call create_class_compiler,smm,x86_64)) |
| 23 | $(eval $(call create_class_compiler,smmstub,x86_64)) |
| 24 | endif |
Edward O'Callaghan | e900802 | 2014-11-11 13:44:16 +1100 | [diff] [blame] | 25 | |
Patrick Georgi | cbe2746 | 2015-03-27 15:32:49 +0100 | [diff] [blame] | 26 | smmstub-generic-ccopts += -D__SMM__ |
| 27 | smm-generic-ccopts += -D__SMM__ |
| 28 | smm-c-deps:=$$(OPTION_TABLE_H) |
| 29 | |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 30 | $(obj)/smm/smm.o: $$(smm-objs) $(COMPILER_RT_smm) |
Patrick Georgi | eec8dfb | 2015-05-07 22:24:41 +0200 | [diff] [blame] | 31 | $(LD_smm) -nostdlib -r -o $@ $(COMPILER_RT_FLAGS_smm) --whole-archive --start-group $(smm-objs) --no-whole-archive $(COMPILER_RT_smm) --end-group |
Edward O'Callaghan | e900802 | 2014-11-11 13:44:16 +1100 | [diff] [blame] | 32 | |
Kyösti Mälkki | 59d262c | 2015-05-29 10:55:59 +0300 | [diff] [blame] | 33 | # change to the target path because objcopy will use the path name in its |
| 34 | # ELF symbol names. |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 35 | $(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] | 36 | @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 37 | cd $(dir $<); $(OBJCOPY_smm) -I binary $(notdir $<) $(target-objcopy) $(abspath $@) |
Kyösti Mälkki | 59d262c | 2015-05-29 10:55:59 +0300 | [diff] [blame] | 38 | |
Vladimir Serbinenko | 44cbe10 | 2015-05-28 21:09:31 +0200 | [diff] [blame] | 39 | ifeq ($(CONFIG_SMM_TSEG),y) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 40 | |
Aaron Durbin | 50a3464 | 2013-01-03 17:38:47 -0600 | [diff] [blame] | 41 | smmstub-y += smm_stub.S |
Aaron Durbin | 50a3464 | 2013-01-03 17:38:47 -0600 | [diff] [blame] | 42 | |
Aaron Durbin | 50a3464 | 2013-01-03 17:38:47 -0600 | [diff] [blame] | 43 | smm-y += smm_module_handler.c |
| 44 | |
Patrick Georgi | f430546 | 2015-04-03 10:39:05 +0200 | [diff] [blame] | 45 | ramstage-srcs += $(obj)/cpu/x86/smm/smm.manual |
| 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. |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 50 | $(obj)/smmstub/smmstub.o: $$(smmstub-objs) |
Patrick Georgi | 5930774 | 2014-05-19 09:23:57 +0200 | [diff] [blame] | 51 | $(CC_smmstub) $(CFLAGS_smmstub) -nostdlib -r -o $@ $^ |
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 | |
Vladimir Serbinenko | 44cbe10 | 2015-05-28 21:09:31 +0200 | [diff] [blame] | 78 | else # CONFIG_SMM_TSEG |
Aaron Durbin | 50a3464 | 2013-01-03 17:38:47 -0600 | [diff] [blame] | 79 | |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 80 | $(obj)/smm/smm: $(obj)/smm/smm.o $(src)/cpu/x86/smm/smm.ld |
| 81 | $(LD_smm) $(LDFLAGS_smm) -o $(obj)/smm/smm.elf -T $(src)/cpu/x86/smm/smm.ld $(obj)/smm/smm.o |
| 82 | $(NM_smm) -n $(obj)/smm/smm.elf | sort > $(obj)/smm/smm.map |
| 83 | $(OBJCOPY_smm) -O binary $(obj)/smm/smm.elf $@ |
Kyösti Mälkki | e2edf71 | 2015-04-10 11:52:53 +0300 | [diff] [blame] | 84 | |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 85 | ifeq ($(CONFIG_HAVE_SMI_HANDLER),y) |
Kyösti Mälkki | 59d262c | 2015-05-29 10:55:59 +0300 | [diff] [blame] | 86 | ramstage-srcs += $(obj)/cpu/x86/smm/smm.manual |
Patrick Georgi | 8463dd9 | 2010-09-30 16:55:02 +0000 | [diff] [blame] | 87 | endif |
Stefan Reinauer | 60fc92a | 2009-10-24 03:33:44 +0000 | [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 | |
Vladimir Serbinenko | 44cbe10 | 2015-05-28 21:09:31 +0200 | [diff] [blame] | 92 | endif # CONFIG_SMM_TSEG |