aboutsummaryrefslogtreecommitdiffstats
path: root/arch/parisc/hpux/wrappers.S
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/parisc/hpux/wrappers.S
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/parisc/hpux/wrappers.S')
-rw-r--r--arch/parisc/hpux/wrappers.S257
1 files changed, 257 insertions, 0 deletions
diff --git a/arch/parisc/hpux/wrappers.S b/arch/parisc/hpux/wrappers.S
new file mode 100644
index 000000000000..1aa936dfe147
--- /dev/null
+++ b/arch/parisc/hpux/wrappers.S
@@ -0,0 +1,257 @@
1/*
2 * Linux/PARISC Project (http://www.parisc-linux.org/)
3 *
4 * HP-UX System Call Wrapper routines and System Call Return Path
5 *
6 * Copyright (C) 2000 Hewlett-Packard (John Marvin)
7 *
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, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#ifdef __LP64__
24#warning PA64 support needs more work...did first cut
25#endif
26
27#include <asm/offsets.h>
28#include <asm/assembly.h>
29#include <asm/signal.h>
30
31#ifdef __LP64__
32 .level 2.0w
33#else
34 .level 1.1
35#endif
36 .text
37
38 /* These should probably go in a header file somewhere.
39 * They are duplicated in kernel/wrappers.S
40 * Possibly we should consider consolidating these
41 * register save/restore macros.
42 */
43 .macro reg_save regs
44#ifdef __LP64__
45#warning NEEDS WORK for 64-bit
46#endif
47 STREG %r3, PT_GR3(\regs)
48 STREG %r4, PT_GR4(\regs)
49 STREG %r5, PT_GR5(\regs)
50 STREG %r6, PT_GR6(\regs)
51 STREG %r7, PT_GR7(\regs)
52 STREG %r8, PT_GR8(\regs)
53 STREG %r9, PT_GR9(\regs)
54 STREG %r10,PT_GR10(\regs)
55 STREG %r11,PT_GR11(\regs)
56 STREG %r12,PT_GR12(\regs)
57 STREG %r13,PT_GR13(\regs)
58 STREG %r14,PT_GR14(\regs)
59 STREG %r15,PT_GR15(\regs)
60 STREG %r16,PT_GR16(\regs)
61 STREG %r17,PT_GR17(\regs)
62 STREG %r18,PT_GR18(\regs)
63 .endm
64
65 .macro reg_restore regs
66 LDREG PT_GR3(\regs), %r3
67 LDREG PT_GR4(\regs), %r4
68 LDREG PT_GR5(\regs), %r5
69 LDREG PT_GR6(\regs), %r6
70 LDREG PT_GR7(\regs), %r7
71 LDREG PT_GR8(\regs), %r8
72 LDREG PT_GR9(\regs), %r9
73 LDREG PT_GR10(\regs),%r10
74 LDREG PT_GR11(\regs),%r11
75 LDREG PT_GR12(\regs),%r12
76 LDREG PT_GR13(\regs),%r13
77 LDREG PT_GR14(\regs),%r14
78 LDREG PT_GR15(\regs),%r15
79 LDREG PT_GR16(\regs),%r16
80 LDREG PT_GR17(\regs),%r17
81 LDREG PT_GR18(\regs),%r18
82 .endm
83
84
85 .export hpux_fork_wrapper
86 .export hpux_child_return
87 .import sys_fork
88
89hpux_fork_wrapper:
90 ldo TASK_REGS-TASK_SZ_ALGN-64(%r30),%r1 ;! get pt regs
91 ;! pointer in task
92 reg_save %r1
93
94 STREG %r2,-20(%r30)
95 ldo 64(%r30),%r30
96 STREG %r2,PT_GR19(%r1) ;! save for child
97 STREG %r30,PT_GR21(%r1) ;! save for child
98
99 LDREG PT_GR30(%r1),%r25
100 mtctl %r25,%cr29
101 copy %r1,%r24
102 bl sys_clone,%r2
103 ldi SIGCHLD,%r26
104
105 LDREG -84(%r30),%r2
106fork_return:
107 ldo -64(%r30),%r30
108 ldo TASK_REGS-TASK_SZ_ALGN-64(%r30),%r1 ;! get pt regs
109
110 reg_restore %r1
111
112 /*
113 * HP-UX wants pid (child gets parent pid, parent gets child pid)
114 * in r28 and a flag in r29 (r29 == 1 for child, 0 for parent).
115 * Linux fork returns 0 for child, pid for parent. Since HP-UX
116 * libc stub throws away parent pid and returns 0 for child,
117 * we'll just return 0 for parent pid now. Only applications
118 * that jump directly to the gateway page (not supported) will
119 * know the difference. We can fix this later if necessary.
120 */
121
122 ldo -1024(%r0),%r1
123 comb,>>=,n %r28,%r1,fork_exit /* just let the syscall exit handle it */
124 or,= %r28,%r0,%r0
125 or,tr %r0,%r0,%r29 /* r28 <> 0, we are parent, set r29 to 0 */
126 ldo 1(%r0),%r29 /* r28 == 0, we are child, set r29 to 1 */
127
128fork_exit:
129 bv %r0(%r2)
130 nop
131
132 /* Set the return value for the child */
133
134hpux_child_return:
135#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
136 bl schedule_tail, %r2
137 nop
138#endif
139
140 LDREG TASK_PT_GR19-TASK_SZ_ALGN-128(%r30),%r2
141 b fork_return
142 copy %r0,%r28
143
144 .export hpux_execve_wrapper
145 .export hpux_execv_wrapper
146 .import hpux_execve
147
148hpux_execv_wrapper:
149 copy %r0,%r24 /* NULL environment */
150
151hpux_execve_wrapper:
152
153 ldo TASK_REGS-TASK_SZ_ALGN-64(%r30),%r1 ;! get pt regs
154
155 /*
156 * Do we need to save/restore r3-r18 here?
157 * I don't think so. why would new thread need old
158 * threads registers?
159 */
160
161 /* Store arg0, arg1 and arg2 so that hpux_execve will find them */
162
163 STREG %r26,PT_GR26(%r1)
164 STREG %r25,PT_GR25(%r1)
165 STREG %r24,PT_GR24(%r1)
166
167 STREG %r2,-20(%r30)
168 ldo 64(%r30),%r30
169 bl hpux_execve,%r2
170 copy %r1,%arg0
171
172 ldo -64(%r30),%r30
173 LDREG -20(%r30),%r2
174
175 /* If exec succeeded we need to load the args */
176
177 ldo -1024(%r0),%r1
178 comb,>>= %r28,%r1,exec_error
179 copy %r2,%r19
180 ldo -TASK_SZ_ALGN-64(%r30),%r1 ;! get task ptr
181 LDREG TASK_PT_GR26(%r1),%r26
182 LDREG TASK_PT_GR25(%r1),%r25
183 LDREG TASK_PT_GR24(%r1),%r24
184 LDREG TASK_PT_GR23(%r1),%r23
185 copy %r0,%r2 /* Flag to syscall_exit not to clear args */
186
187exec_error:
188 bv %r0(%r19)
189 nop
190
191 .export hpux_pipe_wrapper
192 .import hpux_pipe
193
194 /* HP-UX expects pipefd's returned in r28 & r29 */
195
196hpux_pipe_wrapper:
197 STREG %r2,-20(%r30)
198 ldo 64(%r30),%r30
199 bl hpux_pipe,%r2
200 ldo -56(%r30),%r26 /* pass local array to hpux_pipe */
201
202
203 ldo -1024(%r0),%r1
204 comb,>>= %r28,%r1,pipe_exit /* let syscall exit handle it */
205 LDREG -84(%r30),%r2
206
207 /* if success, load fd's from stack array */
208
209 LDREG -56(%r30),%r28
210 LDREG -52(%r30),%r29
211
212pipe_exit:
213 bv %r0(%r2)
214 ldo -64(%r30),%r30
215
216 .export hpux_syscall_exit
217 .import syscall_exit
218
219hpux_syscall_exit:
220
221 /*
222 *
223 * HP-UX call return conventions:
224 *
225 * if error:
226 * r22 = 1
227 * r28 = errno value
228 * r29 = secondary return value
229 * else
230 * r22 = 0
231 * r28 = return value
232 * r29 = secondary return value
233 *
234 * For now, we'll just check to see if r28 is < (unsigned long)-1024
235 * (to handle addresses > 2 Gb) and if so set r22 to zero. If not,
236 * we'll complement r28 and set r22 to 1. Wrappers will be
237 * needed for syscalls that care about the secondary return value.
238 * The wrapper may also need a way of avoiding the following code,
239 * but we'll deal with that when it becomes necessary.
240 */
241
242 ldo -1024(%r0),%r1
243 comb,<< %r28,%r1,no_error
244 copy %r0,%r22
245 subi 0,%r28,%r28
246 ldo 1(%r0),%r22
247
248no_error:
249 b syscall_exit
250 nop
251
252 .export hpux_unimplemented_wrapper
253 .import hpux_unimplemented
254
255hpux_unimplemented_wrapper:
256 b hpux_unimplemented
257 STREG %r22,-64(%r30) /* overwrite arg8 with syscall number */