|
Packit |
6c4009 |
/* Copyright (C) 2001-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <sysdep.h>
|
|
Packit |
6c4009 |
#include <features.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include "ucontext_i.h"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* __getcontext (ucontext_t *ucp)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Saves the machine context in UCP such that when it is activated,
|
|
Packit |
6c4009 |
it appears as if __getcontext() returned again. The only difference
|
|
Packit |
6c4009 |
is that on a first return, r9 contains 1 and on a subsequent
|
|
Packit |
6c4009 |
return, it contains 0.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
This implementation in intended to be used for *synchronous* context
|
|
Packit |
6c4009 |
switches only. Therefore, it does not have to save anything
|
|
Packit |
6c4009 |
other than the PRESERVED state. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ENTRY(__getcontext)
|
|
Packit |
6c4009 |
.prologue
|
|
Packit |
6c4009 |
.body
|
|
Packit |
6c4009 |
alloc r11 = ar.pfs, 1, 0, 4, 0
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
// sigprocmask (SIG_BLOCK, NULL, &sc->sc_mask):
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
mov r3 = SC_MASK
|
|
Packit |
6c4009 |
mov out0 = SIG_BLOCK
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
flushrs // save dirty partition on rbs
|
|
Packit |
6c4009 |
mov out1 = 0
|
|
Packit |
6c4009 |
add out2 = r3, in0
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
mov out3 = 8 // sizeof kernel sigset_t
|
|
Packit |
6c4009 |
DO_CALL(__NR_rt_sigprocmask)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
mov.m rFPSR = ar.fpsr
|
|
Packit |
6c4009 |
mov.m rRSC = ar.rsc
|
|
Packit |
6c4009 |
add r2 = SC_GR+1*8, r32
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
mov.m rBSP = ar.bsp
|
|
Packit |
6c4009 |
.prologue
|
|
Packit |
6c4009 |
.save ar.unat, rUNAT
|
|
Packit |
6c4009 |
mov.m rUNAT = ar.unat
|
|
Packit |
6c4009 |
.body
|
|
Packit |
6c4009 |
add r3 = SC_GR+4*8, r32
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.mem.offset 0,0; st8.spill [r2] = r1, (5*8 - 1*8)
|
|
Packit |
6c4009 |
.mem.offset 8,0; st8.spill [r3] = r4, 16
|
|
Packit |
6c4009 |
mov rPFS = r11
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
.mem.offset 0,0; st8.spill [r2] = r5, 16
|
|
Packit |
6c4009 |
.mem.offset 8,0; st8.spill [r3] = r6, 48
|
|
Packit |
6c4009 |
and rTMP = ~0x3, rRSC
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
.mem.offset 0,0; st8.spill [r2] = r7, (SC_FR+2*16-(SC_GR+7*8))
|
|
Packit |
6c4009 |
.mem.offset 8,0; st8.spill [r3] = sp, (SC_FR+3*16-(SC_GR+12*8))
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
mov.m ar.rsc = rTMP // put RSE into enforced lazy mode
|
|
Packit |
6c4009 |
mov.m rNAT = ar.unat
|
|
Packit |
6c4009 |
mov.i rLC = ar.lc
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
mov.m rRNAT = ar.rnat
|
|
Packit |
6c4009 |
mov.m ar.rsc = rRSC // restore RSE mode
|
|
Packit |
6c4009 |
mov rPR = pr
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/*
|
|
Packit |
6c4009 |
* Rotate NaT bits by rPOS positions to the right:
|
|
Packit |
6c4009 |
*/
|
|
Packit |
6c4009 |
stf.spill [r2] = f2, 32
|
|
Packit |
6c4009 |
stf.spill [r3] = f3, 32
|
|
Packit |
6c4009 |
add rPOS = SC_GR, r32 // rPOS <- &sc_gr[0]
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
stf.spill [r2] = f4, (16*16-4*16)
|
|
Packit |
6c4009 |
stf.spill [r3] = f5, (17*16-5*16)
|
|
Packit |
6c4009 |
extr.u rPOS = rPOS, 3, 6 // get NaT bit number for r0
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
stf.spill [r2] = f16, 32
|
|
Packit |
6c4009 |
stf.spill [r3] = f17, 32
|
|
Packit |
6c4009 |
sub rCPOS = 64, rPOS
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
stf.spill [r2] = f18, 32
|
|
Packit |
6c4009 |
stf.spill [r3] = f19, 32
|
|
Packit |
6c4009 |
shr.u rTMP = rNAT, rPOS
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
stf.spill [r2] = f20, 32
|
|
Packit |
6c4009 |
stf.spill [r3] = f21, 32
|
|
Packit |
6c4009 |
shl rNAT = rNAT, rCPOS
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
stf.spill [r2] = f22, 32
|
|
Packit |
6c4009 |
stf.spill [r3] = f23, 32
|
|
Packit |
6c4009 |
or rNAT = rNAT, rTMP
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
stf.spill [r2] = f24, 32
|
|
Packit |
6c4009 |
stf.spill [r3] = f25, 32
|
|
Packit |
6c4009 |
mov r8 = 0
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
stf.spill [r2] = f26, 32
|
|
Packit |
6c4009 |
stf.spill [r3] = f27, 32
|
|
Packit |
6c4009 |
mov r9 = 1
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
stf.spill [r2] = f28, 32
|
|
Packit |
6c4009 |
stf.spill [r3] = f29, 32
|
|
Packit |
6c4009 |
mov rB0 = b0
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
stf.spill [r2] = f30, 32
|
|
Packit |
6c4009 |
stf.spill [r3] = f31, 32
|
|
Packit |
6c4009 |
mov rB1 = b1
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
mov ar.unat = rUNAT // we're done spilling integer regs; restore caller's UNaT
|
|
Packit |
6c4009 |
add r2 = SC_NAT, r32
|
|
Packit |
6c4009 |
add r3 = SC_BSP, r32
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
st8 [r2] = rNAT, (SC_RNAT-SC_NAT)
|
|
Packit |
6c4009 |
st8 [r3] = rBSP, (SC_UNAT-SC_BSP)
|
|
Packit |
6c4009 |
mov rB2 = b2
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
st8 [r2] = rRNAT, (SC_FPSR-SC_RNAT)
|
|
Packit |
6c4009 |
st8 [r3] = rUNAT, (SC_PFS-SC_UNAT)
|
|
Packit |
6c4009 |
mov rB3 = b3
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
st8 [r2] = rFPSR, (SC_LC-SC_FPSR)
|
|
Packit |
6c4009 |
st8 [r3] = rPFS, (SC_PR-SC_PFS)
|
|
Packit |
6c4009 |
mov rB4 = b4
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
st8 [r2] = rLC, (SC_BR+0*8-SC_LC)
|
|
Packit |
6c4009 |
st8 [r3] = rPR, (SC_BR+1*8-SC_PR)
|
|
Packit |
6c4009 |
mov rB5 = b5
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
st8 [r2] = rB0, 16
|
|
Packit |
6c4009 |
st8 [r3] = rB1, 16
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
st8 [r2] = rB2, 16
|
|
Packit |
6c4009 |
st8 [r3] = rB3, 16
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
st8 [r2] = rB4
|
|
Packit |
6c4009 |
st8 [r3] = rB5
|
|
Packit |
6c4009 |
ret
|
|
Packit |
6c4009 |
END(__getcontext)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
weak_alias (__getcontext, getcontext)
|