Skip to content

Commit

Permalink
* sysdeps/unix/sysv/linux/sh/makecontext.S: New file.
Browse files Browse the repository at this point in the history
	* sysdeps/unix/sysv/linux/sh/sh3/getcontext.S: New file.
	* sysdeps/unix/sysv/linux/sh/sh4/getcontext.S: New file.
	* sysdeps/unix/sysv/linux/sh/sh3/setcontext.S: New file.
	* sysdeps/unix/sysv/linux/sh/sh4/setcontext.S: New file.
	* sysdeps/unix/sysv/linux/sh/sh3/swapcontext.S: New file.
	* sysdeps/unix/sysv/linux/sh/sh4/swapcontext.S: New file.
	* sysdeps/unix/sysv/linux/sh/sh3/ucontext_i.h: New file.
	* sysdeps/unix/sysv/linux/sh/sh4/ucontext_i.h: New file.
	* sysdeps/unix/sysv/linux/sh/sys/ucontext.h: Removed.
	* sysdeps/unix/sysv/linux/sh/sh3/sys/ucontext.h: New file.
	* sysdeps/unix/sysv/linux/sh/sh4/sys/ucontext.h: New file.
  • Loading branch information
Ulrich Drepper committed Oct 16, 2005
1 parent f53d5af commit 76e95c8
Show file tree
Hide file tree
Showing 12 changed files with 1,314 additions and 3 deletions.
15 changes: 15 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
2005-10-16 Kaz Kojima <kkojima@rr.iij4u.or.jp>

* sysdeps/unix/sysv/linux/sh/makecontext.S: New file.
* sysdeps/unix/sysv/linux/sh/sh3/getcontext.S: New file.
* sysdeps/unix/sysv/linux/sh/sh4/getcontext.S: New file.
* sysdeps/unix/sysv/linux/sh/sh3/setcontext.S: New file.
* sysdeps/unix/sysv/linux/sh/sh4/setcontext.S: New file.
* sysdeps/unix/sysv/linux/sh/sh3/swapcontext.S: New file.
* sysdeps/unix/sysv/linux/sh/sh4/swapcontext.S: New file.
* sysdeps/unix/sysv/linux/sh/sh3/ucontext_i.h: New file.
* sysdeps/unix/sysv/linux/sh/sh4/ucontext_i.h: New file.
* sysdeps/unix/sysv/linux/sh/sys/ucontext.h: Removed.
* sysdeps/unix/sysv/linux/sh/sh3/sys/ucontext.h: New file.
* sysdeps/unix/sysv/linux/sh/sh4/sys/ucontext.h: New file.

2005-09-13 Jakub Jelinek <jakub@redhat.com>

[BZ #1228]
Expand Down
145 changes: 145 additions & 0 deletions sysdeps/unix/sysv/linux/sh/makecontext.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/* Create new context.
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */

#include <sysdep.h>

#include "ucontext_i.h"

/* void __makecontext (struct ucontext *ucp, void (*func)(), int argc, ...);
__makecontext sets up a stack and registers for context to run a given
function. The registers are set up like this:
r4-r7: parameters 1 to 4
r8 : uc_link from ucontext structure
pc : (*func) pointer
pr : address of exitcode
r15 : stack pointer for func. */

.text
.align 5
cfi_startproc
ENTRY(__makecontext)
mov #4, r3
mov.l @(oSS_SP,r4), r1
mov.l @(oSS_SIZE,r4), r2
add r1, r2
cmp/gt r6, r3
bf/s 1f
shlr2 r2
sub r6, r2
add r3, r2
1:
shll2 r2
mov #oR15, r0
mov.l @(oLINK,r4), r1
mov.l r2, @(r0,r4)
mov.l r1, @(oR8,r4)
mov #oPC, r0
mov.l r5, @(r0,r4)

cmp/pl r6
bf/s .L1
dt r6
mov.l r7, @(oR4,r4)
cmp/pl r6
bf/s .L1
dt r6
mov.l @(0,r15), r1
mov.l r1, @(oR5,r4)
cmp/pl r6
bf/s .L1
dt r6
mov.l @(4,r15), r1
mov.l r1, @(oR6,r4)
cmp/pl r6
bf/s .L1
dt r6
mov.l @(8,r15), r1
mov.l r1, @(oR7,r4)
mov #12,r0
.L0:
cmp/pl r6
bf/s .L1
dt r6
mov.l @(r0,r15), r1
mov.l r1, @r2
add #4, r0
bra .L0
add #4, r2
.L1:
#ifdef PIC
mova .Lexitcode, r0
#else
mov.l .L2, r0
#endif
add #oPR, r4
rts
mov.l r0, @r4
#ifndef PIC
.align 2
.L2:
.long .Lexitcode
#endif
cfi_endproc

.align 5
.Lexitcode:
tst r8, r8
bt/s 2f
mov r8, r4
#ifdef PIC
mova .Lgot, r0
mov.l .Lgot, r12
add r0, r12
mov.l .L3, r1
bsrf r1
.LPCS0:
nop
#else
mov.l .L3, r1
jsr @r1
nop
#endif
2:
mov.l .L4, r1
#ifdef PIC
add r12, r1
#endif
jsr @r1
mov r0, r4
0:
bra 0b
nop

.align 2
#ifdef PIC
.Lgot:
.long _GLOBAL_OFFSET_TABLE_
.L3:
.long __setcontext@PLT-(.LPCS0+2-(.))
.L4:
.long HIDDEN_JUMPTARGET(exit)@GOTOFF
#else
.L3:
.long __setcontext
.L4:
.long HIDDEN_JUMPTARGET(exit)
#endif
PSEUDO_END(__makecontext)

weak_alias (__makecontext, makecontext)
90 changes: 90 additions & 0 deletions sysdeps/unix/sysv/linux/sh/sh3/getcontext.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/* Save current context.
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */

#include <sysdep.h>

#include "ucontext_i.h"

/* int __getcontext (ucontext_t *uc); */

.text
.align 5
cfi_startproc
ENTRY(__getcontext)

/* Return value of getcontext. R0 is the only register whose
value is not preserved. */
mov #0, r0
mov.l r0, @(oR0,r4)
mov.l r1, @(oR1,r4)
mov.l r2, @(oR2,r4)
mov.l r3, @(oR3,r4)
mov.l r4, @(oR4,r4)
mov.l r5, @(oR5,r4)
mov.l r6, @(oR6,r4)
mov.l r7, @(oR7,r4)
mov r4, r0
add #(oMACL+4), r0
sts.l macl, @-r0
sts.l mach, @-r0
stc.l gbr, @-r0

/* Save T flag to SR. */
movt r1
mov.l r1, @-r0
sts.l pr, @-r0

/* The return address of getcontext is the restart pc. */
sts.l pr, @-r0

mov.l r15, @-r0
mov.l r14, @-r0
mov.l r13, @-r0
mov.l r12, @-r0
mov.l r11, @-r0
mov.l r10, @-r0
mov.l r9, @-r0
mov.l r8, @-r0

/* sigprocmask (SIG_BLOCK, NULL, &uc->uc_sigmask). */
mov r4, r6
add #oSIGMASK, r6
mov #SIG_BLOCK, r4
mov #0, r5
mov #+SYS_ify(sigprocmask), r3
trapa #0x13
mov r0, r1
mov #-12, r2
shad r2, r1
not r1, r1 // r1=0 means r0 = -1 to -4095
tst r1, r1 // i.e. error in linux
bf .Lgetcontext_end
.Lsyscall_error:
SYSCALL_ERROR_HANDLER
.Lgetcontext_end:
/* All done, return 0 for success. */
mov #0, r0
.Lpseudo_end:
rts
nop

cfi_endproc
PSEUDO_END(__getcontext)

weak_alias (__getcontext, getcontext)
101 changes: 101 additions & 0 deletions sysdeps/unix/sysv/linux/sh/sh3/setcontext.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/* Install given context.
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */

#include <sysdep.h>

#include "ucontext_i.h"

/* int __setcontext (const ucontext_t *uc); */

.text
.align 5
cfi_startproc
ENTRY(__setcontext)

mov r4, r8

/* sigprocmask (SIG_SETMASK, &uc->uc_sigmask, NULL). */
mov r4, r5
add #oSIGMASK, r5
mov #SIG_SETMASK, r4
mov #0, r6
mov #+SYS_ify(sigprocmask), r3
trapa #0x13
mov r0, r1
mov #-12, r2
shad r2, r1
not r1, r1 // r1=0 means r0 = -1 to -4095
tst r1, r1 // i.e. error in linux
bf .Lsetcontext_restore
.Lsyscall_error:
SYSCALL_ERROR_HANDLER
.Lpseudo_end:
rts
nop

.Lsetcontext_restore:
mov r8, r0
add #(oPC), r0
mov.l @r0+, r2
lds.l @r0+, pr

/* Restore T frag. */
mov.l @r0+, r1
shlr r1
/* Skip GBR which is used for thread pointer. */
add #4, r0

lds.l @r0+, mach
lds.l @r0+, macl

mov r8, r0
add #(oR9), r0
mov.l @r0+, r9
mov.l @r0+, r10
mov.l @r0+, r11
mov.l @r0+, r12
mov.l @r0+, r13
mov.l @r0+, r14
mov.l @r0+, r15

mov r8, r0
mov.l @(oR0,r0), r1
mov.l r1, @-r15
cfi_adjust_cfa_offset(4)
cfi_rel_offset (r1, 0)
mov.l r2, @-r15
cfi_adjust_cfa_offset(4)
cfi_rel_offset (r2, 0)

mov.l @(oR1,r0), r1
mov.l @(oR2,r0), r2
mov.l @(oR3,r0), r3
mov.l @(oR4,r0), r4
mov.l @(oR5,r0), r5
mov.l @(oR6,r0), r6
mov.l @(oR7,r0), r7
mov.l @(oR8,r0), r8
mov.l @r15+, r0
jmp @r0
mov.l @r15+, r0

cfi_endproc
PSEUDO_END(__setcontext)

weak_alias (__setcontext, setcontext)
Loading

0 comments on commit 76e95c8

Please sign in to comment.