blob: e55ed1b450e1a39304e6ae28d387746c85392518 [file] [log] [blame]
Arthur Heymans98a46fb2023-07-13 18:31:13 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <cbmem.h>
4#include <console/console.h>
5#include "opensil_console.h"
6#include <xSIM-api.h>
7#include <xPRF-api.h>
8
9uintptr_t cbmem_top_chipset(void)
10{
11 SilDebugSetup(HostDebugService);
12 uintptr_t top_mem = xPrfGetLowUsableDramAddress(0);
13 printk(BIOS_DEBUG, "xPrfGetLowUsableDramAddress: 0x%lx\n", top_mem);
14
15 /* The TSEG MSR has an 8M granularity. TSEG also needs to be aligned to its size so
16 account for potentially ill aligned TOP_MEM. */
17 if (CONFIG_SMM_TSEG_SIZE) {
18 top_mem -= CONFIG_SMM_TSEG_SIZE;
19 top_mem = ALIGN_DOWN(top_mem, CONFIG_SMM_TSEG_SIZE);
20 }
21
22 return top_mem;
23}