blob: e0867f40c7797f0ffa2313dd0195ef164c977073 [file] [log] [blame]
Felix Held8d268e92021-08-21 00:07:25 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <console/console.h>
4#include <fsp/util.h>
5#include <types.h>
6
Julian Schroederd2e278d2022-01-20 15:09:52 -06007struct amd_image_revision {
8 uint8_t build;
9 uint8_t revision;
10 uint8_t minor;
11 uint8_t major;
12} __packed;
13
Felix Held8d268e92021-08-21 00:07:25 +020014/* Validate the FSP-M header in romstage */
15void soc_validate_fspm_header(const struct fsp_header *hdr)
16{
Julian Schroederd2e278d2022-01-20 15:09:52 -060017 struct amd_image_revision *rev;
18
Elyes Haouas68fc51f2022-07-16 09:48:27 +020019 rev = (struct amd_image_revision *)&(hdr->image_revision);
Julian Schroederd2e278d2022-01-20 15:09:52 -060020
Felix Held8d268e92021-08-21 00:07:25 +020021 /* Check if the image fits into the reserved memory region */
22 if (hdr->image_size > CONFIG_FSP_M_SIZE)
Julian Schroederd2e278d2022-01-20 15:09:52 -060023 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 Held8d268e92021-08-21 00:07:25 +020025 hdr->image_size - CONFIG_FSP_M_SIZE);
Julian Schroederd2e278d2022-01-20 15:09:52 -060026
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 Schroeder017ad9a2022-02-24 15:13:19 -060030 printk(BIOS_WARNING, "No AMD FSP image revision information available\n");
Julian Schroederd2e278d2022-01-20 15:09:52 -060031 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 Held8d268e92021-08-21 00:07:25 +020052}