about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/ia64/getcontext.S
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-03-16 21:07:22 +0000
committerUlrich Drepper <drepper@redhat.com>2001-03-16 21:07:22 +0000
commitaeba9785a6e2e8dca120bb0b62b74ea1eda0a4a8 (patch)
tree8438c4d6081766a1ede6c89328dfbcd389dbff82 /sysdeps/unix/sysv/linux/ia64/getcontext.S
parentb8a8413c6f7970bc4d5659791c3b3670cc037578 (diff)
downloadglibc-aeba9785a6e2e8dca120bb0b62b74ea1eda0a4a8.tar.gz
glibc-aeba9785a6e2e8dca120bb0b62b74ea1eda0a4a8.tar.xz
glibc-aeba9785a6e2e8dca120bb0b62b74ea1eda0a4a8.zip
Update.
2001-03-16  David Mosberger  <davidm@hpl.hp.com>

	* sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h (struct sigcontext):
	Drop hack that was needed for 2.1.1 kernel headers.

	* sysdeps/unix/sysv/linux/ia64/ucontext_i.h: New file.

	* sysdeps/unix/sysv/linux/ia64/sys/ucontext.h: Rewrite to make it
	overlay with kernel's "struct sigcontext".

	* sysdeps/unix/sysv/linux/ia64/Makefile (sysdep_headers): Add
	sys/rse.h for "misc" subdir.
	(sysdep_routines): Add __start_context for "stdlib" subdir.

	* sysdeps/unix/sysv/linux/ia64/sys/rse.h: New file (based on
	kernel file of the same name).

	* stdlib/Makefile (tests): Add tst-setcontext.
	* stdlib/tst-setcontext.c: New file (based on a sample program by
	Uli Drepper).

	* sysdeps/unix/sysv/linux/ia64/setcontext.S: New file.
	* sysdeps/unix/sysv/linux/ia64/getcontext.S: New file.
	* sysdeps/unix/sysv/linux/ia64/__start_context.S: New file.
	* sysdeps/unix/sysv/linux/ia64/makecontext.c: New file.

	* sysdeps/unix/sysv/linux/ia64/__longjmp.S (__longjmp): Use extr.u
	instead of shift & and.
Diffstat (limited to 'sysdeps/unix/sysv/linux/ia64/getcontext.S')
-rw-r--r--sysdeps/unix/sysv/linux/ia64/getcontext.S153
1 files changed, 153 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/ia64/getcontext.S b/sysdeps/unix/sysv/linux/ia64/getcontext.S
new file mode 100644
index 0000000000..24b58d435a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/ia64/getcontext.S
@@ -0,0 +1,153 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+     Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, write to the Free Software Foundation, Inc.,
+   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+#include <features.h>
+
+#include "ucontext_i.h"
+
+/*  __getcontext (const ucontext_t *ucp)
+
+  Saves the machine context in UCP such that when it is activated,
+  it appears as if __getcontext() returned again.  The only difference
+  is that on a first return, r9 contains 1 and on a subsequent
+  return, it contains 0.
+
+  This implementation in intended to be used for *synchronous* context
+  switches only.  Therefore, it does not have to save anything
+  other than the PRESERVED state.  */
+
+ENTRY(__getcontext)
+	alloc r16 = ar.pfs, 1, 0, 3, 0
+
+	// sigprocmask (SIG_BLOCK, NULL, &sc->sc_mask):
+
+	mov r2 = SC_MASK
+	mov r15 = __NR_rt_sigprocmask
+	;;
+	mov out0 = SIG_BLOCK
+	mov out1 = 0
+	add out2 = r2, in0
+
+	break __BREAK_SYSCALL
+	flushrs					// save dirty partition on rbs
+
+	mov.m rFPSR = ar.fpsr
+	mov.m rRSC = ar.rsc
+	add r2 = SC_GR+1*8, r32
+	;;
+	mov.m rBSP = ar.bsp
+	mov.m rUNAT = ar.unat
+	add r3 = SC_GR+4*8, r32
+	;;
+
+.mem.offset 0,0; st8.spill [r2] = r1, (5*8 - 1*8)
+.mem.offset 8,0; st8.spill [r3] = r4, 16
+	mov.i rPFS = ar.pfs
+	;;
+.mem.offset 0,0; st8.spill [r2] = r5, 16
+.mem.offset 8,0; st8.spill [r3] = r6
+	add r3 = (SC_FR+3*16-(SC_GR+6*8)), r3
+	;;
+	st8.spill [r2] = r7, (SC_FR+2*16-(SC_GR+7*8))
+	nop 0
+	and rTMP = ~0x3, rRSC
+	;;
+	mov.m ar.rsc = rTMP 		// put RSE into enforced lazy mode
+	mov.m rNAT = ar.unat
+	mov.i rLC = ar.lc
+	;;
+	mov.m rRNAT = ar.rnat
+	mov.m ar.rsc = rRSC 		// restore RSE mode
+	mov rPR = pr
+
+ 	/*
+	 * Rotate NaT bits by rPOS positions to the right:
+	 */
+	stf.spill [r2] = f2, 32
+	stf.spill [r3] = f3, 32
+	add rPOS = SC_GR, r32			// rPOS <- &sc_gr[0]
+	;;
+	stf.spill [r2] = f4, (16*16-4*16)
+	stf.spill [r3] = f5, (17*16-5*16)
+	extr.u rPOS = rPOS, 3, 6		// get NaT bit number for r0
+	;;
+	stf.spill [r2] = f16, 32
+	stf.spill [r3] = f17, 32
+	sub rCPOS = 64, rPOS
+	;;
+	stf.spill [r2] = f18, 32
+	stf.spill [r3] = f19, 32
+	shr.u rTMP = rNAT, rPOS
+	;;
+	stf.spill [r2] = f20, 32
+	stf.spill [r3] = f21, 32
+	shl rNAT = rNAT, rCPOS
+	;;
+	stf.spill [r2] = f22, 32
+	stf.spill [r3] = f23, 32
+	or rNAT = rNAT, rTMP
+	;;
+	stf.spill [r2] = f24, 32
+	stf.spill [r3] = f25, 32
+	mov r8 = 0
+	;;
+	stf.spill [r2] = f26, 32
+	stf.spill [r3] = f27, 32
+	mov r9 = 1
+	;;
+	stf.spill [r2] = f28, 32
+	stf.spill [r3] = f29, 32
+	mov rB0 = b0
+	;;
+	stf.spill [r2] = f30, 32
+	stf.spill [r3] = f31, 32
+	mov rB1 = b1
+	;;
+	add r2 = SC_NAT, r32
+	nop 0
+	add r3 = SC_BSP, r32
+	;;
+	st8 [r2] = rNAT, (SC_RNAT-SC_NAT)
+	st8 [r3] = rBSP, (SC_UNAT-SC_BSP)
+	mov rB2 = b2
+	;;
+	st8 [r2] = rRNAT, (SC_FPSR-SC_RNAT)
+	st8 [r3] = rUNAT, (SC_PFS-SC_UNAT)
+	mov rB3 = b3
+	;;
+	st8 [r2] = rFPSR, (SC_LC-SC_FPSR)
+	st8 [r3] = rPFS, (SC_PR-SC_PFS)
+	mov rB4 = b4
+	;;
+	st8 [r2] = rLC, (SC_BR+0*8-SC_LC)
+	st8 [r3] = rPR, (SC_BR+1*8-SC_PR)
+	mov rB5 = b5
+
+	st8 [r2] = rB0, 16
+	st8 [r3] = rB1, 16
+	;;
+	st8 [r3] = rB2, 16
+	st8 [r3] = rB3, 16
+	;;
+	st8 [r2] = rB4
+	st8 [r3] = rB5
+	ret
+END(__getcontext)
+
+weak_alias(__getcontext, getcontext)