diff --git a/lib/libc/arch/riscv/SYS.h b/lib/libc/arch/riscv/SYS.h index f09e9bfad008..dacded557372 100644 --- a/lib/libc/arch/riscv/SYS.h +++ b/lib/libc/arch/riscv/SYS.h @@ -1,4 +1,4 @@ -/* $NetBSD: SYS.h,v 1.1 2014/09/19 17:36:25 matt Exp $ */ +/* $NetBSD: SYS.h,v 1.2 2015/03/27 06:44:28 matt Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include #include -#define SYSTRAP(x) li v0,SYS_ ## x; scall +#define SYSTRAP(x) li t6,SYS_ ## x; scall #define JUMP_TO_CERROR() j _C_LABEL(__cerror) /* diff --git a/lib/libc/arch/riscv/gen/__setjmp14.S b/lib/libc/arch/riscv/gen/__setjmp14.S index c5e2bd7d388b..802a953ae92d 100644 --- a/lib/libc/arch/riscv/gen/__setjmp14.S +++ b/lib/libc/arch/riscv/gen/__setjmp14.S @@ -1,10 +1,10 @@ -/* $NetBSD: __setjmp14.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ +/* $NetBSD: __setjmp14.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ #include "SYS.h" #include "assym.h" #if defined(LIBC_SCCS) -__RCSID("$NetBSD: __setjmp14.S,v 1.1 2014/09/19 17:36:25 matt Exp $") +__RCSID("$NetBSD: __setjmp14.S,v 1.2 2015/03/27 06:44:28 matt Exp $") #endif /* @@ -21,6 +21,9 @@ ENTRY(__setjmp14) li a1, 1 REG_S a1, JB_MAGIC(a0) /* indicate sigmask */ REG_S ra, JB_RA(a0) /* save return address */ + REG_S sp, JB_SP(a0) /* save stack pointer */ + REG_S gp, JB_GP(a0) /* save global pointer */ + REG_S tp, JB_TP(a0) /* save thread pointer */ REG_S s0, JB_S0(a0) /* save callee saved register */ REG_S s1, JB_S1(a0) /* save callee saved register */ REG_S s2, JB_S2(a0) /* save callee saved register */ @@ -33,40 +36,36 @@ ENTRY(__setjmp14) REG_S s9, JB_S9(a0) /* save callee saved register */ REG_S s10, JB_S10(a0) /* save callee saved register */ REG_S s11, JB_S11(a0) /* save callee saved register */ - REG_S sp, JB_SP(a0) /* save stack pointer */ - REG_S tp, JB_TP(a0) /* save thread pointer */ - REG_S gp, JB_GP(a0) /* save global pointer */ #ifndef _SOFT_FLOAT frcsr t2 /* get FSCR */ REG_S t2, JB_FCSR(a0) /* save it */ - fsd fs0, JB_F0(a0) /* save callee saved register */ - fsd fs1, JB_F1(a0) /* save callee saved register */ - fsd fs2, JB_F2(a0) /* save callee saved register */ - fsd fs3, JB_F3(a0) /* save callee saved register */ - fsd fs4, JB_F4(a0) /* save callee saved register */ - fsd fs5, JB_F5(a0) /* save callee saved register */ - fsd fs6, JB_F6(a0) /* save callee saved register */ - fsd fs7, JB_F7(a0) /* save callee saved register */ - fsd fs8, JB_F8(a0) /* save callee saved register */ - fsd fs9, JB_F9(a0) /* save callee saved register */ - fsd fs10, JB_F10(a0) /* save callee saved register */ - fsd fs11, JB_F11(a0) /* save callee saved register */ - fsd fs12, JB_F12(a0) /* save callee saved register */ - fsd fs13, JB_F13(a0) /* save callee saved register */ - fsd fs14, JB_F14(a0) /* save callee saved register */ - fsd fs15, JB_F15(a0) /* save callee saved register */ + fsd fs0, JB_FS0(a0) /* save callee saved register */ + fsd fs1, JB_FS1(a0) /* save callee saved register */ + fsd fs2, JB_FS2(a0) /* save callee saved register */ + fsd fs3, JB_FS3(a0) /* save callee saved register */ + fsd fs4, JB_FS4(a0) /* save callee saved register */ + fsd fs5, JB_FS5(a0) /* save callee saved register */ + fsd fs6, JB_FS6(a0) /* save callee saved register */ + fsd fs7, JB_FS7(a0) /* save callee saved register */ + fsd fs8, JB_FS8(a0) /* save callee saved register */ + fsd fs9, JB_FS9(a0) /* save callee saved register */ + fsd fs10, JB_FS10(a0) /* save callee saved register */ + fsd fs11, JB_FS11(a0) /* save callee saved register */ #endif addi a2, a0, JB_SIGMASK /* &sigmask */ li a1, 0 li a0, SIG_BLOCK SYSTRAP(__sigprocmask14) /* assume no error */ - li v0, 0 /* success */ /* indicate success */ + li a0, 0 /* success */ /* indicate success */ ret /* error */ /* return */ END(__setjmp14) ENTRY(__longjmp14) REG_L ra, JB_RA(a0) /* restore return address */ + REG_L sp, JB_SP(a0) /* restore stack pointer */ + REG_L gp, JB_GP(a0) /* restore global pointer */ + #REG_L tp, JB_TP(a0) /* restore thread pointer */ REG_L s0, JB_S0(a0) /* restore callee saved register */ REG_L s1, JB_S1(a0) /* restore callee saved register */ REG_L s2, JB_S2(a0) /* restore callee saved register */ @@ -79,28 +78,21 @@ ENTRY(__longjmp14) REG_L s9, JB_S9(a0) /* restore callee saved register */ REG_L s10, JB_S10(a0) /* restore callee saved register */ REG_L s11, JB_S11(a0) /* restore callee saved register */ - REG_L sp, JB_SP(a0) /* restore stack pointer */ - #REG_L tp, JB_TP(a0) /* restore thread pointer */ - REG_L gp, JB_GP(a0) /* restore global pointer */ #ifndef _SOFT_FLOAT REG_L t2, JB_FCSR(a0) /* get it */ fscsr t2 /* restore FSCR */ - fld fs0, JB_F0(a0) /* restore callee saved register */ - fld fs1, JB_F1(a0) /* restore callee saved register */ - fld fs2, JB_F2(a0) /* restore callee saved register */ - fld fs3, JB_F3(a0) /* restore callee saved register */ - fld fs4, JB_F4(a0) /* restore callee saved register */ - fld fs5, JB_F5(a0) /* restore callee saved register */ - fld fs6, JB_F6(a0) /* restore callee saved register */ - fld fs7, JB_F7(a0) /* restore callee saved register */ - fld fs8, JB_F8(a0) /* restore callee saved register */ - fld fs9, JB_F9(a0) /* restore callee saved register */ - fld fs10, JB_F10(a0) /* restore callee saved register */ - fld fs11, JB_F11(a0) /* restore callee saved register */ - fld fs12, JB_F12(a0) /* restore callee saved register */ - fld fs13, JB_F13(a0) /* restore callee saved register */ - fld fs14, JB_F14(a0) /* restore callee saved register */ - fld fs15, JB_F15(a0) /* restore callee saved register */ + fld fs0, JB_FS0(a0) /* restore callee saved register */ + fld fs1, JB_FS1(a0) /* restore callee saved register */ + fld fs2, JB_FS2(a0) /* restore callee saved register */ + fld fs3, JB_FS3(a0) /* restore callee saved register */ + fld fs4, JB_FS4(a0) /* restore callee saved register */ + fld fs5, JB_FS5(a0) /* restore callee saved register */ + fld fs6, JB_FS6(a0) /* restore callee saved register */ + fld fs7, JB_FS7(a0) /* restore callee saved register */ + fld fs8, JB_FS8(a0) /* restore callee saved register */ + fld fs9, JB_FS9(a0) /* restore callee saved register */ + fld fs10, JB_FS10(a0) /* restore callee saved register */ + fld fs11, JB_FS11(a0) /* restore callee saved register */ #endif move t1, a1 /* save return value */ li a2, 0 @@ -108,8 +100,8 @@ ENTRY(__longjmp14) li a0, SIG_SETMASK SYSTRAP(__sigprocmask14) /* assume no error */ nop /* error */ - li v0, 1 /* success */ /* default return value */ + li a0, 1 /* success */ /* default return value */ beqz t1, 1f /* test return value */ - move v0, t1 /* use it if not 0 */ + move a0, t1 /* use it if not 0 */ 1: ret END(__longjmp14) diff --git a/lib/libc/arch/riscv/gen/_setjmp.S b/lib/libc/arch/riscv/gen/_setjmp.S index 732740e73746..6d430c52f3e0 100644 --- a/lib/libc/arch/riscv/gen/_setjmp.S +++ b/lib/libc/arch/riscv/gen/_setjmp.S @@ -1,4 +1,4 @@ -/* $NetBSD: _setjmp.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ +/* $NetBSD: _setjmp.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ #include "assym.h" #if defined(LIBC_SCCS) -__RCSID("$NetBSD: _setjmp.S,v 1.1 2014/09/19 17:36:25 matt Exp $") +__RCSID("$NetBSD: _setjmp.S,v 1.2 2015/03/27 06:44:28 matt Exp $") #endif /* @@ -49,6 +49,9 @@ __RCSID("$NetBSD: _setjmp.S,v 1.1 2014/09/19 17:36:25 matt Exp $") ENTRY(_setjmp) REG_S zero, JB_MAGIC(a0) /* indicate no sigmask */ REG_S ra, JB_RA(a0) /* save return address */ + REG_S sp, JB_SP(a0) /* save stack pointer */ + REG_S gp, JB_GP(a0) /* save global pointer */ + REG_S tp, JB_TP(a0) /* save thread pointer */ REG_S s0, JB_S0(a0) /* save callee saved register */ REG_S s1, JB_S1(a0) /* save callee saved register */ REG_S s2, JB_S2(a0) /* save callee saved register */ @@ -61,35 +64,31 @@ ENTRY(_setjmp) REG_S s9, JB_S9(a0) /* save callee saved register */ REG_S s10, JB_S10(a0) /* save callee saved register */ REG_S s11, JB_S11(a0) /* save callee saved register */ - REG_S sp, JB_SP(a0) /* save stack pointer */ - REG_S tp, JB_TP(a0) /* save thread pointer */ - REG_S gp, JB_GP(a0) /* save global pointer */ #ifndef _SOFT_FLOAT frcsr t2 /* get FSCR */ REG_S t2, JB_FCSR(a0) /* save it */ - fsd fs0, JB_F0(a0) /* save callee saved register */ - fsd fs1, JB_F1(a0) /* save callee saved register */ - fsd fs2, JB_F2(a0) /* save callee saved register */ - fsd fs3, JB_F3(a0) /* save callee saved register */ - fsd fs4, JB_F4(a0) /* save callee saved register */ - fsd fs5, JB_F5(a0) /* save callee saved register */ - fsd fs6, JB_F6(a0) /* save callee saved register */ - fsd fs7, JB_F7(a0) /* save callee saved register */ - fsd fs8, JB_F8(a0) /* save callee saved register */ - fsd fs9, JB_F9(a0) /* save callee saved register */ - fsd fs10, JB_F10(a0) /* save callee saved register */ - fsd fs11, JB_F11(a0) /* save callee saved register */ - fsd fs12, JB_F12(a0) /* save callee saved register */ - fsd fs13, JB_F13(a0) /* save callee saved register */ - fsd fs14, JB_F14(a0) /* save callee saved register */ - fsd fs15, JB_F15(a0) /* save callee saved register */ + fsd fs0, JB_FS0(a0) /* save callee saved register */ + fsd fs1, JB_FS1(a0) /* save callee saved register */ + fsd fs2, JB_FS2(a0) /* save callee saved register */ + fsd fs3, JB_FS3(a0) /* save callee saved register */ + fsd fs4, JB_FS4(a0) /* save callee saved register */ + fsd fs5, JB_FS5(a0) /* save callee saved register */ + fsd fs6, JB_FS6(a0) /* save callee saved register */ + fsd fs7, JB_FS7(a0) /* save callee saved register */ + fsd fs8, JB_FS8(a0) /* save callee saved register */ + fsd fs9, JB_FS9(a0) /* save callee saved register */ + fsd fs10, JB_FS10(a0) /* save callee saved register */ + fsd fs11, JB_FS11(a0) /* save callee saved register */ #endif - li x1, 0 /* indicate success */ + li a0, 0 /* indicate success */ ret /* return */ END(_setjmp) ENTRY(_longjmp) REG_L ra, JB_RA(a0) /* save return address */ + REG_L sp, JB_SP(a0) /* save stack pointer */ + REG_L gp, JB_GP(a0) /* save global pointer */ + #REG_L tp, JB_TP(a0) /* save thread pointer */ REG_L s0, JB_S0(a0) /* save callee saved register */ REG_L s1, JB_S1(a0) /* save callee saved register */ REG_L s2, JB_S2(a0) /* save callee saved register */ @@ -102,31 +101,24 @@ ENTRY(_longjmp) REG_L s9, JB_S9(a0) /* save callee saved register */ REG_L s10, JB_S10(a0) /* save callee saved register */ REG_L s11, JB_S11(a0) /* save callee saved register */ - REG_L sp, JB_SP(a0) /* save stack pointer */ - #REG_L tp, JB_TP(a0) /* save thread pointer */ - REG_L gp, JB_GP(a0) /* save global pointer */ #ifndef _SOFT_FLOAT REG_L t2, JB_FCSR(a0) /* get it */ fscsr t2 /* restore FSCR */ - fld fs0, JB_F0(a0) /* restore callee saved register */ - fld fs1, JB_F1(a0) /* restore callee saved register */ - fld fs2, JB_F2(a0) /* restore callee saved register */ - fld fs3, JB_F3(a0) /* restore callee saved register */ - fld fs4, JB_F4(a0) /* restore callee saved register */ - fld fs5, JB_F5(a0) /* restore callee saved register */ - fld fs6, JB_F6(a0) /* restore callee saved register */ - fld fs7, JB_F7(a0) /* restore callee saved register */ - fld fs8, JB_F8(a0) /* restore callee saved register */ - fld fs9, JB_F9(a0) /* restore callee saved register */ - fld fs10, JB_F10(a0) /* restore callee saved register */ - fld fs11, JB_F11(a0) /* restore callee saved register */ - fld fs12, JB_F12(a0) /* restore callee saved register */ - fld fs13, JB_F13(a0) /* restore callee saved register */ - fld fs14, JB_F14(a0) /* restore callee saved register */ - fld fs15, JB_F15(a0) /* restore callee saved register */ + fld fs0, JB_FS0(a0) /* restore callee saved register */ + fld fs1, JB_FS1(a0) /* restore callee saved register */ + fld fs2, JB_FS2(a0) /* restore callee saved register */ + fld fs3, JB_FS3(a0) /* restore callee saved register */ + fld fs4, JB_FS4(a0) /* restore callee saved register */ + fld fs5, JB_FS5(a0) /* restore callee saved register */ + fld fs6, JB_FS6(a0) /* restore callee saved register */ + fld fs7, JB_FS7(a0) /* restore callee saved register */ + fld fs8, JB_FS8(a0) /* restore callee saved register */ + fld fs9, JB_FS9(a0) /* restore callee saved register */ + fld fs10, JB_FS10(a0) /* restore callee saved register */ + fld fs11, JB_FS11(a0) /* restore callee saved register */ #endif - li v0, 1 /* default return value */ + li a0, 1 /* default return value */ beqz a1, 1f /* test return value */ - move v0, a1 /* use it if not 0 */ + move a0, a1 /* use it if not 0 */ 1: ret END(_longjmp) diff --git a/lib/libc/arch/riscv/gen/swapcontext.S b/lib/libc/arch/riscv/gen/swapcontext.S index dcfa9b6f9557..4a6cf4e2e1e4 100644 --- a/lib/libc/arch/riscv/gen/swapcontext.S +++ b/lib/libc/arch/riscv/gen/swapcontext.S @@ -1,4 +1,4 @@ -/* $NetBSD: swapcontext.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ +/* $NetBSD: swapcontext.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "SYS.h" #include "assym.h" -__RCSID("$NetBSD: swapcontext.S,v 1.1 2014/09/19 17:36:25 matt Exp $") +__RCSID("$NetBSD: swapcontext.S,v 1.2 2015/03/27 06:44:28 matt Exp $") #define CALLFRAME_UCP CALLFRAME_S1 #define CALLFRAME_OUCP CALLFRAME_S0 @@ -44,13 +44,14 @@ ENTRY(swapcontext) REG_S a1, CALLFRAME_UCP(sp) # save ucp call PLT(_C_LABEL(_getcontext)) # getcontext(oucp) + mv t0, a0 # save return value REG_L ra, CALLFRAME_RA(sp) # restore return address REG_L a0, CALLFRAME_UCP(sp) # load ucp REG_L a1, CALLFRAME_OUCP(sp) # load oucp for adjustment addi sp, sp, CALLFRAME_SIZ # restore stack - bnez v0, 1f # error? yes, cleanup + bnez t0, 1f # error? yes, cleanup REG_S ra, UC_GREGS_PC(a1) # pc <- ra REG_S sp, UC_GREGS_SP(a1) # adjust sp diff --git a/lib/libc/arch/riscv/sys/__clone.S b/lib/libc/arch/riscv/sys/__clone.S index 04b274d4d4e6..aed6ecfcc009 100644 --- a/lib/libc/arch/riscv/sys/__clone.S +++ b/lib/libc/arch/riscv/sys/__clone.S @@ -1,4 +1,4 @@ -/* $NetBSD: __clone.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ +/* $NetBSD: __clone.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ #include "SYS.h" #if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: __clone.S,v 1.1 2014/09/19 17:36:25 matt Exp $"); + RCSID("$NetBSD: __clone.S,v 1.2 2015/03/27 06:44:28 matt Exp $"); #endif /* SYSLIBC_SCCS and not lint */ #ifdef WEAK_ALIAS @@ -48,8 +48,9 @@ ENTRY(__clone) /* * Sanity checks: func and stack may not be NULL. */ - li v0, EINVAL - beqz a0, 8f + mv t0, a0 /* we need a0 for return value */ + li a0, EINVAL + beqz t0, 8f beqz a1, 8f /* @@ -58,7 +59,7 @@ ENTRY(__clone) * do this: the child's stack. */ addi a1, a1, -CALLFRAME_SIZ - REG_S a0, 0(a1) + REG_S t0, 0(a1) REG_S a3, SZREG(a1) /* @@ -66,9 +67,9 @@ ENTRY(__clone) */ mv a0, a2 SYSTRAP(__clone) - # v1 (rv[1]) == 0, parent, child pid in v0 + # a1 (rv[1]) == 0, parent, child pid in a0 8: JUMP_TO_CERROR() /* error */ - bnez v1, 9f /* success */ + bnez a1, 9f /* success */ ret # parent return /* NOTREACHED */ @@ -82,16 +83,15 @@ ENTRY(__clone) * highest is unused. a1 should equal sp now. */ - REG_L v1, 0(sp) + REG_L t0, 0(sp) REG_L a0, SZREG(sp) REG_S zero, CALLFRAME_RA(sp) /* make sure stack frame ends */ /* Call the clone's entry point. */ - jalr v1 + jalr t0 /* Pass the return value to _exit. */ - mv a0, v0 jump _C_LABEL(_exit) /* NOTREACHED */ diff --git a/lib/libc/arch/riscv/sys/__sigtramp2.S b/lib/libc/arch/riscv/sys/__sigtramp2.S index 1069d1c6bf3d..b82df24debcd 100644 --- a/lib/libc/arch/riscv/sys/__sigtramp2.S +++ b/lib/libc/arch/riscv/sys/__sigtramp2.S @@ -1,4 +1,4 @@ -/* $NetBSD: __sigtramp2.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ +/* $NetBSD: __sigtramp2.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ #include "assym.h" #if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: __sigtramp2.S,v 1.1 2014/09/19 17:36:25 matt Exp $") + RCSID("$NetBSD: __sigtramp2.S,v 1.2 2015/03/27 06:44:28 matt Exp $") #endif /* SYSLIBC_SCCS and not lint */ @@ -50,6 +50,5 @@ ENTRY_NP(__sigtramp_siginfo_2) addi a0, sp, SIGINFO_SIZE /* address of ucontext */ SYSTRAP(setcontext) /* and do setcontext */ nop - move a0, v0 /* exit with errno */ SYSTRAP(exit) /* if sigreturn fails */ END(__sigtramp_siginfo_2) diff --git a/lib/libc/arch/riscv/sys/__syscall.S b/lib/libc/arch/riscv/sys/__syscall.S index 1bbfa24cdc9b..bfb1aa1083de 100644 --- a/lib/libc/arch/riscv/sys/__syscall.S +++ b/lib/libc/arch/riscv/sys/__syscall.S @@ -1,9 +1,9 @@ -/* $NetBSD: __syscall.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ +/* $NetBSD: __syscall.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ #include "SYS.h" ENTRY(__syscall) - mv v0, a0 + mv t6, a0 mv a0, a1 mv a1, a2 mv a2, a3 diff --git a/lib/libc/arch/riscv/sys/__vfork14.S b/lib/libc/arch/riscv/sys/__vfork14.S index 6430bfe13668..b88122ac6bb3 100644 --- a/lib/libc/arch/riscv/sys/__vfork14.S +++ b/lib/libc/arch/riscv/sys/__vfork14.S @@ -1,4 +1,4 @@ -/* $NetBSD: __vfork14.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ +/* $NetBSD: __vfork14.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -38,21 +38,21 @@ #if 0 RCSID("from: @(#)Ovfork.s 8.1 (Berkeley) 6/4/93") #else - RCSID("$NetBSD: __vfork14.S,v 1.1 2014/09/19 17:36:25 matt Exp $") + RCSID("$NetBSD: __vfork14.S,v 1.2 2015/03/27 06:44:28 matt Exp $") #endif #endif /* LIBC_SCCS and not lint */ /* * pid = vfork(); * - * v1 == 0 in parent process, v1 == 1 in child process. - * v0 == pid of child in parent, v0 == pid of parent in child. + * a1 == 0 in parent process, a1 == 1 in child process. + * a0 == pid of child in parent, a0 == pid of parent in child. */ ENTRY(__vfork14) SYSTRAP(__vfork14) JUMP_TO_CERROR() /* error */ - addi v1, v1, -1 /* success */ - and v0, v0, v1 + addi a1, a1, -1 /* success */ + and a0, a0, a1 ret END(__vfork14) diff --git a/lib/libc/arch/riscv/sys/brk.S b/lib/libc/arch/riscv/sys/brk.S index 6c76f410cf8f..46431924abd6 100644 --- a/lib/libc/arch/riscv/sys/brk.S +++ b/lib/libc/arch/riscv/sys/brk.S @@ -1,4 +1,4 @@ -/* $NetBSD: brk.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ +/* $NetBSD: brk.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "SYS.h" #if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: brk.S,v 1.1 2014/09/19 17:36:25 matt Exp $") + RCSID("$NetBSD: brk.S,v 1.2 2015/03/27 06:44:28 matt Exp $") #endif /* LIBC_SCCS and not lint */ .hidden _C_LABEL(__minbrk) @@ -57,13 +57,13 @@ _C_LABEL(__curbrk): ENTRY(_brk) auipc t1, %pcrel_hi(_C_LABEL(__minbrk)) addi t1, t1, %pcrel_lo(_C_LABEL(__minbrk)) - PTR_L v0, 0(t1) - bgeu a0, v0, 1f - move a0, v0 # dont allow break < minbrk + PTR_L t5, 0(t1) + bgeu a0, t5, 1f + move a0, t5 # dont allow break < minbrk 1: SYSTRAP(break) JUMP_TO_CERROR() /* error */ PTR_S a0, __SIZEOF_POINTER__(t1) /* success */ - move v0, zero + move a0, zero ret END(_brk) diff --git a/lib/libc/arch/riscv/sys/cerror.S b/lib/libc/arch/riscv/sys/cerror.S index 0aede8a43a08..42ec12f510e2 100644 --- a/lib/libc/arch/riscv/sys/cerror.S +++ b/lib/libc/arch/riscv/sys/cerror.S @@ -1,4 +1,4 @@ -/* $NetBSD: cerror.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ +/* $NetBSD: cerror.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -35,7 +35,7 @@ #include "SYS.h" #if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: cerror.S,v 1.1 2014/09/19 17:36:25 matt Exp $") + RCSID("$NetBSD: cerror.S,v 1.2 2015/03/27 06:44:28 matt Exp $") #endif /* LIBC_SCCS and not lint */ .protected _C_LABEL(__cerror) @@ -45,19 +45,19 @@ ENTRY_NP(__cerror) #ifdef _REENTRANT addi sp, sp, -CALLFRAME_SIZ REG_S ra, CALLFRAME_RA(sp) # save return address - sw v0, CALLFRAME_S0(sp) # save errno value + INT_S a0, CALLFRAME_S0(sp) # save errno value call PLT(_C_LABEL(__errno)) # locate address of errno - lw t0, CALLFRAME_S0(sp) # retrieve errno value + INT_L t0, CALLFRAME_S0(sp) # retrieve errno value REG_L ra, CALLFRAME_RA(sp) # retrieve return address - sw t0, 0(v0) # update errno value + INT_S t0, 0(a0) # update errno value addi sp, sp, CALLFRAME_SIZ #else - aiupc v1, %hi(_C_LABEL(errno)) - sw v0, %lo(_C_LABEL(errno))(v1) + aiupc a1, %hi(_C_LABEL(errno)) + sw a0, %lo(_C_LABEL(errno))(a1) #endif /* _REENTRANT */ - li v0, -1 - li v1, -1 + li a0, -1 + li a1, -1 ret END(__cerror) diff --git a/lib/libc/arch/riscv/sys/fork.S b/lib/libc/arch/riscv/sys/fork.S index 3c8cc8dee154..0ad2e6bd036b 100644 --- a/lib/libc/arch/riscv/sys/fork.S +++ b/lib/libc/arch/riscv/sys/fork.S @@ -1,4 +1,4 @@ -/* $NetBSD: fork.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ +/* $NetBSD: fork.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ /*- @@ -32,14 +32,14 @@ #include "SYS.h" #if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: fork.S,v 1.1 2014/09/19 17:36:25 matt Exp $") + RCSID("$NetBSD: fork.S,v 1.2 2015/03/27 06:44:28 matt Exp $") #endif /* LIBC_SCCS and not lint */ ENTRY(__fork) SYSTRAP(fork) // pid = fork() JUMP_TO_CERROR() /* error */ /* success */ - addi v1, v1, -1 // v1 0->0xffffffff in parent, 1->0 in child - and v0, v0, v1 // v0 = child pid in parent, 0 in child + addi a1, a1, -1 // a1 0->0xffffffff in parent, 1->0 in child + and a0, a0, a1 // a0 = child pid in parent, 0 in child ret END(__fork) diff --git a/lib/libc/arch/riscv/sys/pipe.S b/lib/libc/arch/riscv/sys/pipe.S index 47c3940fd13a..34daef12f612 100644 --- a/lib/libc/arch/riscv/sys/pipe.S +++ b/lib/libc/arch/riscv/sys/pipe.S @@ -1,4 +1,4 @@ -/* $NetBSD: pipe.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ +/* $NetBSD: pipe.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "SYS.h" #if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: pipe.S,v 1.1 2014/09/19 17:36:25 matt Exp $") + RCSID("$NetBSD: pipe.S,v 1.2 2015/03/27 06:44:28 matt Exp $") #endif /* LIBC_SCCS and not lint */ #ifdef WEAK_ALIAS @@ -40,11 +40,12 @@ WEAK_ALIAS(pipe, _pipe) #endif ENTRY(_pipe) + mv a2, a0 # a0 will be overwritten SYSTRAP(pipe) # pipe(fildes) int fildes[2]; JUMP_TO_CERROR() /* error */ /* success */ - sw v0, 0(a0) # store the two file descriptors - sw v1, __SIZEOF_INT__(a0) - li v0, 0 + sw a0, 0(a2) # store the two file descriptors + sw a1, __SIZEOF_INT__(a2) + li a0, 0 ret END(_pipe) diff --git a/lib/libc/arch/riscv/sys/ptrace.S b/lib/libc/arch/riscv/sys/ptrace.S index 0fc998f5eff3..48cfc19ff94e 100644 --- a/lib/libc/arch/riscv/sys/ptrace.S +++ b/lib/libc/arch/riscv/sys/ptrace.S @@ -1,4 +1,4 @@ -/* $NetBSD: ptrace.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ +/* $NetBSD: ptrace.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -35,7 +35,7 @@ #include "SYS.h" #if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: ptrace.S,v 1.1 2014/09/19 17:36:25 matt Exp $") + RCSID("$NetBSD: ptrace.S,v 1.2 2015/03/27 06:44:28 matt Exp $") #endif /* LIBC_SCCS and not lint */ #define XCALLFRAME_SIZ (8*SZREG) @@ -56,6 +56,8 @@ ENTRY(ptrace) call PLT(_C_LABEL(__errno)) + INT_S zero, 0(a0) + REG_L a3, XCALLFRAME_A3(sp) REG_L a2, XCALLFRAME_A2(sp) REG_L a1, XCALLFRAME_A1(sp) @@ -63,10 +65,9 @@ ENTRY(ptrace) REG_L ra, XCALLFRAME_RA(sp) addi sp, sp, XCALLFRAME_SIZ - sw zero, 0(v0) #else - auipc v0, %hi(_C_LABEL(errno)) - sw zero, %lo(_C_LABEL(errno))(v0) + auipc t0, %hi(_C_LABEL(errno)) + INT_S zero, %lo(_C_LABEL(errno))(t0) #endif SYSTRAP(ptrace) diff --git a/lib/libc/arch/riscv/sys/sbrk.S b/lib/libc/arch/riscv/sys/sbrk.S index 9a75576bd154..7d64004ca168 100644 --- a/lib/libc/arch/riscv/sys/sbrk.S +++ b/lib/libc/arch/riscv/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $NetBSD: sbrk.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ +/* $NetBSD: sbrk.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -46,8 +46,8 @@ ENTRY(_sbrk) add a0, a0, t2 // compute current break SYSTRAP(break) JUMP_TO_CERROR() /* error */ - move v0, t2 // return old val of curbrk from above PTR_S a0, 0(t1) // save current val of curbrk from above + move a0, t2 // return old val of curbrk from above ret 1: END(_sbrk)