diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/internal/ppc/syscall.S | 24 | ||||
-rw-r--r-- | src/ldso/ppc/dlsym.S | 9 | ||||
-rw-r--r-- | src/ldso/ppc/start.S | 22 | ||||
-rw-r--r-- | src/setjmp/ppc/longjmp.S | 17 | ||||
-rw-r--r-- | src/setjmp/ppc/setjmp.S | 18 | ||||
-rw-r--r-- | src/signal/ppc/restore.S | 13 | ||||
-rw-r--r-- | src/signal/ppc/sigsetjmp.S | 12 | ||||
-rw-r--r-- | src/thread/ppc/__unmapself.S | 11 |
8 files changed, 126 insertions, 0 deletions
diff --git a/src/internal/ppc/syscall.S b/src/internal/ppc/syscall.S new file mode 100644 index 00000000..e56abc6f --- /dev/null +++ b/src/internal/ppc/syscall.S @@ -0,0 +1,24 @@ +#include <bits/asm.h> + .global __syscall + .type __syscall,@function +__syscall: + mflr r0 + stw r0, -4(r1) // Save the return address. + mr r0, r3 // Save the system call number + mr r3, r4 // Shift the arguments: arg1 + mr r4, r5 // arg2 + mr r5, r6 // arg3 + mr r6, r7 // arg4 + mr r7, r8 // arg5 + mr r8, r9 // arg6 + sc + mfcr r0 // Check for an error + rlwinm r4, r0, r0, 3, 3 // by checking for bit 28. + cmplwi r0, r4, 0 // It is an error if non-zero. + beq r0, 1f // Jump if not an error. + neg r3, r3 // Negate the error number. +1: lwz r0, -4(r1) // Restore the return address. + mtlr r0 + blr + .end __syscall + .size __syscall, .-__syscall diff --git a/src/ldso/ppc/dlsym.S b/src/ldso/ppc/dlsym.S new file mode 100644 index 00000000..e36de10b --- /dev/null +++ b/src/ldso/ppc/dlsym.S @@ -0,0 +1,9 @@ +#include <bits/asm.h> + .text + .global dlsym + .type dlsym,@function +dlsym: + mflr r5 // The return address is arg3. + b __dlsym + .end dlsym + .size dlsym, .-dlsym diff --git a/src/ldso/ppc/start.S b/src/ldso/ppc/start.S new file mode 100644 index 00000000..f3419824 --- /dev/null +++ b/src/ldso/ppc/start.S @@ -0,0 +1,22 @@ +#include <bits/asm.h> + .global _start + .type _start,@function +_start: + mr r9, r1 // Save the original stack pointer. + clrrwi r1, r1, 4 // Align the stack to 16 bytes. + lis r13, _SDA_BASE_@ha // r13 points to the small data area. + addi r13, r13, _SDA_BASE_@l // + li r0, 0 // Zero the frame pointer. + lwz r3, 0(r9) // and argc... + addi r4, r9, 4 // and argv ... + mtlr r0 // Clear the link register. + // Go to the musl dynamic linker entry point. + bl __dynlink + cmpi r4, 0, r3, 1 // Check for a 1. + bne r4, . // Stay here + mtlr r3 // Set the link address... + li r3, 0 + blr // and go. + .end _start + .size _start, .-_start + diff --git a/src/setjmp/ppc/longjmp.S b/src/setjmp/ppc/longjmp.S new file mode 100644 index 00000000..df13c7b1 --- /dev/null +++ b/src/setjmp/ppc/longjmp.S @@ -0,0 +1,17 @@ +#include <bits/asm.h> + .global _longjmp + .global longjmp + .type _longjmp,@function + .type longjmp,@function +_longjmp: +longjmp: + cmpi 7, 0, r3, 0 + bne 7, 1f + addi r3, r3, 1 +1: lmw r8, 4(r3) // load r8-r31 + mr r6, r4 + mtlr r11 + mtcr r12 + mr r2, r9 + mr r1, r10 + blr diff --git a/src/setjmp/ppc/setjmp.S b/src/setjmp/ppc/setjmp.S new file mode 100644 index 00000000..7d0b9ac5 --- /dev/null +++ b/src/setjmp/ppc/setjmp.S @@ -0,0 +1,18 @@ +#include <bits/asm.h> + .global __setjmp + .global _setjmp + .global setjmp + .type __setjmp,@function + .type _setjmp,@function + .type setjmp,@function +__setjmp: +_setjmp: +setjmp: + mflr r11 + mfcr r12 + mr r10, r1 + mr r9, r2 + stmw r8, 0(r3) // save r8-r31 + li r3,0 + blr + diff --git a/src/signal/ppc/restore.S b/src/signal/ppc/restore.S new file mode 100644 index 00000000..50887e91 --- /dev/null +++ b/src/signal/ppc/restore.S @@ -0,0 +1,13 @@ +#include <bits/asm.h> +#include <bits/syscall.h> + .global __restore + .type __restore,@function +__restore: + li r0, __NR_sigreturn + sc + + .global __restore_rt + .type __restore_rt,@function +__restore_rt: + li r0, __NR_rt_sigreturn + sc diff --git a/src/signal/ppc/sigsetjmp.S b/src/signal/ppc/sigsetjmp.S new file mode 100644 index 00000000..527ef8e4 --- /dev/null +++ b/src/signal/ppc/sigsetjmp.S @@ -0,0 +1,12 @@ +#include <bits/asm.h> + .global sigsetjmp + .type sigsetjmp,@function +sigsetjmp: + lwz r4, 64*4-2*4(r3) // Second last long. + cmpi r4, 0, r4, 0 + bne r4, 1f + addi r5, r3, 64*4-1*4 // Address of last long. + li r4, 0 + li r3, 2 + bl sigprocmask +1: b setjmp diff --git a/src/thread/ppc/__unmapself.S b/src/thread/ppc/__unmapself.S new file mode 100644 index 00000000..e14663e7 --- /dev/null +++ b/src/thread/ppc/__unmapself.S @@ -0,0 +1,11 @@ +#include <bits/asm.h> +#include <bits/syscall.h> + .text + .global __unmapself + .type __unmapself,%function +__unmapself: + li r0, __NR_munmap + sc + li r0, __NR_exit + sc + blr |