diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2020-06-25 02:38:29 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2020-06-25 02:38:29 +0000 |
commit | 66ecddcb15b8fedc1403cf598137751abbefc7be (patch) | |
tree | 9d1d504cb4e02c7069de8fcf7fdedaab403b5b1e /lib/libc/arch | |
parent | e48a47fbba8d389dfbdb556465d810e5d5cfac95 (diff) |
PowerPC64 libc powerpc sys files
Initial attempt to port powerpc code to powerpc64
Expects TOC loading in ENTRY(),
ok kettenis@ (some cleanup required)
Diffstat (limited to 'lib/libc/arch')
-rw-r--r-- | lib/libc/arch/powerpc64/sys/Ovfork.S | 30 | ||||
-rw-r--r-- | lib/libc/arch/powerpc64/sys/brk.S | 70 | ||||
-rw-r--r-- | lib/libc/arch/powerpc64/sys/sbrk.S | 63 | ||||
-rw-r--r-- | lib/libc/arch/powerpc64/sys/sigpending.S | 29 | ||||
-rw-r--r-- | lib/libc/arch/powerpc64/sys/sigprocmask.S | 65 | ||||
-rw-r--r-- | lib/libc/arch/powerpc64/sys/sigsuspend.S | 37 | ||||
-rw-r--r-- | lib/libc/arch/powerpc64/sys/syscall.S | 30 | ||||
-rw-r--r-- | lib/libc/arch/powerpc64/sys/tfork_thread.S | 44 |
8 files changed, 368 insertions, 0 deletions
diff --git a/lib/libc/arch/powerpc64/sys/Ovfork.S b/lib/libc/arch/powerpc64/sys/Ovfork.S new file mode 100644 index 00000000000..fc084d81b2b --- /dev/null +++ b/lib/libc/arch/powerpc64/sys/Ovfork.S @@ -0,0 +1,30 @@ +/* $OpenBSD: Ovfork.S,v 1.1 2020/06/25 02:38:28 drahn Exp $ */ + +/* + * Copyright (c) 1996 Dale Rahn + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "SYS.h" + +RSYSCALL_HIDDEN(vfork) diff --git a/lib/libc/arch/powerpc64/sys/brk.S b/lib/libc/arch/powerpc64/sys/brk.S new file mode 100644 index 00000000000..df6354b8be4 --- /dev/null +++ b/lib/libc/arch/powerpc64/sys/brk.S @@ -0,0 +1,70 @@ +/* $OpenBSD: brk.S,v 1.1 2020/06/25 02:38:28 drahn Exp $ */ + +/* + * Copyright (c) 1996 Dale Rahn + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "SYS.h" + + .extern __curbrk + .extern _C_LABEL(_end) + + .weak brk + +PSEUDO_PREFIX(,brk,break) + /* check >= _end, if not make the call for _end */ + addis 5,2,.LC0@toc@ha + ld 5,.LC0@toc@l(5) /* # 5 = &_end */ + + cmplw %r3,%r5 + bge+ .L_brk_call + mr %r3, %r5 + +.L_brk_call: + mr %r7, %r3 + /* call break(size) */ + addis %r6, %r2, __curbrk@toc@ha + addi %r6, %r6, __curbrk@toc@l /* # 6 = &__curbrk */ + + sc + + /* check for error */ + cmpwi %r0, 0 + beq+ .L_brk_ok /* OK so this is stupid but I haven't read b */ + stw %r0, R13_OFFSET_ERRNO(13) + li %r3, -1 + blr + nop + + /* update, __curbrk and return */ +.L_brk_ok: + stw %r7, 0(%r6) /* # remember, 6=&__curbrk, 3= new value */ + mr %r3, 0 /* # return 0 */ + blr +END(brk) + + .section .toc,"aw",@progbits +.LC0: + .tc _end[TC],_end + diff --git a/lib/libc/arch/powerpc64/sys/sbrk.S b/lib/libc/arch/powerpc64/sys/sbrk.S new file mode 100644 index 00000000000..a737473e3a6 --- /dev/null +++ b/lib/libc/arch/powerpc64/sys/sbrk.S @@ -0,0 +1,63 @@ +/* $OpenBSD: sbrk.S,v 1.1 2020/06/25 02:38:28 drahn Exp $ */ + +/* + * Copyright (c) 1996 Dale Rahn + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "SYS.h" + + .data + .globl __curbrk + .hidden __curbrk +__curbrk: + END(__curbrk) + .type __curbrk,@object + + .weak sbrk + + .text +PSEUDO_PREFIX(,sbrk,break) + /* call break(__curbrk + size) */ + addis %r6, %r2, __curbrk@toc@ha + addi %r6, %r6, __curbrk@toc@l /* # %r6 = &__curbrk */ + + lwz %r5, 0(%r6) /* # %r5 = *%r6 (old_curbrk) */ + add %r3, %r5, %r3 /* # %r3 = new_curbrk */ + mr %r7, %r3 + + sc + + /* check for error */ + cmpwi %r0, 0 + beq+ .L_sbrk_ok + stw %r0, R13_OFFSET_ERRNO(13) + li %r3, -1 + blr + + /* update, __curbrk and return */ +.L_sbrk_ok: + stw %r7, 0(6) /* # remember, %r6=&__curbrk, %r7=new_curbrk */ + mr %r3, %r5 /* # remember, %r5=old_curbrk */ + blr +END(sbrk) diff --git a/lib/libc/arch/powerpc64/sys/sigpending.S b/lib/libc/arch/powerpc64/sys/sigpending.S new file mode 100644 index 00000000000..1b36eece3eb --- /dev/null +++ b/lib/libc/arch/powerpc64/sys/sigpending.S @@ -0,0 +1,29 @@ +/* $OpenBSD: sigpending.S,v 1.1 2020/06/25 02:38:28 drahn Exp $ */ +/* + * Copyright (c) 2012 Mark Kettenis + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* sigpending(sigset_t *set); */ + +#include "SYS.h" + + .text +PREFIX(sigpending) + mr %r5, %r3 + sc + stw %r3, 0(%r5) + li %r3, 0 + blr +SYSCALL_END(sigpending) diff --git a/lib/libc/arch/powerpc64/sys/sigprocmask.S b/lib/libc/arch/powerpc64/sys/sigprocmask.S new file mode 100644 index 00000000000..0767330e5ca --- /dev/null +++ b/lib/libc/arch/powerpc64/sys/sigprocmask.S @@ -0,0 +1,65 @@ +/* $OpenBSD: sigprocmask.S,v 1.1 2020/06/25 02:38:28 drahn Exp $ */ + +/* + * Copyright (c) 1996 Dale Rahn + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* sigprocmask(int how, const sigset_t *set, sigset_t *oset); */ + +#include "SYS.h" + + .text +PREFIX_HIDDEN(sigprocmask) + stdu 1, -32(1) + stw 5, 16(1) + + /* check set (new mask value) for null, in which case + fiddle arguments */ + cmpwi 4, 0 + bne+ .L_load_set + addi 3, 0, 1 /* how = SIG_BLOCK, new mask already 0 */ + b .L_do_call +.L_load_set: + lwz 4, 0(4) /* get new mask */ +.L_do_call: + + sc + + /* didnt work? */ + cmpwi 0, 0 + beq+ .L_sigprocmask_ok + stw 0, R13_OFFSET_ERRNO(13) + li 3, -1 + blr + +.L_sigprocmask_ok: + lwz 5, 16(1) + cmpwi 5, 0 + beq+ .L_sigprocmask_done + stw 3, 0(5) +.L_sigprocmask_done: + li 3, 0 + addi 1, 1, 32 + blr +SYSCALL_END_HIDDEN(sigprocmask) diff --git a/lib/libc/arch/powerpc64/sys/sigsuspend.S b/lib/libc/arch/powerpc64/sys/sigsuspend.S new file mode 100644 index 00000000000..33d80dc0dee --- /dev/null +++ b/lib/libc/arch/powerpc64/sys/sigsuspend.S @@ -0,0 +1,37 @@ +/* $OpenBSD: sigsuspend.S,v 1.1 2020/06/25 02:38:28 drahn Exp $ */ + +/* + * Copyright (c) 1996 Dale Rahn <drahn@openbsd.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* int sigsuspend(int *mask) */ + +#include "SYS.h" + + .text +PREFIX_HIDDEN(sigsuspend) + lwz 3, 0(3) /* load the mask */ + sc + PSEUDO_SUFFIX +SYSCALL_END_HIDDEN(sigsuspend) diff --git a/lib/libc/arch/powerpc64/sys/syscall.S b/lib/libc/arch/powerpc64/sys/syscall.S new file mode 100644 index 00000000000..410616cb6a9 --- /dev/null +++ b/lib/libc/arch/powerpc64/sys/syscall.S @@ -0,0 +1,30 @@ +/* $OpenBSD: syscall.S,v 1.1 2020/06/25 02:38:28 drahn Exp $ */ + +/* + * Copyright (c) 1996 Dale Rahn <drahn@openbsd.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "SYS.h" + +RSYSCALL(syscall) diff --git a/lib/libc/arch/powerpc64/sys/tfork_thread.S b/lib/libc/arch/powerpc64/sys/tfork_thread.S new file mode 100644 index 00000000000..0968077b847 --- /dev/null +++ b/lib/libc/arch/powerpc64/sys/tfork_thread.S @@ -0,0 +1,44 @@ +/* $OpenBSD: tfork_thread.S,v 1.1 2020/06/25 02:38:28 drahn Exp $ */ + +/* + * Copyright (c) 2005 Tim Wiess <tim@nop.cx> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "SYS.h" + +ENTRY(__tfork_thread) + /* call __tfork */ + li %r0, SYS___tfork + sc + bne 1f + + /* check if we are parent or child */ + cmpwi %r3, 0 + bnelr + + /* child */ + mtlr %r5 /* fp */ + mr %r3, %r6 /* arg */ + subi %r1, %r1, 32 /* fixup sp to get headroom */ + blrl + + /* child returned, call __threxit */ + li %r0, SYS___threxit + sc +1: + stw %r0, R13_OFFSET_ERRNO(%r13) + li %r3, -1 + blr +END(__tfork_thread) |