blob: acb91011d59f863e3efcb30ff9fcd5b5d5560320 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
18
19#include <features.h>
20#include <sys/asm.h>
21#include <sys/regdef.h>
22
23#ifdef __PIC__
24 .option pic2
25#endif
26.text
27.align 2
28.globl syscall
29.type syscall,@function
30.ent syscall
31syscall:
32#ifdef __PIC__
33 SETUP_GP
34#endif
35 move v0, a0 /* Load system call number from first arg. */
36 move a0, a1 /* Move the next three args up a register. */
37 move a1, a2
38 move a2, a3
39 /* Load the remaining possible args (up to 7) from the stack. */
40#ifdef __mips64
41 move a3, a4
42 move a4, a5
43 move a5, a6
44 move a6, a7
45 daddiu sp,sp,-16
46 sd v0,0*8(sp)
47 ld v0,0*8(sp) /* for system call restarts */
48#else
49 lw a3,4*4(sp)
50 lw t0,5*4(sp)
51 lw t1,6*4(sp)
52 lw t2,7*4(sp)
53 addiu sp,sp,-32
54 sw t0,4*4(sp)
55 sw t1,5*4(sp)
56 sw t2,6*4(sp)
57 sw v0,7*4(sp)
58 lw v0,7*4(sp) /* for system call restarts */
59#endif
60 syscall /* Do the system call. */
61#ifdef __mips64
62 daddiu sp,sp,16
63#else
64 addiu sp,sp,32
65#endif
66 bnez a3, 1f
67 j ra /* Return to caller. */
681:
69 move a0,v0 /* Pass return val to C function. */
70
71#ifdef __PIC__
72 SETUP_GP64(v0, syscall)
73 PTR_LA t9, __syscall_error
74 RESTORE_GP64
75 jr t9
76#else
77 j __syscall_error
78#endif
79.end syscall
80.size syscall,.-syscall