1/* 2 * Copyright (c) 2013-2014 Wind River Systems, Inc. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7#include <zephyr/toolchain.h> 8#include <zephyr/linker/sections.h> 9#include <zephyr/arch/cpu.h> 10#include <offsets_short.h> 11 12_ASM_FILE_PROLOGUE 13 14GDATA(z_interrupt_stacks) 15 16GTEXT(z_do_software_reboot) 17SECTION_FUNC(TEXT,z_do_software_reboot) 18 19 eors r0, r0 20 21 /* move exception table back to 0 */ 22 ldr r1, =0xe000e000 23 str r0, [r1, #0xd08] /* VTOR */ 24 25 ldr r0, [r0, #4] 26 bx r0 27 28 29GTEXT(z_force_exit_one_nested_irq) 30SECTION_FUNC(TEXT,z_force_exit_one_nested_irq) 31 32 ldr r0, =_SCS_ICSR_RETTOBASE 33 ldr r1, =_SCS_ICSR 34 ldr r1, [r1] 35 ands.w r0, r1 36 37 /* 38 * If Z flag is set, we are nested, so un-nest one level and get 39 * back to this function to unwind the next level; else, exit the 40 * last interrupt by jumping to reboot code. 41 */ 42 ittee eq 43 ldreq lr, =0xfffffff1 44 ldreq r2, =z_force_exit_one_nested_irq 45 ldrne lr, =0xfffffffd 46 ldrne r2, =z_do_software_reboot 47 48 ldr ip, =z_interrupt_stacks 49 add.w ip, ip, #(___esf_t_SIZEOF * 2) /* enough for a stack frame */ 50 ldr r1, =0xfffffffe 51 and.w r2, r1 52 str r2, [ip, #(6 * 4)] 53 ldr r2, =0x01000000 54 str r2, [ip, #(7 * 4)] 55 56 ite eq 57 moveq sp, ip 58 msrne PSP, ip 59 60 bx lr 61