diff options
author | David S. Miller <davem@davemloft.net> | 2008-04-28 03:47:20 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-04-28 03:47:20 -0400 |
commit | 6eda3a75928a3dc1072dfffd228ab818869d83ad (patch) | |
tree | 56e44907f23134273fe383424c69df4d62c6544c /arch/sparc64/kernel/syscalls.S | |
parent | 194f1a68b93e959ede6ec363db4714e630bdbb6a (diff) |
sparc64: Split entry.S up into seperate files.
entry.S was a hodge-podge of several totally unrelated
sets of assembler routines, ranging from FPU trap handlers
to hypervisor call functions.
Split it up into topic-sized pieces.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64/kernel/syscalls.S')
-rw-r--r-- | arch/sparc64/kernel/syscalls.S | 279 |
1 files changed, 279 insertions, 0 deletions
diff --git a/arch/sparc64/kernel/syscalls.S b/arch/sparc64/kernel/syscalls.S new file mode 100644 index 000000000000..db19ed67acf6 --- /dev/null +++ b/arch/sparc64/kernel/syscalls.S | |||
@@ -0,0 +1,279 @@ | |||
1 | /* SunOS's execv() call only specifies the argv argument, the | ||
2 | * environment settings are the same as the calling processes. | ||
3 | */ | ||
4 | sys_execve: | ||
5 | sethi %hi(sparc_execve), %g1 | ||
6 | ba,pt %xcc, execve_merge | ||
7 | or %g1, %lo(sparc_execve), %g1 | ||
8 | |||
9 | #ifdef CONFIG_COMPAT | ||
10 | sunos_execv: | ||
11 | stx %g0, [%sp + PTREGS_OFF + PT_V9_I2] | ||
12 | sys32_execve: | ||
13 | sethi %hi(sparc32_execve), %g1 | ||
14 | or %g1, %lo(sparc32_execve), %g1 | ||
15 | #endif | ||
16 | |||
17 | execve_merge: | ||
18 | flushw | ||
19 | jmpl %g1, %g0 | ||
20 | add %sp, PTREGS_OFF, %o0 | ||
21 | |||
22 | .align 32 | ||
23 | sys_pipe: | ||
24 | ba,pt %xcc, sparc_pipe | ||
25 | add %sp, PTREGS_OFF, %o0 | ||
26 | sys_nis_syscall: | ||
27 | ba,pt %xcc, c_sys_nis_syscall | ||
28 | add %sp, PTREGS_OFF, %o0 | ||
29 | sys_memory_ordering: | ||
30 | ba,pt %xcc, sparc_memory_ordering | ||
31 | add %sp, PTREGS_OFF, %o1 | ||
32 | sys_sigaltstack: | ||
33 | ba,pt %xcc, do_sigaltstack | ||
34 | add %i6, STACK_BIAS, %o2 | ||
35 | #ifdef CONFIG_COMPAT | ||
36 | sys32_sigstack: | ||
37 | ba,pt %xcc, do_sys32_sigstack | ||
38 | mov %i6, %o2 | ||
39 | sys32_sigaltstack: | ||
40 | ba,pt %xcc, do_sys32_sigaltstack | ||
41 | mov %i6, %o2 | ||
42 | #endif | ||
43 | .align 32 | ||
44 | #ifdef CONFIG_COMPAT | ||
45 | sys32_sigreturn: | ||
46 | add %sp, PTREGS_OFF, %o0 | ||
47 | call do_sigreturn32 | ||
48 | add %o7, 1f-.-4, %o7 | ||
49 | nop | ||
50 | #endif | ||
51 | sys_rt_sigreturn: | ||
52 | add %sp, PTREGS_OFF, %o0 | ||
53 | call do_rt_sigreturn | ||
54 | add %o7, 1f-.-4, %o7 | ||
55 | nop | ||
56 | #ifdef CONFIG_COMPAT | ||
57 | sys32_rt_sigreturn: | ||
58 | add %sp, PTREGS_OFF, %o0 | ||
59 | call do_rt_sigreturn32 | ||
60 | add %o7, 1f-.-4, %o7 | ||
61 | nop | ||
62 | #endif | ||
63 | .align 32 | ||
64 | 1: ldx [%g6 + TI_FLAGS], %l5 | ||
65 | andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0 | ||
66 | be,pt %icc, rtrap | ||
67 | nop | ||
68 | add %sp, PTREGS_OFF, %o0 | ||
69 | call syscall_trace | ||
70 | mov 1, %o1 | ||
71 | ba,pt %xcc, rtrap | ||
72 | nop | ||
73 | |||
74 | /* This is how fork() was meant to be done, 8 instruction entry. | ||
75 | * | ||
76 | * I questioned the following code briefly, let me clear things | ||
77 | * up so you must not reason on it like I did. | ||
78 | * | ||
79 | * Know the fork_kpsr etc. we use in the sparc32 port? We don't | ||
80 | * need it here because the only piece of window state we copy to | ||
81 | * the child is the CWP register. Even if the parent sleeps, | ||
82 | * we are safe because we stuck it into pt_regs of the parent | ||
83 | * so it will not change. | ||
84 | * | ||
85 | * XXX This raises the question, whether we can do the same on | ||
86 | * XXX sparc32 to get rid of fork_kpsr _and_ fork_kwim. The | ||
87 | * XXX answer is yes. We stick fork_kpsr in UREG_G0 and | ||
88 | * XXX fork_kwim in UREG_G1 (global registers are considered | ||
89 | * XXX volatile across a system call in the sparc ABI I think | ||
90 | * XXX if it isn't we can use regs->y instead, anyone who depends | ||
91 | * XXX upon the Y register being preserved across a fork deserves | ||
92 | * XXX to lose). | ||
93 | * | ||
94 | * In fact we should take advantage of that fact for other things | ||
95 | * during system calls... | ||
96 | */ | ||
97 | .align 32 | ||
98 | sys_vfork: /* Under Linux, vfork and fork are just special cases of clone. */ | ||
99 | sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0 | ||
100 | or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0 | ||
101 | ba,pt %xcc, sys_clone | ||
102 | sys_fork: | ||
103 | clr %o1 | ||
104 | mov SIGCHLD, %o0 | ||
105 | sys_clone: | ||
106 | flushw | ||
107 | movrz %o1, %fp, %o1 | ||
108 | mov 0, %o3 | ||
109 | ba,pt %xcc, sparc_do_fork | ||
110 | add %sp, PTREGS_OFF, %o2 | ||
111 | |||
112 | .globl ret_from_syscall | ||
113 | ret_from_syscall: | ||
114 | /* Clear current_thread_info()->new_child, and | ||
115 | * check performance counter stuff too. | ||
116 | */ | ||
117 | stb %g0, [%g6 + TI_NEW_CHILD] | ||
118 | ldx [%g6 + TI_FLAGS], %l0 | ||
119 | call schedule_tail | ||
120 | mov %g7, %o0 | ||
121 | andcc %l0, _TIF_PERFCTR, %g0 | ||
122 | be,pt %icc, 1f | ||
123 | nop | ||
124 | ldx [%g6 + TI_PCR], %o7 | ||
125 | wr %g0, %o7, %pcr | ||
126 | |||
127 | /* Blackbird errata workaround. See commentary in | ||
128 | * smp.c:smp_percpu_timer_interrupt() for more | ||
129 | * information. | ||
130 | */ | ||
131 | ba,pt %xcc, 99f | ||
132 | nop | ||
133 | |||
134 | .align 64 | ||
135 | 99: wr %g0, %g0, %pic | ||
136 | rd %pic, %g0 | ||
137 | |||
138 | 1: ba,pt %xcc, ret_sys_call | ||
139 | ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0 | ||
140 | |||
141 | .globl sparc_exit | ||
142 | .type sparc_exit,#function | ||
143 | sparc_exit: | ||
144 | rdpr %pstate, %g2 | ||
145 | wrpr %g2, PSTATE_IE, %pstate | ||
146 | rdpr %otherwin, %g1 | ||
147 | rdpr %cansave, %g3 | ||
148 | add %g3, %g1, %g3 | ||
149 | wrpr %g3, 0x0, %cansave | ||
150 | wrpr %g0, 0x0, %otherwin | ||
151 | wrpr %g2, 0x0, %pstate | ||
152 | ba,pt %xcc, sys_exit | ||
153 | stb %g0, [%g6 + TI_WSAVED] | ||
154 | .size sparc_exit,.-sparc_exit | ||
155 | |||
156 | linux_sparc_ni_syscall: | ||
157 | sethi %hi(sys_ni_syscall), %l7 | ||
158 | ba,pt %xcc, 4f | ||
159 | or %l7, %lo(sys_ni_syscall), %l7 | ||
160 | |||
161 | linux_syscall_trace32: | ||
162 | add %sp, PTREGS_OFF, %o0 | ||
163 | call syscall_trace | ||
164 | clr %o1 | ||
165 | srl %i0, 0, %o0 | ||
166 | srl %i4, 0, %o4 | ||
167 | srl %i1, 0, %o1 | ||
168 | srl %i2, 0, %o2 | ||
169 | ba,pt %xcc, 2f | ||
170 | srl %i3, 0, %o3 | ||
171 | |||
172 | linux_syscall_trace: | ||
173 | add %sp, PTREGS_OFF, %o0 | ||
174 | call syscall_trace | ||
175 | clr %o1 | ||
176 | mov %i0, %o0 | ||
177 | mov %i1, %o1 | ||
178 | mov %i2, %o2 | ||
179 | mov %i3, %o3 | ||
180 | b,pt %xcc, 2f | ||
181 | mov %i4, %o4 | ||
182 | |||
183 | |||
184 | /* Linux 32-bit system calls enter here... */ | ||
185 | .align 32 | ||
186 | .globl linux_sparc_syscall32 | ||
187 | linux_sparc_syscall32: | ||
188 | /* Direct access to user regs, much faster. */ | ||
189 | cmp %g1, NR_SYSCALLS ! IEU1 Group | ||
190 | bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI | ||
191 | srl %i0, 0, %o0 ! IEU0 | ||
192 | sll %g1, 2, %l4 ! IEU0 Group | ||
193 | srl %i4, 0, %o4 ! IEU1 | ||
194 | lduw [%l7 + %l4], %l7 ! Load | ||
195 | srl %i1, 0, %o1 ! IEU0 Group | ||
196 | ldx [%g6 + TI_FLAGS], %l0 ! Load | ||
197 | |||
198 | srl %i5, 0, %o5 ! IEU1 | ||
199 | srl %i2, 0, %o2 ! IEU0 Group | ||
200 | andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0 | ||
201 | bne,pn %icc, linux_syscall_trace32 ! CTI | ||
202 | mov %i0, %l5 ! IEU1 | ||
203 | call %l7 ! CTI Group brk forced | ||
204 | srl %i3, 0, %o3 ! IEU0 | ||
205 | ba,a,pt %xcc, 3f | ||
206 | |||
207 | /* Linux native system calls enter here... */ | ||
208 | .align 32 | ||
209 | .globl linux_sparc_syscall | ||
210 | linux_sparc_syscall: | ||
211 | /* Direct access to user regs, much faster. */ | ||
212 | cmp %g1, NR_SYSCALLS ! IEU1 Group | ||
213 | bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI | ||
214 | mov %i0, %o0 ! IEU0 | ||
215 | sll %g1, 2, %l4 ! IEU0 Group | ||
216 | mov %i1, %o1 ! IEU1 | ||
217 | lduw [%l7 + %l4], %l7 ! Load | ||
218 | 4: mov %i2, %o2 ! IEU0 Group | ||
219 | ldx [%g6 + TI_FLAGS], %l0 ! Load | ||
220 | |||
221 | mov %i3, %o3 ! IEU1 | ||
222 | mov %i4, %o4 ! IEU0 Group | ||
223 | andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0 | ||
224 | bne,pn %icc, linux_syscall_trace ! CTI Group | ||
225 | mov %i0, %l5 ! IEU0 | ||
226 | 2: call %l7 ! CTI Group brk forced | ||
227 | mov %i5, %o5 ! IEU0 | ||
228 | nop | ||
229 | |||
230 | 3: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0] | ||
231 | ret_sys_call: | ||
232 | ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3 | ||
233 | ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc | ||
234 | sra %o0, 0, %o0 | ||
235 | mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2 | ||
236 | sllx %g2, 32, %g2 | ||
237 | |||
238 | /* Check if force_successful_syscall_return() | ||
239 | * was invoked. | ||
240 | */ | ||
241 | ldub [%g6 + TI_SYS_NOERROR], %l2 | ||
242 | brnz,a,pn %l2, 80f | ||
243 | stb %g0, [%g6 + TI_SYS_NOERROR] | ||
244 | |||
245 | cmp %o0, -ERESTART_RESTARTBLOCK | ||
246 | bgeu,pn %xcc, 1f | ||
247 | andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6 | ||
248 | 80: | ||
249 | /* System call success, clear Carry condition code. */ | ||
250 | andn %g3, %g2, %g3 | ||
251 | stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE] | ||
252 | bne,pn %icc, linux_syscall_trace2 | ||
253 | add %l1, 0x4, %l2 ! npc = npc+4 | ||
254 | stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] | ||
255 | ba,pt %xcc, rtrap | ||
256 | stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] | ||
257 | |||
258 | 1: | ||
259 | /* System call failure, set Carry condition code. | ||
260 | * Also, get abs(errno) to return to the process. | ||
261 | */ | ||
262 | andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6 | ||
263 | sub %g0, %o0, %o0 | ||
264 | or %g3, %g2, %g3 | ||
265 | stx %o0, [%sp + PTREGS_OFF + PT_V9_I0] | ||
266 | stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE] | ||
267 | bne,pn %icc, linux_syscall_trace2 | ||
268 | add %l1, 0x4, %l2 ! npc = npc+4 | ||
269 | stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] | ||
270 | |||
271 | b,pt %xcc, rtrap | ||
272 | stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] | ||
273 | linux_syscall_trace2: | ||
274 | add %sp, PTREGS_OFF, %o0 | ||
275 | call syscall_trace | ||
276 | mov 1, %o1 | ||
277 | stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] | ||
278 | ba,pt %xcc, rtrap | ||
279 | stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] | ||