Felix Held | 8d268e9 | 2021-08-21 00:07:25 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <console/console.h> |
| 4 | #include <fsp/util.h> |
| 5 | #include <types.h> |
| 6 | |
Julian Schroeder | d2e278d | 2022-01-20 15:09:52 -0600 | [diff] [blame] | 7 | struct amd_image_revision { |
| 8 | uint8_t build; |
| 9 | uint8_t revision; |
| 10 | uint8_t minor; |
| 11 | uint8_t major; |
| 12 | } __packed; |
| 13 | |
Felix Held | 8d268e9 | 2021-08-21 00:07:25 +0200 | [diff] [blame] | 14 | /* Validate the FSP-M header in romstage */ |
| 15 | void soc_validate_fspm_header(const struct fsp_header *hdr) |
| 16 | { |
Julian Schroeder | d2e278d | 2022-01-20 15:09:52 -0600 | [diff] [blame] | 17 | struct amd_image_revision *rev; |
| 18 | |
Elyes Haouas | 68fc51f | 2022-07-16 09:48:27 +0200 | [diff] [blame] | 19 | rev = (struct amd_image_revision *)&(hdr->image_revision); |
Julian Schroeder | d2e278d | 2022-01-20 15:09:52 -0600 | [diff] [blame] | 20 | |
Felix Held | 8d268e9 | 2021-08-21 00:07:25 +0200 | [diff] [blame] | 21 | /* Check if the image fits into the reserved memory region */ |
| 22 | if (hdr->image_size > CONFIG_FSP_M_SIZE) |
Julian Schroeder | d2e278d | 2022-01-20 15:09:52 -0600 | [diff] [blame] | 23 | die("The FSP-M binary is %u bytes larger than the memory region" |
| 24 | " allocated for it. Increase FSP_M_SIZE to make it fit.\n", |
Felix Held | 8d268e9 | 2021-08-21 00:07:25 +0200 | [diff] [blame] | 25 | hdr->image_size - CONFIG_FSP_M_SIZE); |
Julian Schroeder | d2e278d | 2022-01-20 15:09:52 -0600 | [diff] [blame] | 26 | |
| 27 | /* a coding bug on the AMD FSP side makes this value 1 in |
| 28 | older versions of the FSP.*/ |
| 29 | if (hdr->image_revision == 1) { |
Julian Schroeder | 017ad9a | 2022-02-24 15:13:19 -0600 | [diff] [blame] | 30 | printk(BIOS_WARNING, "No AMD FSP image revision information available\n"); |
Julian Schroeder | d2e278d | 2022-01-20 15:09:52 -0600 | [diff] [blame] | 31 | return; |
| 32 | } |
| 33 | |
| 34 | printk(BIOS_INFO, "FSP major = %d\n", rev->major); |
| 35 | printk(BIOS_INFO, "FSP minor = %d\n", rev->minor); |
| 36 | printk(BIOS_INFO, "FSP revision = %d\n", rev->revision); |
| 37 | printk(BIOS_INFO, "FSP build = %d\n", rev->build); |
| 38 | |
| 39 | if ((rev->major != IMAGE_REVISION_MAJOR_VERSION) || |
| 40 | (rev->minor != IMAGE_REVISION_MINOR_VERSION)) { |
| 41 | printk(BIOS_WARNING, "FSP binary and SOC FSP header file don't match.\n"); |
| 42 | printk(BIOS_WARNING, "include file ImageRevisionMajorVersion=%d\n", |
| 43 | IMAGE_REVISION_MAJOR_VERSION); |
| 44 | printk(BIOS_WARNING, "include file ImageRevisionMinorVersion=%d\n", |
| 45 | IMAGE_REVISION_MINOR_VERSION); |
| 46 | printk(BIOS_WARNING, "Please update FspmUpd.h based on the corresponding FSP" |
| 47 | " build's FspmUpd.h\n"); |
| 48 | } |
| 49 | |
| 50 | if (rev->major != IMAGE_REVISION_MAJOR_VERSION) |
| 51 | die("IMAGE_REVISION_MAJOR_VERSION mismatch, halting\nGoodbye now\n"); |
Felix Held | 8d268e9 | 2021-08-21 00:07:25 +0200 | [diff] [blame] | 52 | } |