diff --git a/include/rthw.h b/include/rthw.h index 672e820918..2298fcbeb4 100644 --- a/include/rthw.h +++ b/include/rthw.h @@ -90,8 +90,9 @@ void rt_hw_cpu_dcache_ops(int ops, void* addr, int size); #endif void rt_hw_cpu_reset(void); +void rt_hw_cpu_reset_hook(void); void rt_hw_cpu_shutdown(void); - +void rt_hw_cpu_shutdown_hook(void); const char *rt_hw_cpu_arch(void); rt_uint8_t *rt_hw_stack_init(void *entry, diff --git a/libcpu/arm/cortex-m4/cpuport.c b/libcpu/arm/cortex-m4/cpuport.c index 9504008e36..c19408a6d2 100644 --- a/libcpu/arm/cortex-m4/cpuport.c +++ b/libcpu/arm/cortex-m4/cpuport.c @@ -433,6 +433,8 @@ void rt_hw_hard_fault_exception(struct exception_info *exception_info) */ void rt_hw_cpu_reset(void) { + rt_kprintf("Reset ...\n"); + rt_hw_cpu_reset_hook(); SCB_AIRCR = SCB_RESET_VALUE; } diff --git a/src/kservice.c b/src/kservice.c index ee03b5af5a..9971112897 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -69,18 +69,30 @@ rt_weak void rt_hw_us_delay(rt_uint32_t us) "Please consider implementing rt_hw_us_delay() in another file."); } +rt_weak void rt_hw_cpu_reset_hook(void) +{ + ; +} + rt_weak void rt_hw_cpu_reset(void) { LOG_W("rt_hw_cpu_reset() doesn't support for this board." "Please consider implementing rt_hw_cpu_reset() in another file."); + rt_hw_cpu_reset_hook(); return; } +rt_weak void rt_hw_cpu_shutdown_hook(void) +{ + ; +} + rt_weak void rt_hw_cpu_shutdown(void) { LOG_I("CPU shutdown..."); LOG_W("Using default rt_hw_cpu_shutdown()." "Please consider implementing rt_hw_cpu_shutdown() in another file."); + rt_hw_cpu_shutdown_hook(); rt_hw_interrupt_disable(); RT_ASSERT(0); return;