Subversion Repositories HelenOS-historic

Rev

Rev 60 | Rev 83 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
55 jermar 1
#
2
# Copyright (C) 2005 Jakub Jermar
3
# All rights reserved.
4
#
5
# Redistribution and use in source and binary forms, with or without
6
# modification, are permitted provided that the following conditions
7
# are met:
8
#
9
# - Redistributions of source code must retain the above copyright
10
#   notice, this list of conditions and the following disclaimer.
11
# - Redistributions in binary form must reproduce the above copyright
12
#   notice, this list of conditions and the following disclaimer in the
13
#   documentation and/or other materials provided with the distribution.
14
# - The name of the author may not be used to endorse or promote products
15
#   derived from this software without specific prior written permission.
16
#
17
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
#
28
 
29
.text
30
 
31
.global context_save
32
.global context_restore
33
 
34
context_save:
82 jermar 35
	alloc loc0 = ar.pfs, 1, 9, 0, 0
59 jermar 36
 
37
	/*
38
	 * TODO: save the rest of the context registers.
39
	 */
40
 
82 jermar 41
	/*
42
	 * Save general registers
43
	 */
59 jermar 44
	st8 [in0] = r1, 8	;;
45
	st8 [in0] = r2, 8	;;
46
	st8 [in0] = r3, 8	;;
47
	st8 [in0] = r4, 8	;;
48
	st8 [in0] = r5, 8	;;
49
	st8 [in0] = r6, 8	;;
50
	st8 [in0] = r7, 8	;;
51
	st8 [in0] = r8, 8	;;
52
	st8 [in0] = r9, 8	;;
53
	st8 [in0] = r10, 8	;;
54
	st8 [in0] = r11, 8	;;
55
	st8 [in0] = r12, 8	;;	/* save sp */
56
	st8 [in0] = r13, 8	;;
57
	st8 [in0] = r14, 8	;;
58
	st8 [in0] = r15, 8	;;
59
	st8 [in0] = r16, 8	;;
60
	st8 [in0] = r17, 8	;;
61
	st8 [in0] = r18, 8	;;
62
	st8 [in0] = r19, 8	;;
63
	st8 [in0] = r20, 8	;;
64
	st8 [in0] = r21, 8	;;
65
	st8 [in0] = r22, 8	;;
66
	st8 [in0] = r23, 8	;;
67
	st8 [in0] = r24, 8	;;
68
	st8 [in0] = r25, 8	;;
69
	st8 [in0] = r26, 8	;;
70
	st8 [in0] = r27, 8	;;
71
	st8 [in0] = r28, 8	;;
72
	st8 [in0] = r29, 8	;;
73
	st8 [in0] = r30, 8	;;
74
	st8 [in0] = r31, 8	;;
75
 
82 jermar 76
	/*
77
	 * Save branch registers
78
	 */
59 jermar 79
	mov loc1 = b0		;;
82 jermar 80
	st8 [in0] = loc1, 8		/* save pc */
81
	mov loc2 = b1		;;
82
	st8 [in0] = loc2, 8
83
	mov loc3 = b2		;;
84
	st8 [in0] = loc3, 8
85
	mov loc4 = b3		;;
86
	st8 [in0] = loc4, 8
87
	mov loc5 = b4		;;
88
	st8 [in0] = loc5, 8
89
	mov loc6 = b5		;;
90
	st8 [in0] = loc6, 8
91
	mov loc7 = b6		;;
92
	st8 [in0] = loc7, 8
93
	mov loc8 = b7		;;
94
	st8 [in0] = loc8, 8
95
 
96
	/*
97
	 * Save predicate registers
98
	 */
99
	mov loc1 = pr		;;
59 jermar 100
	st8 [in0] = loc1, 8
101
 
102
	mov ar.pfs = loc0
103
 
104
	add r8 = r0, r0, 1 		/* context_save returns 1 */
60 jermar 105
	br.ret.sptk.many b0
55 jermar 106
 
107
context_restore:
82 jermar 108
	alloc loc0 = ar.pfs, 1, 9, 0, 0
59 jermar 109
 
110
	/*
111
	 * TODO: restore the rest of the context registers.
112
	 */
113
 
82 jermar 114
	/*
115
	 * Restore general registers
116
	 */
59 jermar 117
	ld8 r1 = [in0], 8	;;
118
	ld8 r2 = [in0], 8	;;
119
	ld8 r3 = [in0], 8	;;
120
	ld8 r4 = [in0], 8	;;
121
	ld8 r5 = [in0], 8	;;
122
	ld8 r6 = [in0], 8	;;
123
	ld8 r7 = [in0], 8	;;
124
	ld8 r8 = [in0], 8	;;
125
	ld8 r9 = [in0], 8	;;
126
	ld8 r10 = [in0], 8	;;
127
	ld8 r11 = [in0], 8	;;
128
	ld8 r12 = [in0], 8	;;	/* restore sp */
129
	ld8 r13 = [in0], 8	;;
130
	ld8 r14 = [in0], 8	;;
131
	ld8 r15 = [in0], 8	;;
132
	ld8 r16 = [in0], 8	;;
133
	ld8 r17 = [in0], 8	;;
134
	ld8 r18 = [in0], 8	;;
135
	ld8 r19 = [in0], 8	;;
136
	ld8 r20 = [in0], 8	;;
137
	ld8 r21 = [in0], 8	;;
138
	ld8 r22 = [in0], 8	;;
139
	ld8 r23 = [in0], 8	;;
140
	ld8 r24 = [in0], 8	;;
141
	ld8 r25 = [in0], 8	;;
142
	ld8 r26 = [in0], 8	;;
143
	ld8 r27 = [in0], 8	;;
144
	ld8 r28 = [in0], 8	;;
145
	ld8 r29 = [in0], 8	;;
146
	ld8 r30 = [in0], 8	;;
147
	ld8 r31 = [in0], 8	;;
148
 
82 jermar 149
	/* 
150
	 * Restore branch registers
151
	 */
152
	ld8 loc1 = [in0], 8	;;	/* restore pc */
153
	mov b0 = loc1
154
	ld8 loc2 = [in0], 8	;;
155
	mov b1 = loc2
156
	ld8 loc3 = [in0], 8	;;
157
	mov b2 = loc3
158
	ld8 loc4 = [in0], 8	;;
159
	mov b3 = loc4
160
	ld8 loc5 = [in0], 8	;;
161
	mov b4 = loc5
162
	ld8 loc6 = [in0], 8	;;
163
	mov b5 = loc6
164
	ld8 loc7 = [in0], 8	;;
165
	mov b6 = loc7
166
	ld8 loc8 = [in0], 8	;;
167
	mov b7 = loc8
168
 
59 jermar 169
	ld8 loc1 = [in0], 8	;;
82 jermar 170
	mov pr = loc1, ~0
59 jermar 171
 
172
	mov ar.pfs = loc0
173
 
174
	mov r8 = r0			/* context_restore returns 0 */
60 jermar 175
	br.ret.sptk.many b0