1 /* 2 * Copyright (c) 2015 Wind River Systems, Inc. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/cache.h> 8 #include <zephyr/drivers/timer/system_timer.h> 9 #include <zephyr/sys/reboot.h> 10 #include <zephyr/kernel.h> 11 #include <zephyr/sys/printk.h> 12 13 extern void sys_arch_reboot(int type); 14 sys_reboot(int type)15FUNC_NORETURN void sys_reboot(int type) 16 { 17 (void)irq_lock(); 18 19 /* Disable caches to ensure all data is flushed */ 20 #if defined(CONFIG_ARCH_CACHE) 21 #if defined(CONFIG_DCACHE) 22 sys_cache_data_disable(); 23 #endif /* CONFIG_DCACHE */ 24 25 #if defined(CONFIG_ICACHE) 26 sys_cache_instr_disable(); 27 #endif /* CONFIG_ICACHE */ 28 #endif /* CONFIG_ARCH_CACHE */ 29 30 if (IS_ENABLED(CONFIG_SYSTEM_TIMER_HAS_DISABLE_SUPPORT)) { 31 sys_clock_disable(); 32 } 33 34 sys_arch_reboot(type); 35 36 /* should never get here */ 37 printk("Failed to reboot: spinning endlessly...\n"); 38 for (;;) { 39 k_cpu_idle(); 40 } 41 } 42