mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-09 23:00:07 +00:00
m68k: add support for {get,make,set,swap}context
This commit is contained in:
parent
d0cd7d0212
commit
aaf5420c6d
@ -1,3 +1,12 @@
|
||||
2012-07-16 Andreas Schwab <schwab@linux-m68k.org>
|
||||
|
||||
* sysdeps/unix/sysv/linux/m68k/m680x0/Makefile: New file.
|
||||
* sysdeps/unix/sysv/linux/m68k/m680x0/getcontext.S: New file.
|
||||
* sysdeps/unix/sysv/linux/m68k/m680x0/makecontext.S: New file.
|
||||
* sysdeps/unix/sysv/linux/m68k/m680x0/setcontext.S: New file.
|
||||
* sysdeps/unix/sysv/linux/m68k/m680x0/swapcontext.S: New file.
|
||||
* sysdeps/unix/sysv/linux/m68k/m680x0/ucontext_i.sym: New file.
|
||||
|
||||
2012-07-09 Andreas Schwab <schwab@linux-m68k.org>
|
||||
|
||||
* sysdeps/m68k/m680x0/fpu/libm-test-ulps: Update.
|
||||
|
3
ports/sysdeps/unix/sysv/linux/m68k/m680x0/Makefile
Normal file
3
ports/sysdeps/unix/sysv/linux/m68k/m680x0/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
ifeq ($(subdir),stdlib)
|
||||
gen-as-const-headers += ucontext_i.sym
|
||||
endif
|
63
ports/sysdeps/unix/sysv/linux/m68k/m680x0/getcontext.S
Normal file
63
ports/sysdeps/unix/sysv/linux/m68k/m680x0/getcontext.S
Normal file
@ -0,0 +1,63 @@
|
||||
/* Save current context.
|
||||
Copyright (C) 2012 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, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <sysdep.h>
|
||||
|
||||
#include "ucontext_i.h"
|
||||
|
||||
|
||||
ENTRY(__getcontext)
|
||||
/* Load address of the context data structure. */
|
||||
move.l 4(%sp), %a0
|
||||
|
||||
/* Save the preserved registers and the return address. */
|
||||
movem.l %d2-%d7, oGREGS+2*4(%a0)
|
||||
movem.l %a2-%a6, oGREGS+10*4(%a0)
|
||||
lea 4(%sp), %a1
|
||||
move.l %a1, oSP(%a0)
|
||||
move.l (%sp), oPC(%a0)
|
||||
fmovem.l %fpsr/%fpcr/%fpiar, oFPREGS(%a0)
|
||||
fmovem.x %fp2-%fp7, oFP2(%a0)
|
||||
cfi_def_cfa (%a0, 0)
|
||||
cfi_offset (%d2, oGREGS+2*4)
|
||||
cfi_offset (%d3, oGREGS+3*4)
|
||||
cfi_offset (%pc, oPC)
|
||||
|
||||
/* Save the current signal mask. */
|
||||
lea oSIGMASK(%a0), %a1
|
||||
move.l %a1, %d3
|
||||
clr.l %d2
|
||||
move.l #SIG_SETMASK, %d1
|
||||
move.l #__NR_sigprocmask, %d0
|
||||
trap #0
|
||||
/* Restore registers. */
|
||||
move.l oGREGS+2*4(%a0), %d2
|
||||
cfi_restore (%d2)
|
||||
move.l oGREGS+3*4(%a0), %d3
|
||||
cfi_restore (%d3)
|
||||
cfi_def_cfa (%sp, 4)
|
||||
cfi_offset (%pc, -4)
|
||||
cmp.l #-4095, %d0 /* Check %d0 for error. */
|
||||
jcc SYSCALL_ERROR_LABEL /* Jump to error handler. */
|
||||
|
||||
0: /* All done, return 0 for success. */
|
||||
clr.l %d0
|
||||
rts
|
||||
PSEUDO_END(__getcontext)
|
||||
|
||||
weak_alias (__getcontext, getcontext)
|
100
ports/sysdeps/unix/sysv/linux/m68k/m680x0/makecontext.S
Normal file
100
ports/sysdeps/unix/sysv/linux/m68k/m680x0/makecontext.S
Normal file
@ -0,0 +1,100 @@
|
||||
/* Create new context.
|
||||
Copyright (C) 2012 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, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <sysdep.h>
|
||||
|
||||
#include "ucontext_i.h"
|
||||
|
||||
|
||||
ENTRY(__makecontext)
|
||||
move.l 4(%sp), %a0
|
||||
|
||||
/* Get the address of the function we are supposed to run. */
|
||||
move.l 8(%sp), oPC(%a0)
|
||||
|
||||
/* Compute the address of the stack. The information comes from
|
||||
to us_stack element. */
|
||||
move.l oSS_SP(%a0), %a1
|
||||
add.l oSS_SIZE(%a0), %a1
|
||||
|
||||
/* Remember the number of parameters for the exit handler since
|
||||
it has to remove them. We store the number in the D7 register
|
||||
which the function we will call must preserve. */
|
||||
move.l 12(%sp), %d1
|
||||
move.l %d1, oGREGS+7*4(%a0)
|
||||
|
||||
/* Make room on the new stack for the parameters.
|
||||
Room for the arguments, return address (== 1f) and
|
||||
oLINK pointer is needed. */
|
||||
neg.l %d1
|
||||
lea -8(%a1,%d1.l*4), %a1
|
||||
neg.l %d1
|
||||
|
||||
/* Store the future stack pointer. */
|
||||
move.l %a1, oSP(%a0)
|
||||
|
||||
/* Put the next context on the new stack (from the uc_link
|
||||
element). */
|
||||
move.l oLINK(%a0), 4(%a1,%d1.l*4)
|
||||
|
||||
/* Copy all the parameters. */
|
||||
1: subq.l #1,%d1
|
||||
jmi 2f
|
||||
move.l 16(%sp,%d1.l*4), 4(%a1,%d1.l*4)
|
||||
jra 1b
|
||||
2:
|
||||
|
||||
/* If the function we call returns we must continue with the
|
||||
context which is given in the uc_link element. To do this
|
||||
set the return address for the function the user provides
|
||||
to a little bit of helper code which does the magic (see
|
||||
below). */
|
||||
lea 1f(%pc), %a0
|
||||
move.l %a0, (%a1)
|
||||
/* 'makecontext' returns no value. */
|
||||
rts
|
||||
|
||||
/* This is the helper code which gets called if a function which
|
||||
is registered with 'makecontext' returns. In this case we
|
||||
have to install the context listed in the uc_link element of
|
||||
the context 'makecontext' manipulated at the time of the
|
||||
'makecontext' call. If the pointer is NULL the process must
|
||||
terminate. */
|
||||
cfi_endproc
|
||||
1:
|
||||
/* This removes the parameters passed to the function given to
|
||||
'makecontext' from the stack. D7 contains the number of
|
||||
parameters (see above). */
|
||||
lea (%sp,%d7.l*4), %sp
|
||||
|
||||
tst.l (%sp) /* Check the next context. */
|
||||
jeq 2f /* If it is zero exit. */
|
||||
|
||||
jbsr JUMPTARGET(__setcontext)
|
||||
/* If this returns (which can happen if the syscall fails) we'll
|
||||
exit the program with the return error value (-1). */
|
||||
|
||||
move.l %d0, (%sp)
|
||||
2: jbsr HIDDEN_JUMPTARGET(exit)
|
||||
/* The 'exit' call should never return. In case it does cause
|
||||
the process to terminate. */
|
||||
illegal
|
||||
cfi_startproc
|
||||
END(__makecontext)
|
||||
|
||||
weak_alias (__makecontext, makecontext)
|
94
ports/sysdeps/unix/sysv/linux/m68k/m680x0/setcontext.S
Normal file
94
ports/sysdeps/unix/sysv/linux/m68k/m680x0/setcontext.S
Normal file
@ -0,0 +1,94 @@
|
||||
/* Install given context.
|
||||
Copyright (C) 2012 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, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <sysdep.h>
|
||||
|
||||
#include "ucontext_i.h"
|
||||
|
||||
ENTRY(__setcontext)
|
||||
/* Load address of the context data structure. */
|
||||
move.l 4(%sp), %a0
|
||||
|
||||
/* Get the current signal mask. Note that we preserve D2/D3 in case
|
||||
the system call fails and we return from the function with an
|
||||
error. */
|
||||
move.l %d3, -(%sp)
|
||||
cfi_adjust_cfa_offset (4)
|
||||
cfi_rel_offset (%d3, 0)
|
||||
move.l %d2, -(%sp)
|
||||
cfi_adjust_cfa_offset (4)
|
||||
cfi_rel_offset (%d2, 0)
|
||||
clr.l %d3
|
||||
lea oSIGMASK(%a0), %a1
|
||||
move.l %a1, %d2
|
||||
move.l #SIG_SETMASK, %d1
|
||||
move.l #__NR_sigprocmask, %d0
|
||||
trap #0
|
||||
cmp.l #-4095, %d0 /* Check %d0 for error. */
|
||||
jcs 0f
|
||||
move.l (%sp)+, %d2
|
||||
cfi_adjust_cfa_offset (-4)
|
||||
cfi_restore (d2)
|
||||
move.l (%sp)+, %d3
|
||||
cfi_adjust_cfa_offset (-4)
|
||||
cfi_restore (d3)
|
||||
jra SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
|
||||
|
||||
0: /* Load the new stack pointer. */
|
||||
move.l oSP(%a0), %sp
|
||||
cfi_def_cfa (%a0, 0)
|
||||
cfi_offset (%d2, oGREGS+2*4)
|
||||
cfi_offset (%d3, oGREGS+3*4)
|
||||
cfi_offset (%d4, oGREGS+4*4)
|
||||
cfi_offset (%d5, oGREGS+5*4)
|
||||
cfi_offset (%d6, oGREGS+6*4)
|
||||
cfi_offset (%d7, oGREGS+7*4)
|
||||
cfi_offset (%a2, oGREGS+10*4)
|
||||
cfi_offset (%a3, oGREGS+11*4)
|
||||
cfi_offset (%a4, oGREGS+12*4)
|
||||
cfi_offset (%a5, oGREGS+13*4)
|
||||
cfi_offset (%a6, oGREGS+14*4)
|
||||
cfi_offset (%fp2, oFP2+0*12)
|
||||
cfi_offset (%fp3, oFP2+1*12)
|
||||
cfi_offset (%fp4, oFP2+2*12)
|
||||
cfi_offset (%fp5, oFP2+3*12)
|
||||
cfi_offset (%fp6, oFP2+4*12)
|
||||
cfi_offset (%fp7, oFP2+5*12)
|
||||
cfi_offset (%pc, oPC)
|
||||
|
||||
/* Load the values of all the preserved registers (except SP). */
|
||||
movem.l oGREGS+2*4(%a0), %d2-%d7
|
||||
movem.l oGREGS+10*4(%a0), %a2-%a6
|
||||
fmovem.l oFPREGS(%a0), %fpsr/%fpcr/%fpiar
|
||||
fmovem.x oFP2(%a0), %fp2-%fp7
|
||||
clr.l %d0
|
||||
|
||||
/* Fetch the address to return to. */
|
||||
movl oPC(%a0), %a1
|
||||
|
||||
/* End FDE here, we fall into another context. */
|
||||
cfi_endproc
|
||||
cfi_startproc
|
||||
cfi_register (%pc, %a1)
|
||||
|
||||
jmp (%a1)
|
||||
|
||||
cfi_offset (%pc, -4)
|
||||
PSEUDO_END(__setcontext)
|
||||
|
||||
weak_alias (__setcontext, setcontext)
|
108
ports/sysdeps/unix/sysv/linux/m68k/m680x0/swapcontext.S
Normal file
108
ports/sysdeps/unix/sysv/linux/m68k/m680x0/swapcontext.S
Normal file
@ -0,0 +1,108 @@
|
||||
/* Save current context and install the given one.
|
||||
Copyright (C) 2012 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, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <sysdep.h>
|
||||
|
||||
#include "ucontext_i.h"
|
||||
|
||||
|
||||
ENTRY(__swapcontext)
|
||||
/* Load address of the context data structure we save in. */
|
||||
move.l 4(%sp), %a0
|
||||
|
||||
/* Save the preserved registers and the return address. */
|
||||
movem.l %d2-%d7, oGREGS+2*4(%a0)
|
||||
movem.l %a2-%a6, oGREGS+10*4(%a0)
|
||||
lea 4(%sp), %a1
|
||||
move.l %a1, oSP(%a0)
|
||||
move.l (%sp), oPC(%a0)
|
||||
fmovem.l %fpsr/%fpcr/%fpiar, oFPREGS(%a0)
|
||||
fmovem.x %fp2-%fp7, oFP2(%a0)
|
||||
cfi_def_cfa (%a0, 0)
|
||||
cfi_offset (%d2, oGREGS+2*4)
|
||||
cfi_offset (%d3, oGREGS+3*4)
|
||||
cfi_offset (%a2, oGREGS+10*4)
|
||||
cfi_offset (%pc, oPC)
|
||||
|
||||
/* Load address of the context data structure we have to load. */
|
||||
move.l 8(%sp), %a1
|
||||
|
||||
/* Save the current signal mask and install the new one. */
|
||||
lea oSIGMASK(%a0), %a2
|
||||
move.l %a2, %d3
|
||||
lea oSIGMASK(%a1), %a2
|
||||
move.l %a2, %d2
|
||||
move.l #SIG_SETMASK, %d1
|
||||
move.l #__NR_sigprocmask, %d0
|
||||
trap #0
|
||||
cmp.l #-4095, %d0 /* Check %d0 for error. */
|
||||
jcs 0f
|
||||
/* Restore registers. */
|
||||
move.l oGREGS+2*4(%a0), %d2
|
||||
cfi_restore (%d2)
|
||||
move.l oGREGS+3*4(%a0), %d3
|
||||
cfi_restore (%d3)
|
||||
move.l oGREGS+10*4(%a0), %a2
|
||||
cfi_restore (%a2)
|
||||
jra SYSCALL_ERROR_LABEL /* Jump to error handler. */
|
||||
|
||||
0: /* Load the new stack pointer. */
|
||||
move.l oSP(%a1), %sp
|
||||
cfi_def_cfa (%a1, 0)
|
||||
cfi_offset (%d2, oGREGS+2*4)
|
||||
cfi_offset (%d3, oGREGS+3*4)
|
||||
cfi_offset (%d4, oGREGS+4*4)
|
||||
cfi_offset (%d5, oGREGS+5*4)
|
||||
cfi_offset (%d6, oGREGS+6*4)
|
||||
cfi_offset (%d7, oGREGS+7*4)
|
||||
cfi_offset (%a2, oGREGS+10*4)
|
||||
cfi_offset (%a3, oGREGS+11*4)
|
||||
cfi_offset (%a4, oGREGS+12*4)
|
||||
cfi_offset (%a5, oGREGS+13*4)
|
||||
cfi_offset (%a6, oGREGS+14*4)
|
||||
cfi_offset (%fp2, oFP2+0*12)
|
||||
cfi_offset (%fp3, oFP2+1*12)
|
||||
cfi_offset (%fp4, oFP2+2*12)
|
||||
cfi_offset (%fp5, oFP2+3*12)
|
||||
cfi_offset (%fp6, oFP2+4*12)
|
||||
cfi_offset (%fp7, oFP2+5*12)
|
||||
cfi_offset (%pc, oPC)
|
||||
|
||||
/* Load the values of all the preserved registers (except SP). */
|
||||
movem.l oGREGS+2*4(%a1), %d2-%d7
|
||||
movem.l oGREGS+10*4(%a1), %a2-%a6
|
||||
fmovem.l oFPREGS(%a1), %fpsr/%fpcr/%fpiar
|
||||
fmovem.x oFP2(%a1), %fp2-%fp7
|
||||
|
||||
/* Clear D0 to indicate success. */
|
||||
clr.l %d0
|
||||
|
||||
/* Fetch the address to return to. */
|
||||
move.l oPC(%a1), %a0
|
||||
|
||||
/* End FDE here, we fall into another context. */
|
||||
cfi_endproc
|
||||
cfi_startproc
|
||||
cfi_register (%pc, %a0)
|
||||
|
||||
jmp (%a0)
|
||||
|
||||
cfi_offset (%pc, -4)
|
||||
PSEUDO_END(__swapcontext)
|
||||
|
||||
weak_alias (__swapcontext, swapcontext)
|
20
ports/sysdeps/unix/sysv/linux/m68k/m680x0/ucontext_i.sym
Normal file
20
ports/sysdeps/unix/sysv/linux/m68k/m680x0/ucontext_i.sym
Normal file
@ -0,0 +1,20 @@
|
||||
#include <stddef.h>
|
||||
#include <signal.h>
|
||||
#include <sys/ucontext.h>
|
||||
|
||||
--
|
||||
|
||||
SIG_SETMASK
|
||||
|
||||
#define ucontext(member) offsetof (ucontext_t, member)
|
||||
#define mcontext(member) ucontext (uc_mcontext.member)
|
||||
|
||||
oLINK ucontext (uc_link)
|
||||
oSS_SP ucontext (uc_stack.ss_sp)
|
||||
oSS_SIZE ucontext (uc_stack.ss_size)
|
||||
oGREGS mcontext (gregs)
|
||||
oSP mcontext (gregs[R_SP])
|
||||
oPC mcontext (gregs[R_PC])
|
||||
oFPREGS mcontext (fpregs)
|
||||
oFP2 mcontext (fpregs.f_fpregs[2])
|
||||
oSIGMASK ucontext (uc_sigmask)
|
Loading…
Reference in New Issue
Block a user