From 2f7d4c362ce75803f3df55e401e8831275f18c41 Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Sun, 9 Aug 2020 16:01:26 +0200 Subject: [PATCH] cpu/x86/smm/smihandler.c: Implement smm_get_save_state() This will be used in common save_state handling code. Change-Id: I4cb3180ec565cee931606e8a8f55b78fdb8932ae Signed-off-by: Arthur Heymans Reviewed-on: https://review.coreboot.org/c/coreboot/+/44320 Reviewed-by: Angel Pons Tested-by: build bot (Jenkins) --- src/cpu/x86/smm/smihandler.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/cpu/x86/smm/smihandler.c b/src/cpu/x86/smm/smihandler.c index 99594beae7..077fa8db8f 100644 --- a/src/cpu/x86/smm/smihandler.c +++ b/src/cpu/x86/smm/smihandler.c @@ -128,6 +128,24 @@ uint32_t smm_revision(void) return *(uint32_t *)(SMM_BASE + SMM_ENTRY_OFFSET * 2 - SMM_REVISION_OFFSET_FROM_TOP); } +void *smm_get_save_state(int cpu) +{ + switch (smm_revision()) { + case 0x00030002: + case 0x00030007: + return smm_save_state(SMM_BASE, SMM_LEGACY_ARCH_OFFSET, cpu); + case 0x00030100: + return smm_save_state(SMM_BASE, SMM_EM64T100_ARCH_OFFSET, cpu); + case 0x00030101: /* SandyBridge, IvyBridge, and Haswell */ + return smm_save_state(SMM_BASE, SMM_EM64T101_ARCH_OFFSET, cpu); + case 0x00020064: + case 0x00030064: + return smm_save_state(SMM_BASE, SMM_AMD64_ARCH_OFFSET, cpu); + } + + return NULL; +} + bool smm_region_overlaps_handler(const struct region *r) { const struct region r_smm = {SMM_BASE, SMM_DEFAULT_SIZE};