mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
change(mem): deprecated tcm and added scp memory utils
This commit is contained in:
@@ -710,8 +710,8 @@ esp_err_t dma2d_set_desc_addr(dma2d_channel_handle_t dma2d_chan, intptr_t desc_b
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
ESP_GOTO_ON_FALSE_ISR(dma2d_chan && desc_base_addr, ESP_ERR_INVALID_ARG, err, TAG, "invalid argument");
|
||||
// 2D-DMA descriptor addr needs 8-byte alignment and not in TCM (addr not in TCM is IDF restriction)
|
||||
ESP_GOTO_ON_FALSE_ISR((desc_base_addr & 0x7) == 0 && !esp_ptr_in_tcm((void *)desc_base_addr), ESP_ERR_INVALID_ARG, err, TAG, "invalid argument");
|
||||
// 2D-DMA descriptor addr needs 8-byte alignment and not in SCP (addr not in SCP is IDF restriction)
|
||||
ESP_GOTO_ON_FALSE_ISR((desc_base_addr & 0x7) == 0 && !esp_ptr_in_scp((void *)desc_base_addr), ESP_ERR_INVALID_ARG, err, TAG, "invalid argument");
|
||||
|
||||
dma2d_group_t *group = dma2d_chan->group;
|
||||
int channel_id = dma2d_chan->channel_id;
|
||||
|
||||
@@ -52,8 +52,8 @@ bool esp_ptr_byte_accessible(const void *p)
|
||||
intptr_t ip = (intptr_t) p;
|
||||
bool r;
|
||||
r = (ip >= SOC_BYTE_ACCESSIBLE_LOW && ip < SOC_BYTE_ACCESSIBLE_HIGH);
|
||||
#if SOC_MEM_TCM_SUPPORTED
|
||||
r |= esp_ptr_in_tcm(p);
|
||||
#if SOC_MEM_SCP_SUPPORTED
|
||||
r |= esp_ptr_in_scp(p);
|
||||
#endif
|
||||
#if CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP
|
||||
/* For ESP32 case, RTC fast memory is accessible to PRO cpu only and hence
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2010-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2010-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -196,19 +196,31 @@ inline static void * esp_ptr_diram_iram_to_dram(const void *p) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if SOC_MEM_TCM_SUPPORTED
|
||||
#if SOC_MEM_SCP_SUPPORTED
|
||||
/**
|
||||
* @brief Check if the pointer is in TCM
|
||||
* @brief Check if the pointer is in TCM (SCP)
|
||||
*
|
||||
* @param p pointer
|
||||
*
|
||||
* @return true: is in TCM; false: not in TCM
|
||||
* @return true: is in TCM (SCP); false: not in TCM (SCP)
|
||||
*/
|
||||
__attribute__((always_inline))
|
||||
__attribute__((always_inline, deprecated("esp_ptr_in_tcm is deprecated, please use esp_ptr_in_scp instead")))
|
||||
inline static bool esp_ptr_in_tcm(const void *p) {
|
||||
return ((intptr_t)p >= SOC_TCM_LOW && (intptr_t)p < SOC_TCM_HIGH);
|
||||
return ((intptr_t)p >= SOC_SCP_LOW && (intptr_t)p < SOC_SCP_HIGH);
|
||||
}
|
||||
#endif //#if SOC_MEM_TCM_SUPPORTED
|
||||
|
||||
/**
|
||||
* @brief Check if the pointer is in SCP
|
||||
*
|
||||
* @param p pointer
|
||||
*
|
||||
* @return true: is in SCP; false: not in SCP
|
||||
*/
|
||||
__attribute__((always_inline))
|
||||
inline static bool esp_ptr_in_scp(const void *p) {
|
||||
return ((intptr_t)p >= SOC_SCP_LOW && (intptr_t)p < SOC_SCP_HIGH);
|
||||
}
|
||||
#endif //#if SOC_MEM_SCP_SUPPORTED
|
||||
|
||||
/** End of common functions to be kept in sync with bootloader_memory_utils.h **/
|
||||
/** Add app-specific functions below **/
|
||||
@@ -278,8 +290,8 @@ inline static bool esp_ptr_internal(const void *p) {
|
||||
bool r;
|
||||
r = ((intptr_t)p >= SOC_MEM_INTERNAL_LOW && (intptr_t)p < SOC_MEM_INTERNAL_HIGH);
|
||||
|
||||
#if SOC_MEM_TCM_SUPPORTED
|
||||
r |= esp_ptr_in_tcm(p);
|
||||
#if SOC_MEM_SCP_SUPPORTED
|
||||
r |= esp_ptr_in_scp(p);
|
||||
#endif
|
||||
|
||||
#if SOC_RTC_SLOW_MEM_SUPPORTED
|
||||
|
||||
@@ -52,7 +52,7 @@ typedef enum {
|
||||
SMP_SKIP_RETENTION,
|
||||
} smp_retention_state_t;
|
||||
|
||||
static TCM_DRAM_ATTR smp_retention_state_t s_smp_retention_state[portNUM_PROCESSORS];
|
||||
static SPM_DRAM_ATTR smp_retention_state_t s_smp_retention_state[portNUM_PROCESSORS];
|
||||
#endif
|
||||
|
||||
static bool s_fpu_saved[portNUM_PROCESSORS];
|
||||
@@ -81,7 +81,7 @@ typedef struct {
|
||||
} retent;
|
||||
} sleep_cpu_retention_t;
|
||||
|
||||
static TCM_DRAM_ATTR __attribute__((unused)) sleep_cpu_retention_t s_cpu_retention;
|
||||
static SPM_DRAM_ATTR __attribute__((unused)) sleep_cpu_retention_t s_cpu_retention;
|
||||
|
||||
extern RvCoreCriticalSleepFrame *rv_core_critical_regs_frame[portNUM_PROCESSORS];
|
||||
|
||||
@@ -189,7 +189,7 @@ FORCE_INLINE_ATTR void restore_mstatus(uint32_t mstatus_val)
|
||||
RV_WRITE_CSR(mstatus, mstatus_val);
|
||||
}
|
||||
|
||||
static TCM_IRAM_ATTR RvCoreNonCriticalSleepFrame * rv_core_noncritical_regs_save(void)
|
||||
static SPM_IRAM_ATTR RvCoreNonCriticalSleepFrame * rv_core_noncritical_regs_save(void)
|
||||
{
|
||||
RvCoreNonCriticalSleepFrame *frame = s_cpu_retention.retent.non_critical_frame[esp_cpu_get_core_id()];
|
||||
|
||||
@@ -258,7 +258,7 @@ static TCM_IRAM_ATTR RvCoreNonCriticalSleepFrame * rv_core_noncritical_regs_save
|
||||
return frame;
|
||||
}
|
||||
|
||||
static TCM_IRAM_ATTR void rv_core_noncritical_regs_restore(void)
|
||||
static SPM_IRAM_ATTR void rv_core_noncritical_regs_restore(void)
|
||||
{
|
||||
RvCoreNonCriticalSleepFrame *frame = s_cpu_retention.retent.non_critical_frame[esp_cpu_get_core_id()];
|
||||
|
||||
@@ -325,7 +325,7 @@ static TCM_IRAM_ATTR void rv_core_noncritical_regs_restore(void)
|
||||
RV_WRITE_CSR(mcycle, frame->mcycle);
|
||||
}
|
||||
|
||||
static TCM_IRAM_ATTR void cpu_domain_dev_regs_save(cpu_domain_dev_sleep_frame_t *frame)
|
||||
static SPM_IRAM_ATTR void cpu_domain_dev_regs_save(cpu_domain_dev_sleep_frame_t *frame)
|
||||
{
|
||||
assert(frame);
|
||||
cpu_domain_dev_regs_region_t *region = frame->region;
|
||||
@@ -339,7 +339,7 @@ static TCM_IRAM_ATTR void cpu_domain_dev_regs_save(cpu_domain_dev_sleep_frame_t
|
||||
}
|
||||
}
|
||||
|
||||
static TCM_IRAM_ATTR void cpu_domain_dev_regs_restore(cpu_domain_dev_sleep_frame_t *frame)
|
||||
static SPM_IRAM_ATTR void cpu_domain_dev_regs_restore(cpu_domain_dev_sleep_frame_t *frame)
|
||||
{
|
||||
assert(frame);
|
||||
cpu_domain_dev_regs_region_t *region = frame->region;
|
||||
@@ -354,12 +354,12 @@ static TCM_IRAM_ATTR void cpu_domain_dev_regs_restore(cpu_domain_dev_sleep_frame
|
||||
}
|
||||
|
||||
#if CONFIG_PM_CHECK_SLEEP_RETENTION_FRAME
|
||||
static TCM_IRAM_ATTR void update_retention_frame_crc(uint32_t *frame_ptr, uint32_t frame_check_size, uint32_t *frame_crc_ptr)
|
||||
static SPM_IRAM_ATTR void update_retention_frame_crc(uint32_t *frame_ptr, uint32_t frame_check_size, uint32_t *frame_crc_ptr)
|
||||
{
|
||||
*(frame_crc_ptr) = esp_rom_crc32_le(0, (void *)frame_ptr, frame_check_size);
|
||||
}
|
||||
|
||||
static TCM_IRAM_ATTR void validate_retention_frame_crc(uint32_t *frame_ptr, uint32_t frame_check_size, uint32_t *frame_crc_ptr)
|
||||
static SPM_IRAM_ATTR void validate_retention_frame_crc(uint32_t *frame_ptr, uint32_t frame_check_size, uint32_t *frame_crc_ptr)
|
||||
{
|
||||
if(*(frame_crc_ptr) != esp_rom_crc32_le(0, (void *)(frame_ptr), frame_check_size)){
|
||||
// resume uarts
|
||||
@@ -383,7 +383,7 @@ extern void rv_core_fpu_save(RvCoreCriticalSleepFrame *frame);
|
||||
extern void rv_core_fpu_restore(RvCoreCriticalSleepFrame *frame);
|
||||
typedef uint32_t (* sleep_cpu_entry_cb_t)(uint32_t, uint32_t, uint32_t, bool);
|
||||
|
||||
static TCM_IRAM_ATTR esp_err_t do_cpu_retention(sleep_cpu_entry_cb_t goto_sleep,
|
||||
static SPM_IRAM_ATTR esp_err_t do_cpu_retention(sleep_cpu_entry_cb_t goto_sleep,
|
||||
uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp_mem_inf_fpu, bool dslp)
|
||||
{
|
||||
uint8_t core_id = esp_cpu_get_core_id();
|
||||
@@ -428,7 +428,7 @@ static TCM_IRAM_ATTR esp_err_t do_cpu_retention(sleep_cpu_entry_cb_t goto_sleep,
|
||||
return pmu_sleep_finish(dslp);
|
||||
}
|
||||
|
||||
esp_err_t TCM_IRAM_ATTR esp_sleep_cpu_retention(uint32_t (*goto_sleep)(uint32_t, uint32_t, uint32_t, bool),
|
||||
esp_err_t SPM_IRAM_ATTR esp_sleep_cpu_retention(uint32_t (*goto_sleep)(uint32_t, uint32_t, uint32_t, bool),
|
||||
uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp_mem_inf_fpu, bool dslp)
|
||||
{
|
||||
esp_sleep_execute_event_callbacks(SLEEP_EVENT_SW_CPU_TO_MEM_START, (void *)0);
|
||||
@@ -507,7 +507,7 @@ esp_err_t sleep_cpu_configure(bool light_sleep_enable)
|
||||
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
#if ESP_SLEEP_POWER_DOWN_CPU
|
||||
static TCM_IRAM_ATTR void smp_core_do_retention(void)
|
||||
static SPM_IRAM_ATTR void smp_core_do_retention(void)
|
||||
{
|
||||
uint8_t core_id = esp_cpu_get_core_id();
|
||||
|
||||
@@ -576,7 +576,7 @@ static TCM_IRAM_ATTR void smp_core_do_retention(void)
|
||||
}
|
||||
|
||||
|
||||
TCM_IRAM_ATTR void esp_sleep_cpu_skip_retention(void) {
|
||||
SPM_IRAM_ATTR void esp_sleep_cpu_skip_retention(void) {
|
||||
atomic_store(&s_smp_retention_state[esp_cpu_get_core_id()], SMP_SKIP_RETENTION);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#define MTVT (0x307)
|
||||
#define MINTTHRESH (0x347)
|
||||
|
||||
.section .tcm.data,"aw"
|
||||
.section .scp.data,"aw"
|
||||
.global rv_core_critical_regs_frame
|
||||
.type rv_core_critical_regs_frame,@object
|
||||
.align 4
|
||||
@@ -33,7 +33,7 @@ rv_core_critical_regs_frame:
|
||||
--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
.section .tcm.text,"ax"
|
||||
.section .scp.text,"ax"
|
||||
.global rv_core_critical_regs_save
|
||||
.type rv_core_critical_regs_save,@function
|
||||
.align 4
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -47,12 +47,12 @@ static void esp_cpu_configure_invalid_regions(void)
|
||||
// 0. Gap at bottom of address space
|
||||
PMA_RESET_AND_ENTRY_SET_NAPOT(0, 0, SOC_CPU_SUBSYSTEM_LOW, PMA_NAPOT | PMA_NONE);
|
||||
|
||||
// 1. Gap between CPU subsystem region & HP TCM
|
||||
// 1. Gap between CPU subsystem region & HP SCP
|
||||
PMA_RESET_AND_ENTRY_SET_TOR(1, SOC_CPU_SUBSYSTEM_HIGH, PMA_NONE);
|
||||
PMA_RESET_AND_ENTRY_SET_TOR(2, SOC_TCM_LOW, PMA_TOR | PMA_NONE);
|
||||
PMA_RESET_AND_ENTRY_SET_TOR(2, SOC_SCP_LOW, PMA_TOR | PMA_NONE);
|
||||
|
||||
// 2. Gap between HP TCM and CPU Peripherals
|
||||
PMA_RESET_AND_ENTRY_SET_TOR(3, SOC_TCM_HIGH, PMA_NONE);
|
||||
// 2. Gap between HP SCP and CPU Peripherals
|
||||
PMA_RESET_AND_ENTRY_SET_TOR(3, SOC_SCP_HIGH, PMA_NONE);
|
||||
PMA_RESET_AND_ENTRY_SET_TOR(4, CPU_PERIPH_LOW, PMA_TOR | PMA_NONE);
|
||||
|
||||
// 3. Gap between CPU Peripherals and I_Cache
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -37,13 +37,13 @@ typedef struct {
|
||||
const pmu_lp_system_analog_param_t *analog;
|
||||
} pmu_lp_system_param_t;
|
||||
|
||||
pmu_context_t * __attribute__((weak)) TCM_IRAM_ATTR PMU_instance(void)
|
||||
pmu_context_t * __attribute__((weak)) SPM_IRAM_ATTR PMU_instance(void)
|
||||
{
|
||||
/* It should be explicitly defined in the internal RAM, because this
|
||||
* instance will be used in pmu_sleep.c */
|
||||
static TCM_DRAM_ATTR pmu_hal_context_t pmu_hal = { .dev = &PMU };
|
||||
static TCM_DRAM_ATTR pmu_sleep_machine_constant_t pmu_mc = PMU_SLEEP_MC_DEFAULT();
|
||||
static TCM_DRAM_ATTR pmu_context_t pmu_context = { .hal = &pmu_hal, .mc = (void *)&pmu_mc };
|
||||
static SPM_DRAM_ATTR pmu_hal_context_t pmu_hal = { .dev = &PMU };
|
||||
static SPM_DRAM_ATTR pmu_sleep_machine_constant_t pmu_mc = PMU_SLEEP_MC_DEFAULT();
|
||||
static SPM_DRAM_ATTR pmu_context_t pmu_context = { .hal = &pmu_hal, .mc = (void *)&pmu_mc };
|
||||
return &pmu_context;
|
||||
}
|
||||
|
||||
|
||||
@@ -371,10 +371,10 @@ FORCE_INLINE_ATTR void pmu_sleep_cache_sync_items(uint32_t gid, uint32_t type, u
|
||||
;
|
||||
}
|
||||
|
||||
static TCM_DRAM_ATTR uint32_t s_mpll_freq_mhz_before_sleep = 0;
|
||||
static SPM_DRAM_ATTR uint32_t s_mpll_freq_mhz_before_sleep = 0;
|
||||
|
||||
__attribute__((optimize("-O2")))
|
||||
TCM_IRAM_ATTR uint32_t pmu_sleep_start(uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp_mem_inf_fpu, bool dslp)
|
||||
SPM_IRAM_ATTR uint32_t pmu_sleep_start(uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp_mem_inf_fpu, bool dslp)
|
||||
{
|
||||
lp_aon_hal_inform_wakeup_type(dslp);
|
||||
|
||||
@@ -452,7 +452,7 @@ TCM_IRAM_ATTR uint32_t pmu_sleep_start(uint32_t wakeup_opt, uint32_t reject_opt,
|
||||
return pmu_sleep_finish(dslp);
|
||||
}
|
||||
|
||||
TCM_IRAM_ATTR bool pmu_sleep_finish(bool dslp)
|
||||
SPM_IRAM_ATTR bool pmu_sleep_finish(bool dslp)
|
||||
{
|
||||
if (dslp) {
|
||||
pmu_ll_hp_set_dcm_vset(&PMU, PMU_MODE_HP_ACTIVE, HP_CALI_ACTIVE_DCM_VSET_DEFAULT);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -28,7 +28,7 @@ static const char *TAG = "rtc_clk";
|
||||
static int s_cur_cpll_freq = 0;
|
||||
|
||||
// MPLL frequency option, 400MHz. Zero if MPLL is not enabled.
|
||||
static TCM_DRAM_ATTR uint32_t s_cur_mpll_freq = 0;
|
||||
static SPM_DRAM_ATTR uint32_t s_cur_mpll_freq = 0;
|
||||
|
||||
void rtc_clk_32k_enable(bool enable)
|
||||
{
|
||||
@@ -631,13 +631,13 @@ bool rtc_dig_8m_enabled(void)
|
||||
}
|
||||
|
||||
//------------------------------------MPLL-------------------------------------//
|
||||
TCM_IRAM_ATTR void rtc_clk_mpll_disable(void)
|
||||
SPM_IRAM_ATTR void rtc_clk_mpll_disable(void)
|
||||
{
|
||||
clk_ll_mpll_disable();
|
||||
s_cur_mpll_freq = 0;
|
||||
}
|
||||
|
||||
TCM_IRAM_ATTR void rtc_clk_mpll_enable(void)
|
||||
SPM_IRAM_ATTR void rtc_clk_mpll_enable(void)
|
||||
{
|
||||
clk_ll_mpll_enable();
|
||||
}
|
||||
@@ -662,7 +662,7 @@ void rtc_clk_mpll_configure(uint32_t xtal_freq, uint32_t mpll_freq, bool thread_
|
||||
s_cur_mpll_freq = mpll_freq;
|
||||
}
|
||||
|
||||
TCM_IRAM_ATTR uint32_t rtc_clk_mpll_get_freq(void)
|
||||
SPM_IRAM_ATTR uint32_t rtc_clk_mpll_get_freq(void)
|
||||
{
|
||||
return s_cur_mpll_freq;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user