blob: a5e644e78cb6a600eb42dc776e7404513af5c2ad [file] [log] [blame]
Martin Roth059988d2017-11-11 20:06:19 -07001#*****************************************************************************
2#
3# Copyright (c) 2012, 2016 Advanced Micro Devices, Inc.
4# 2013 - 2014, Sage Electronic Engineering, LLC
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are met:
9# * Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# * Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14# * Neither the name of Advanced Micro Devices, Inc. nor the names of
15# its contributors may be used to endorse or promote products derived
16# from this software without specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21# DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
22# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28#
29#*****************************************************************************
30
31ifeq ($(CONFIG_SOC_AMD_STONEYRIDGE_FP4)$(CONFIG_SOC_AMD_STONEYRIDGE_FT4),y)
32# AGESA V5 Files
33
34AGESA_ROOT = $(call strip_quotes,$(CONFIG_AGESA_BINARY_PI_VENDORCODE_PATH))
35
Martin Rothece69f22017-11-16 22:34:26 -070036BINARY_PI_INC = -I$(AGESA_ROOT)
37BINARY_PI_INC += -I$(AGESA_ROOT)/binaryPI
38BINARY_PI_INC += -I$(AGESA_ROOT)/Include
39BINARY_PI_INC += -I$(AGESA_ROOT)/Lib
40BINARY_PI_INC += -I$(AGESA_ROOT)/Proc
41BINARY_PI_INC += -I$(AGESA_ROOT)/Proc/Common
42BINARY_PI_INC += -I$(AGESA_ROOT)/Proc/CPU
43BINARY_PI_INC += -I$(AGESA_ROOT)/Proc/CPU/Family
44BINARY_PI_INC += -I$(AGESA_ROOT)/Proc/Fch
45BINARY_PI_INC += -I$(AGESA_ROOT)/Proc/Fch/Common
46BINARY_PI_INC += -I$(AGESA_ROOT)/Proc/Psp/PspBaseLib
47
48
Martin Roth24139182017-11-16 16:00:53 -070049AGESA_INC = -I$(obj)
Martin Rothece69f22017-11-16 22:34:26 -070050AGESA_INC += $(BINARY_PI_INC)
Martin Roth059988d2017-11-11 20:06:19 -070051
52AGESA_INC += -I$(src)/soc/amd/stoneyridge/include
Aaron Durbin49ec3f02017-12-12 10:01:06 -070053AGESA_INC += -I$(src)/soc/amd/common/block/include
Martin Roth059988d2017-11-11 20:06:19 -070054
55AGESA_INC += -I$(src)/arch/x86/include
56AGESA_INC += -I$(src)/include
57AGESA_INC += -I$(src)/commonlib/include
58AGESA_INC += -I$(VBOOT_SOURCE)/firmware/include
59
Martin Rothece69f22017-11-16 22:34:26 -070060AGESA_CFLAGS += -march=amdfam10 -fno-strict-aliasing -D__LIBAGESA__
Martin Roth059988d2017-11-11 20:06:19 -070061
Martin Rothece69f22017-11-16 22:34:26 -070062CC_bootblock := $(CC_bootblock) $(BINARY_PI_INC)
63CC_romstage := $(CC_romstage) $(BINARY_PI_INC)
Martin Roth059988d2017-11-11 20:06:19 -070064CC_postcar:= $(CC_postcar) -I$(AGESA_ROOT)/binaryPI
Martin Rothece69f22017-11-16 22:34:26 -070065CC_ramstage := $(CC_ramstage) $(BINARY_PI_INC)
Martin Roth059988d2017-11-11 20:06:19 -070066
67#######################################################################
68
69define create_agesa_cp_template
70# $1 AGESA source file
71
72$(agesa_src_path)/$(notdir $1): $1
73 @printf " AGESA Copying $$(notdir $1) => $$(@D)\n"
74 if [ ! -r $(agesa_src_path)/$(notdir $1) ]; then \
75 cp -f $1 $$(@D); \
76 fi
77
78$(call src-to-obj,libagesa,$1): $(agesa_src_path)/$(notdir $1) $(obj)/config.h $(src)/include/kconfig.h
79 @printf " CC $$(subst $(obj)/,,$$(@))\n"
Martin Rothece69f22017-11-16 22:34:26 -070080 $(CC_libagesa) -c -MMD $(CFLAGS_libagesa) $(AGESA_CFLAGS) \
81 $(AGESA_INC) \
82 -include $(src)/include/rules.h \
83 -include $(src)/include/kconfig.h \
84 -o $$@ \
Martin Roth059988d2017-11-11 20:06:19 -070085 $(agesa_src_path)/$(notdir $1)
86
87endef
88
Martin Roth744104e2017-11-12 09:59:37 -070089agesa_raw_files += $(wildcard $(AGESA_ROOT)/Lib/*.[cS])
Martin Roth059988d2017-11-11 20:06:19 -070090
91agesa_raw_files += $(wildcard $(AGESA_ROOT)/binaryPI/*.[cS])
92
93agesa_raw_files += $(wildcard $(AGESA_ROOT)/Proc/Fch/Common/*.[cS])
94agesa_raw_files += $(wildcard $(AGESA_ROOT)/Proc/Psp/PspBaseLib/*.[cS])
95ifeq ($(CONFIG_STONEYRIDGE_IMC_FWM),y)
Martin Roth744104e2017-11-12 09:59:37 -070096agesa_raw_files += $(wildcard $(AGESA_ROOT)/Lib/imc/*.c)
Martin Roth059988d2017-11-11 20:06:19 -070097endif
98
99classes-$(CONFIG_CPU_AMD_AGESA_BINARY_PI) += libagesa
100
101ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
102$(eval $(call create_class_compiler,libagesa,x86_32))
103else
104$(eval $(call create_class_compiler,libagesa,x86_64))
105endif
106
107agesa_src_files := $(strip $(sort $(foreach file,$(strip $(agesa_raw_files)),$(call strip_quotes,$(file)))))
108agesa_output_path := $(obj)/libagesa
109agesa_src_path := $(agesa_output_path)
110agesa_dirs := $(sort $(abspath $(dir $(call src-to-obj,libagesa,$(agesa_src_files)))))
111
112additional-dirs += $(agesa_src_path) $(agesa_dirs)
113
114$(foreach file,$(strip $(agesa_src_files)),$(eval $(call create_agesa_cp_template,$(file))))
115
116$(agesa_output_path)/libagesa.a: $(call src-to-obj,libagesa,$(agesa_src_files))
117 @printf " AGESA $(subst $(obj)/,,$(@))\n"
118 $(AR_libagesa) rcs $@ $+
119
120bootblock-libs += $(agesa_output_path)/libagesa.a
121romstage-libs += $(agesa_output_path)/libagesa.a
122ramstage-libs += $(agesa_output_path)/libagesa.a
123
124#######################################################################
125
126cbfs-files-$(CONFIG_CPU_AMD_AGESA_BINARY_PI) += $(CONFIG_AGESA_CBFS_NAME)
127$(CONFIG_AGESA_CBFS_NAME)-file := $(CONFIG_AGESA_BINARY_PI_FILE)
128$(CONFIG_AGESA_CBFS_NAME)-type := raw
129$(CONFIG_AGESA_CBFS_NAME)-position := $(CONFIG_AGESA_BINARY_PI_LOCATION)
130
131endif