blob: 08c8c1b039a934ec69a8cade1894946494227e29 [file] [log] [blame]
Martin Roth7687e772023-08-22 16:32:20 -06001## SPDX-License-Identifier: BSD-3-Clause
2
Martin Roth059988d2017-11-11 20:06:19 -07003#*****************************************************************************
4#
Martin Roth059988d2017-11-11 20:06:19 -07005# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are met:
7# * Redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer.
9# * Redistributions in binary form must reproduce the above copyright
10# notice, this list of conditions and the following disclaimer in the
11# documentation and/or other materials provided with the distribution.
12# * Neither the name of Advanced Micro Devices, Inc. nor the names of
13# its contributors may be used to endorse or promote products derived
14# from this software without specific prior written permission.
15#
16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19# DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
20# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26#
27#*****************************************************************************
28
Marshall Dawsond7868432019-11-25 11:47:32 -070029ifeq ($(CONFIG_SOC_AMD_STONEYRIDGE),y)
Martin Roth059988d2017-11-11 20:06:19 -070030
Martin Rothece69f22017-11-16 22:34:26 -070031AGESA_CFLAGS += -march=amdfam10 -fno-strict-aliasing -D__LIBAGESA__
Martin Roth059988d2017-11-11 20:06:19 -070032
Martin Rothece69f22017-11-16 22:34:26 -070033CC_bootblock := $(CC_bootblock) $(BINARY_PI_INC)
34CC_romstage := $(CC_romstage) $(BINARY_PI_INC)
Martin Roth059988d2017-11-11 20:06:19 -070035CC_postcar:= $(CC_postcar) -I$(AGESA_ROOT)/binaryPI
Martin Rothece69f22017-11-16 22:34:26 -070036CC_ramstage := $(CC_ramstage) $(BINARY_PI_INC)
Martin Roth059988d2017-11-11 20:06:19 -070037
38#######################################################################
39
40define create_agesa_cp_template
41# $1 AGESA source file
42
43$(agesa_src_path)/$(notdir $1): $1
44 @printf " AGESA Copying $$(notdir $1) => $$(@D)\n"
45 if [ ! -r $(agesa_src_path)/$(notdir $1) ]; then \
46 cp -f $1 $$(@D); \
47 fi
48
49$(call src-to-obj,libagesa,$1): $(agesa_src_path)/$(notdir $1) $(obj)/config.h $(src)/include/kconfig.h
50 @printf " CC $$(subst $(obj)/,,$$(@))\n"
Julius Werner98eeb962019-12-11 15:47:42 -080051 $(CC_libagesa) -c -MMD $(CFLAGS_libagesa) $(AGESA_CFLAGS) \
52 $(AGESA_INC) \
53 -include $(src)/include/kconfig.h \
54 -include $(src)/include/rules.h \
55 -include $(src)/commonlib/bsd/include/commonlib/bsd/compiler.h \
56 -o $$@ \
Martin Roth059988d2017-11-11 20:06:19 -070057 $(agesa_src_path)/$(notdir $1)
58
59endef
60
Martin Roth744104e2017-11-12 09:59:37 -070061agesa_raw_files += $(wildcard $(AGESA_ROOT)/Lib/*.[cS])
Martin Roth059988d2017-11-11 20:06:19 -070062
63agesa_raw_files += $(wildcard $(AGESA_ROOT)/binaryPI/*.[cS])
64
Arthur Heymans81a4fef2022-11-01 23:33:45 +010065classes-y += libagesa
Martin Roth059988d2017-11-11 20:06:19 -070066
67ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
68$(eval $(call create_class_compiler,libagesa,x86_32))
69else
70$(eval $(call create_class_compiler,libagesa,x86_64))
71endif
72
73agesa_src_files := $(strip $(sort $(foreach file,$(strip $(agesa_raw_files)),$(call strip_quotes,$(file)))))
74agesa_output_path := $(obj)/libagesa
75agesa_src_path := $(agesa_output_path)
76agesa_dirs := $(sort $(abspath $(dir $(call src-to-obj,libagesa,$(agesa_src_files)))))
77
78additional-dirs += $(agesa_src_path) $(agesa_dirs)
79
80$(foreach file,$(strip $(agesa_src_files)),$(eval $(call create_agesa_cp_template,$(file))))
81
82$(agesa_output_path)/libagesa.a: $(call src-to-obj,libagesa,$(agesa_src_files))
83 @printf " AGESA $(subst $(obj)/,,$(@))\n"
84 $(AR_libagesa) rcs $@ $+
85
86bootblock-libs += $(agesa_output_path)/libagesa.a
87romstage-libs += $(agesa_output_path)/libagesa.a
88ramstage-libs += $(agesa_output_path)/libagesa.a
89
90#######################################################################
91
Marshall Dawsonfd6fb282019-11-25 17:53:29 -070092warn_no_agesa:
93 printf "\n\t** WARNING **\n"
94 printf "coreboot has been built with no AGESA support. Successfully "
95 printf "booting this image will be impossible.\n\n"
96
Marshall Dawson19be7b52020-01-02 15:38:59 -070097PHONY+=warn_no_agesa
Marshall Dawsonfd6fb282019-11-25 17:53:29 -070098
Justin TerAvest92261952017-12-22 15:15:02 -070099ifeq ($(CONFIG_AGESA_SPLIT_MEMORY_FILES), y)
Aaron Durbin931ed7f2017-12-22 17:13:17 -0700100
101# convert input elf to rmodule
102AGESA_POST_MEM_INPUT_ELF = $(call strip_quotes,$(CONFIG_AGESA_POST_MEMORY_BINARY_PI_FILE))
Marshall Dawsonfd6fb282019-11-25 17:53:29 -0700103
104# If no post-mem file then also skip pre-mem file
Patrick Georgia1d668e2019-12-12 16:25:28 +0100105ifeq ($(AGESA_POST_MEM_INPUT_ELF),)
Marshall Dawsonfd6fb282019-11-25 17:53:29 -0700106files_added:: warn_no_agesa
107else
Aaron Durbin931ed7f2017-12-22 17:13:17 -0700108AGESA_POST_MEM_ELF = $(objcbfs)/$(patsubst %.elf,%.debug,$(notdir $(AGESA_POST_MEM_INPUT_ELF)))
109AGESA_POST_MEM_ELF_RMOD = $(AGESA_POST_MEM_ELF).rmod
110
111$(AGESA_POST_MEM_ELF): $(AGESA_POST_MEM_INPUT_ELF)
112 cp $< $@
113
114$(AGESA_POST_MEM_ELF_RMOD): $(AGESA_POST_MEM_ELF)
115
Arthur Heymans81a4fef2022-11-01 23:33:45 +0100116cbfs-files-y += $(CONFIG_AGESA_PRE_MEMORY_CBFS_NAME)
Justin TerAvest92261952017-12-22 15:15:02 -0700117$(CONFIG_AGESA_PRE_MEMORY_CBFS_NAME)-file := $(CONFIG_AGESA_PRE_MEMORY_BINARY_PI_FILE)
118$(CONFIG_AGESA_PRE_MEMORY_CBFS_NAME)-type := stage
119$(CONFIG_AGESA_PRE_MEMORY_CBFS_NAME)-options := --xip
120# 4KiB alignment to handle any interior alignment. Current AGESA only has
121# 64 byte alignment.
122$(CONFIG_AGESA_PRE_MEMORY_CBFS_NAME)-align := 4096
123
Arthur Heymans81a4fef2022-11-01 23:33:45 +0100124cbfs-files-y += $(CONFIG_AGESA_POST_MEMORY_CBFS_NAME)
Aaron Durbin931ed7f2017-12-22 17:13:17 -0700125$(CONFIG_AGESA_POST_MEMORY_CBFS_NAME)-file := $(AGESA_POST_MEM_ELF_RMOD)
Justin TerAvest92261952017-12-22 15:15:02 -0700126$(CONFIG_AGESA_POST_MEMORY_CBFS_NAME)-type := stage
Aaron Durbin931ed7f2017-12-22 17:13:17 -0700127$(CONFIG_AGESA_POST_MEMORY_CBFS_NAME)-compression := $(CBFS_COMPRESS_FLAG)
Marshall Dawsonfd6fb282019-11-25 17:53:29 -0700128
129endif # AGESA_POST_MEM_INPUT_ELF == ""
130
131else # CONFIG_AGESA_SPLIT_MEMORY_FILES
132
133AGESA_BINARYPI_INPUT_FILE = $(call strip_quotes,$(CONFIG_AGESA_BINARY_PI_FILE))
134ifeq ($(AGESA_BINARYPI_INPUT_FILE),)
135files_added:: warn_no_agesa
Justin TerAvest92261952017-12-22 15:15:02 -0700136else
137
Arthur Heymans81a4fef2022-11-01 23:33:45 +0100138cbfs-files-y += $(CONFIG_AGESA_CBFS_NAME)
Marshall Dawsonfd6fb282019-11-25 17:53:29 -0700139$(CONFIG_AGESA_CBFS_NAME)-file := $(AGESA_BINARYPI_INPUT_FILE)
Justin TerAvest92261952017-12-22 15:15:02 -0700140
Aaron Durbin02b43aa2017-12-12 14:56:41 -0700141ifeq ($(CONFIG_AGESA_BINARY_PI_AS_STAGE),y)
142$(CONFIG_AGESA_CBFS_NAME)-type := stage
143$(CONFIG_AGESA_CBFS_NAME)-options := --xip
144# 4KiB alignment to handle any interior alignment. Current AGESA only has
145# 64 byte alignment.
146$(CONFIG_AGESA_CBFS_NAME)-align := 4096
147else
Martin Roth059988d2017-11-11 20:06:19 -0700148$(CONFIG_AGESA_CBFS_NAME)-type := raw
149$(CONFIG_AGESA_CBFS_NAME)-position := $(CONFIG_AGESA_BINARY_PI_LOCATION)
Furquan Shaikh6c8ba9b2020-11-20 22:26:38 -0800150regions-for-file-$(CONFIG_AGESA_CBFS_NAME) = COREBOOT
Justin TerAvest92261952017-12-22 15:15:02 -0700151endif # CONFIG_AGESA_BINARY_PI_AS_STAGE
152
Marshall Dawsonfd6fb282019-11-25 17:53:29 -0700153endif # AGESA_BINARYPI_INPUT_FILE == ""
Justin TerAvest92261952017-12-22 15:15:02 -0700154endif # CONFIG_AGESA_SPLIT_MEMORY_FILES
Martin Roth059988d2017-11-11 20:06:19 -0700155
156endif