aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/machine/arc/setjmp.S
blob: bd6acdcc4a7dcf918352cc3b56f431e8715f3e56 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
   Copyright (c) 2015-2024, Synopsys, Inc. All rights reserved.

   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are met:

   1) Redistributions of source code must retain the above copyright notice,
   this list of conditions and the following disclaimer.

   2) Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

   3) Neither the name of the Synopsys, Inc., nor the names of its contributors
   may be used to endorse or promote products derived from this software
   without specific prior written permission.

   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   POSSIBILITY OF SUCH DAMAGE.
*/

/* ABI interface file
   these are the stack mappings for the registers
   as stored in the ABI for ARC */

ABIr13	= 0
ABIr14	= ABIr13 + 4
ABIr15	= ABIr14 + 4
ABIr16	= ABIr15 + 4
ABIr17	= ABIr16 + 4
ABIr18	= ABIr17 + 4
ABIr19	= ABIr18 + 4
ABIr20	= ABIr19 + 4
ABIr21	= ABIr20 + 4
ABIr22	= ABIr21 + 4
ABIr23	= ABIr22 + 4
ABIr24	= ABIr23 + 4
ABIr25	= ABIr24 + 4
ABIr26	= ABIr25 + 4
ABIr27	= ABIr26 + 4
ABIr28	= ABIr27 + 4
ABIr29	= ABIr28 + 4
ABIr30	= ABIr29 + 4
ABIr31	= ABIr30 + 4
ABIlpc	= ABIr31 + 4
ABIlps	= ABIlpc + 4
ABIlpe	= ABIlps + 4

ABIflg	= ABIlpe + 4
ABImlo	= ABIflg + 4
ABImhi	= ABImlo + 4

	.text
	.align 4
	.global setjmp
	.type setjmp,@function
setjmp:
	st	r13, [r0, ABIr13]
	st	r14, [r0, ABIr14]
	st	r15, [r0, ABIr15]
	st	r16, [r0, ABIr16]
	st	r17, [r0, ABIr17]
	st	r18, [r0, ABIr18]
	st	r19, [r0, ABIr19]
	st	r20, [r0, ABIr20]
	st	r21, [r0, ABIr21]
	st	r22, [r0, ABIr22]
	st	r23, [r0, ABIr23]
	st	r24, [r0, ABIr24]
	st	r25, [r0, ABIr25]
	st	r26, [r0, ABIr26]
	st	r27, [r0, ABIr27]
	st	r28, [r0, ABIr28]
	st	r29, [r0, ABIr29]
	st	r30, [r0, ABIr30]
	st	blink, [r0, ABIr31]
	st	lp_count, [r0, ABIlpc]

	lr	r2, [lp_start]
	lr	r3, [lp_end]
	st	r2, [r0, ABIlps]
	st	r3, [r0, ABIlpe]

#if (!defined (__ARC700__) && !defined (__ARCEM__) && !defined (__ARCHS__))
; Till the configure changes are decided, and implemented, the code working on
; mlo/mhi and using mul64 should be disabled.
; 	st	mlo, [r0, ABImlo]
; 	st	mhi, [r0, ABImhi]
	lr	r2, [status32]
	st	r2, [r0, ABIflg]
#endif

	j.d	[blink]
	mov	r0,0
.Lfe1:
	.size	setjmp,.Lfe1-setjmp

	.align	4
	.global longjmp
	.type longjmp,@function
longjmp:

	; load registers
	ld	r13, [r0, ABIr13]
	ld	r14, [r0, ABIr14]
	ld	r15, [r0, ABIr15]
	ld	r16, [r0, ABIr16]
	ld	r17, [r0, ABIr17]
	ld	r18, [r0, ABIr18]
	ld	r19, [r0, ABIr19]
	ld	r20, [r0, ABIr20]
	ld	r21, [r0, ABIr21]
	ld	r22, [r0, ABIr22]
	ld	r23, [r0, ABIr23]
	ld	r24, [r0, ABIr24]
	ld	r25, [r0, ABIr25]
	ld	r26, [r0, ABIr26]
	ld	r27, [r0, ABIr27]
	ld	r28, [r0, ABIr28]

	ld	r3, [r0, ABIr29]
	mov	r29, r3

	ld	r3, [r0, ABIr30]
	mov	r30, r3

	ld	blink, [r0, ABIr31]

	ld	r3,  [r0, ABIlpc]
	mov	lp_count, r3

	ld	r2, [r0, ABIlps]
	ld	r3, [r0, ABIlpe]
	sr	r2, [lp_start]
	sr	r3, [lp_end]

#if (!defined (__ARC700__) && !defined (__ARCEM__) && !defined (__ARCHS__))
	ld	r2, [r0, ABImlo]
	ld	r3, [r0, ABImhi]
; We do not support restoring of mulhi and mlo registers, yet.

;	mulu64	0,r2,1			; restores mlo
;	mov	0,mlo			; force multiply to finish
;	sr	r3, [mulhi]
	ld	r2, [r0, ABIflg]
	flag	r2			; restore "status32" register
#endif

	mov.f	r1, r1			; to avoid return 0 from longjmp
	mov.eq	r1, 1
	j.d	[blink]
	mov	r0,r1
.Lfe2:
	.size	longjmp,.Lfe2-longjmp