2 * linux/arch/arm/kernel/entry-v7m.S
4 * Copyright (C) 2008 ARM Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * Low-level vector interface routines for the ARMv7-M architecture
12 #include <asm/memory.h>
14 #include <asm/thread_notify.h>
17 #include "entry-header.S"
19 #ifdef CONFIG_TRACE_IRQFLAGS
20 #error "CONFIG_TRACE_IRQFLAGS not supported on the current ARMv7M implementation"
32 ENDPROC(__invalid_entry)
34 strerr: .asciz "\nUnhandled exception: IPSR = %08lx LR = %08lx\n"
41 @ Invoke the IRQ handler
44 ldr r1, =V7M_xPSR_EXCEPTIONNO
49 @ routine called with r0 = irq number, r1 = struct pt_regs *
54 @ Check for any pending work if returning to user
56 ldr r1, =BASEADDR_V7M_SCB
57 ldr r0, [r1, V7M_SCB_ICSR]
58 tst r0, V7M_SCB_ICSR_RETTOBASE
62 ldr r2, [tsk, #TI_FLAGS]
63 tst r2, #_TIF_WORK_MASK
64 beq 2f @ no work pending
65 mov r0, #V7M_SCB_ICSR_PENDSVSET
66 str r0, [r1, V7M_SCB_ICSR] @ raise PendSV
69 @ registers r0-r3 and r12 are automatically restored on exception
70 @ return. r4-r7 were not clobbered in v7m_exception_entry so for
71 @ correctness they don't need to be restored. So only r8-r11 must be
72 @ restored here. The easiest way to do so is to restore r0-r7, too.
74 add sp, #S_FRAME_SIZE-S_IP
82 ldr r1, =BASEADDR_V7M_SCB
83 mov r0, #V7M_SCB_ICSR_PENDSVCLR
84 str r0, [r1, V7M_SCB_ICSR] @ clear PendSV
86 @ execute the pending work, including reschedule
90 ENDPROC(__pendsv_entry)
93 * Register switch for ARMv7-M processors.
94 * r0 = previous task_struct, r1 = previous thread_info, r2 = next thread_info
95 * previous and next are guaranteed not to be the same.
100 add ip, r1, #TI_CPU_SAVE
101 stmia ip!, {r4 - r11} @ Store most regs on stack
105 add r4, r2, #TI_CPU_SAVE
106 ldr r0, =thread_notify_head
107 mov r1, #THREAD_NOTIFY_SWITCH
108 bl atomic_notifier_call_chain
111 ldmia ip!, {r4 - r11} @ Load all regs saved previously
120 * Vector table (64 words => 256 bytes natural alignment)
123 .long 0 @ 0 - Reset stack pointer
124 .long __invalid_entry @ 1 - Reset
125 .long __invalid_entry @ 2 - NMI
126 .long __invalid_entry @ 3 - HardFault
127 .long __invalid_entry @ 4 - MemManage
128 .long __invalid_entry @ 5 - BusFault
129 .long __invalid_entry @ 6 - UsageFault
130 .long __invalid_entry @ 7 - Reserved
131 .long __invalid_entry @ 8 - Reserved
132 .long __invalid_entry @ 9 - Reserved
133 .long __invalid_entry @ 10 - Reserved
134 .long vector_swi @ 11 - SVCall
135 .long __invalid_entry @ 12 - Debug Monitor
136 .long __invalid_entry @ 13 - Reserved
137 .long __pendsv_entry @ 14 - PendSV
138 .long __invalid_entry @ 15 - SysTick
140 .long __irq_entry @ 16..64 - External Interrupts