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 */
54 stw r24, PT_ORIG_R2(sp)
55 stw r7, PT_ORIG_R7(sp)
61 stw r24, PT_ESTATUS(sp)
66 ldw r1, PT_R1(sp) /* Restore registers */
84 ldw r24, PT_ESTATUS(sp)
87 ldw sp, PT_SP(sp) /* Restore sp last */
90 .macro SAVE_SWITCH_STACK
91 addi sp, sp, -SWITCH_STACK_SIZE
105 .macro RESTORE_SWITCH_STACK
117 addi sp, sp, SWITCH_STACK_SIZE
120 #endif /* __ASSEMBLY__ */
121 #endif /* _ASM_NIOS2_ENTRY_H */