2 * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
3 * Copyright (C) 2004 Microtronix Datacom Ltd.
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
10 #ifndef _ASM_NIOS2_ENTRY_H
11 #define _ASM_NIOS2_ENTRY_H
15 #include <asm/processor.h>
16 #include <asm/registers.h>
17 #include <asm/asm-offsets.h>
20 * Standard Nios2 interrupt entry and exit macros.
21 * Must be called with interrupts disabled.
25 andi r24
, r24
, ESTATUS_EU
26 beq r24
, r0
, 1f
/* In supervisor mode, already on kernel stack */
28 movia r24
, _current_thread
/* Switch to current kernel stack */
29 ldw r24
, 0(r24
) /* using the thread_info */
30 addi r24
, r24
, THREAD_SIZE
-PT_REGS_SIZE
31 stw sp
, PT_SP(r24
) /* Save user stack before changing */
36 addi sp
, sp
, -PT_REGS_SIZE
/* Backup the kernel stack pointer */
53 stw r2
, PT_ORIG_R2(sp
)
54 stw r7
, PT_ORIG_R7(sp
)
60 stw r24
, PT_ESTATUS(sp
)
65 ldw r1
, PT_R1(sp
) /* Restore registers */
83 ldw r24
, PT_ESTATUS(sp
)
86 ldw sp
, PT_SP(sp
) /* Restore sp last */
89 .macro SAVE_SWITCH_STACK
90 addi sp
, sp
, -SWITCH_STACK_SIZE
104 .macro RESTORE_SWITCH_STACK
116 addi sp
, sp
, SWITCH_STACK_SIZE
119 #endif /* __ASSEMBLY__ */
120 #endif /* _ASM_NIOS2_ENTRY_H */