blob: 71898a3c543499d1cce7f29e3164a842f8c1c8f9 [file] [log] [blame]
Martin Roth059988d2017-11-11 20:06:19 -07001#*****************************************************************************
2#
Martin Roth059988d2017-11-11 20:06:19 -07003# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions are met:
5# * Redistributions of source code must retain the above copyright
6# notice, this list of conditions and the following disclaimer.
7# * Redistributions in binary form must reproduce the above copyright
8# notice, this list of conditions and the following disclaimer in the
9# documentation and/or other materials provided with the distribution.
10# * Neither the name of Advanced Micro Devices, Inc. nor the names of
11# its contributors may be used to endorse or promote products derived
12# from this software without specific prior written permission.
13#
14# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17# DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
18# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24#
25#*****************************************************************************
26
Marshall Dawsond7868432019-11-25 11:47:32 -070027ifeq ($(CONFIG_SOC_AMD_STONEYRIDGE),y)
Martin Roth059988d2017-11-11 20:06:19 -070028# AGESA V5 Files
29
30AGESA_ROOT = $(call strip_quotes,$(CONFIG_AGESA_BINARY_PI_VENDORCODE_PATH))
31
Martin Rothece69f22017-11-16 22:34:26 -070032BINARY_PI_INC = -I$(AGESA_ROOT)
33BINARY_PI_INC += -I$(AGESA_ROOT)/binaryPI
34BINARY_PI_INC += -I$(AGESA_ROOT)/Include
35BINARY_PI_INC += -I$(AGESA_ROOT)/Lib
36BINARY_PI_INC += -I$(AGESA_ROOT)/Proc
37BINARY_PI_INC += -I$(AGESA_ROOT)/Proc/Common
38BINARY_PI_INC += -I$(AGESA_ROOT)/Proc/CPU
39BINARY_PI_INC += -I$(AGESA_ROOT)/Proc/CPU/Family
40BINARY_PI_INC += -I$(AGESA_ROOT)/Proc/Fch
41BINARY_PI_INC += -I$(AGESA_ROOT)/Proc/Fch/Common
Martin Rothece69f22017-11-16 22:34:26 -070042
Martin Roth24139182017-11-16 16:00:53 -070043AGESA_INC = -I$(obj)
Martin Rothece69f22017-11-16 22:34:26 -070044AGESA_INC += $(BINARY_PI_INC)
Martin Roth059988d2017-11-11 20:06:19 -070045
46AGESA_INC += -I$(src)/soc/amd/stoneyridge/include
Aaron Durbin49ec3f02017-12-12 10:01:06 -070047AGESA_INC += -I$(src)/soc/amd/common/block/include
Martin Roth059988d2017-11-11 20:06:19 -070048
49AGESA_INC += -I$(src)/arch/x86/include
50AGESA_INC += -I$(src)/include
51AGESA_INC += -I$(src)/commonlib/include
52AGESA_INC += -I$(VBOOT_SOURCE)/firmware/include
53
Martin Rothece69f22017-11-16 22:34:26 -070054AGESA_CFLAGS += -march=amdfam10 -fno-strict-aliasing -D__LIBAGESA__
Martin Roth059988d2017-11-11 20:06:19 -070055
Martin Rothece69f22017-11-16 22:34:26 -070056CC_bootblock := $(CC_bootblock) $(BINARY_PI_INC)
57CC_romstage := $(CC_romstage) $(BINARY_PI_INC)
Martin Roth059988d2017-11-11 20:06:19 -070058CC_postcar:= $(CC_postcar) -I$(AGESA_ROOT)/binaryPI
Martin Rothece69f22017-11-16 22:34:26 -070059CC_ramstage := $(CC_ramstage) $(BINARY_PI_INC)
Martin Roth059988d2017-11-11 20:06:19 -070060
61#######################################################################
62
63define create_agesa_cp_template
64# $1 AGESA source file
65
66$(agesa_src_path)/$(notdir $1): $1
67 @printf " AGESA Copying $$(notdir $1) => $$(@D)\n"
68 if [ ! -r $(agesa_src_path)/$(notdir $1) ]; then \
69 cp -f $1 $$(@D); \
70 fi
71
72$(call src-to-obj,libagesa,$1): $(agesa_src_path)/$(notdir $1) $(obj)/config.h $(src)/include/kconfig.h
73 @printf " CC $$(subst $(obj)/,,$$(@))\n"
Julius Werner98eeb962019-12-11 15:47:42 -080074 $(CC_libagesa) -c -MMD $(CFLAGS_libagesa) $(AGESA_CFLAGS) \
75 $(AGESA_INC) \
76 -include $(src)/include/kconfig.h \
77 -include $(src)/include/rules.h \
78 -include $(src)/commonlib/bsd/include/commonlib/bsd/compiler.h \
79 -o $$@ \
Martin Roth059988d2017-11-11 20:06:19 -070080 $(agesa_src_path)/$(notdir $1)
81
82endef
83
Martin Roth744104e2017-11-12 09:59:37 -070084agesa_raw_files += $(wildcard $(AGESA_ROOT)/Lib/*.[cS])
Martin Roth059988d2017-11-11 20:06:19 -070085
86agesa_raw_files += $(wildcard $(AGESA_ROOT)/binaryPI/*.[cS])
87
Martin Roth059988d2017-11-11 20:06:19 -070088classes-$(CONFIG_CPU_AMD_AGESA_BINARY_PI) += libagesa
89
90ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
91$(eval $(call create_class_compiler,libagesa,x86_32))
92else
93$(eval $(call create_class_compiler,libagesa,x86_64))
94endif
95
96agesa_src_files := $(strip $(sort $(foreach file,$(strip $(agesa_raw_files)),$(call strip_quotes,$(file)))))
97agesa_output_path := $(obj)/libagesa
98agesa_src_path := $(agesa_output_path)
99agesa_dirs := $(sort $(abspath $(dir $(call src-to-obj,libagesa,$(agesa_src_files)))))
100
101additional-dirs += $(agesa_src_path) $(agesa_dirs)
102
103$(foreach file,$(strip $(agesa_src_files)),$(eval $(call create_agesa_cp_template,$(file))))
104
105$(agesa_output_path)/libagesa.a: $(call src-to-obj,libagesa,$(agesa_src_files))
106 @printf " AGESA $(subst $(obj)/,,$(@))\n"
107 $(AR_libagesa) rcs $@ $+
108
109bootblock-libs += $(agesa_output_path)/libagesa.a
110romstage-libs += $(agesa_output_path)/libagesa.a
111ramstage-libs += $(agesa_output_path)/libagesa.a
112
113#######################################################################
114
Marshall Dawsonfd6fb282019-11-25 17:53:29 -0700115warn_no_agesa:
116 printf "\n\t** WARNING **\n"
117 printf "coreboot has been built with no AGESA support. Successfully "
118 printf "booting this image will be impossible.\n\n"
119
Marshall Dawson19be7b52020-01-02 15:38:59 -0700120PHONY+=warn_no_agesa
Marshall Dawsonfd6fb282019-11-25 17:53:29 -0700121
Justin TerAvest92261952017-12-22 15:15:02 -0700122ifeq ($(CONFIG_AGESA_SPLIT_MEMORY_FILES), y)
Aaron Durbin931ed7f2017-12-22 17:13:17 -0700123
124# convert input elf to rmodule
125AGESA_POST_MEM_INPUT_ELF = $(call strip_quotes,$(CONFIG_AGESA_POST_MEMORY_BINARY_PI_FILE))
Marshall Dawsonfd6fb282019-11-25 17:53:29 -0700126
127# If no post-mem file then also skip pre-mem file
Patrick Georgia1d668e2019-12-12 16:25:28 +0100128ifeq ($(AGESA_POST_MEM_INPUT_ELF),)
Marshall Dawsonfd6fb282019-11-25 17:53:29 -0700129files_added:: warn_no_agesa
130else
Aaron Durbin931ed7f2017-12-22 17:13:17 -0700131AGESA_POST_MEM_ELF = $(objcbfs)/$(patsubst %.elf,%.debug,$(notdir $(AGESA_POST_MEM_INPUT_ELF)))
132AGESA_POST_MEM_ELF_RMOD = $(AGESA_POST_MEM_ELF).rmod
133
134$(AGESA_POST_MEM_ELF): $(AGESA_POST_MEM_INPUT_ELF)
135 cp $< $@
136
137$(AGESA_POST_MEM_ELF_RMOD): $(AGESA_POST_MEM_ELF)
138
Justin TerAvest92261952017-12-22 15:15:02 -0700139cbfs-files-$(CONFIG_CPU_AMD_AGESA_BINARY_PI) += $(CONFIG_AGESA_PRE_MEMORY_CBFS_NAME)
140$(CONFIG_AGESA_PRE_MEMORY_CBFS_NAME)-file := $(CONFIG_AGESA_PRE_MEMORY_BINARY_PI_FILE)
141$(CONFIG_AGESA_PRE_MEMORY_CBFS_NAME)-type := stage
142$(CONFIG_AGESA_PRE_MEMORY_CBFS_NAME)-options := --xip
143# 4KiB alignment to handle any interior alignment. Current AGESA only has
144# 64 byte alignment.
145$(CONFIG_AGESA_PRE_MEMORY_CBFS_NAME)-align := 4096
146
147cbfs-files-$(CONFIG_CPU_AMD_AGESA_BINARY_PI) += $(CONFIG_AGESA_POST_MEMORY_CBFS_NAME)
Aaron Durbin931ed7f2017-12-22 17:13:17 -0700148$(CONFIG_AGESA_POST_MEMORY_CBFS_NAME)-file := $(AGESA_POST_MEM_ELF_RMOD)
Justin TerAvest92261952017-12-22 15:15:02 -0700149$(CONFIG_AGESA_POST_MEMORY_CBFS_NAME)-type := stage
Aaron Durbin931ed7f2017-12-22 17:13:17 -0700150$(CONFIG_AGESA_POST_MEMORY_CBFS_NAME)-compression := $(CBFS_COMPRESS_FLAG)
Marshall Dawsonfd6fb282019-11-25 17:53:29 -0700151
152endif # AGESA_POST_MEM_INPUT_ELF == ""
153
154else # CONFIG_AGESA_SPLIT_MEMORY_FILES
155
156AGESA_BINARYPI_INPUT_FILE = $(call strip_quotes,$(CONFIG_AGESA_BINARY_PI_FILE))
157ifeq ($(AGESA_BINARYPI_INPUT_FILE),)
158files_added:: warn_no_agesa
Justin TerAvest92261952017-12-22 15:15:02 -0700159else
160
Martin Roth059988d2017-11-11 20:06:19 -0700161cbfs-files-$(CONFIG_CPU_AMD_AGESA_BINARY_PI) += $(CONFIG_AGESA_CBFS_NAME)
Marshall Dawsonfd6fb282019-11-25 17:53:29 -0700162$(CONFIG_AGESA_CBFS_NAME)-file := $(AGESA_BINARYPI_INPUT_FILE)
Justin TerAvest92261952017-12-22 15:15:02 -0700163
Aaron Durbin02b43aa2017-12-12 14:56:41 -0700164ifeq ($(CONFIG_AGESA_BINARY_PI_AS_STAGE),y)
165$(CONFIG_AGESA_CBFS_NAME)-type := stage
166$(CONFIG_AGESA_CBFS_NAME)-options := --xip
167# 4KiB alignment to handle any interior alignment. Current AGESA only has
168# 64 byte alignment.
169$(CONFIG_AGESA_CBFS_NAME)-align := 4096
170else
Martin Roth059988d2017-11-11 20:06:19 -0700171$(CONFIG_AGESA_CBFS_NAME)-type := raw
172$(CONFIG_AGESA_CBFS_NAME)-position := $(CONFIG_AGESA_BINARY_PI_LOCATION)
Furquan Shaikh6c8ba9b2020-11-20 22:26:38 -0800173regions-for-file-$(CONFIG_AGESA_CBFS_NAME) = COREBOOT
Justin TerAvest92261952017-12-22 15:15:02 -0700174endif # CONFIG_AGESA_BINARY_PI_AS_STAGE
175
Marshall Dawsonfd6fb282019-11-25 17:53:29 -0700176endif # AGESA_BINARYPI_INPUT_FILE == ""
Justin TerAvest92261952017-12-22 15:15:02 -0700177endif # CONFIG_AGESA_SPLIT_MEMORY_FILES
Martin Roth059988d2017-11-11 20:06:19 -0700178
179endif