MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / include / asm-nios2nommu / entry.h
blob4b1773f8eda4ad4dd8a2675421c1b19587b22fe9
1 /*
2 * Hacked from m68knommu port.
4 * Copyright(C) 2004 Microtronix Datacom Ltd.
6 * All rights reserved.
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
17 * details.
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
28 #ifdef __ASSEMBLY__
30 #include <asm/setup.h>
31 #include <asm/page.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
39 * 0(sp) - r8
40 * 4(sp) - r9
41 * 8(sp) - r10
42 * C(sp) - r11
43 * 10(sp) - r12
44 * 14(sp) - r13
45 * 18(sp) - r14
46 * 1C(sp) - r15
47 * 20(sp) - r1
48 * 24(sp) - r2
49 * 28(sp) - r3
50 * 2C(sp) - r4
51 * 30(sp) - r5
52 * 34(sp) - r6
53 * 38(sp) - r7
54 * 3C(sp) - orig_r2
55 * 40(sp) - ra
56 * 44(sp) - fp
57 * 48(sp) - sp
58 * 4C(sp) - gp
59 * 50(sp) - estatus
60 * 54(sp) - status_extension
61 * 58(sp) - ea
65 /* process bits for task_struct.flags */
66 PF_TRACESYS_OFF = 3
67 PF_TRACESYS_BIT = 5
68 PF_PTRACED_OFF = 3
69 PF_PTRACED_BIT = 4
70 PF_DTRACE_OFF = 1
71 PF_DTRACE_BIT = 5
73 LENOSYS = 38
76 * This defines the normal kernel pt-regs layout.
81 * Standard Nios2 interrupt entry and exit macros.
82 * Must be called with interrupts disabled.
84 .macro SAVE_ALL
85 movia r24,status_extension // Read status extension
86 ldw r24,0(r24)
87 andi r24,r24,PS_S_ASM
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
93 mov sp,r24
94 br 2f
96 1: mov r24,sp
97 addi sp,sp,-PT_REGS_SIZE // Backup the kernel stack pointer
98 stw r24,PT_SP(sp)
99 2: stw r1,PT_R1(sp)
100 stw r2,PT_R2(sp)
101 stw r3,PT_R3(sp)
102 stw r4,PT_R4(sp)
103 stw r5,PT_R5(sp)
104 stw r6,PT_R6(sp)
105 stw r7,PT_R7(sp)
106 stw r8,PT_R8(sp)
107 stw r9,PT_R9(sp)
108 stw r10,PT_R10(sp)
109 stw r11,PT_R11(sp)
110 stw r12,PT_R12(sp)
111 stw r13,PT_R13(sp)
112 stw r14,PT_R14(sp)
113 stw r15,PT_R15(sp)
114 stw r2,PT_ORIG_R2(sp)
115 stw ra,PT_RA(sp)
116 stw fp,PT_FP(sp)
117 stw gp,PT_GP(sp)
118 rdctl r24,estatus
119 stw r24,PT_ESTATUS(sp)
120 movia r24,status_extension // Read status extension
121 ldw r1,0(r24)
122 stw r1,PT_STATUS_EXTENSION(sp) // Store user/supervisor status
123 ORI32 r1,r1,PS_S_ASM // Set supervisor mode
124 stw r1,0(r24)
125 stw ea,PT_EA(sp)
126 .endm
128 .macro RESTORE_ALL
129 ldw r1,PT_STATUS_EXTENSION(sp) // Restore user/supervisor status
130 movia r24,status_extension
131 stw r1,0(r24)
132 ldw r1,PT_R1(sp) // Restore registers
133 ldw r2,PT_R2(sp)
134 ldw r3,PT_R3(sp)
135 ldw r4,PT_R4(sp)
136 ldw r5,PT_R5(sp)
137 ldw r6,PT_R6(sp)
138 ldw r7,PT_R7(sp)
139 ldw r8,PT_R8(sp)
140 ldw r9,PT_R9(sp)
141 ldw r10,PT_R10(sp)
142 ldw r11,PT_R11(sp)
143 ldw r12,PT_R12(sp)
144 ldw r13,PT_R13(sp)
145 ldw r14,PT_R14(sp)
146 ldw r15,PT_R15(sp)
147 ldw ra,PT_RA(sp)
148 ldw fp,PT_FP(sp)
149 ldw gp,PT_GP(sp)
150 ldw r24,PT_ESTATUS(sp)
151 wrctl estatus,r24
152 ldw ea,PT_EA(sp)
153 ldw sp,PT_SP(sp) // Restore sp last
154 .endm
156 .macro SAVE_SWITCH_STACK
157 addi sp,sp,-SWITCH_STACK_SIZE
158 stw r16,SW_R16(sp)
159 stw r17,SW_R17(sp)
160 stw r18,SW_R18(sp)
161 stw r19,SW_R19(sp)
162 stw r20,SW_R20(sp)
163 stw r21,SW_R21(sp)
164 stw r22,SW_R22(sp)
165 stw r23,SW_R23(sp)
166 stw fp,SW_FP(sp)
167 stw gp,SW_GP(sp)
168 stw ra,SW_RA(sp)
169 .endm
171 .macro RESTORE_SWITCH_STACK
172 ldw r16,SW_R16(sp)
173 ldw r17,SW_R17(sp)
174 ldw r18,SW_R18(sp)
175 ldw r19,SW_R19(sp)
176 ldw r20,SW_R20(sp)
177 ldw r21,SW_R21(sp)
178 ldw r22,SW_R22(sp)
179 ldw r23,SW_R23(sp)
180 ldw fp,SW_FP(sp)
181 ldw gp,SW_GP(sp)
182 ldw ra,SW_RA(sp)
183 addi sp,sp,SWITCH_STACK_SIZE
184 .endm
186 #endif /* __ASSEMBLY__ */
187 #endif /* __NIOS2NOMMU_ENTRY_H */