• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* libunwind - a platform-independent unwind library
2   Copyright (C) 2008 Google, Inc
3	Contributed by Paul Pluzhnikov <ppluzhnikov@google.com>
4   Copyright (C) 2010 Konstantin Belousov <kib@freebsd.org>
5   Copyright (C) 2017 IBM
6
7   Modified for s390x by Michael Munday <mike.munday@ibm.com>
8
9This file is part of libunwind.
10
11Permission is hereby granted, free of charge, to any person obtaining
12a copy of this software and associated documentation files (the
13"Software"), to deal in the Software without restriction, including
14without limitation the rights to use, copy, modify, merge, publish,
15distribute, sublicense, and/or sell copies of the Software, and to
16permit persons to whom the Software is furnished to do so, subject to
17the following conditions:
18
19The above copyright notice and this permission notice shall be
20included in all copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
29
30// int _Us390x_setcontext (const ucontext_t *ucp)
31
32	.global _Us390x_setcontext
33	.type _Us390x_setcontext, @function
34_Us390x_setcontext:
35	.cfi_startproc
36
37	// Must only restore registers saved by getcontext, other fields
38	// in the ucontext_t might be uninitialised.
39
40	// Stop this function being unwound. We are clobbering callee-save
41	// registers in this function so unwinding it is unsafe.
42	// Ideally we'd save callee-save registers, update the CFI for them
43	// and then switch to the new CFI once the context switch is
44	// complete.
45	.cfi_undefined %r14
46
47	// floating point parameters
48	ld    %f0,0x100(%r2)
49	ld    %f2,0x110(%r2)
50	ld    %f4,0x120(%r2)
51	ld    %f6,0x130(%r2)
52
53	// floating point preserved registers
54	lfpc  0xf8(%r2)
55	ld    %f8,0x140(%r2)
56	ld    %f9,0x148(%r2)
57	ld    %f10,0x150(%r2)
58	ld    %f11,0x158(%r2)
59	ld    %f12,0x160(%r2)
60	ld    %f13,0x168(%r2)
61	ld    %f14,0x170(%r2)
62	ld    %f15,0x178(%r2)
63
64	// preserved registers and parameters
65	lgr   %r1,%r2
66	lmg   %r2,%r15,0x48(%r1)
67
68	// restore PSW address
69	lg    %r1,0x30(%r1)
70	br    %r1
71
72	.cfi_endproc
73	.size _Us390x_setcontext, . - _Us390x_setcontext
74
75	// We do not need executable stack.
76	.section        .note.GNU-stack,"",@progbits
77