From 190a7e7b1ea7caa9bd57dfaad50499d361367a7c Mon Sep 17 00:00:00 2001 From: Tim Lin Date: Fri, 7 Nov 2025 10:26:40 +0800 Subject: [PATCH] it8xxx2: add support for putting switch.S in ram code section Get better performance from executing z_riscv_switch() function. Signed-off-by: Tim Lin --- soc/ite/ec/it8xxx2/Kconfig | 7 +++++++ soc/ite/ec/it8xxx2/linker.ld | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/soc/ite/ec/it8xxx2/Kconfig b/soc/ite/ec/it8xxx2/Kconfig index 5531371682b57..c08ee93b74b99 100644 --- a/soc/ite/ec/it8xxx2/Kconfig +++ b/soc/ite/ec/it8xxx2/Kconfig @@ -216,6 +216,13 @@ config SOC_IT8XXX2_LIBRARY_TO_RAM If this is selected it means that there is a library that needs to be excluded from the text section. +config SOC_IT8XXX2_SWITCH_IN_RAM + bool "Place switch handling code in RAM" + select SOC_IT8XXX2_USE_ILM + select SOC_IT8XXX2_LIBRARY_TO_RAM + help + Place content switching code in ILM for better performance. + config SOC_IT8XXX2_SERIAL_IN_RAM bool "Place serial handling code in RAM" select SOC_IT8XXX2_USE_ILM diff --git a/soc/ite/ec/it8xxx2/linker.ld b/soc/ite/ec/it8xxx2/linker.ld index 179934eb852a7..111135137d7f7 100644 --- a/soc/ite/ec/it8xxx2/linker.ld +++ b/soc/ite/ec/it8xxx2/linker.ld @@ -173,6 +173,9 @@ SECTIONS #ifdef CONFIG_SOC_IT8XXX2_LIBRARY_TO_RAM *(EXCLUDE_FILE ( #endif +#ifdef CONFIG_SOC_IT8XXX2_SWITCH_IN_RAM + *libarch__riscv__core.a:* +#endif #ifdef CONFIG_SOC_IT8XXX2_SERIAL_IN_RAM *libdrivers__serial.a:* #endif @@ -191,6 +194,9 @@ SECTIONS #ifdef CONFIG_SOC_IT8XXX2_LIBRARY_TO_RAM *(EXCLUDE_FILE ( #endif +#ifdef CONFIG_SOC_IT8XXX2_SWITCH_IN_RAM + *libarch__riscv__core.a:* +#endif #ifdef CONFIG_SOC_IT8XXX2_SERIAL_IN_RAM *libdrivers__serial.a:* #endif @@ -227,6 +233,9 @@ SECTIONS KEEP(*(".exception.entry.*")) *(".exception.other.*") #endif +#ifdef CONFIG_SOC_IT8XXX2_SWITCH_IN_RAM + *libarch__riscv__core.a:*(.text .text.*) +#endif #ifdef CONFIG_SOC_IT8XXX2_SERIAL_IN_RAM *libdrivers__serial.a:*(.text .text.*) *libdrivers__serial.a:*(.rodata .rodata.*)