blob: ec526e850dfc42d0b2b8035c474de8245ff72f84 [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Lee Leahy52d0c682016-08-01 15:47:42 -07002
3#include <cbmem.h>
4#include <console/console.h>
5#include <fsp/util.h>
6
Lee Leahy52d0c682016-08-01 15:47:42 -07007void fsp_verify_memory_init_hobs(void)
8{
9 struct range_entry fsp_mem;
10 struct range_entry tolum;
11
Michael Niewöhnerbc1dbb32019-10-24 22:58:25 +020012 /* Verify the size of the TOLUM range */
13 fsp_find_bootloader_tolum(&tolum);
Lee Leahy52d0c682016-08-01 15:47:42 -070014 if (range_entry_size(&tolum) < cbmem_overhead_size()) {
15 printk(BIOS_CRIT,
Paul Menzel8eed67b2017-10-21 11:22:57 +020016 "FSP_BOOTLOADER_TOLUM_SIZE: 0x%08llx < 0x%08zx\n",
Lee Leahy52d0c682016-08-01 15:47:42 -070017 range_entry_size(&tolum), cbmem_overhead_size());
18 die("FSP_BOOTLOADER_TOLUM_HOB too small!\n");
19 }
20
Jonathan Neuschäfer45e6c822018-12-11 17:53:07 +010021 /* Verify the bootloader tolum is above the FSP reserved area */
Michael Niewöhnerbc1dbb32019-10-24 22:58:25 +020022 fsp_find_reserved_memory(&fsp_mem);
Lee Leahy52d0c682016-08-01 15:47:42 -070023 if (range_entry_end(&tolum) <= range_entry_base(&fsp_mem)) {
24 printk(BIOS_CRIT,
25 "TOLUM end: 0x%08llx != 0x%08llx: FSP rsvd base\n",
26 range_entry_end(&tolum), range_entry_base(&fsp_mem));
27 die("FSP reserved region after BIOS TOLUM!\n");
28 }
29 if (range_entry_base(&tolum) < range_entry_end(&fsp_mem)) {
30 printk(BIOS_CRIT,
31 "TOLUM base: 0x%08llx < 0x%08llx: FSP rsvd end\n",
32 range_entry_base(&tolum), range_entry_end(&fsp_mem));
33 die("FSP reserved region overlaps BIOS TOLUM!\n");
34 }
35
36 /* Verify that the FSP reserved area immediately follows the BIOS
37 * reserved area
38 */
39 if (range_entry_base(&tolum) != range_entry_end(&fsp_mem)) {
40 printk(BIOS_CRIT,
41 "TOLUM base: 0x%08llx != 0x%08llx: FSP rsvd end\n",
42 range_entry_base(&tolum), range_entry_end(&fsp_mem));
43 die("Space between FSP reserved region and BIOS TOLUM!\n");
44 }
45
Felix Held46e6a582021-07-06 18:39:05 +020046 if (range_entry_end(&tolum) != (uintptr_t)cbmem_top()) {
Julius Werner540a9802019-12-09 13:03:29 -080047 printk(BIOS_CRIT, "TOLUM end: 0x%08llx != %p: cbmem_top\n",
Lee Leahy52d0c682016-08-01 15:47:42 -070048 range_entry_end(&tolum), cbmem_top());
49 die("Space between cbmem_top and BIOS TOLUM!\n");
50 }
Lee Leahy52d0c682016-08-01 15:47:42 -070051}