diff options
Diffstat (limited to 'sysdeps/unix/sysv')
-rw-r--r-- | sysdeps/unix/sysv/linux/alpha/Makefile | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/alpha/getcontext.S | 186 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/alpha/makecontext.S | 164 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/alpha/setcontext.S | 35 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/alpha/swapcontext.S | 51 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/alpha/ucontext-offsets.sym | 18 |
6 files changed, 458 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/alpha/Makefile b/sysdeps/unix/sysv/linux/alpha/Makefile index 3097cc3047..37a9214fe9 100644 --- a/sysdeps/unix/sysv/linux/alpha/Makefile +++ b/sysdeps/unix/sysv/linux/alpha/Makefile @@ -2,6 +2,10 @@ ifeq ($(subdir),posix) sysdep_routines += oldglob endif +ifeq ($(subdir),stdlib) +gen-as-const-headers += ucontext-offsets.sym +endif + ifeq ($(subdir),misc) sysdep_headers += alpha/ptrace.h alpha/regdef.h sys/io.h diff --git a/sysdeps/unix/sysv/linux/alpha/getcontext.S b/sysdeps/unix/sysv/linux/alpha/getcontext.S new file mode 100644 index 0000000000..3566890cf9 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/getcontext.S @@ -0,0 +1,186 @@ +/* Save current context. + Copyright (C) 2004 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-offsets.h> + +/* ??? Should be a better place for this that's asm friendly. */ +#define SIG_BLOCK 1 + + +ENTRY (__getcontext) +#ifdef PROF + ldgp gp, 0(pv) + .set noat + lda AT, _mcount + jsr AT, (AT), _mcount + .set at + .prologue 1 +#else + .prologue 0 +#endif + + bsr $0, __getcontext_x + mov $31, $0 + ret + +END(__getcontext) +weak_alias(__getcontext, getcontext) + + +/* An internal routine used by getcontext and setcontext. + The incomming return address register is $0. */ + + .align 4 + .globl __getcontext_x + .hidden __getcontext_x + .usepv __getcontext_x, no + + cfi_startproc + cfi_return_column (64) +__getcontext_x: + cfi_register (64, 0) + + /* Return value of getcontext. $0 is the only register + whose value is not preserved. */ + stq $31, UC_SIGCTX+SC_REGS($16) + + /* Store all registers into the context. */ + stq $1, UC_SIGCTX+SC_REGS+1*8($16) + stq $2, UC_SIGCTX+SC_REGS+2*8($16) + stq $3, UC_SIGCTX+SC_REGS+3*8($16) + stq $4, UC_SIGCTX+SC_REGS+4*8($16) + stq $5, UC_SIGCTX+SC_REGS+5*8($16) + stq $6, UC_SIGCTX+SC_REGS+6*8($16) + stq $7, UC_SIGCTX+SC_REGS+7*8($16) + stq $8, UC_SIGCTX+SC_REGS+8*8($16) + stq $9, UC_SIGCTX+SC_REGS+9*8($16) + stq $10, UC_SIGCTX+SC_REGS+10*8($16) + stq $11, UC_SIGCTX+SC_REGS+11*8($16) + stq $12, UC_SIGCTX+SC_REGS+12*8($16) + stq $13, UC_SIGCTX+SC_REGS+13*8($16) + stq $14, UC_SIGCTX+SC_REGS+14*8($16) + stq $15, UC_SIGCTX+SC_REGS+15*8($16) + stq $16, UC_SIGCTX+SC_REGS+16*8($16) + stq $17, UC_SIGCTX+SC_REGS+17*8($16) + stq $18, UC_SIGCTX+SC_REGS+18*8($16) + stq $19, UC_SIGCTX+SC_REGS+19*8($16) + stq $20, UC_SIGCTX+SC_REGS+20*8($16) + stq $21, UC_SIGCTX+SC_REGS+21*8($16) + stq $22, UC_SIGCTX+SC_REGS+22*8($16) + stq $23, UC_SIGCTX+SC_REGS+23*8($16) + stq $24, UC_SIGCTX+SC_REGS+24*8($16) + stq $25, UC_SIGCTX+SC_REGS+25*8($16) + stq $26, UC_SIGCTX+SC_REGS+26*8($16) + stq $27, UC_SIGCTX+SC_REGS+27*8($16) + stq $28, UC_SIGCTX+SC_REGS+28*8($16) + stq $29, UC_SIGCTX+SC_REGS+29*8($16) + stq $30, UC_SIGCTX+SC_REGS+30*8($16) + stq $31, UC_SIGCTX+SC_REGS+31*8($16) + + stt $f0, UC_SIGCTX+SC_FPREGS+0*8($16) + stt $f1, UC_SIGCTX+SC_FPREGS+1*8($16) + stt $f2, UC_SIGCTX+SC_FPREGS+2*8($16) + stt $f3, UC_SIGCTX+SC_FPREGS+3*8($16) + stt $f4, UC_SIGCTX+SC_FPREGS+4*8($16) + stt $f5, UC_SIGCTX+SC_FPREGS+5*8($16) + stt $f6, UC_SIGCTX+SC_FPREGS+6*8($16) + stt $f7, UC_SIGCTX+SC_FPREGS+7*8($16) + stt $f8, UC_SIGCTX+SC_FPREGS+8*8($16) + stt $f9, UC_SIGCTX+SC_FPREGS+9*8($16) + stt $f10, UC_SIGCTX+SC_FPREGS+10*8($16) + stt $f11, UC_SIGCTX+SC_FPREGS+11*8($16) + stt $f12, UC_SIGCTX+SC_FPREGS+12*8($16) + stt $f13, UC_SIGCTX+SC_FPREGS+13*8($16) + stt $f14, UC_SIGCTX+SC_FPREGS+14*8($16) + stt $f15, UC_SIGCTX+SC_FPREGS+15*8($16) + stt $f16, UC_SIGCTX+SC_FPREGS+16*8($16) + stt $f17, UC_SIGCTX+SC_FPREGS+17*8($16) + stt $f18, UC_SIGCTX+SC_FPREGS+18*8($16) + stt $f19, UC_SIGCTX+SC_FPREGS+19*8($16) + stt $f20, UC_SIGCTX+SC_FPREGS+20*8($16) + stt $f21, UC_SIGCTX+SC_FPREGS+21*8($16) + stt $f22, UC_SIGCTX+SC_FPREGS+22*8($16) + stt $f23, UC_SIGCTX+SC_FPREGS+23*8($16) + stt $f24, UC_SIGCTX+SC_FPREGS+24*8($16) + stt $f25, UC_SIGCTX+SC_FPREGS+25*8($16) + stt $f26, UC_SIGCTX+SC_FPREGS+26*8($16) + stt $f27, UC_SIGCTX+SC_FPREGS+27*8($16) + stt $f28, UC_SIGCTX+SC_FPREGS+28*8($16) + stt $f29, UC_SIGCTX+SC_FPREGS+29*8($16) + stt $f30, UC_SIGCTX+SC_FPREGS+30*8($16) + stt $f31, UC_SIGCTX+SC_FPREGS+31*8($16) + + mf_fpcr $f0 + lda $1, 8 + stt $f0, UC_SIGCTX+SC_FPCR($16) + + /* The return address of getcontext is the restart pc. */ + stq $26, UC_SIGCTX+SC_PC($16) + + /* Userlevel always has a processor status word of 8. */ + stq $1, UC_SIGCTX+SC_PS($16) + + /* Save registers around the syscall. We preserve $17 + for the benefit of swapcontext. */ + subq $30, 4*8, $30 + cfi_adjust_cfa_offset(4*8) + stq $0, 0($30) + cfi_rel_offset(64, 0) + stq $16, 8($30) + stq $17, 16($30) + + /* Save the current signal mask. Whee, there are three + copies of this in the alpha ucontext_t. */ + lda $16, SIG_BLOCK + lda $17, 0 + lda $0, __NR_osf_sigprocmask + callsys + + ldq $16, 8($30) + ldq $17, 16($30) + + stq $0, UC_OSF_SIGMASK($16) + stq $0, UC_SIGCTX+SC_MASK($16) + stq $0, UC_SIGMASK($16) + stq $31, UC_SIGMASK + 1*8($16) + stq $31, UC_SIGMASK + 2*8($16) + stq $31, UC_SIGMASK + 3*8($16) + stq $31, UC_SIGMASK + 4*8($16) + stq $31, UC_SIGMASK + 5*8($16) + stq $31, UC_SIGMASK + 6*8($16) + stq $31, UC_SIGMASK + 7*8($16) + stq $31, UC_SIGMASK + 8*8($16) + stq $31, UC_SIGMASK + 9*8($16) + stq $31, UC_SIGMASK +10*8($16) + stq $31, UC_SIGMASK +11*8($16) + stq $31, UC_SIGMASK +12*8($16) + stq $31, UC_SIGMASK +13*8($16) + stq $31, UC_SIGMASK +14*8($16) + stq $31, UC_SIGMASK +15*8($16) + + ldq $0, 0($30) + addq $30, 4*8, $30 + cfi_register (64, 0) + cfi_adjust_cfa_offset(-4*8) + ret $31, ($0), 1 + + cfi_endproc + .size __getcontext_x, .-__getcontext_x + .type __getcontext_x, @function diff --git a/sysdeps/unix/sysv/linux/alpha/makecontext.S b/sysdeps/unix/sysv/linux/alpha/makecontext.S new file mode 100644 index 0000000000..223117e26d --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/makecontext.S @@ -0,0 +1,164 @@ +/* Copyright (C) 2004 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-offsets.h> + + +ENTRY(__makecontext) + ldgp $29, 0($27) +#ifdef PROF + .set noat + lda AT, _mcount + jsr AT, (AT), _mcount + .set at +#endif + .prologue 1 + + /* Compute top of stack, including arguments. */ + ldq $1, UC_STACK+SS_SP($16) + ldq $2, UC_STACK+SS_SIZE($16) + addq $1, $2, $8 + subq $18, 6, $1 + cmovlt $1, 0, $1 + s8addq $1, 0, $2 + subq $8, $2, $8 + + /* Copy all parameters. Switch statement header here. */ + ldah $3, $jumptable($29) !gprelhigh + cmple $18, 6, $1 + mov $18, $2 + cmoveq $1, 7, $2 + s4addq $2, $3, $3 + ldl $4, $jumptable($3) !gprellow + addq $4, $29, $4 + jmp $31, ($4), $args1 + + .section .rodata + .align 2 +$jumptable: + .gprel32 $args0 + .gprel32 $args1 + .gprel32 $args2 + .gprel32 $args3 + .gprel32 $args4 + .gprel32 $args5 + .gprel32 $args6 + .gprel32 $argsN + .text + + /* Here we process arguments 7 through N. This is a straight + stack-to-stack copy. */ + .align 4 +$argsN: + subq $18, 6, $1 + lda $2, 0($8) + lda $3, 3*8($30) + .align 4 +1: + ldq $0, 0($3) + subq $1, 1, $1 + lda $3, 8($3) + stq $0, 0($2) + lda $2, 8($2) + bne $1, 1b + + /* Here we process arguments 6 through 0. This involves + copying into the register save areas of the ucontext. */ + .align 4 +$args6: + ldq $0, 2*8($30) + stq $0, UC_SIGCTX+SC_REGS+21*8($16) + unop + stq $0, UC_SIGCTX+SC_FPREGS+21*8($16) +$args5: + ldq $0, 1*8($30) + stq $0, UC_SIGCTX+SC_REGS+20*8($16) + unop + stq $0, UC_SIGCTX+SC_FPREGS+20*8($16) +$args4: + ldq $0, 0*8($30) + stq $0, UC_SIGCTX+SC_REGS+19*8($16) + unop + stq $0, UC_SIGCTX+SC_FPREGS+19*8($16) +$args3: + unop + stq $21, UC_SIGCTX+SC_REGS+18*8($16) + unop + stt $f21, UC_SIGCTX+SC_FPREGS+18*8($16) +$args2: + unop + stq $20, UC_SIGCTX+SC_REGS+17*8($16) + unop + stt $f20, UC_SIGCTX+SC_FPREGS+17*8($16) +$args1: + unop + stq $19, UC_SIGCTX+SC_REGS+16*8($16) + unop + stt $f19, UC_SIGCTX+SC_FPREGS+16*8($16) +$args0: + + /* Set up the registers ready to invoke __startcontext. + We seed $27 with the target function address, and $9 + with the link from ucp. */ + ldah $0, __startcontext($29) !gprelhigh + ldq $1, UC_LINK($16) + lda $0, __startcontext($0) !gprellow + stq $17, UC_SIGCTX+SC_REGS+27*8($16) + stq $8, UC_SIGCTX+SC_REGS+30*8($16) + stq $0, UC_SIGCTX+SC_PC($16) + stq $1, UC_SIGCTX+SC_REGS+9*8($16) + + /* No return value from makecontext. */ + ret + +END(__makecontext) +weak_alias (__makecontext, makecontext) + +/* This function is where a new makecontext "thread" begins life. + We have already set up $27 for calling the target function, and + we've set $9 to the UC_LINK of the parent context. + + If the function returns, we either jump to the linked context + (if non-null) or exit. */ + + .align 4 + .ent __startcontext +__startcontext: + .frame $31, 0, $31, 0 + .prologue 0 + + jsr $26, ($27), 0 + ldgp $29, 0($26) + mov $9, $16 + beq $9, 1f + +#ifdef PIC + bsr $26, __setcontext !samegp +1: mov $31, $16 + bsr $26, HIDDEN_JUMPTARGET(exit) !samegp +#else + jsr $26, __setcontext + ldgp $29, 0($26) +1: mov $31, $16 + jsr $26, HIDDEN_JUMPTARGET(exit) +#endif + + halt + + .end __startcontext diff --git a/sysdeps/unix/sysv/linux/alpha/setcontext.S b/sysdeps/unix/sysv/linux/alpha/setcontext.S new file mode 100644 index 0000000000..7d443d41c7 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/setcontext.S @@ -0,0 +1,35 @@ +/* Install given context. + Copyright (C) 2004 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-offsets.h> + + +/* In case the user fiddled it, copy the "official" signal mask + from the ucontext_t into the sigcontext structure. */ +#undef PSEUDO_PREPARE_ARGS +#define PSEUDO_PREPARE_ARGS \ + ldq $0, UC_SIGMASK($16); \ + stq $0, UC_SIGCTX+SC_MASK($16); \ + lda $16, UC_SIGCTX($16); + +PSEUDO(__setcontext, sigreturn, 1) + ret +PSEUDO_END(__setcontext) +weak_alias(__setcontext, setcontext) diff --git a/sysdeps/unix/sysv/linux/alpha/swapcontext.S b/sysdeps/unix/sysv/linux/alpha/swapcontext.S new file mode 100644 index 0000000000..5f6615e0b6 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/swapcontext.S @@ -0,0 +1,51 @@ +/* Save current context and install the given one. + Copyright (C) 2004 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-offsets.h> + +ENTRY(__swapcontext) + +#ifdef PROF + ldgp $29, 0($27) + .set noat + lda AT, _mcount + jsr AT, (AT), _mcount + .set at + .prologue 1 +#elif defined PIC + .prologue 0 +#else + ldgp $29, 0($27) + .prologue 1 +#endif + +#ifdef PIC + unop + bsr $0, __getcontext_x !samegp + mov $17, $16 + br $31, __setcontext !samegp +#else + jsr $0, __getcontext_x + mov $17, $16 + jmp $31, __setcontext +#endif + +END(__swapcontext) +weak_alias(__swapcontext, swapcontext) diff --git a/sysdeps/unix/sysv/linux/alpha/ucontext-offsets.sym b/sysdeps/unix/sysv/linux/alpha/ucontext-offsets.sym new file mode 100644 index 0000000000..f95ff75636 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/ucontext-offsets.sym @@ -0,0 +1,18 @@ +#include <stddef.h> +#include <sys/ucontext.h> + +-- +UC_LINK offsetof (ucontext_t, uc_link) +UC_OSF_SIGMASK offsetof (ucontext_t, __uc_osf_sigmask) +UC_STACK offsetof (ucontext_t, uc_stack) +UC_SIGCTX offsetof (ucontext_t, uc_mcontext) +UC_SIGMASK offsetof (ucontext_t, uc_sigmask) +SC_REGS offsetof (struct sigcontext, sc_regs) +SC_FPREGS offsetof (struct sigcontext, sc_fpregs) +SC_PC offsetof (struct sigcontext, sc_pc) +SC_PS offsetof (struct sigcontext, sc_ps) +SC_FPCRS offsetof (struct sigcontext, sc_fpcr) +SC_MASK offsetof (struct sigcontext, sc_mask) +SC_FPCR offsetof (struct sigcontext, sc_fpcr) +SS_SP offsetof (stack_t, ss_sp) +SS_SIZE offsetof (stack_t, ss_size) |