Felix Held has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/50463 )
Change subject: soc/amd: move southbridge_smi_handler to common code ......................................................................
soc/amd: move southbridge_smi_handler to common code
Signed-off-by: Felix Held felix-coreboot@felixheld.de Change-Id: I650498321736eee3d33af51216eda1b650f11744 --- M src/soc/amd/cezanne/smihandler.c M src/soc/amd/common/block/cpu/smm/Makefile.inc A src/soc/amd/common/block/cpu/smm/smi_handler.c M src/soc/amd/common/block/include/amdblocks/smm.h M src/soc/amd/picasso/smihandler.c M src/soc/amd/stoneyridge/smihandler.c 6 files changed, 61 insertions(+), 92 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/63/50463/1
diff --git a/src/soc/amd/cezanne/smihandler.c b/src/soc/amd/cezanne/smihandler.c index 2d9e487..b941293 100644 --- a/src/soc/amd/cezanne/smihandler.c +++ b/src/soc/amd/cezanne/smihandler.c @@ -1,7 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */
-#include <cpu/x86/smm.h> +#include <amdblocks/smm.h>
-void southbridge_smi_handler(void) +void *get_smi_source_handler(int source) { + return NULL; } diff --git a/src/soc/amd/common/block/cpu/smm/Makefile.inc b/src/soc/amd/common/block/cpu/smm/Makefile.inc index 0639890..c881522 100644 --- a/src/soc/amd/common/block/cpu/smm/Makefile.inc +++ b/src/soc/amd/common/block/cpu/smm/Makefile.inc @@ -1,5 +1,6 @@ ifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_SMM),y)
ramstage-y += smm_relocate.c +smm-y += smi_handler.c
endif # CONFIG_SOC_AMD_COMMON_BLOCK_SMM diff --git a/src/soc/amd/common/block/cpu/smm/smi_handler.c b/src/soc/amd/common/block/cpu/smm/smi_handler.c new file mode 100644 index 0000000..00c03f0 --- /dev/null +++ b/src/soc/amd/common/block/cpu/smm/smi_handler.c @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include <amdblocks/acpimmio.h> +#include <amdblocks/smi.h> +#include <amdblocks/smm.h> +#include <cpu/x86/smm.h> +#include <soc/smi.h> + +static void process_smi_sources(uint32_t reg) +{ + const uint32_t status = smi_read32(reg); + int bit_zero = 32 / sizeof(uint32_t) * (reg - SMI_REG_SMISTS0); + void (*source_handler)(void); + int i; + + for (i = 0 ; i < 32 ; i++) { + if (status & (1 << i)) { + source_handler = get_smi_source_handler(i + bit_zero); + if (source_handler) + source_handler(); + } + } + + if (reg == SMI_REG_SMISTS0) + if (status & GEVENT_MASK) + /* Gevent[23:0] are assumed to be mainboard-specific */ + mainboard_smi_gpi(status & GEVENT_MASK); + + /* Clear all events in this register */ + smi_write32(reg, status); +} + +void southbridge_smi_handler(void) +{ + const uint16_t smi_src = smi_read16(SMI_REG_POINTER); + + if (smi_src & SMI_STATUS_SRC_SCI) + /* Clear events to prevent re-entering SMI if event isn't handled */ + clear_smi_sci_status(); + if (smi_src & SMI_STATUS_SRC_0) + process_smi_sources(SMI_REG_SMISTS0); + if (smi_src & SMI_STATUS_SRC_1) + process_smi_sources(SMI_REG_SMISTS1); + if (smi_src & SMI_STATUS_SRC_2) + process_smi_sources(SMI_REG_SMISTS2); + if (smi_src & SMI_STATUS_SRC_3) + process_smi_sources(SMI_REG_SMISTS3); + if (smi_src & SMI_STATUS_SRC_4) + process_smi_sources(SMI_REG_SMISTS4); +} diff --git a/src/soc/amd/common/block/include/amdblocks/smm.h b/src/soc/amd/common/block/include/amdblocks/smm.h index 0fbef42..637f034 100644 --- a/src/soc/amd/common/block/include/amdblocks/smm.h +++ b/src/soc/amd/common/block/include/amdblocks/smm.h @@ -10,3 +10,4 @@
void get_smm_info(uintptr_t *perm_smbase, size_t *perm_smsize, size_t *smm_save_state_size); void smm_relocation_handler(int cpu, uintptr_t curr_smbase, uintptr_t staggered_smbase); +void *get_smi_source_handler(int source); diff --git a/src/soc/amd/picasso/smihandler.c b/src/soc/amd/picasso/smihandler.c index 626daad..77bdaea 100644 --- a/src/soc/amd/picasso/smihandler.c +++ b/src/soc/amd/picasso/smihandler.c @@ -15,6 +15,7 @@ #include <amdblocks/acpi.h> #include <amdblocks/psp.h> #include <amdblocks/smi.h> +#include <amdblocks/smm.h> #include <elog.h> #include <soc/smu.h>
@@ -222,7 +223,7 @@ { .type = SMITYPE_SLP_TYP, .handler = sb_slp_typ_handler}, };
-static void *get_source_handler(int source) +void *get_smi_source_handler(int source) { int i;
@@ -231,47 +232,4 @@ return smi_sources[i].handler;
return NULL; -} - -static void process_smi_sources(uint32_t reg) -{ - const uint32_t status = smi_read32(reg); - int bit_zero = 32 / sizeof(uint32_t) * (reg - SMI_REG_SMISTS0); - void (*source_handler)(void); - int i; - - for (i = 0 ; i < 32 ; i++) { - if (status & (1 << i)) { - source_handler = get_source_handler(i + bit_zero); - if (source_handler) - source_handler(); - } - } - - if (reg == SMI_REG_SMISTS0) - if (status & GEVENT_MASK) - /* Gevent[23:0] are assumed to be mainboard-specific */ - mainboard_smi_gpi(status & GEVENT_MASK); - - /* Clear all events in this register */ - smi_write32(reg, status); -} - -void southbridge_smi_handler(void) -{ - const uint16_t smi_src = smi_read16(SMI_REG_POINTER); - - if (smi_src & SMI_STATUS_SRC_SCI) - /* Clear events to prevent re-entering SMI if event isn't handled */ - clear_smi_sci_status(); - if (smi_src & SMI_STATUS_SRC_0) - process_smi_sources(SMI_REG_SMISTS0); - if (smi_src & SMI_STATUS_SRC_1) - process_smi_sources(SMI_REG_SMISTS1); - if (smi_src & SMI_STATUS_SRC_2) - process_smi_sources(SMI_REG_SMISTS2); - if (smi_src & SMI_STATUS_SRC_3) - process_smi_sources(SMI_REG_SMISTS3); - if (smi_src & SMI_STATUS_SRC_4) - process_smi_sources(SMI_REG_SMISTS4); -} +} \ No newline at end of file diff --git a/src/soc/amd/stoneyridge/smihandler.c b/src/soc/amd/stoneyridge/smihandler.c index ffcbaea..ca0f792 100644 --- a/src/soc/amd/stoneyridge/smihandler.c +++ b/src/soc/amd/stoneyridge/smihandler.c @@ -14,6 +14,7 @@ #include <amdblocks/acpimmio.h> #include <amdblocks/acpi.h> #include <amdblocks/smi.h> +#include <amdblocks/smm.h> #include <elog.h>
/* bits in smm_io_trap */ @@ -217,7 +218,7 @@ { .type = SMITYPE_SLP_TYP, .handler = sb_slp_typ_handler}, };
-static void *get_source_handler(int source) +void *get_smi_source_handler(int source) { int i;
@@ -226,47 +227,4 @@ return smi_sources[i].handler;
return NULL; -} - -static void process_smi_sources(uint32_t reg) -{ - const uint32_t status = smi_read32(reg); - int bit_zero = 32 / sizeof(uint32_t) * (reg - SMI_REG_SMISTS0); - void (*source_handler)(void); - int i; - - for (i = 0 ; i < 32 ; i++) { - if (status & (1 << i)) { - source_handler = get_source_handler(i + bit_zero); - if (source_handler) - source_handler(); - } - } - - if (reg == SMI_REG_SMISTS0) - if (status & GEVENT_MASK) - /* Gevent[23:0] are assumed to be mainboard-specific */ - mainboard_smi_gpi(status & GEVENT_MASK); - - /* Clear all events in this register */ - smi_write32(reg, status); -} - -void southbridge_smi_handler(void) -{ - const uint16_t smi_src = smi_read16(SMI_REG_POINTER); - - if (smi_src & SMI_STATUS_SRC_SCI) - /* Clear events to prevent re-entering SMI if event isn't handled */ - clear_smi_sci_status(); - if (smi_src & SMI_STATUS_SRC_0) - process_smi_sources(SMI_REG_SMISTS0); - if (smi_src & SMI_STATUS_SRC_1) - process_smi_sources(SMI_REG_SMISTS1); - if (smi_src & SMI_STATUS_SRC_2) - process_smi_sources(SMI_REG_SMISTS2); - if (smi_src & SMI_STATUS_SRC_3) - process_smi_sources(SMI_REG_SMISTS3); - if (smi_src & SMI_STATUS_SRC_4) - process_smi_sources(SMI_REG_SMISTS4); -} +} \ No newline at end of file