Skip to content

Commit 157c5b5

Browse files
committed
change(esp_hw_support): put more code into TCM to speed up the sleep and wake-up process
1 parent c97ab13 commit 157c5b5

File tree

1 file changed

+10
-10
lines changed
  • components/esp_hw_support/lowpower/cpu_retention/port/esp32p4

1 file changed

+10
-10
lines changed

components/esp_hw_support/lowpower/cpu_retention/port/esp32p4/sleep_cpu.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ typedef struct {
8181
} retent;
8282
} sleep_cpu_retention_t;
8383

84-
static DRAM_ATTR __attribute__((unused)) sleep_cpu_retention_t s_cpu_retention;
84+
static TCM_DRAM_ATTR __attribute__((unused)) sleep_cpu_retention_t s_cpu_retention;
8585

8686
extern RvCoreCriticalSleepFrame *rv_core_critical_regs_frame[portNUM_PROCESSORS];
8787

@@ -209,7 +209,7 @@ FORCE_INLINE_ATTR void restore_mstatus(uint32_t mstatus_val)
209209
RV_WRITE_CSR(mstatus, mstatus_val);
210210
}
211211

212-
static IRAM_ATTR RvCoreNonCriticalSleepFrame * rv_core_noncritical_regs_save(void)
212+
static TCM_IRAM_ATTR RvCoreNonCriticalSleepFrame * rv_core_noncritical_regs_save(void)
213213
{
214214
RvCoreNonCriticalSleepFrame *frame = s_cpu_retention.retent.non_critical_frame[esp_cpu_get_core_id()];
215215

@@ -277,7 +277,7 @@ static IRAM_ATTR RvCoreNonCriticalSleepFrame * rv_core_noncritical_regs_save(voi
277277
return frame;
278278
}
279279

280-
static IRAM_ATTR void rv_core_noncritical_regs_restore(void)
280+
static TCM_IRAM_ATTR void rv_core_noncritical_regs_restore(void)
281281
{
282282
RvCoreNonCriticalSleepFrame *frame = s_cpu_retention.retent.non_critical_frame[esp_cpu_get_core_id()];
283283

@@ -343,7 +343,7 @@ static IRAM_ATTR void rv_core_noncritical_regs_restore(void)
343343
RV_WRITE_CSR(mcycle, frame->mcycle);
344344
}
345345

346-
static IRAM_ATTR void cpu_domain_dev_regs_save(cpu_domain_dev_sleep_frame_t *frame)
346+
static TCM_IRAM_ATTR void cpu_domain_dev_regs_save(cpu_domain_dev_sleep_frame_t *frame)
347347
{
348348
assert(frame);
349349
cpu_domain_dev_regs_region_t *region = frame->region;
@@ -357,7 +357,7 @@ static IRAM_ATTR void cpu_domain_dev_regs_save(cpu_domain_dev_sleep_frame_t *fra
357357
}
358358
}
359359

360-
static IRAM_ATTR void cpu_domain_dev_regs_restore(cpu_domain_dev_sleep_frame_t *frame)
360+
static TCM_IRAM_ATTR void cpu_domain_dev_regs_restore(cpu_domain_dev_sleep_frame_t *frame)
361361
{
362362
assert(frame);
363363
cpu_domain_dev_regs_region_t *region = frame->region;
@@ -372,12 +372,12 @@ static IRAM_ATTR void cpu_domain_dev_regs_restore(cpu_domain_dev_sleep_frame_t *
372372
}
373373

374374
#if CONFIG_PM_CHECK_SLEEP_RETENTION_FRAME
375-
static IRAM_ATTR void update_retention_frame_crc(uint32_t *frame_ptr, uint32_t frame_check_size, uint32_t *frame_crc_ptr)
375+
static TCM_IRAM_ATTR void update_retention_frame_crc(uint32_t *frame_ptr, uint32_t frame_check_size, uint32_t *frame_crc_ptr)
376376
{
377377
*(frame_crc_ptr) = esp_crc32_le(0, (void *)frame_ptr, frame_check_size);
378378
}
379379

380-
static IRAM_ATTR void validate_retention_frame_crc(uint32_t *frame_ptr, uint32_t frame_check_size, uint32_t *frame_crc_ptr)
380+
static TCM_IRAM_ATTR void validate_retention_frame_crc(uint32_t *frame_ptr, uint32_t frame_check_size, uint32_t *frame_crc_ptr)
381381
{
382382
if(*(frame_crc_ptr) != esp_crc32_le(0, (void *)(frame_ptr), frame_check_size)){
383383
// resume uarts
@@ -399,7 +399,7 @@ extern RvCoreCriticalSleepFrame * rv_core_critical_regs_save(void);
399399
extern RvCoreCriticalSleepFrame * rv_core_critical_regs_restore(void);
400400
typedef uint32_t (* sleep_cpu_entry_cb_t)(uint32_t, uint32_t, uint32_t, bool);
401401

402-
static IRAM_ATTR esp_err_t do_cpu_retention(sleep_cpu_entry_cb_t goto_sleep,
402+
static TCM_IRAM_ATTR esp_err_t do_cpu_retention(sleep_cpu_entry_cb_t goto_sleep,
403403
uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp_mem_inf_fpu, bool dslp)
404404
{
405405
uint8_t core_id = esp_cpu_get_core_id();
@@ -432,7 +432,7 @@ static IRAM_ATTR esp_err_t do_cpu_retention(sleep_cpu_entry_cb_t goto_sleep,
432432
return pmu_sleep_finish();
433433
}
434434

435-
esp_err_t IRAM_ATTR esp_sleep_cpu_retention(uint32_t (*goto_sleep)(uint32_t, uint32_t, uint32_t, bool),
435+
esp_err_t TCM_IRAM_ATTR esp_sleep_cpu_retention(uint32_t (*goto_sleep)(uint32_t, uint32_t, uint32_t, bool),
436436
uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp_mem_inf_fpu, bool dslp)
437437
{
438438
esp_sleep_execute_event_callbacks(SLEEP_EVENT_SW_CPU_TO_MEM_START, (void *)0);
@@ -572,7 +572,7 @@ static TCM_IRAM_ATTR void smp_core_do_retention(void)
572572
}
573573

574574

575-
IRAM_ATTR void esp_sleep_cpu_skip_retention(void) {
575+
TCM_IRAM_ATTR void esp_sleep_cpu_skip_retention(void) {
576576
atomic_store(&s_smp_retention_state[esp_cpu_get_core_id()], SMP_SKIP_RETENTION);
577577
}
578578
#endif

0 commit comments

Comments
 (0)