1 /* 2 * Copyright (c) 2013-2014 Wind River Systems, Inc. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/kernel.h> 8 #include <zephyr/arch/cpu.h> 9 #include <zephyr/sys/util.h> 10 #include <cmsis_core.h> 11 12 /** 13 * 14 * @brief Reset the system 15 * 16 * This routine resets the processor. 17 * 18 */ 19 sys_arch_reboot(int type)20void sys_arch_reboot(int type) 21 { 22 ARG_UNUSED(type); 23 24 /* 25 * QEMU is missing the support for rebooting through the SYSRESETREQ 26 * mechanism. Just jump back to __reset() of the image in flash, 27 * which address can _always_ be found in the vector table reset slot 28 * located at address 0x4. 29 */ 30 extern void z_do_software_reboot(void); 31 extern void z_force_exit_one_nested_irq(void); 32 /* 33 * force enable interrupts locked via PRIMASK if somehow disabled: the 34 * boot code does not enable them 35 */ 36 __asm__ volatile("cpsie i" :::); 37 38 if ((SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) == 0) { 39 z_do_software_reboot(); 40 } else { 41 __asm__ volatile( 42 "ldr r0, =z_force_exit_one_nested_irq\n\t" 43 "bx r0\n\t" 44 :::); 45 } 46 } 47