drivers/amd/opensil/romstage.c: Implement cbmem_top_chipset in driver

Define the generic cbmem_top_chipset() in the driver code, which will
invoke a SoC-specific vendorcode openSIL call to retrieve the low
usable DRAM address.

Change-Id: Ibc79456b0429cdd3d8e3fa5c224799a05add8359
Signed-off-by: Nicolas Kochlowski <nickkochlowski@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85635
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
This commit is contained in:
Nicolas Kochlowski 2024-12-17 13:01:28 -03:00 committed by Felix Held
commit 3a57347955
5 changed files with 38 additions and 24 deletions

View file

@ -4,6 +4,8 @@ ifeq ($(CONFIG_OPENSIL_DRIVER),y)
subdirs-y += mpio
romstage-y += romstage.c
ramstage-y += acpi.c
ramstage-y += ramstage.c

View file

@ -0,0 +1,21 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <cbmem.h>
#include <console/console.h>
#include <cpu/amd/mtrr.h>
#include <vendorcode/amd/opensil/opensil.h>
uintptr_t cbmem_top_chipset(void)
{
printk(BIOS_DEBUG, "TOM1: 0x%x\n", get_top_of_mem_below_4gb());
uintptr_t top_mem = opensil_get_low_usable_dram_address();
/* The TSEG MSR has an 8M granularity. TSEG also needs to be aligned to its size to
account for potentially ill aligned TOP_MEM. */
if (CONFIG_SMM_TSEG_SIZE) {
top_mem -= CONFIG_SMM_TSEG_SIZE;
top_mem = ALIGN_DOWN(top_mem, CONFIG_SMM_TSEG_SIZE);
}
return top_mem;
}

View file

@ -1,23 +1,17 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <cbmem.h>
#include <console/console.h>
#include "opensil_console.h"
#include <xSIM-api.h>
#include <xPRF-api.h>
uintptr_t cbmem_top_chipset(void)
#include "../opensil.h"
uintptr_t opensil_get_low_usable_dram_address(void)
{
SilDebugSetup(HostDebugService);
uintptr_t top_mem = xPrfGetLowUsableDramAddress(0);
printk(BIOS_DEBUG, "xPrfGetLowUsableDramAddress: 0x%lx\n", top_mem);
uintptr_t low_usable_dram_addr = xPrfGetLowUsableDramAddress(0);
printk(BIOS_DEBUG, "xPrfGetLowUsableDramAddress: 0x%lx\n", low_usable_dram_addr);
/* The TSEG MSR has an 8M granularity. TSEG also needs to be aligned to its size so
account for potentially ill aligned TOP_MEM. */
if (CONFIG_SMM_TSEG_SIZE) {
top_mem -= CONFIG_SMM_TSEG_SIZE;
top_mem = ALIGN_DOWN(top_mem, CONFIG_SMM_TSEG_SIZE);
}
return top_mem;
return low_usable_dram_addr;
}

View file

@ -5,6 +5,7 @@
#include <acpi/acpi.h>
#include <device/device.h>
#include <types.h>
void SIL_STATUS_report(const char *function, const int status);
// Add the memory map to dev, starting at index idx, returns last use idx
@ -13,6 +14,8 @@ void add_opensil_memmap(struct device *dev, unsigned long *idx);
void opensil_fill_fadt(acpi_fadt_t *fadt);
unsigned long add_opensil_acpi_table(unsigned long current, acpi_rsdp_t *rsdp);
uintptr_t opensil_get_low_usable_dram_address(void);
void setup_opensil(void);
void opensil_xSIM_timepoint_1(void);
void opensil_xSIM_timepoint_2(void);

View file

@ -1,23 +1,17 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <cbmem.h>
#include <console/console.h>
#include <inttypes.h>
uintptr_t cbmem_top_chipset(void)
#include "../opensil.h"
uintptr_t opensil_get_low_usable_dram_address(void)
{
/* Since the stub doesn't have the openSIL function xPrfGetLowUsableDramAddress to
call, we just use 0xc0000000 here which should be a usable value in most cases */
uintptr_t top_mem = 0xc0000000;
uintptr_t low_usable_dram_addr = 0xc0000000;
printk(BIOS_NOTICE, "openSIL stub: %s retuns %" PRIxPTR "\n", __func__, top_mem);
printk(BIOS_NOTICE, "openSIL stub: %s retuns %" PRIxPTR "\n", __func__, low_usable_dram_addr);
/* The TSEG MSR has an 8M granularity. TSEG also needs to be aligned to its size so
account for potentially ill aligned TOP_MEM. */
if (CONFIG_SMM_TSEG_SIZE) {
top_mem -= CONFIG_SMM_TSEG_SIZE;
top_mem = ALIGN_DOWN(top_mem, CONFIG_SMM_TSEG_SIZE);
}
return top_mem;
return low_usable_dram_addr;
}