Martin Roth | 9231f0b | 2022-10-28 22:39:23 -0600 | [diff] [blame] | 1 | ## SPDX-License-Identifier: GPL-2.0-only |
Felix Held | ea34022 | 2020-11-14 01:58:47 +0100 | [diff] [blame] | 2 | ifeq ($(CONFIG_SOC_AMD_COMMON),y) |
| 3 | subdirs-y += block |
Felix Held | e04a18f | 2020-12-10 16:49:28 +0100 | [diff] [blame] | 4 | subdirs-y += fsp |
Felix Held | c9737c5c | 2021-09-23 17:16:32 +0200 | [diff] [blame] | 5 | subdirs-y += pi |
Felix Held | ea34022 | 2020-11-14 01:58:47 +0100 | [diff] [blame] | 6 | subdirs-y += vboot |
Zheng Bao | e47bff8 | 2022-03-08 14:59:27 +0800 | [diff] [blame] | 7 | |
| 8 | ifneq ($(CONFIG_AMDFW_CONFIG_FILE), ) |
| 9 | FIRMWARE_LOCATION=$(shell grep -e FIRMWARE_LOCATION $(CONFIG_AMDFW_CONFIG_FILE) | awk '{print $$2}') |
| 10 | |
Martin Roth | d729df0 | 2023-03-08 15:33:13 -0700 | [diff] [blame^] | 11 | # Add all the files listed in the config file to the dependency list |
Zheng Bao | e47bff8 | 2022-03-08 14:59:27 +0800 | [diff] [blame] | 12 | POUND_SIGN=$(call strip_quotes, "\#") |
Martin Roth | d729df0 | 2023-03-08 15:33:13 -0700 | [diff] [blame^] | 13 | REMOVE_MP2 = |
| 14 | # If the MP2 file is not being loaded, remove it as a dependency |
| 15 | ifneq ($(CONFIG_PSP_LOAD_MP2_FW),y) |
| 16 | REMOVE_MP2 = /MP2/d |
| 17 | endif |
| 18 | |
| 19 | # Steps below to generate the dependency list |
| 20 | # 1a: Delete any line that starts with #, FIRMWARE_LOCATION, or SOC_NAME |
| 21 | # 1b: Delete any line containing a * |
| 22 | # 1c: Filter out lines containing MP2 or not, decided above. |
| 23 | # 1d: Use awk to return only field 2, the filename |
| 24 | # 2: Gather filenames with no path to add the firmware location later |
| 25 | # 3: Gather filenames with a path |
| 26 | # 4a: Add the firmware location to any files without a path to the dependencies |
| 27 | # 4b: add the lines containing a path to the dependencies |
| 28 | AMDFW_CFG_FILES = $(shell sed "/^$(POUND_SIGN)\|^FIRMWARE_LOCATION\|^SOC_NAME/d; \ |
| 29 | /*/d; \ |
| 30 | $(REMOVE_MP2)" $(CONFIG_AMDFW_CONFIG_FILE) | \ |
| 31 | awk '{print $$2}') |
| 32 | AMDFW_CFG_IN_FW_LOC = $(shell echo "$(AMDFW_CFG_FILES)" | tr ' ' '\n' | grep -v "/") |
| 33 | AMDFW_CFG_WITH_PATH = $(shell echo "$(AMDFW_CFG_FILES)" | tr ' ' '\n' | grep "/") |
| 34 | DEP_FILES = $(patsubst %,$(FIRMWARE_LOCATION)/%, $(AMDFW_CFG_IN_FW_LOC)) \ |
| 35 | $(AMDFW_CFG_WITH_PATH) |
Zheng Bao | e47bff8 | 2022-03-08 14:59:27 +0800 | [diff] [blame] | 36 | |
| 37 | amd_microcode_bins += $(wildcard ${FIRMWARE_LOCATION}/*UcodePatch_*.bin) |
| 38 | |
Karthikeyan Ramasubramanian | 8d66fb1 | 2022-09-20 23:53:40 -0600 | [diff] [blame] | 39 | ifeq ($(CONFIG_RESET_VECTOR_IN_RAM),y) |
| 40 | $(objcbfs)/bootblock.bin: $(obj)/amdfw.rom |
| 41 | cp $< $@ |
| 42 | |
| 43 | add_bootblock = \ |
| 44 | $(CBFSTOOL) $(1) add -f $(2) -n apu/amdfw -t amdfw \ |
| 45 | -b $(call int-add, \ |
| 46 | $(call int-subtract, 0xffffffff \ |
| 47 | $(call int-shift-left, \ |
| 48 | 0x80000 $(CONFIG_AMD_FWM_POSITION_INDEX))) 0x20000 1) |
| 49 | endif # ifeq ($(CONFIG_RESET_VECTOR_IN_RAM),y) |
| 50 | |
Karthikeyan Ramasubramanian | 7835861 | 2022-08-16 17:30:06 -0600 | [diff] [blame] | 51 | ifeq ($(CONFIG_VBOOT_GSCVD),y) |
Fred Reitberger | 552d287 | 2023-02-10 12:31:22 -0500 | [diff] [blame] | 52 | build_complete:: $(obj)/ro-amdfw-list |
Karthikeyan Ramasubramanian | d1130b7 | 2022-08-16 17:42:57 -0600 | [diff] [blame] | 53 | |
Fred Reitberger | 552d287 | 2023-02-10 12:31:22 -0500 | [diff] [blame] | 54 | $(obj)/ro-amdfw-list: $(AMDFWREAD) |
| 55 | $(AMDFWREAD) --ro-list $(obj)/coreboot.rom > $@ |
| 56 | |
| 57 | amdfwread-offset-size-cmd = grep '$(1)' $(obj)/ro-amdfw-list | \ |
| 58 | sed 's/^.* 0x0*\(.*\) 0x0*\(.*\)$$/\1:\2/' |
Karthikeyan Ramasubramanian | d1130b7 | 2022-08-16 17:42:57 -0600 | [diff] [blame] | 59 | |
| 60 | amdfwread-range-cmd = $(shell ( \ |
| 61 | range=$$($(call amdfwread-offset-size-cmd,$(1))) ;\ |
| 62 | if [ -n "$$range" ]; then \ |
| 63 | printf $$range ;\ |
| 64 | else \ |
| 65 | printf "error" ;\ |
| 66 | fi ;\ |
| 67 | )) |
Karthikeyan Ramasubramanian | 7835861 | 2022-08-16 17:30:06 -0600 | [diff] [blame] | 68 | endif # ifeq ($(CONFIG_VBOOT_GSCVD),y) |
| 69 | |
Fred Reitberger | e814b26 | 2022-12-01 08:49:44 -0500 | [diff] [blame] | 70 | endif # ifneq ($(CONFIG_AMDFW_CONFIG_FILE), ) |
Fred Reitberger | 8190840 | 2022-11-07 13:21:48 -0500 | [diff] [blame] | 71 | |
| 72 | MAINBOARD_BLOBS_DIR := $(call strip_quotes, $(CONFIG_APCB_BLOBS_DIR)) |
Fred Reitberger | e814b26 | 2022-12-01 08:49:44 -0500 | [diff] [blame] | 73 | |
Fred Reitberger | a63fac3 | 2023-02-13 11:06:15 -0500 | [diff] [blame] | 74 | PHONY+=warn_no_apcb |
| 75 | warn_no_apcb: |
| 76 | printf "\n\t** WARNING **\n" |
| 77 | printf "coreboot has been built without an APCB.\n" |
| 78 | printf "This image will not boot.\n\n" |
| 79 | |
Fred Reitberger | 38954e2 | 2023-02-13 15:22:02 -0500 | [diff] [blame] | 80 | PHONY+=die_no_apcb |
| 81 | die_no_apcb: warn_no_apcb |
| 82 | $(error This board requires the APCB to build correctly) |
| 83 | |
Fred Reitberger | e814b26 | 2022-12-01 08:49:44 -0500 | [diff] [blame] | 84 | endif # ifeq ($(CONFIG_SOC_AMD_COMMON),y) |