2015-09-29 03:53:04 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-09-29 03:53:04 +08:00
|
|
|
*/
|
|
|
|
|
2023-01-24 20:16:23 +08:00
|
|
|
#include <zephyr/cache.h>
|
2022-05-06 17:23:05 +08:00
|
|
|
#include <zephyr/drivers/timer/system_timer.h>
|
|
|
|
#include <zephyr/sys/reboot.h>
|
|
|
|
#include <zephyr/kernel.h>
|
|
|
|
#include <zephyr/sys/printk.h>
|
2015-09-29 03:53:04 +08:00
|
|
|
|
|
|
|
extern void sys_arch_reboot(int type);
|
|
|
|
|
2021-08-11 19:43:31 +08:00
|
|
|
FUNC_NORETURN void sys_reboot(int type)
|
2015-09-29 03:53:04 +08:00
|
|
|
{
|
|
|
|
(void)irq_lock();
|
2023-01-18 15:38:21 +08:00
|
|
|
|
|
|
|
/* Disable caches to ensure all data is flushed */
|
|
|
|
#if defined(CONFIG_ARCH_CACHE)
|
|
|
|
#if defined(CONFIG_DCACHE)
|
|
|
|
sys_cache_data_disable();
|
|
|
|
#endif /* CONFIG_DCACHE */
|
|
|
|
|
|
|
|
#if defined(CONFIG_ICACHE)
|
|
|
|
sys_cache_instr_disable();
|
|
|
|
#endif /* CONFIG_ICACHE */
|
|
|
|
#endif /* CONFIG_ARCH_CACHE */
|
|
|
|
|
2022-12-20 21:24:40 +08:00
|
|
|
if (IS_ENABLED(CONFIG_SYSTEM_TIMER_HAS_DISABLE_SUPPORT)) {
|
|
|
|
sys_clock_disable();
|
|
|
|
}
|
2015-09-29 03:53:04 +08:00
|
|
|
|
|
|
|
sys_arch_reboot(type);
|
|
|
|
|
|
|
|
/* should never get here */
|
|
|
|
printk("Failed to reboot: spinning endlessly...\n");
|
|
|
|
for (;;) {
|
2016-12-15 02:04:36 +08:00
|
|
|
k_cpu_idle();
|
2015-09-29 03:53:04 +08:00
|
|
|
}
|
|
|
|
}
|