2 * Hacked from m68knommu port.
4 * Copyright(C) 2004 Microtronix Datacom Ltd.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
16 * NON INFRINGEMENT. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #ifndef __NIOS2NOMMU_ENTRY_H
26 #define __NIOS2NOMMU_ENTRY_H
30 #include <asm/setup.h>
32 #include <asm/asm-offsets.h>
35 * Stack layout in 'ret_from_exception':
37 * This allows access to the syscall arguments in registers r4-r8
60 * 54(sp) - status_extension
65 /* process bits for task_struct.flags */
76 * This defines the normal kernel pt-regs layout.
81 * Standard Nios2 interrupt entry and exit macros.
82 * Must be called with interrupts disabled.
85 movia r24
,status_extension
// Read status extension
88 bne r24
,r0
,1f
// In supervisor mode, already on kernel stack
89 movia r24
,_current_thread
// Switch to current kernel stack
90 ldw r24
,0(r24
) // using the thread_info
91 addi r24
,r24
,THREAD_SIZE_ASM
-PT_REGS_SIZE
92 stw sp
,PT_SP(r24
) // Save user stack before changing
97 addi sp
,sp
,-PT_REGS_SIZE
// Backup the kernel stack pointer
114 stw r2
,PT_ORIG_R2(sp
)
119 stw r24
,PT_ESTATUS(sp
)
120 movia r24
,status_extension
// Read status extension
122 stw r1
,PT_STATUS_EXTENSION(sp
) // Store user/supervisor status
123 ORI32 r1
,r1
,PS_S_ASM
// Set supervisor mode
129 ldw r1
,PT_STATUS_EXTENSION(sp
) // Restore user/supervisor status
130 movia r24
,status_extension
132 ldw r1
,PT_R1(sp
) // Restore registers
150 ldw r24
,PT_ESTATUS(sp
)
153 ldw sp
,PT_SP(sp
) // Restore sp last
156 .macro SAVE_SWITCH_STACK
157 addi sp
,sp
,-SWITCH_STACK_SIZE
171 .macro RESTORE_SWITCH_STACK
183 addi sp
,sp
,SWITCH_STACK_SIZE
186 #endif /* __ASSEMBLY__ */
187 #endif /* __NIOS2NOMMU_ENTRY_H */