blob: 32f5ea713d1788c4e2e5001aa28face733ca1567 [file] [log] [blame]
Patrick Georgi0588d192009-08-12 15:00:51 +00001##
2## This file is part of the coreboot project.
3##
Stefan Reinauerb987f7b2010-05-30 13:44:32 +00004## Copyright (C) 2008-2010 coresystems GmbH
Patrick Georgi0588d192009-08-12 15:00:51 +00005##
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 Reinauerb987f7b2010-05-30 13:44:32 +00008## the Free Software Foundation; version 2 of the License.
Patrick Georgi0588d192009-08-12 15:00:51 +00009##
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 Georgi0588d192009-08-12 15:00:51 +000015
Aaron Durbina41e0302016-04-30 14:56:20 -050016ramstage-y += smm_module_loader.c
Aaron Durbinb4b9eb32014-02-13 10:26:18 -060017
Stefan Reinauer87200e22015-03-15 00:21:17 +010018ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070019$(eval $(call create_class_compiler,smm,x86_32))
20$(eval $(call create_class_compiler,smmstub,x86_32))
Stefan Reinauer87200e22015-03-15 00:21:17 +010021else
22$(eval $(call create_class_compiler,smm,x86_64))
23$(eval $(call create_class_compiler,smmstub,x86_64))
24endif
Edward O'Callaghane9008022014-11-11 13:44:16 +110025
Patrick Georgicbe27462015-03-27 15:32:49 +010026smmstub-generic-ccopts += -D__SMM__
27smm-generic-ccopts += -D__SMM__
28smm-c-deps:=$$(OPTION_TABLE_H)
29
Nico Huber98fc4262016-01-23 01:24:33 +010030$(obj)/smm/smm.o: $$(smm-objs) $(COMPILER_RT_smm)
Patrick Georgieec8dfb2015-05-07 22:24:41 +020031 $(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'Callaghane9008022014-11-11 13:44:16 +110032
Kyösti Mälkki59d262c2015-05-29 10:55:59 +030033# change to the target path because objcopy will use the path name in its
34# ELF symbol names.
Nico Huber98fc4262016-01-23 01:24:33 +010035$(call src-to-obj,ramstage,$(obj)/cpu/x86/smm/smm.manual): $(obj)/smm/smm
Kyösti Mälkki59d262c2015-05-29 10:55:59 +030036 @printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
Nico Huber98fc4262016-01-23 01:24:33 +010037 cd $(dir $<); $(OBJCOPY_smm) -I binary $(notdir $<) $(target-objcopy) $(abspath $@)
Kyösti Mälkki59d262c2015-05-29 10:55:59 +030038
Vladimir Serbinenko44cbe102015-05-28 21:09:31 +020039ifeq ($(CONFIG_SMM_TSEG),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070040
Aaron Durbin50a34642013-01-03 17:38:47 -060041smmstub-y += smm_stub.S
Aaron Durbin50a34642013-01-03 17:38:47 -060042
Aaron Durbin50a34642013-01-03 17:38:47 -060043smm-y += smm_module_handler.c
44
Patrick Georgif4305462015-04-03 10:39:05 +020045ramstage-srcs += $(obj)/cpu/x86/smm/smm.manual
46ramstage-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.
Nico Huber98fc4262016-01-23 01:24:33 +010050$(obj)/smmstub/smmstub.o: $$(smmstub-objs)
Patrick Georgi59307742014-05-19 09:23:57 +020051 $(CC_smmstub) $(CFLAGS_smmstub) -nostdlib -r -o $@ $^
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
Vladimir Serbinenko44cbe102015-05-28 21:09:31 +020078else # CONFIG_SMM_TSEG
Aaron Durbin50a34642013-01-03 17:38:47 -060079
Nico Huber98fc4262016-01-23 01:24:33 +010080$(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älkkie2edf712015-04-10 11:52:53 +030084
Patrick Georgi8463dd92010-09-30 16:55:02 +000085ifeq ($(CONFIG_HAVE_SMI_HANDLER),y)
Kyösti Mälkki59d262c2015-05-29 10:55:59 +030086ramstage-srcs += $(obj)/cpu/x86/smm/smm.manual
Patrick Georgi8463dd92010-09-30 16:55:02 +000087endif
Stefan Reinauer60fc92a2009-10-24 03:33:44 +000088
Patrick Georgi8463dd92010-09-30 16:55:02 +000089smm-y += smmhandler.S
90smm-y += smihandler.c
Stefan Reinauer60fc92a2009-10-24 03:33:44 +000091
Vladimir Serbinenko44cbe102015-05-28 21:09:31 +020092endif # CONFIG_SMM_TSEG