Martin Roth | 059988d | 2017-11-11 20:06:19 -0700 | [diff] [blame] | 1 | #***************************************************************************** |
| 2 | # |
Martin Roth | 059988d | 2017-11-11 20:06:19 -0700 | [diff] [blame] | 3 | # 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 Dawson | d786843 | 2019-11-25 11:47:32 -0700 | [diff] [blame] | 27 | ifeq ($(CONFIG_SOC_AMD_STONEYRIDGE),y) |
Martin Roth | 059988d | 2017-11-11 20:06:19 -0700 | [diff] [blame] | 28 | # AGESA V5 Files |
| 29 | |
| 30 | AGESA_ROOT = $(call strip_quotes,$(CONFIG_AGESA_BINARY_PI_VENDORCODE_PATH)) |
| 31 | |
Martin Roth | ece69f2 | 2017-11-16 22:34:26 -0700 | [diff] [blame] | 32 | BINARY_PI_INC = -I$(AGESA_ROOT) |
| 33 | BINARY_PI_INC += -I$(AGESA_ROOT)/binaryPI |
| 34 | BINARY_PI_INC += -I$(AGESA_ROOT)/Include |
Martin Roth | ece69f2 | 2017-11-16 22:34:26 -0700 | [diff] [blame] | 35 | BINARY_PI_INC += -I$(AGESA_ROOT)/Proc |
| 36 | BINARY_PI_INC += -I$(AGESA_ROOT)/Proc/Common |
| 37 | BINARY_PI_INC += -I$(AGESA_ROOT)/Proc/CPU |
| 38 | BINARY_PI_INC += -I$(AGESA_ROOT)/Proc/CPU/Family |
| 39 | BINARY_PI_INC += -I$(AGESA_ROOT)/Proc/Fch |
| 40 | BINARY_PI_INC += -I$(AGESA_ROOT)/Proc/Fch/Common |
Martin Roth | ece69f2 | 2017-11-16 22:34:26 -0700 | [diff] [blame] | 41 | |
Martin Roth | 2413918 | 2017-11-16 16:00:53 -0700 | [diff] [blame] | 42 | AGESA_INC = -I$(obj) |
Martin Roth | ece69f2 | 2017-11-16 22:34:26 -0700 | [diff] [blame] | 43 | AGESA_INC += $(BINARY_PI_INC) |
Martin Roth | 059988d | 2017-11-11 20:06:19 -0700 | [diff] [blame] | 44 | |
| 45 | AGESA_INC += -I$(src)/soc/amd/stoneyridge/include |
Aaron Durbin | 49ec3f0 | 2017-12-12 10:01:06 -0700 | [diff] [blame] | 46 | AGESA_INC += -I$(src)/soc/amd/common/block/include |
Martin Roth | 059988d | 2017-11-11 20:06:19 -0700 | [diff] [blame] | 47 | |
| 48 | AGESA_INC += -I$(src)/arch/x86/include |
| 49 | AGESA_INC += -I$(src)/include |
| 50 | AGESA_INC += -I$(src)/commonlib/include |
| 51 | AGESA_INC += -I$(VBOOT_SOURCE)/firmware/include |
| 52 | |
Martin Roth | ece69f2 | 2017-11-16 22:34:26 -0700 | [diff] [blame] | 53 | AGESA_CFLAGS += -march=amdfam10 -fno-strict-aliasing -D__LIBAGESA__ |
Martin Roth | 059988d | 2017-11-11 20:06:19 -0700 | [diff] [blame] | 54 | |
Martin Roth | ece69f2 | 2017-11-16 22:34:26 -0700 | [diff] [blame] | 55 | CC_bootblock := $(CC_bootblock) $(BINARY_PI_INC) |
| 56 | CC_romstage := $(CC_romstage) $(BINARY_PI_INC) |
Martin Roth | 059988d | 2017-11-11 20:06:19 -0700 | [diff] [blame] | 57 | CC_postcar:= $(CC_postcar) -I$(AGESA_ROOT)/binaryPI |
Martin Roth | ece69f2 | 2017-11-16 22:34:26 -0700 | [diff] [blame] | 58 | CC_ramstage := $(CC_ramstage) $(BINARY_PI_INC) |
Martin Roth | 059988d | 2017-11-11 20:06:19 -0700 | [diff] [blame] | 59 | |
| 60 | ####################################################################### |
| 61 | |
| 62 | define create_agesa_cp_template |
| 63 | # $1 AGESA source file |
| 64 | |
| 65 | $(agesa_src_path)/$(notdir $1): $1 |
| 66 | @printf " AGESA Copying $$(notdir $1) => $$(@D)\n" |
| 67 | if [ ! -r $(agesa_src_path)/$(notdir $1) ]; then \ |
| 68 | cp -f $1 $$(@D); \ |
| 69 | fi |
| 70 | |
| 71 | $(call src-to-obj,libagesa,$1): $(agesa_src_path)/$(notdir $1) $(obj)/config.h $(src)/include/kconfig.h |
| 72 | @printf " CC $$(subst $(obj)/,,$$(@))\n" |
Julius Werner | 98eeb96 | 2019-12-11 15:47:42 -0800 | [diff] [blame] | 73 | $(CC_libagesa) -c -MMD $(CFLAGS_libagesa) $(AGESA_CFLAGS) \ |
| 74 | $(AGESA_INC) \ |
| 75 | -include $(src)/include/kconfig.h \ |
| 76 | -include $(src)/include/rules.h \ |
| 77 | -include $(src)/commonlib/bsd/include/commonlib/bsd/compiler.h \ |
| 78 | -o $$@ \ |
Martin Roth | 059988d | 2017-11-11 20:06:19 -0700 | [diff] [blame] | 79 | $(agesa_src_path)/$(notdir $1) |
| 80 | |
| 81 | endef |
| 82 | |
Martin Roth | 744104e | 2017-11-12 09:59:37 -0700 | [diff] [blame] | 83 | agesa_raw_files += $(wildcard $(AGESA_ROOT)/Lib/*.[cS]) |
Martin Roth | 059988d | 2017-11-11 20:06:19 -0700 | [diff] [blame] | 84 | |
| 85 | agesa_raw_files += $(wildcard $(AGESA_ROOT)/binaryPI/*.[cS]) |
| 86 | |
Arthur Heymans | 81a4fef | 2022-11-01 23:33:45 +0100 | [diff] [blame] | 87 | classes-y += libagesa |
Martin Roth | 059988d | 2017-11-11 20:06:19 -0700 | [diff] [blame] | 88 | |
| 89 | ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y) |
| 90 | $(eval $(call create_class_compiler,libagesa,x86_32)) |
| 91 | else |
| 92 | $(eval $(call create_class_compiler,libagesa,x86_64)) |
| 93 | endif |
| 94 | |
| 95 | agesa_src_files := $(strip $(sort $(foreach file,$(strip $(agesa_raw_files)),$(call strip_quotes,$(file))))) |
| 96 | agesa_output_path := $(obj)/libagesa |
| 97 | agesa_src_path := $(agesa_output_path) |
| 98 | agesa_dirs := $(sort $(abspath $(dir $(call src-to-obj,libagesa,$(agesa_src_files))))) |
| 99 | |
| 100 | additional-dirs += $(agesa_src_path) $(agesa_dirs) |
| 101 | |
| 102 | $(foreach file,$(strip $(agesa_src_files)),$(eval $(call create_agesa_cp_template,$(file)))) |
| 103 | |
| 104 | $(agesa_output_path)/libagesa.a: $(call src-to-obj,libagesa,$(agesa_src_files)) |
| 105 | @printf " AGESA $(subst $(obj)/,,$(@))\n" |
| 106 | $(AR_libagesa) rcs $@ $+ |
| 107 | |
| 108 | bootblock-libs += $(agesa_output_path)/libagesa.a |
| 109 | romstage-libs += $(agesa_output_path)/libagesa.a |
| 110 | ramstage-libs += $(agesa_output_path)/libagesa.a |
| 111 | |
| 112 | ####################################################################### |
| 113 | |
Marshall Dawson | fd6fb28 | 2019-11-25 17:53:29 -0700 | [diff] [blame] | 114 | warn_no_agesa: |
| 115 | printf "\n\t** WARNING **\n" |
| 116 | printf "coreboot has been built with no AGESA support. Successfully " |
| 117 | printf "booting this image will be impossible.\n\n" |
| 118 | |
Marshall Dawson | 19be7b5 | 2020-01-02 15:38:59 -0700 | [diff] [blame] | 119 | PHONY+=warn_no_agesa |
Marshall Dawson | fd6fb28 | 2019-11-25 17:53:29 -0700 | [diff] [blame] | 120 | |
Justin TerAvest | 9226195 | 2017-12-22 15:15:02 -0700 | [diff] [blame] | 121 | ifeq ($(CONFIG_AGESA_SPLIT_MEMORY_FILES), y) |
Aaron Durbin | 931ed7f | 2017-12-22 17:13:17 -0700 | [diff] [blame] | 122 | |
| 123 | # convert input elf to rmodule |
| 124 | AGESA_POST_MEM_INPUT_ELF = $(call strip_quotes,$(CONFIG_AGESA_POST_MEMORY_BINARY_PI_FILE)) |
Marshall Dawson | fd6fb28 | 2019-11-25 17:53:29 -0700 | [diff] [blame] | 125 | |
| 126 | # If no post-mem file then also skip pre-mem file |
Patrick Georgi | a1d668e | 2019-12-12 16:25:28 +0100 | [diff] [blame] | 127 | ifeq ($(AGESA_POST_MEM_INPUT_ELF),) |
Marshall Dawson | fd6fb28 | 2019-11-25 17:53:29 -0700 | [diff] [blame] | 128 | files_added:: warn_no_agesa |
| 129 | else |
Aaron Durbin | 931ed7f | 2017-12-22 17:13:17 -0700 | [diff] [blame] | 130 | AGESA_POST_MEM_ELF = $(objcbfs)/$(patsubst %.elf,%.debug,$(notdir $(AGESA_POST_MEM_INPUT_ELF))) |
| 131 | AGESA_POST_MEM_ELF_RMOD = $(AGESA_POST_MEM_ELF).rmod |
| 132 | |
| 133 | $(AGESA_POST_MEM_ELF): $(AGESA_POST_MEM_INPUT_ELF) |
| 134 | cp $< $@ |
| 135 | |
| 136 | $(AGESA_POST_MEM_ELF_RMOD): $(AGESA_POST_MEM_ELF) |
| 137 | |
Arthur Heymans | 81a4fef | 2022-11-01 23:33:45 +0100 | [diff] [blame] | 138 | cbfs-files-y += $(CONFIG_AGESA_PRE_MEMORY_CBFS_NAME) |
Justin TerAvest | 9226195 | 2017-12-22 15:15:02 -0700 | [diff] [blame] | 139 | $(CONFIG_AGESA_PRE_MEMORY_CBFS_NAME)-file := $(CONFIG_AGESA_PRE_MEMORY_BINARY_PI_FILE) |
| 140 | $(CONFIG_AGESA_PRE_MEMORY_CBFS_NAME)-type := stage |
| 141 | $(CONFIG_AGESA_PRE_MEMORY_CBFS_NAME)-options := --xip |
| 142 | # 4KiB alignment to handle any interior alignment. Current AGESA only has |
| 143 | # 64 byte alignment. |
| 144 | $(CONFIG_AGESA_PRE_MEMORY_CBFS_NAME)-align := 4096 |
| 145 | |
Arthur Heymans | 81a4fef | 2022-11-01 23:33:45 +0100 | [diff] [blame] | 146 | cbfs-files-y += $(CONFIG_AGESA_POST_MEMORY_CBFS_NAME) |
Aaron Durbin | 931ed7f | 2017-12-22 17:13:17 -0700 | [diff] [blame] | 147 | $(CONFIG_AGESA_POST_MEMORY_CBFS_NAME)-file := $(AGESA_POST_MEM_ELF_RMOD) |
Justin TerAvest | 9226195 | 2017-12-22 15:15:02 -0700 | [diff] [blame] | 148 | $(CONFIG_AGESA_POST_MEMORY_CBFS_NAME)-type := stage |
Aaron Durbin | 931ed7f | 2017-12-22 17:13:17 -0700 | [diff] [blame] | 149 | $(CONFIG_AGESA_POST_MEMORY_CBFS_NAME)-compression := $(CBFS_COMPRESS_FLAG) |
Marshall Dawson | fd6fb28 | 2019-11-25 17:53:29 -0700 | [diff] [blame] | 150 | |
| 151 | endif # AGESA_POST_MEM_INPUT_ELF == "" |
| 152 | |
| 153 | else # CONFIG_AGESA_SPLIT_MEMORY_FILES |
| 154 | |
| 155 | AGESA_BINARYPI_INPUT_FILE = $(call strip_quotes,$(CONFIG_AGESA_BINARY_PI_FILE)) |
| 156 | ifeq ($(AGESA_BINARYPI_INPUT_FILE),) |
| 157 | files_added:: warn_no_agesa |
Justin TerAvest | 9226195 | 2017-12-22 15:15:02 -0700 | [diff] [blame] | 158 | else |
| 159 | |
Arthur Heymans | 81a4fef | 2022-11-01 23:33:45 +0100 | [diff] [blame] | 160 | cbfs-files-y += $(CONFIG_AGESA_CBFS_NAME) |
Marshall Dawson | fd6fb28 | 2019-11-25 17:53:29 -0700 | [diff] [blame] | 161 | $(CONFIG_AGESA_CBFS_NAME)-file := $(AGESA_BINARYPI_INPUT_FILE) |
Justin TerAvest | 9226195 | 2017-12-22 15:15:02 -0700 | [diff] [blame] | 162 | |
Aaron Durbin | 02b43aa | 2017-12-12 14:56:41 -0700 | [diff] [blame] | 163 | ifeq ($(CONFIG_AGESA_BINARY_PI_AS_STAGE),y) |
| 164 | $(CONFIG_AGESA_CBFS_NAME)-type := stage |
| 165 | $(CONFIG_AGESA_CBFS_NAME)-options := --xip |
| 166 | # 4KiB alignment to handle any interior alignment. Current AGESA only has |
| 167 | # 64 byte alignment. |
| 168 | $(CONFIG_AGESA_CBFS_NAME)-align := 4096 |
| 169 | else |
Martin Roth | 059988d | 2017-11-11 20:06:19 -0700 | [diff] [blame] | 170 | $(CONFIG_AGESA_CBFS_NAME)-type := raw |
| 171 | $(CONFIG_AGESA_CBFS_NAME)-position := $(CONFIG_AGESA_BINARY_PI_LOCATION) |
Furquan Shaikh | 6c8ba9b | 2020-11-20 22:26:38 -0800 | [diff] [blame] | 172 | regions-for-file-$(CONFIG_AGESA_CBFS_NAME) = COREBOOT |
Justin TerAvest | 9226195 | 2017-12-22 15:15:02 -0700 | [diff] [blame] | 173 | endif # CONFIG_AGESA_BINARY_PI_AS_STAGE |
| 174 | |
Marshall Dawson | fd6fb28 | 2019-11-25 17:53:29 -0700 | [diff] [blame] | 175 | endif # AGESA_BINARYPI_INPUT_FILE == "" |
Justin TerAvest | 9226195 | 2017-12-22 15:15:02 -0700 | [diff] [blame] | 176 | endif # CONFIG_AGESA_SPLIT_MEMORY_FILES |
Martin Roth | 059988d | 2017-11-11 20:06:19 -0700 | [diff] [blame] | 177 | |
| 178 | endif |