import preliminary ppc work by rdp.
[musl] / src / internal / ppc / syscall.S
1 #include <bits/asm.h>
2         .global __syscall
3         .type   __syscall,@function
4 __syscall:
5         mflr    r0
6         stw     r0, -4(r1)              // Save the return address.
7         mr      r0, r3                  // Save the system call number
8         mr      r3, r4                  // Shift the arguments: arg1
9         mr      r4, r5                  // arg2
10         mr      r5, r6                  // arg3
11         mr      r6, r7                  // arg4
12         mr      r7, r8                  // arg5
13         mr      r8, r9                  // arg6
14         sc
15         mfcr    r0                      // Check for an error
16         rlwinm  r4, r0, r0, 3, 3        // by checking for bit 28.
17         cmplwi  r0, r4, 0               // It is an error if non-zero.
18         beq     r0, 1f                  // Jump if not an error.
19         neg     r3, r3                  // Negate the error number.
20 1:      lwz     r0, -4(r1)              // Restore the return address.
21         mtlr    r0
22         blr
23         .end    __syscall
24         .size   __syscall, .-__syscall