summaryrefslogtreecommitdiff
path: root/src/third_party/unwind/dist/src/s390x/setcontext.S
blob: 6cf55688aa436ff0c5020ef8be5642ceb536d365 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* libunwind - a platform-independent unwind library
   Copyright (C) 2008 Google, Inc
	Contributed by Paul Pluzhnikov <ppluzhnikov@google.com>
   Copyright (C) 2010 Konstantin Belousov <kib@freebsd.org>
   Copyright (C) 2017 IBM

   Modified for s390x by Michael Munday <mike.munday@ibm.com>

This file is part of libunwind.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */

// int _Us390x_setcontext (const ucontext_t *ucp)

	.global _Us390x_setcontext
	.type _Us390x_setcontext, @function
_Us390x_setcontext:
	.cfi_startproc

	// Must only restore registers saved by getcontext, other fields
	// in the ucontext_t might be uninitialised.

	// Stop this function being unwound. We are clobbering callee-save
	// registers in this function so unwinding it is unsafe.
	// Ideally we'd save callee-save registers, update the CFI for them
	// and then switch to the new CFI once the context switch is
	// complete.
	.cfi_undefined %r14

	// floating point parameters
	ld    %f0,0x100(%r2)
	ld    %f2,0x110(%r2)
	ld    %f4,0x120(%r2)
	ld    %f6,0x130(%r2)

	// floating point preserved registers
	lfpc  0xf8(%r2)
	ld    %f8,0x140(%r2)
	ld    %f9,0x148(%r2)
	ld    %f10,0x150(%r2)
	ld    %f11,0x158(%r2)
	ld    %f12,0x160(%r2)
	ld    %f13,0x168(%r2)
	ld    %f14,0x170(%r2)
	ld    %f15,0x178(%r2)

	// preserved registers and parameters
	lgr   %r1,%r2
	lmg   %r2,%r15,0x48(%r1)

	// restore PSW address
	lg    %r1,0x30(%r1)
	br    %r1

	.cfi_endproc
	.size _Us390x_setcontext, . - _Us390x_setcontext

	// We do not need executable stack.
	.section        .note.GNU-stack,"",@progbits