Merge with Linux 2.5.59.
[linux-2.6/linux-mips.git] / arch / alpha / kernel / entry.S
blobc21786dfff32a0b1c3cca6acbba5166fe661c6fd
1 /*
2  * arch/alpha/kernel/entry.S
3  *
4  * Kernel entry-points.
5  */
7 #include <linux/config.h>
8 #include <asm/asm_offsets.h>
9 #include <asm/thread_info.h>
10 #include <asm/pal.h>
11 #include <asm/errno.h>
12 #include <asm/unistd.h>
14         .text
15         .set noat
17 /* Stack offsets.  */
18 #define SP_OFF                  184
19 #define SWITCH_STACK_SIZE       320
22  * This defines the normal kernel pt-regs layout.
23  *
24  * regs 9-15 preserved by C code
25  * regs 16-18 saved by PAL-code
26  * regs 29-30 saved and set up by PAL-code
27  * JRP - Save regs 16-18 in a special area of the stack, so that
28  * the palcode-provided values are available to the signal handler.
29  */
31 #define SAVE_ALL                        \
32         subq    $sp, SP_OFF, $sp;       \
33         stq     $0, 0($sp);             \
34         stq     $1, 8($sp);             \
35         stq     $2, 16($sp);            \
36         stq     $3, 24($sp);            \
37         stq     $4, 32($sp);            \
38         stq     $28, 144($sp);          \
39         lda     $2, alpha_mv;           \
40         stq     $5, 40($sp);            \
41         stq     $6, 48($sp);            \
42         stq     $7, 56($sp);            \
43         stq     $8, 64($sp);            \
44         stq     $19, 72($sp);           \
45         stq     $20, 80($sp);           \
46         stq     $21, 88($sp);           \
47         ldq     $2, HAE_CACHE($2);      \
48         stq     $22, 96($sp);           \
49         stq     $23, 104($sp);          \
50         stq     $24, 112($sp);          \
51         stq     $25, 120($sp);          \
52         stq     $26, 128($sp);          \
53         stq     $27, 136($sp);          \
54         stq     $2, 152($sp);           \
55         stq     $16, 160($sp);          \
56         stq     $17, 168($sp);          \
57         stq     $18, 176($sp)
59 #define RESTORE_ALL                     \
60         lda     $19, alpha_mv;          \
61         ldq     $0, 0($sp);             \
62         ldq     $1, 8($sp);             \
63         ldq     $2, 16($sp);            \
64         ldq     $3, 24($sp);            \
65         ldq     $21, 152($sp);          \
66         ldq     $20, HAE_CACHE($19);    \
67         ldq     $4, 32($sp);            \
68         ldq     $5, 40($sp);            \
69         ldq     $6, 48($sp);            \
70         ldq     $7, 56($sp);            \
71         subq    $20, $21, $20;          \
72         ldq     $8, 64($sp);            \
73         beq     $20, 99f;               \
74         ldq     $20, HAE_REG($19);      \
75         stq     $21, HAE_CACHE($19);    \
76         stq     $21, 0($20);            \
77         ldq     $0, 0($sp);             \
78         ldq     $1, 8($sp);             \
79 99:;                                    \
80         ldq     $19, 72($sp);           \
81         ldq     $20, 80($sp);           \
82         ldq     $21, 88($sp);           \
83         ldq     $22, 96($sp);           \
84         ldq     $23, 104($sp);          \
85         ldq     $24, 112($sp);          \
86         ldq     $25, 120($sp);          \
87         ldq     $26, 128($sp);          \
88         ldq     $27, 136($sp);          \
89         ldq     $28, 144($sp);          \
90         addq    $sp, SP_OFF, $sp
93  * Non-syscall kernel entry points.
94  */
96         .align  4
97         .globl  entInt
98         .ent    entInt
99 entInt:
100         SAVE_ALL
101         lda     $8, 0x3fff
102         lda     $26, ret_from_sys_call
103         bic     $sp, $8, $8
104         mov     $sp, $19
105         jsr     $31, do_entInt
106 .end entInt
108         .align  4
109         .globl  entArith
110         .ent    entArith
111 entArith:
112         SAVE_ALL
113         lda     $8, 0x3fff
114         lda     $26, ret_from_sys_call
115         bic     $sp, $8, $8
116         mov     $sp, $18
117         jsr     $31, do_entArith
118 .end entArith
120         .align  4
121         .globl  entMM
122         .ent    entMM
123 entMM:
124         SAVE_ALL
125 /* save $9 - $15 so the inline exception code can manipulate them.  */
126         subq    $sp, 56, $sp
127         stq     $9, 0($sp)
128         stq     $10, 8($sp)
129         stq     $11, 16($sp)
130         stq     $12, 24($sp)
131         stq     $13, 32($sp)
132         stq     $14, 40($sp)
133         stq     $15, 48($sp)
134         addq    $sp, 56, $19
135 /* handle the fault */
136         lda     $8, 0x3fff
137         bic     $sp, $8, $8
138         jsr     $26, do_page_fault
139 /* reload the registers after the exception code played.  */
140         ldq     $9, 0($sp)
141         ldq     $10, 8($sp)
142         ldq     $11, 16($sp)
143         ldq     $12, 24($sp)
144         ldq     $13, 32($sp)
145         ldq     $14, 40($sp)
146         ldq     $15, 48($sp)
147         addq    $sp, 56, $sp
148 /* finish up the syscall as normal.  */
149         br      ret_from_sys_call
150 .end entMM
152         .align  4
153         .globl  entIF
154         .ent    entIF
155 entIF:
156         SAVE_ALL
157         lda     $8, 0x3fff
158         lda     $26, ret_from_sys_call
159         bic     $sp, $8, $8
160         mov     $sp, $17
161         jsr     $31, do_entIF
162 .end entIF
164         .align  4
165         .globl  entUna
166         .ent    entUna
167 entUna:
168         lda     $sp, -256($sp)
169         stq     $0, 0($sp)
170         ldq     $0, 256($sp)    /* get PS */
171         stq     $1, 8($sp)
172         stq     $2, 16($sp)
173         stq     $3, 24($sp)
174         and     $0, 8, $0               /* user mode? */
175         stq     $4, 32($sp)
176         bne     $0, entUnaUser  /* yup -> do user-level unaligned fault */
177         stq     $5, 40($sp)
178         stq     $6, 48($sp)
179         stq     $7, 56($sp)
180         stq     $8, 64($sp)
181         stq     $9, 72($sp)
182         stq     $10, 80($sp)
183         stq     $11, 88($sp)
184         stq     $12, 96($sp)
185         stq     $13, 104($sp)
186         stq     $14, 112($sp)
187         stq     $15, 120($sp)
188         /* 16-18 PAL-saved */
189         stq     $19, 152($sp)
190         stq     $20, 160($sp)
191         stq     $21, 168($sp)
192         stq     $22, 176($sp)
193         stq     $23, 184($sp)
194         stq     $24, 192($sp)
195         stq     $25, 200($sp)
196         stq     $26, 208($sp)
197         stq     $27, 216($sp)
198         stq     $28, 224($sp)
199         stq     $gp, 232($sp)
200         lda     $8, 0x3fff
201         stq     $31, 248($sp)
202         bic     $sp, $8, $8
203         jsr     $26, do_entUna
204         ldq     $0, 0($sp)
205         ldq     $1, 8($sp)
206         ldq     $2, 16($sp)
207         ldq     $3, 24($sp)
208         ldq     $4, 32($sp)
209         ldq     $5, 40($sp)
210         ldq     $6, 48($sp)
211         ldq     $7, 56($sp)
212         ldq     $8, 64($sp)
213         ldq     $9, 72($sp)
214         ldq     $10, 80($sp)
215         ldq     $11, 88($sp)
216         ldq     $12, 96($sp)
217         ldq     $13, 104($sp)
218         ldq     $14, 112($sp)
219         ldq     $15, 120($sp)
220         /* 16-18 PAL-saved */
221         ldq     $19, 152($sp)
222         ldq     $20, 160($sp)
223         ldq     $21, 168($sp)
224         ldq     $22, 176($sp)
225         ldq     $23, 184($sp)
226         ldq     $24, 192($sp)
227         ldq     $25, 200($sp)
228         ldq     $26, 208($sp)
229         ldq     $27, 216($sp)
230         ldq     $28, 224($sp)
231         ldq     $gp, 232($sp)
232         lda     $sp, 256($sp)
233         call_pal PAL_rti
234 .end entUna
236         .align  4
237         .ent    entUnaUser
238 entUnaUser:
239         ldq     $0, 0($sp)      /* restore original $0 */
240         lda     $sp, 256($sp)   /* pop entUna's stack frame */
241         SAVE_ALL                /* setup normal kernel stack */
242         lda     $sp, -56($sp)
243         stq     $9, 0($sp)
244         stq     $10, 8($sp)
245         stq     $11, 16($sp)
246         stq     $12, 24($sp)
247         stq     $13, 32($sp)
248         stq     $14, 40($sp)
249         stq     $15, 48($sp)
250         lda     $8, 0x3fff
251         addq    $sp, 56, $19
252         bic     $sp, $8, $8
253         jsr     $26, do_entUnaUser
254         ldq     $9, 0($sp)
255         ldq     $10, 8($sp)
256         ldq     $11, 16($sp)
257         ldq     $12, 24($sp)
258         ldq     $13, 32($sp)
259         ldq     $14, 40($sp)
260         ldq     $15, 48($sp)
261         lda     $sp, 56($sp)
262         br      ret_from_sys_call
263 .end entUnaUser
265         .align  4
266         .globl  entDbg
267         .ent    entDbg
268 entDbg:
269         SAVE_ALL
270         lda     $8, 0x3fff
271         lda     $26, ret_from_sys_call
272         bic     $sp, $8, $8
273         mov     $sp, $16
274         jsr     $31, do_entDbg
275 .end entDbg
278  * The system call entry point is special.  Most importantly, it looks
279  * like a function call to userspace as far as clobbered registers.  We
280  * do preserve the argument registers (for syscall restarts) and $26
281  * (for leaf syscall functions).
283  * So much for theory.  We don't take advantage of this yet.
285  * Note that a0-a2 are not saved by PALcode as with the other entry points.
286  */
288         .align  4
289         .globl  entSys
290         .globl  ret_from_sys_call
291         .ent    entSys
292 entSys:
293         SAVE_ALL
294         lda     $8, 0x3fff
295         bic     $sp, $8, $8
296         lda     $4, NR_SYSCALLS($31)
297         stq     $16, SP_OFF+24($sp)
298         lda     $5, sys_call_table
299         lda     $27, sys_ni_syscall
300         cmpult  $0, $4, $4
301         ldl     $3, TI_FLAGS($8)
302         stq     $17, SP_OFF+32($sp)
303         s8addq  $0, $5, $5
304         stq     $18, SP_OFF+40($sp)
305         blbs    $3, strace
306         beq     $4, 1f
307         ldq     $27, 0($5)
308 1:      jsr     $26, ($27), alpha_ni_syscall
309         ldgp    $gp, 0($26)
310         blt     $0, $syscall_error      /* the call failed */
311         stq     $0, 0($sp)
312         stq     $31, 72($sp)            /* a3=0 => no error */
314         .align  4
315 ret_from_sys_call:
316         cmovne  $26, 0, $19             /* $19 = 0 => non-restartable */
317         ldq     $0, SP_OFF($sp)
318         and     $0, 8, $0
319         beq     $0, restore_all
320 ret_from_reschedule:
321         /* Make sure need_resched and sigpending don't change between
322                 sampling and the rti.  */
323         lda     $16, 7
324         call_pal PAL_swpipl
325         ldl     $5, TI_FLAGS($8)
326         and     $5, _TIF_WORK_MASK, $2
327         bne     $5, work_pending
328 restore_all:
329         RESTORE_ALL
330         call_pal PAL_rti
332         .align 3
333 $syscall_error:
334         /*
335          * Some system calls (e.g., ptrace) can return arbitrary
336          * values which might normally be mistaken as error numbers.
337          * Those functions must zero $0 (v0) directly in the stack
338          * frame to indicate that a negative return value wasn't an
339          * error number..
340          */
341         ldq     $19, 0($sp)     /* old syscall nr (zero if success) */
342         beq     $19, $ret_success
344         ldq     $20, 72($sp)    /* .. and this a3 */
345         subq    $31, $0, $0     /* with error in v0 */
346         addq    $31, 1, $1      /* set a3 for errno return */
347         stq     $0, 0($sp)
348         mov     $31, $26        /* tell "ret_from_sys_call" we can restart */
349         stq     $1, 72($sp)     /* a3 for return */
350         br      ret_from_sys_call
352 $ret_success:
353         stq     $0, 0($sp)
354         stq     $31, 72($sp)    /* a3=0 => no error */
355         br      ret_from_sys_call
356 .end entSys
359  * Do all cleanup when returning from all interrupts and system calls.
361  * Arguments:
362  *       $5: TI_FLAGS.
363  *       $8: current.
364  *      $19: The old syscall number, or zero if this is not a return
365  *           from a syscall that errored and is possibly restartable.
366  *      $20: Error indication.
367  */
369         .align  4
370         .ent    work_pending
371 work_pending:
372         and     $5, _TIF_NEED_RESCHED, $2
373         beq     $2, $work_notifysig
375 $work_resched:
376         subq    $sp, 16, $sp
377         stq     $19, 0($sp)              /* save syscall nr */
378         stq     $20, 8($sp)              /* and error indication (a3) */
379         jsr     $26, schedule
380         ldq     $19, 0($sp)
381         ldq     $20, 8($sp)
382         addq    $sp, 16, $sp
383         /* Make sure need_resched and sigpending don't change between
384                 sampling and the rti.  */
385         lda     $16, 7
386         call_pal PAL_swpipl
387         ldl     $5, TI_FLAGS($8)
388         and     $5, _TIF_WORK_MASK, $2
389         beq     $2, restore_all
390         and     $5, _TIF_NEED_RESCHED, $2
391         bne     $2, $work_resched
393 $work_notifysig:
394         mov     $sp, $17
395         br      $1, do_switch_stack
396         mov     $5, $21
397         mov     $sp, $18
398         mov     $31, $16
399         jsr     $26, do_notify_resume
400         bsr     $1, undo_switch_stack
401         br      restore_all
402 .end work_pending
405  * PTRACE syscall handler
406  */
408         .align  4
409         .ent    strace
410 strace:
411         /* set up signal stack, call syscall_trace */
412         bsr     $1, do_switch_stack
413         jsr     $26, syscall_trace
414         bsr     $1, undo_switch_stack
416         /* get the system call number and the arguments back.. */
417         ldq     $0, 0($sp)
418         ldq     $16, SP_OFF+24($sp)
419         ldq     $17, SP_OFF+32($sp)
420         ldq     $18, SP_OFF+40($sp)
421         ldq     $19, 72($sp)
422         ldq     $20, 80($sp)
423         ldq     $21, 88($sp)
425         /* get the system call pointer.. */
426         lda     $1, NR_SYSCALLS($31)
427         lda     $2, sys_call_table
428         lda     $27, alpha_ni_syscall
429         cmpult  $0, $1, $1
430         s8addq  $0, $2, $2
431         beq     $1, 1f
432         ldq     $27, 0($2)
433 1:      jsr     $26, ($27), sys_gettimeofday
434         ldgp    $gp, 0($26)
436         /* check return.. */
437         blt     $0, $strace_error       /* the call failed */
438         stq     $31, 72($sp)            /* a3=0 => no error */
439 $strace_success:
440         stq     $0, 0($sp)              /* save return value */
442         bsr     $1, do_switch_stack
443         jsr     $26, syscall_trace
444         bsr     $1, undo_switch_stack
445         br      $31, ret_from_sys_call
447         .align  3
448 $strace_error:
449         ldq     $19, 0($sp)     /* old syscall nr (zero if success) */
450         beq     $19, $strace_success
451         ldq     $20, 72($sp)    /* .. and this a3 */
453         subq    $31, $0, $0     /* with error in v0 */
454         addq    $31, 1, $1      /* set a3 for errno return */
455         stq     $0, 0($sp)
456         stq     $1, 72($sp)     /* a3 for return */
458         bsr     $1, do_switch_stack
459         mov     $19, $9         /* save old syscall number */
460         mov     $20, $10        /* save old a3 */
461         jsr     $26, syscall_trace
462         mov     $9, $19
463         mov     $10, $20
464         bsr     $1, undo_switch_stack
466         mov     $31, $26        /* tell "ret_from_sys_call" we can restart */
467         br      ret_from_sys_call
468 .end strace
471  * Save and restore the switch stack -- aka the balance of the user context.
472  */
474         .align  4
475         .ent    do_switch_stack
476 do_switch_stack:
477         lda     $sp, -SWITCH_STACK_SIZE($sp)
478         stq     $9, 0($sp)
479         stq     $10, 8($sp)
480         stq     $11, 16($sp)
481         stq     $12, 24($sp)
482         stq     $13, 32($sp)
483         stq     $14, 40($sp)
484         stq     $15, 48($sp)
485         stq     $26, 56($sp)
486         stt     $f0, 64($sp)
487         stt     $f1, 72($sp)
488         stt     $f2, 80($sp)
489         stt     $f3, 88($sp)
490         stt     $f4, 96($sp)
491         stt     $f5, 104($sp)
492         stt     $f6, 112($sp)
493         stt     $f7, 120($sp)
494         stt     $f8, 128($sp)
495         stt     $f9, 136($sp)
496         stt     $f10, 144($sp)
497         stt     $f11, 152($sp)
498         stt     $f12, 160($sp)
499         stt     $f13, 168($sp)
500         stt     $f14, 176($sp)
501         stt     $f15, 184($sp)
502         stt     $f16, 192($sp)
503         stt     $f17, 200($sp)
504         stt     $f18, 208($sp)
505         stt     $f19, 216($sp)
506         stt     $f20, 224($sp)
507         stt     $f21, 232($sp)
508         stt     $f22, 240($sp)
509         stt     $f23, 248($sp)
510         stt     $f24, 256($sp)
511         stt     $f25, 264($sp)
512         stt     $f26, 272($sp)
513         stt     $f27, 280($sp)
514         mf_fpcr $f0             # get fpcr
515         stt     $f28, 288($sp)
516         stt     $f29, 296($sp)
517         stt     $f30, 304($sp)
518         stt     $f0, 312($sp)   # save fpcr in slot of $f31
519         ldt     $f0, 64($sp)    # dont let "do_switch_stack" change fp state.
520         ret     $31, ($1), 1
521 .end do_switch_stack
523         .align  4
524         .ent    undo_switch_stack
525 undo_switch_stack:
526         ldq     $9, 0($sp)
527         ldq     $10, 8($sp)
528         ldq     $11, 16($sp)
529         ldq     $12, 24($sp)
530         ldq     $13, 32($sp)
531         ldq     $14, 40($sp)
532         ldq     $15, 48($sp)
533         ldq     $26, 56($sp)
534         ldt     $f30, 312($sp)  # get saved fpcr
535         ldt     $f0, 64($sp)
536         ldt     $f1, 72($sp)
537         ldt     $f2, 80($sp)
538         ldt     $f3, 88($sp)
539         mt_fpcr $f30            # install saved fpcr
540         ldt     $f4, 96($sp)
541         ldt     $f5, 104($sp)
542         ldt     $f6, 112($sp)
543         ldt     $f7, 120($sp)
544         ldt     $f8, 128($sp)
545         ldt     $f9, 136($sp)
546         ldt     $f10, 144($sp)
547         ldt     $f11, 152($sp)
548         ldt     $f12, 160($sp)
549         ldt     $f13, 168($sp)
550         ldt     $f14, 176($sp)
551         ldt     $f15, 184($sp)
552         ldt     $f16, 192($sp)
553         ldt     $f17, 200($sp)
554         ldt     $f18, 208($sp)
555         ldt     $f19, 216($sp)
556         ldt     $f20, 224($sp)
557         ldt     $f21, 232($sp)
558         ldt     $f22, 240($sp)
559         ldt     $f23, 248($sp)
560         ldt     $f24, 256($sp)
561         ldt     $f25, 264($sp)
562         ldt     $f26, 272($sp)
563         ldt     $f27, 280($sp)
564         ldt     $f28, 288($sp)
565         ldt     $f29, 296($sp)
566         ldt     $f30, 304($sp)
567         lda     $sp, SWITCH_STACK_SIZE($sp)
568         ret     $31, ($1), 1
569 .end undo_switch_stack
572  * The meat of the context switch code.
573  */
575         .align  4
576         .globl  alpha_switch_to
577         .ent    alpha_switch_to
578 alpha_switch_to:
579         .prologue 0
580         bsr     $1, do_switch_stack
581         call_pal PAL_swpctx
582         lda     $8, 0x3fff
583         bsr     $1, undo_switch_stack
584         bic     $sp, $8, $8
585         ret
586 .end alpha_switch_to
589  * New processes begin life here.
590  */
592         .globl  ret_from_fork
593 #if CONFIG_SMP || CONFIG_PREEMPT
594         .align  4
595         .ent    ret_from_fork
596 ret_from_fork:
597         lda     $26, ret_from_sys_call
598         mov     $17, $16
599         jmp     $31, schedule_tail
600 .end ret_from_fork
601 #else
602 ret_from_fork = ret_from_sys_call
603 #endif
606  * kernel_thread(fn, arg, clone_flags)
607  */
608         .align 4
609         .globl  kernel_thread
610         .ent    kernel_thread
611 kernel_thread:
612         ldgp    $gp, 0($27)     /* we can be called from a module */
613         .prologue 1
614         subq    $sp, SP_OFF+6*8, $sp
615         br      $1, 2f          /* load start address */
617         /* We've now "returned" from a fake system call.  */
618         unop
619         blt     $0, 1f          /* error?  */
620         ldi     $1, 0x3fff
621         beq     $20, 1f         /* parent or child?  */
623         bic     $sp, $1, $8     /* in child.  */
624         jsr     $26, ($27)
625         ldgp    $gp, 0($26)
626         mov     $0, $16
627         mov     $31, $26
628         jmp     $31, sys_exit
630 1:      ret                     /* in parent.  */
632         .align 4
633 2:      /* Fake a system call stack frame, as we can't do system calls
634            from kernel space.  Note that we store FN and ARG as they
635            need to be set up in the child for the call.  Also store $8
636            and $26 for use in the parent.  */
637         stq     $31, SP_OFF($sp)        /* ps */
638         stq     $1, SP_OFF+8($sp)       /* pc */
639         stq     $gp, SP_OFF+16($sp)     /* gp */
640         stq     $16, 136($sp)           /* $27; FN for child */
641         stq     $17, SP_OFF+24($sp)     /* $16; ARG for child */
642         stq     $8, 64($sp)             /* $8 */
643         stq     $26, 128($sp)           /* $26 */
644         /* Avoid the HAE being gratuitously wrong, to avoid restoring it.  */
645         ldq     $2, alpha_mv+HAE_CACHE
646         stq     $2, 152($sp)            /* HAE */
648         /* Shuffle FLAGS to the front; add CLONE_VM.  */
649         ldi     $1, CLONE_VM|CLONE_UNTRACED
650         or      $18, $1, $16
651         bsr     $26, sys_clone
653         /* We don't actually care for a3 success widgetry in the kernel.
654            Not for positive errno values.  */
655         stq     $0, 0($sp)              /* $0 */
656         br      restore_all
657 .end kernel_thread
660  * __kernel_execve(path, argv, envp, regs)
661  */
662         .align  4
663         .globl  __kernel_execve
664         .ent    __kernel_execve
665 __kernel_execve:
666         ldgp    $gp, 0($27)     /* we can be called from modules.  */
667         subq    $sp, 16, $sp
668         .frame  $sp, 16, $26, 0
669         stq     $26, 0($sp)
670         stq     $19, 8($sp)
671         .prologue 1
672         jsr     $26, do_execve
673         bne     $0, 1f          /* error! */
674         ldq     $sp, 8($sp)
675         br      $31, ret_from_sys_call
676 1:      ldq     $26, 0($sp)
677         addq    $sp, 16, $sp
678         ret
679 .end __kernel_execve
683  * Special system calls.  Most of these are special in that they either
684  * have to play switch_stack games or in some way use the pt_regs struct.
685  */
686         .align  4
687         .globl  sys_fork
688         .ent    sys_fork
689 sys_fork:
690         .prologue 0
691         mov     $sp, $21
692         bsr     $1, do_switch_stack
693         bis     $31, SIGCHLD, $16
694         mov     $31, $17
695         mov     $31, $18
696         mov     $31, $19
697         mov     $31, $20
698         jsr     $26, alpha_clone
699         bsr     $1, undo_switch_stack
700         ret
701 .end sys_fork
703         .align  4
704         .globl  sys_clone
705         .ent    sys_clone
706 sys_clone:
707         .prologue 0
708         mov     $sp, $21
709         bsr     $1, do_switch_stack
710         /* $16, $17, $18, $19, $20 come from the user.  */
711         jsr     $26, alpha_clone
712         bsr     $1, undo_switch_stack
713         ret
714 .end sys_clone
716         .align  4
717         .globl  sys_vfork
718         .ent    sys_vfork
719 sys_vfork:
720         .prologue 0
721         mov     $sp, $16
722         bsr     $1, do_switch_stack
723         jsr     $26, alpha_vfork
724         bsr     $1, undo_switch_stack
725         ret
726 .end sys_vfork
728         .align  4
729         .globl  sys_sigreturn
730         .ent    sys_sigreturn
731 sys_sigreturn:
732         .prologue 0
733         mov     $sp, $17
734         lda     $18, -SWITCH_STACK_SIZE($sp)
735         lda     $sp, -SWITCH_STACK_SIZE($sp)
736         jsr     $26, do_sigreturn
737         br      $1, undo_switch_stack
738         br      ret_from_sys_call
739 .end sys_sigreturn
741         .align  4
742         .globl  sys_rt_sigreturn
743         .ent    sys_rt_sigreturn
744 sys_rt_sigreturn:
745         .prologue 0
746         mov     $sp, $17
747         lda     $18, -SWITCH_STACK_SIZE($sp)
748         lda     $sp, -SWITCH_STACK_SIZE($sp)
749         jsr     $26, do_rt_sigreturn
750         br      $1, undo_switch_stack
751         br      ret_from_sys_call
752 .end sys_rt_sigreturn
754         .align  4
755         .globl  sys_sigsuspend
756         .ent    sys_sigsuspend
757 sys_sigsuspend:
758         .prologue 0
759         mov     $sp, $17
760         br      $1, do_switch_stack
761         mov     $sp, $18
762         subq    $sp, 16, $sp
763         stq     $26, 0($sp)
764         jsr     $26, do_sigsuspend
765         ldq     $26, 0($sp)
766         lda     $sp, SWITCH_STACK_SIZE+16($sp)
767         ret
768 .end sys_sigsuspend
770         .align  4
771         .globl  sys_rt_sigsuspend
772         .ent    sys_rt_sigsuspend
773 sys_rt_sigsuspend:
774         .prologue 0
775         mov     $sp, $18
776         br      $1, do_switch_stack
777         mov     $sp, $19
778         subq    $sp, 16, $sp
779         stq     $26, 0($sp)
780         jsr     $26, do_rt_sigsuspend
781         ldq     $26, 0($sp)
782         lda     $sp, SWITCH_STACK_SIZE+16($sp)
783         ret
784 .end sys_rt_sigsuspend
786         .align  4
787         .globl  sys_sethae
788         .ent    sys_sethae
789 sys_sethae:
790         .prologue 0
791         stq     $16, 152($sp)
792         ret
793 .end sys_sethae
795         .align  4
796         .globl  osf_getpriority
797         .ent    osf_getpriority
798 osf_getpriority:
799         lda     $sp, -16($sp)
800         stq     $26, 0($sp)
801         .prologue 0
803         jsr     $26, sys_getpriority
805         ldq     $26, 0($sp)
806         blt     $0, 1f
808         /* Return value is the unbiased priority, i.e. 20 - prio.
809            This does result in negative return values, so signal
810            no error by writing into the R0 slot.  */
811         lda     $1, 20
812         stq     $31, 16($sp)
813         subl    $1, $0, $0
814         unop
816 1:      lda     $sp, 16($sp)
817         ret
818 .end osf_getpriority
820         .align  4
821         .globl  sys_getxuid
822         .ent    sys_getxuid
823 sys_getxuid:
824         .prologue 0
825         ldq     $2, TI_TASK($8)
826         ldl     $0, TASK_UID($2)
827         ldl     $1, TASK_EUID($2)
828         stq     $1, 80($sp)
829         ret
830 .end sys_getxuid
832         .align  4
833         .globl  sys_getxgid
834         .ent    sys_getxgid
835 sys_getxgid:
836         .prologue 0
837         ldq     $2, TI_TASK($8)
838         ldl     $0, TASK_GID($2)
839         ldl     $1, TASK_EGID($2)
840         stq     $1, 80($sp)
841         ret
842 .end sys_getxgid
844         .align  4
845         .globl  sys_getxpid
846         .ent    sys_getxpid
847 sys_getxpid:
848         .prologue 0
849         ldq     $2, TI_TASK($8)
851         /* See linux/kernel/timer.c sys_getppid for discussion
852            about this loop.  */
853         ldq     $3, TASK_REAL_PARENT($2)
854 1:      ldl     $1, TASK_TGID($3)
855 #if CONFIG_SMP
856         mov     $3, $4
857         mb
858         ldq     $3, TASK_REAL_PARENT($2)
859         cmpeq   $3, $4, $4
860         beq     $4, 1b
861 #endif
862         stq     $1, 80($sp)
863         ldl     $0, TASK_TGID($2)
864         ret
865 .end sys_getxpid
867         .align  4
868         .globl  sys_pipe
869         .ent    sys_pipe
870 sys_pipe:
871         lda     $sp, -16($sp)
872         stq     $26, 0($sp)
873         .prologue 0
875         lda     $16, 8($sp)
876         jsr     $26, do_pipe
878         ldq     $26, 0($sp)
879         bne     $0, 1f
881         /* The return values are in $0 and $20.  */
882         ldl     $1, 12($sp)
883         ldl     $0, 8($sp)
885         stq     $1, 80+16($sp)
886 1:      lda     $sp, 16($sp)
887         ret
888 .end sys_pipe
890         .align  4
891         .globl  sys_ptrace
892         .ent    sys_ptrace
893 sys_ptrace:
894         .prologue 0
895         mov     $sp, $20
896         jmp     $31, do_sys_ptrace
897 .end sys_ptrace
899         .align  4
900         .globl  alpha_ni_syscall
901         .ent    alpha_ni_syscall
902 alpha_ni_syscall:
903         .prologue 0
904         /* Special because it also implements overflow handling via
905            syscall number 0.  And if you recall, zero is a special
906            trigger for "not an error".  Store large non-zero there.  */
907         lda     $0, -ENOSYS
908         unop
909         stq     $0, 0($sp)
910         ret
911 .end alpha_ni_syscall