| 1 |
|
| 2 |
subdirs-y += ./* |
| 3 |
|
| 4 |
romstage-y += cpu.c |
| 5 |
|
| 6 |
ramstage-y += cpu.c |
| 7 |
ramstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_SVI2) += svi2.c |
| 8 |
ramstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_SVI3) += svi3.c |
| 9 |
ramstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_UCODE) += update_microcode.c |
| 10 |
|
| 11 |
ifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_UCODE),y) |
| 12 |
|
| 13 |
define add-ucode-as-cbfs |
| 14 |
|
| 15 |
# check for duplicate microcode files. Same sbin and bin ucode is allowed here though, because mendocino has a duplicate. |
| 16 |
ifeq ($(cpu_microcode_$(2).bin-file), $(obj)/cpu_microcode_$(2).$(3)) |
| 17 |
$$(info Tried to add ucode: $(1)) |
| 18 |
$$(error Error: The cbfs filename "cpu_microcode_$(2).bin" is already used. Check your microcode patches for duplicates.) |
| 19 |
endif |
| 20 |
|
| 21 |
# offset 0x14 contains the size of the unwrapped ucode file |
| 22 |
# .sbin files contain a 256 wrapper around the usual microcode file |
| 23 |
$(obj)/cpu_microcode_$(2).$(3): $(1) |
| 24 |
echo $$< "->" $$@ |
| 25 |
if [ $(3) = "bin" ]; then \ |
| 26 |
cp $$< $$@; \ |
| 27 |
elif [ $(3) = "sbin" ]; then \ |
| 28 |
size=$$$$(od --endian little --address-radix n --read-bytes 4 --skip-bytes 0x14 --format u4 $$<); \ |
| 29 |
dd status=none ibs=1 skip=256 count=$$$$((size)) if=$$< of=$$@; \ |
| 30 |
fi |
| 31 |
|
| 32 |
# if there is both a sbin and bin microcode only include the bin one to keep the old behaviour |
| 33 |
ifeq ($(cpu_microcode_$(2).bin-file),) |
| 34 |
cbfs-files-y += cpu_microcode_$(2).bin |
| 35 |
cpu_microcode_$(2).bin-file := $(obj)/cpu_microcode_$(2).$(3) |
| 36 |
cpu_microcode_$(2).bin-type := microcode |
| 37 |
|
| 38 |
ifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_LPC_SPI_DMA),y) |
| 39 |
cpu_microcode_$(2).bin-align := 64 |
| 40 |
else |
| 41 |
cpu_microcode_$(2).bin-align := 16 |
| 42 |
endif |
| 43 |
endif |
| 44 |
|
| 45 |
endef |
| 46 |
|
| 47 |
amd_microcode_bins += $(wildcard ${FIRMWARE_LOCATION}/*U?odePatch*.bin) |
| 48 |
amd_microcode_sbins += $(wildcard ${FIRMWARE_LOCATION}/*UcodePatch_*.sbin) |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
extract-bytes = $(shell echo $(shell od --endian little --address-radix n --read-bytes $(2) --skip-bytes $(3) --format $(4) $(1))) |
| 53 |
|
| 54 |
$(foreach ucode, $(amd_microcode_bins), \ |
| 55 |
$(eval $(call add-ucode-as-cbfs,$(ucode),$(call extract-bytes,$(ucode),2,0x18,x2),bin))) |
| 56 |
|
| 57 |
$(foreach ucode, $(amd_microcode_sbins), \ |
| 58 |
$(eval $(call add-ucode-as-cbfs,$(ucode),$(call extract-bytes,$(ucode),2,0x118,x2),sbin))) |
| 59 |
|
| 60 |
endif |