|
Packit |
6c4009 |
/* Copyright (C) 1999-2018 Free Software Foundation, Inc.
|
|
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 |
Note that __sigsetjmp() did NOT flush the register stack. Instead,
|
|
Packit |
6c4009 |
we do it here since __longjmp() is usually much less frequently
|
|
Packit |
6c4009 |
invoked than __sigsetjmp(). The only difficulty is that __sigsetjmp()
|
|
Packit |
6c4009 |
didn't (and wouldn't be able to) save ar.rnat either. This is a problem
|
|
Packit |
6c4009 |
because if we're not careful, we could end up loading random NaT bits.
|
|
Packit |
6c4009 |
There are two cases:
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
(i) ar.bsp < ia64_rse_rnat_addr(jmpbuf.ar_bsp)
|
|
Packit |
6c4009 |
ar.rnat contains the desired bits---preserve ar.rnat
|
|
Packit |
6c4009 |
across loadrs and write to ar.bspstore
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
(ii) ar.bsp >= ia64_rse_rnat_addr(jmpbuf.ar_bsp)
|
|
Packit |
6c4009 |
The desired ar.rnat is stored in
|
|
Packit |
6c4009 |
ia64_rse_rnat_addr(jmpbuf.ar_bsp). Load those
|
|
Packit |
6c4009 |
bits into ar.rnat after setting ar.bspstore. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <sysdep.h>
|
|
Packit |
6c4009 |
#include <features.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# define pPos p6 /* is rotate count positive? */
|
|
Packit |
6c4009 |
# define pNeg p7 /* is rotate count negative? */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* __longjmp(__jmp_buf buf, int val) */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
LEAF(__longjmp)
|
|
Packit |
6c4009 |
#ifdef CHECK_RSP
|
|
Packit |
6c4009 |
alloc r8=ar.pfs,2,1,3,0
|
|
Packit |
6c4009 |
CHECK_RSP
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
alloc r8=ar.pfs,2,0,0,0
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
mov r27=ar.rsc
|
|
Packit |
6c4009 |
add r2=0x98,in0 // r2 <- &jmpbuf.orig_jmp_buf_addr
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ld8 r8=[r2],-16 // r8 <- orig_jmp_buf_addr
|
|
Packit |
6c4009 |
mov r10=ar.bsp
|
|
Packit |
6c4009 |
and r11=~0x3,r27 // clear ar.rsc.mode
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
flushrs // flush dirty regs to backing store (must be first in insn grp)
|
|
Packit |
6c4009 |
ld8 r23=[r2],8 // r23 <- jmpbuf.ar_bsp
|
|
Packit |
6c4009 |
sub r8=r8,in0 // r8 <- &orig_jmpbuf - &jmpbuf
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ld8 r25=[r2] // r25 <- jmpbuf.ar_unat
|
|
Packit |
6c4009 |
extr.u r8=r8,3,6 // r8 <- (&orig_jmpbuf - &jmpbuf)/8 & 0x3f
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
cmp.lt pNeg,pPos=r8,r0
|
|
Packit |
6c4009 |
mov r2=in0
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
(pPos) mov r16=r8
|
|
Packit |
6c4009 |
(pNeg) add r16=64,r8
|
|
Packit |
6c4009 |
(pPos) sub r17=64,r8
|
|
Packit |
6c4009 |
(pNeg) sub r17=r0,r8
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
mov ar.rsc=r11 // put RSE in enforced lazy mode
|
|
Packit |
6c4009 |
shr.u r8=r25,r16
|
|
Packit |
6c4009 |
add r3=8,in0 // r3 <- &jmpbuf.r1
|
|
Packit |
6c4009 |
shl r9=r25,r17
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ld8.fill.nta r28=[r2],16 // r28 <- jmpbuf.sp
|
|
Packit |
6c4009 |
or r25=r8,r9
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
mov r26=ar.rnat
|
|
Packit |
6c4009 |
mov ar.unat=r25 // setup ar.unat (NaT bits for r1, r4-r7, and r12)
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ld8.fill.nta gp=[r3],32 // r1 (gp)
|
|
Packit |
6c4009 |
dep r11=-1,r23,3,6 // r11 <- ia64_rse_rnat_addr(jmpbuf.ar_bsp)
|
|
Packit |
6c4009 |
mov sp=r28 // r12 (sp)
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ld8.nta r16=[r2],16 // caller's unat
|
|
Packit |
6c4009 |
// ld8.nta r17=[r3],16 // fpsr
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ld8.fill.nta r4=[r2],16 // r4
|
|
Packit |
6c4009 |
ld8.fill.nta r5=[r3],16 // r5 (gp)
|
|
Packit |
6c4009 |
cmp.geu p8,p0=r10,r11 // p8 <- (ar.bsp >= jmpbuf.ar_bsp)
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ld8.fill.nta r6=[r2],16 // r6
|
|
Packit |
6c4009 |
ld8.fill.nta r7=[r3],16 // r7
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
mov ar.unat=r16 // restore caller's unat
|
|
Packit |
6c4009 |
// mov ar.fpsr=r17 // restore fpsr
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ld8.nta r16=[r2],16 // b0
|
|
Packit |
6c4009 |
ld8.nta r17=[r3],16 // b1
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
(p8) ld8 r26=[r11] // r26 <- *ia64_rse_rnat_addr(jmpbuf.ar_bsp)
|
|
Packit |
6c4009 |
mov ar.bspstore=r23 // restore ar.bspstore
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ld8.nta r18=[r2],16 // b2
|
|
Packit |
6c4009 |
ld8.nta r19=[r3],16 // b3
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
#ifdef PTR_DEMANGLE
|
|
Packit |
6c4009 |
PTR_DEMANGLE (r16, r24)
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
ld8.nta r20=[r2],16 // b4
|
|
Packit |
6c4009 |
ld8.nta r21=[r3],16 // b5
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ld8.nta r11=[r2],16 // ar.pfs
|
|
Packit |
6c4009 |
ld8.nta r22=[r3],56 // ar.lc
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ld8.nta r24=[r2],32 // pr
|
|
Packit |
6c4009 |
mov b0=r16
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ldf.fill.nta f2=[r2],32
|
|
Packit |
6c4009 |
ldf.fill.nta f3=[r3],32
|
|
Packit |
6c4009 |
mov b1=r17
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ldf.fill.nta f4=[r2],32
|
|
Packit |
6c4009 |
ldf.fill.nta f5=[r3],32
|
|
Packit |
6c4009 |
mov b2=r18
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ldf.fill.nta f16=[r2],32
|
|
Packit |
6c4009 |
ldf.fill.nta f17=[r3],32
|
|
Packit |
6c4009 |
mov b3=r19
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ldf.fill.nta f18=[r2],32
|
|
Packit |
6c4009 |
ldf.fill.nta f19=[r3],32
|
|
Packit |
6c4009 |
mov b4=r20
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ldf.fill.nta f20=[r2],32
|
|
Packit |
6c4009 |
ldf.fill.nta f21=[r3],32
|
|
Packit |
6c4009 |
mov b5=r21
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ldf.fill.nta f22=[r2],32
|
|
Packit |
6c4009 |
ldf.fill.nta f23=[r3],32
|
|
Packit |
6c4009 |
mov ar.lc=r22
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ldf.fill.nta f24=[r2],32
|
|
Packit |
6c4009 |
ldf.fill.nta f25=[r3],32
|
|
Packit |
6c4009 |
cmp.eq p8,p9=0,in1
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ldf.fill.nta f26=[r2],32
|
|
Packit |
6c4009 |
ldf.fill.nta f27=[r3],32
|
|
Packit |
6c4009 |
mov ar.pfs=r11
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ldf.fill.nta f28=[r2],32
|
|
Packit |
6c4009 |
ldf.fill.nta f29=[r3],32
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
ldf.fill.nta f30=[r2]
|
|
Packit |
6c4009 |
ldf.fill.nta f31=[r3]
|
|
Packit |
6c4009 |
(p8) mov r8=1
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
mov ar.rnat=r26 // restore ar.rnat
|
|
Packit |
6c4009 |
;;
|
|
Packit |
6c4009 |
mov ar.rsc=r27 // restore ar.rsc
|
|
Packit |
6c4009 |
(p9) mov r8=in1
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
invala // virt. -> phys. regnum mapping may change
|
|
Packit |
6c4009 |
mov pr=r24,-1
|
|
Packit |
6c4009 |
ret
|
|
Packit |
6c4009 |
END(__longjmp)
|