soc/amd/fsp: Cache smm_region() results

This avoids searching the HOB output multiple times when calling
smm_region().

Change-Id: Iad09c3aa3298745ba3ba7012e6bb8cfb8785d525
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/65787
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
This commit is contained in:
Arthur Heymans 2022-07-12 12:12:19 +02:00 committed by Felix Held
parent 50a27072d0
commit 7f611018d4
1 changed files with 11 additions and 5 deletions

View File

@ -37,12 +37,16 @@ const struct memmap_early_dram *memmap_get_early_dram_usage(void)
void smm_region(uintptr_t *start, size_t *size)
{
static int once;
struct range_entry tseg;
static uintptr_t smm_start;
static size_t smm_size;
int status;
*start = 0;
*size = 0;
*start = smm_start;
*size = smm_size;
if (*size && *start)
return;
struct range_entry tseg;
status = fsp_find_range_hob(&tseg, AMD_FSP_TSEG_HOB_GUID.b);
if (status < 0) {
@ -50,8 +54,10 @@ void smm_region(uintptr_t *start, size_t *size)
return;
}
*start = (uintptr_t)range_entry_base(&tseg);
*size = range_entry_size(&tseg);
smm_start = (uintptr_t)range_entry_base(&tseg);
smm_size = range_entry_size(&tseg);
*start = smm_start;
*size = smm_size;
if (!once) {
clear_tvalid();