blob: 8f27d64f20f788165bb136d08e791adab01583ce [file] [log] [blame]
Stefan Reinauer55feadd2015-06-10 16:15:36 -07001#*****************************************************************************
2#
Marc Jones21e5dd82016-09-20 20:32:47 -06003# Copyright (c) 2012, 2016 Advanced Micro Devices, Inc.
Stefan Reinauer55feadd2015-06-10 16:15:36 -07004# 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
Martin Roth059988d2017-11-11 20:06:19 -070031subdirs-y += 00670F00
32
33ifeq ($(CONFIG_CPU_AMD_PI_00630F01)$(CONFIG_CPU_AMD_PI_00730F01)$(CONFIG_CPU_AMD_PI_00660F01),y)
Stefan Reinauer55feadd2015-06-10 16:15:36 -070034# AGESA V5 Files
Marc Jones21cde8b2017-05-07 16:47:36 -060035
Marc Jones0b11bd02015-07-19 15:20:17 -060036AGESA_ROOT = $(call strip_quotes,$(CONFIG_AGESA_BINARY_PI_VENDORCODE_PATH))
Stefan Reinauer55feadd2015-06-10 16:15:36 -070037
Stefan Reinauerf652f822017-06-24 21:57:30 +020038AGESA_INC = -I$(obj) -I$(src)/vendorcode/amd/include
Stefan Reinauer55feadd2015-06-10 16:15:36 -070039
40AGESA_INC += -I$(src)/mainboard/$(MAINBOARDDIR)
41AGESA_INC += -I$(AGESA_ROOT)/binaryPI
42AGESA_INC += -I$(AGESA_ROOT)
43AGESA_INC += -I$(AGESA_ROOT)/Include
44AGESA_INC += -I$(src)/vendorcode/amd/pi
45AGESA_INC += -I$(src)/vendorcode/amd/pi/Lib
46
47AGESA_INC += -I$(AGESA_ROOT)/Proc
48AGESA_INC += -I$(AGESA_ROOT)/Proc/Common
49AGESA_INC += -I$(AGESA_ROOT)/Proc/CPU
50AGESA_INC += -I$(AGESA_ROOT)/Proc/CPU/Family
51AGESA_INC += -I$(AGESA_ROOT)/Proc/CPU/Feature
52AGESA_INC += -I$(AGESA_ROOT)/Proc/Fch
53AGESA_INC += -I$(AGESA_ROOT)/Proc/Fch/Common
Martin Roth059988d2017-11-11 20:06:19 -070054
Stefan Reinauer55feadd2015-06-10 16:15:36 -070055ifeq ($(CONFIG_CPU_AMD_PI_00660F01),y)
56AGESA_INC += -I$(AGESA_ROOT)/Proc/Fch/Kern
57AGESA_INC += -I$(AGESA_ROOT)/Proc/Psp/PspBaseLib
58endif
59ifeq ($(CONFIG_CPU_AMD_PI_00630F01),y)
60AGESA_INC += -I$(AGESA_ROOT)/Proc/IDS
61endif
62
Marc Jones1587dc82017-05-15 18:55:11 -060063AGESA_INC += -I$(src)/northbridge/amd/pi
Stefan Reinauer55feadd2015-06-10 16:15:36 -070064AGESA_INC += -I$(src)/southbridge/amd/pi/hudson
65
66AGESA_INC += -I$(src)/arch/x86/include
67AGESA_INC += -I$(src)/include
Aaron Durbindc9f5cd2015-09-08 13:34:43 -050068AGESA_INC += -I$(src)/commonlib/include
Julius Werner98eeb962019-12-11 15:47:42 -080069AGESA_INC += -I$(src)/commonlib/bsd/include
Paul Kocialkowski46114512016-07-24 12:10:38 +020070AGESA_INC += -I$(VBOOT_SOURCE)/firmware/include
Stefan Reinauer55feadd2015-06-10 16:15:36 -070071
Krystian Hebel0df1cccc2019-11-19 17:44:32 +010072AGESA_CFLAGS += -march=amdfam10 -mno-3dnow
Martin Roth5b2954e2017-06-29 21:42:02 -060073AGESA_CFLAGS += -fno-strict-aliasing -D__LIBAGESA__
Stefan Reinauer55feadd2015-06-10 16:15:36 -070074CFLAGS_x86_32 += $(AGESA_CFLAGS)
Stefan Reinauerd91ddc82015-07-30 11:17:40 -070075CFLAGS_x86_64 += $(AGESA_CFLAGS)
Stefan Reinauer55feadd2015-06-10 16:15:36 -070076
77export AGESA_ROOT := $(AGESA_ROOT)
78export AGESA_INC := $(AGESA_INC)
79export AGESA_CFLAGS := $(AGESA_CFLAGS)
80
81CC_bootblock := $(CC_bootblock) $(AGESA_INC) $(AGESA_CFLAGS)
82CC_romstage := $(CC_romstage) $(AGESA_INC) $(AGESA_CFLAGS)
Kyösti Mälkki63fac812017-09-02 16:41:43 +030083CC_postcar:= $(CC_postcar) -I$(AGESA_ROOT)/binaryPI
Stefan Reinauer55feadd2015-06-10 16:15:36 -070084CC_ramstage := $(CC_ramstage) $(AGESA_INC) $(AGESA_CFLAGS)
Kyösti Mälkki63fac812017-09-02 16:41:43 +030085
Stefan Reinauer55feadd2015-06-10 16:15:36 -070086CC_x86_32 := $(CC_x86_32) $(AGESA_INC) $(AGESA_CFLAGS)
Stefan Reinauerd91ddc82015-07-30 11:17:40 -070087CC_x86_64 := $(CC_x86_64) $(AGESA_INC) $(AGESA_CFLAGS)
Stefan Reinauer55feadd2015-06-10 16:15:36 -070088
89#######################################################################
90
91define create_agesa_cp_template
Stefan Reinauer55feadd2015-06-10 16:15:36 -070092# $1 AGESA source file
Nico Huber81b09f42016-01-23 00:50:00 +010093
94$(agesa_src_path)/$(notdir $1): $1
95 @printf " AGESA Copying $$(notdir $1) => $$(@D)\n"
96 if [ ! -r $(agesa_src_path)/$(notdir $1) ]; then \
97 cp -f $1 $$(@D); \
Stefan Reinauer55feadd2015-06-10 16:15:36 -070098 fi
99
Nico Huber81b09f42016-01-23 00:50:00 +0100100$(call src-to-obj,libagesa,$1): $(agesa_src_path)/$(notdir $1) $(obj)/config.h $(src)/include/kconfig.h
101 @printf " CC $$(subst $(obj)/,,$$(@))\n"
Julius Werner98eeb962019-12-11 15:47:42 -0800102 $(CC_libagesa) -c -MMD $(CFLAGS_libagesa) $(AGESA_CFLAGS) \
103 $(AGESA_INC) \
104 -include $(src)/include/kconfig.h \
105 -include $(src)/include/rules.h \
106 -include $(src)/commonlib/bsd/include/commonlib/bsd/compiler.h \
107 -o $$@ \
Nico Huber81b09f42016-01-23 00:50:00 +0100108 $(agesa_src_path)/$(notdir $1)
Stefan Reinauer55feadd2015-06-10 16:15:36 -0700109
110endef
111
112agesa_raw_files += $(wildcard $(src)/vendorcode/amd/pi/Lib/*.[cS])
Kyösti Mälkki903ce252016-11-25 11:21:02 +0200113
Stefan Reinauer55feadd2015-06-10 16:15:36 -0700114ifeq ($(CONFIG_CPU_AMD_PI_00660F01),y)
115agesa_raw_files += $(wildcard $(AGESA_ROOT)/Proc/Fch/Kern/KernImc/*.[cS])
116agesa_raw_files += $(wildcard $(AGESA_ROOT)/Proc/Fch/Common/*.[cS])
117agesa_raw_files += $(wildcard $(AGESA_ROOT)/Proc/Psp/PspBaseLib/*.[cS])
118endif
Martin Roth059988d2017-11-11 20:06:19 -0700119ifeq ($(CONFIG_HUDSON_IMC_FWM),y)
WANG Siyuan3f95f1d2015-06-23 22:14:33 +0800120agesa_raw_files += $(wildcard $(src)/vendorcode/amd/pi/Lib/imc/*.c)
121endif
Stefan Reinauer55feadd2015-06-10 16:15:36 -0700122
123classes-$(CONFIG_CPU_AMD_AGESA_BINARY_PI) += libagesa
Stefan Reinauerd91ddc82015-07-30 11:17:40 -0700124
125ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
Stefan Reinauer55feadd2015-06-10 16:15:36 -0700126$(eval $(call create_class_compiler,libagesa,x86_32))
Stefan Reinauerd91ddc82015-07-30 11:17:40 -0700127else
128$(eval $(call create_class_compiler,libagesa,x86_64))
129endif
Stefan Reinauer55feadd2015-06-10 16:15:36 -0700130
131agesa_src_files := $(strip $(sort $(foreach file,$(strip $(agesa_raw_files)),$(call strip_quotes,$(file)))))
Martin Roth4460e8f2017-09-26 10:07:35 -0600132agesa_output_path := $(obj)/libagesa
133agesa_src_path := $(agesa_output_path)
Nico Huber81b09f42016-01-23 00:50:00 +0100134agesa_dirs := $(sort $(abspath $(dir $(call src-to-obj,libagesa,$(agesa_src_files)))))
Stefan Reinauer55feadd2015-06-10 16:15:36 -0700135
Nico Huber81b09f42016-01-23 00:50:00 +0100136additional-dirs += $(agesa_src_path) $(agesa_dirs)
Stefan Reinauer55feadd2015-06-10 16:15:36 -0700137
Nico Huber81b09f42016-01-23 00:50:00 +0100138$(foreach file,$(strip $(agesa_src_files)),$(eval $(call create_agesa_cp_template,$(file))))
Stefan Reinauer55feadd2015-06-10 16:15:36 -0700139
Martin Roth4460e8f2017-09-26 10:07:35 -0600140$(agesa_output_path)/libagesa.a: $(call src-to-obj,libagesa,$(agesa_src_files))
Nico Huber81b09f42016-01-23 00:50:00 +0100141 @printf " AGESA $(subst $(obj)/,,$(@))\n"
Kyösti Mälkki807e4232017-10-08 21:51:06 +0300142 $(AR_libagesa) rcsDT $@ $+
Stefan Reinauer55feadd2015-06-10 16:15:36 -0700143
Martin Roth4460e8f2017-09-26 10:07:35 -0600144bootblock-libs += $(agesa_output_path)/libagesa.a
145romstage-libs += $(agesa_output_path)/libagesa.a
146ramstage-libs += $(agesa_output_path)/libagesa.a
Stefan Reinauer55feadd2015-06-10 16:15:36 -0700147
148#######################################################################
149
Kyösti Mälkki7104fe22017-05-27 20:53:29 +0300150cbfs-files-$(CONFIG_CPU_AMD_AGESA_BINARY_PI) += $(CONFIG_AGESA_CBFS_NAME)
151$(CONFIG_AGESA_CBFS_NAME)-file := $(CONFIG_AGESA_BINARY_PI_FILE)
152$(CONFIG_AGESA_CBFS_NAME)-type := raw
153$(CONFIG_AGESA_CBFS_NAME)-position := $(CONFIG_AGESA_BINARY_PI_LOCATION)
Stefan Reinauer55feadd2015-06-10 16:15:36 -0700154
155endif