summaryrefslogtreecommitdiff
path: root/src/soc/amd
diff options
context:
space:
mode:
authorFelix Held <felix-coreboot@felixheld.de>2023-07-26 17:37:35 +0200
committerFelix Held <felix-coreboot@felixheld.de>2023-07-27 16:01:27 +0000
commitf3cdd0110da9b13c38ede5ad0a9cdebef7ae0622 (patch)
tree44bb68ab0fb064dad9dedf9be0ef978a35f9e670 /src/soc/amd
parent6b248a2da381928a5670aa1e50e7c9e790749c51 (diff)
soc/amd/noncar/memmap.c: factor out FSP-specific SMM region code
Factor out the common FSP-specific code to get the location and size of the SMM region from the HOB that FSP has put into memory. This moves FSP-specific code out of the common AMD SoC code into the FSP-specific common AMD SoC code folder. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: Ie137bb0f4e7438a1694810ae71592a34f9d8c86e Reviewed-on: https://review.coreboot.org/c/coreboot/+/76760 Reviewed-by: Martin L Roth <gaumless@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com> Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com>
Diffstat (limited to 'src/soc/amd')
-rw-r--r--src/soc/amd/common/block/cpu/noncar/memmap.c21
-rw-r--r--src/soc/amd/common/block/include/amdblocks/memmap.h2
-rw-r--r--src/soc/amd/common/fsp/Makefile.inc2
-rw-r--r--src/soc/amd/common/fsp/fsp_memmap.c31
4 files changed, 36 insertions, 20 deletions
diff --git a/src/soc/amd/common/block/cpu/noncar/memmap.c b/src/soc/amd/common/block/cpu/noncar/memmap.c
index ef87318183..b0e4bcb2c6 100644
--- a/src/soc/amd/common/block/cpu/noncar/memmap.c
+++ b/src/soc/amd/common/block/cpu/noncar/memmap.c
@@ -5,8 +5,6 @@
#include <console/console.h>
#include <cbmem.h>
#include <cpu/x86/smm.h>
-#include <fsp/util.h>
-#include <FspGuids.h>
#include <memrange.h>
#include <types.h>
@@ -36,25 +34,8 @@ const struct memmap_early_dram *memmap_get_early_dram_usage(void)
void smm_region(uintptr_t *start, size_t *size)
{
static int once;
- static uintptr_t smm_start;
- static size_t smm_size;
- *start = smm_start;
- *size = smm_size;
- if (*size && *start)
- return;
-
- struct range_entry tseg;
-
- if (fsp_find_range_hob(&tseg, AMD_FSP_TSEG_HOB_GUID.b) != CB_SUCCESS) {
- printk(BIOS_ERR, "unable to find TSEG HOB\n");
- return;
- }
-
- smm_start = (uintptr_t)range_entry_base(&tseg);
- smm_size = range_entry_size(&tseg);
- *start = smm_start;
- *size = smm_size;
+ fsp_get_smm_region(start, size);
if (!once) {
clear_tvalid();
diff --git a/src/soc/amd/common/block/include/amdblocks/memmap.h b/src/soc/amd/common/block/include/amdblocks/memmap.h
index 0894cf7ce4..cc89d86d50 100644
--- a/src/soc/amd/common/block/include/amdblocks/memmap.h
+++ b/src/soc/amd/common/block/include/amdblocks/memmap.h
@@ -17,4 +17,6 @@ struct memmap_early_dram {
void memmap_stash_early_dram_usage(void);
const struct memmap_early_dram *memmap_get_early_dram_usage(void);
+void fsp_get_smm_region(uintptr_t *start, size_t *size);
+
#endif /* AMD_BLOCK_MEMMAP_H */
diff --git a/src/soc/amd/common/fsp/Makefile.inc b/src/soc/amd/common/fsp/Makefile.inc
index cb4b675975..f26fe8f884 100644
--- a/src/soc/amd/common/fsp/Makefile.inc
+++ b/src/soc/amd/common/fsp/Makefile.inc
@@ -1,7 +1,9 @@
## SPDX-License-Identifier: GPL-2.0-only
ifeq ($(CONFIG_PLATFORM_USES_FSP2_0),y)
+romstage-y += fsp_memmap.c
romstage-y += fsp_reset.c
romstage-y += fsp_validate.c
+ramstage-y += fsp_memmap.c
ramstage-y += fsp_report_resources.c
ramstage-y += fsp_reset.c
ramstage-$(CONFIG_HAVE_ACPI_TABLES) += fsp-acpi.c
diff --git a/src/soc/amd/common/fsp/fsp_memmap.c b/src/soc/amd/common/fsp/fsp_memmap.c
new file mode 100644
index 0000000000..8bed87b111
--- /dev/null
+++ b/src/soc/amd/common/fsp/fsp_memmap.c
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <amdblocks/memmap.h>
+#include <console/console.h>
+#include <fsp/util.h>
+#include <FspGuids.h>
+#include <memrange.h>
+#include <types.h>
+
+void fsp_get_smm_region(uintptr_t *start, size_t *size)
+{
+ static uintptr_t smm_start;
+ static size_t smm_size;
+
+ *start = smm_start;
+ *size = smm_size;
+ if (*size && *start)
+ return;
+
+ struct range_entry tseg;
+
+ if (fsp_find_range_hob(&tseg, AMD_FSP_TSEG_HOB_GUID.b) != CB_SUCCESS) {
+ printk(BIOS_ERR, "unable to find TSEG HOB\n");
+ return;
+ }
+
+ smm_start = (uintptr_t)range_entry_base(&tseg);
+ smm_size = range_entry_size(&tseg);
+ *start = smm_start;
+ *size = smm_size;
+}