1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/arch/arm/kernel/entry-v7m.S
5 * Copyright (C) 2008 ARM Ltd.
7 * Low-level vector interface routines for the ARMv7-M architecture
9 #include <asm/memory.h>
11 #include <asm/thread_notify.h>
14 #include "entry-header.S"
16 #ifdef CONFIG_TRACE_IRQFLAGS
17 #error "CONFIG_TRACE_IRQFLAGS not supported on the current ARMv7M implementation"
31 ENDPROC(__invalid_entry)
33 strerr: .asciz "\nUnhandled exception: IPSR = %08lx LR = %08lx\n"
40 @ Invoke the IRQ handler
43 ldr r1, =V7M_xPSR_EXCEPTIONNO
48 @ routine called with r0 = irq number, r1 = struct pt_regs *
53 @ Check for any pending work if returning to user
55 ldr r1, =BASEADDR_V7M_SCB
56 ldr r0, [r1, V7M_SCB_ICSR]
57 tst r0, V7M_SCB_ICSR_RETTOBASE
61 ldr r2, [tsk, #TI_FLAGS]
62 tst r2, #_TIF_WORK_MASK
63 beq 2f @ no work pending
64 mov r0, #V7M_SCB_ICSR_PENDSVSET
65 str r0, [r1, V7M_SCB_ICSR] @ raise PendSV
68 @ registers r0-r3 and r12 are automatically restored on exception
69 @ return. r4-r7 were not clobbered in v7m_exception_entry so for
70 @ correctness they don't need to be restored. So only r8-r11 must be
71 @ restored here. The easiest way to do so is to restore r0-r7, too.
73 add sp, #PT_REGS_SIZE-S_IP
81 ldr r1, =BASEADDR_V7M_SCB
82 mov r0, #V7M_SCB_ICSR_PENDSVCLR
83 str r0, [r1, V7M_SCB_ICSR] @ clear PendSV
85 @ execute the pending work, including reschedule
88 b ret_to_user_from_irq
89 ENDPROC(__pendsv_entry)
92 * Register switch for ARMv7-M processors.
93 * r0 = previous task_struct, r1 = previous thread_info, r2 = next thread_info
94 * previous and next are guaranteed not to be the same.
99 add ip, r1, #TI_CPU_SAVE
100 stmia ip!, {r4 - r11} @ Store most regs on stack
104 add r4, r2, #TI_CPU_SAVE
105 ldr r0, =thread_notify_head
106 mov r1, #THREAD_NOTIFY_SWITCH
107 bl atomic_notifier_call_chain
110 ldmia ip!, {r4 - r11} @ Load all regs saved previously
117 #if CONFIG_CPU_V7M_NUM_IRQ <= 112
124 * Vector table (Natural alignment need to be ensured)
127 .long 0 @ 0 - Reset stack pointer
128 .long __invalid_entry @ 1 - Reset
129 .long __invalid_entry @ 2 - NMI
130 .long __invalid_entry @ 3 - HardFault
131 .long __invalid_entry @ 4 - MemManage
132 .long __invalid_entry @ 5 - BusFault
133 .long __invalid_entry @ 6 - UsageFault
134 .long __invalid_entry @ 7 - Reserved
135 .long __invalid_entry @ 8 - Reserved
136 .long __invalid_entry @ 9 - Reserved
137 .long __invalid_entry @ 10 - Reserved
138 .long vector_swi @ 11 - SVCall
139 .long __invalid_entry @ 12 - Debug Monitor
140 .long __invalid_entry @ 13 - Reserved
141 .long __pendsv_entry @ 14 - PendSV
142 .long __invalid_entry @ 15 - SysTick
143 .rept CONFIG_CPU_V7M_NUM_IRQ
144 .long __irq_entry @ External Interrupts