Subversion Repositories HelenOS-historic

Rev

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

Rev Author Line No. Line
162 decky 1
#
2
# Copyright (C) 2005 Martin Decky
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
 
845 decky 29
#include <arch/asm/regname.h>
191 decky 30
 
162 decky 31
.text
32
 
1220 decky 33
.global userspace_asm
1004 decky 34
.global iret
1277 decky 35
.global iret_syscall
210 decky 36
.global memsetb
37
.global memcpy
185 decky 38
 
1220 decky 39
userspace_asm:
40
 
41
	# r3 = uspace_uarg
42
	# r4 = stack
1267 decky 43
	# r5 = entry
44
 
45
	# disable interrupts
1220 decky 46
 
47
	mfmsr r31
48
	rlwinm r31, r31, 0, 17, 15
49
	mtmsr r31
50
 
51
	# set entry point
52
 
53
	mtsrr0 r5
54
 
55
	# set problem state, enable interrupts
56
 
1267 decky 57
	ori r31, r31, msr_pr
58
	ori r31, r31, msr_ee
1220 decky 59
	mtsrr1 r31
60
 
61
	# set stack
62
 
63
	mr sp, r4
64
 
65
	# jump to userspace
66
 
67
	rfi
68
 
1004 decky 69
iret:
1277 decky 70
 
71
	# disable interrupts
72
 
73
	mfmsr r31
74
	rlwinm r31, r31, 0, 17, 15
75
	mtmsr r31
76
 
1004 decky 77
	lwz r0, 0(sp)
78
	lwz r2, 4(sp)
79
	lwz r3, 8(sp)
80
	lwz r4, 12(sp)
81
	lwz r5, 16(sp)
82
	lwz r6, 20(sp)
83
	lwz r7, 24(sp)
84
	lwz r8, 28(sp)
85
	lwz r9, 32(sp)
86
	lwz r10, 36(sp)
87
	lwz r11, 40(sp)
1267 decky 88
	lwz r13, 44(sp)
89
	lwz r14, 48(sp)
90
	lwz r15, 52(sp)
91
	lwz r16, 56(sp)
92
	lwz r17, 60(sp)
93
	lwz r18, 64(sp)
94
	lwz r19, 68(sp)
95
	lwz r20, 72(sp)
96
	lwz r21, 76(sp)
97
	lwz r22, 80(sp)
98
	lwz r23, 84(sp)
99
	lwz r24, 88(sp)
100
	lwz r25, 92(sp)
101
	lwz r26, 96(sp)
102
	lwz r27, 100(sp)
103
	lwz r28, 104(sp)
104
	lwz r29, 108(sp)
105
	lwz r30, 112(sp)
106
	lwz r31, 116(sp)
1004 decky 107
 
1267 decky 108
	lwz r12, 120(sp)
1277 decky 109
	mtcr r12
110
 
111
	lwz r12, 124(sp)
1267 decky 112
	mtsrr0 r12
1004 decky 113
 
1277 decky 114
	lwz r12, 128(sp)
1267 decky 115
	mtsrr1 r12
116
 
1277 decky 117
	lwz r12, 132(sp)
1267 decky 118
	mtlr r12
119
 
1277 decky 120
	lwz r12, 136(sp)
121
	mtctr r12
122
 
123
	lwz r12, 140(sp)
124
	mtxer r12
125
 
126
	lwz r12, 144(sp)
127
	lwz sp, 148(sp)
128
 
129
	rfi
130
 
131
iret_syscall:
132
 
133
	# disable interrupts
134
 
135
	mfmsr r31
136
	rlwinm r31, r31, 0, 17, 15
137
	mtmsr r31
138
 
139
	lwz r0, 0(sp)
140
	lwz r2, 4(sp)
141
	lwz r4, 12(sp)
142
	lwz r5, 16(sp)
143
	lwz r6, 20(sp)
144
	lwz r7, 24(sp)
145
	lwz r8, 28(sp)
146
	lwz r9, 32(sp)
147
	lwz r10, 36(sp)
148
	lwz r11, 40(sp)
149
	lwz r13, 44(sp)
150
	lwz r14, 48(sp)
151
	lwz r15, 52(sp)
152
	lwz r16, 56(sp)
153
	lwz r17, 60(sp)
154
	lwz r18, 64(sp)
155
	lwz r19, 68(sp)
156
	lwz r20, 72(sp)
157
	lwz r21, 76(sp)
158
	lwz r22, 80(sp)
159
	lwz r23, 84(sp)
160
	lwz r24, 88(sp)
161
	lwz r25, 92(sp)
162
	lwz r26, 96(sp)
163
	lwz r27, 100(sp)
164
	lwz r28, 104(sp)
165
	lwz r29, 108(sp)
166
	lwz r30, 112(sp)
167
	lwz r31, 116(sp)
168
 
169
	lwz r12, 120(sp)
1267 decky 170
	mtcr r12
171
 
1277 decky 172
	lwz r12, 124(sp)
173
	mtsrr0 r12
174
 
175
	lwz r12, 128(sp)
176
	mtsrr1 r12
177
 
178
	lwz r12, 132(sp)
179
	mtlr r12
180
 
1267 decky 181
	lwz r12, 136(sp)
182
	mtctr r12
183
 
184
	lwz r12, 140(sp)
185
	mtxer r12
1277 decky 186
 
187
	lwz r12, 144(sp)
188
	lwz sp, 148(sp)
1267 decky 189
 
1004 decky 190
	rfi
191
 
210 decky 192
memsetb:
193
	rlwimi r5, r5, 8, 16, 23
194
	rlwimi r5, r5, 16, 0, 15
195
 
196
	addi r14, r3, -4
197
 
198
	cmplwi 0, r4, 4
199
	blt 7f
200
 
201
	stwu r5, 4(r14)
202
	beqlr
203
 
204
	andi. r15, r14, 3
205
	add r4, r15, r4
206
	subf r14, r15, r14
207
	srwi r15, r4, 2
208
	mtctr r15
209
 
210
	bdz 6f
211
 
212
	1:
213
		stwu r5, 4(r14)
214
		bdnz 1b
215
 
216
	6:
217
 
218
	andi. r4, r4, 3
219
 
220
	7:
221
 
222
	cmpwi 0, r4, 0
223
	beqlr
224
 
225
	mtctr r4
226
	addi r6, r6, 3
227
 
228
	8:
229
 
230
	stbu r5, 1(r14)
231
	bdnz 8b
232
 
233
	blr
234
 
235
memcpy:
860 decky 236
	srwi. r7, r5, 3
237
	addi r6, r3, -4
238
	addi r4, r4, -4
239
	beq	2f
240
 
241
	andi. r0, r6, 3
242
	mtctr r7
243
	bne 5f
244
 
245
	1:
246
 
247
	lwz r7, 4(r4)
248
	lwzu r8, 8(r4)
249
	stw r7, 4(r6)
250
	stwu r8, 8(r6)
251
	bdnz 1b
252
 
253
	andi. r5, r5, 7
254
 
255
	2:
256
 
257
	cmplwi 0, r5, 4
258
	blt 3f
259
 
260
	lwzu r0, 4(r4)
261
	addi r5, r5, -4
262
	stwu r0, 4(r6)
263
 
264
	3:
265
 
266
	cmpwi 0, r5, 0
267
	beqlr
268
	mtctr r5
269
	addi r4, r4, 3
270
	addi r6, r6, 3
271
 
272
	4:
273
 
274
	lbzu r0, 1(r4)
275
	stbu r0, 1(r6)
276
	bdnz 4b
210 decky 277
	blr
860 decky 278
 
279
	5:
280
 
281
	subfic r0, r0, 4
282
	mtctr r0
283
 
284
	6:
285
 
286
	lbz r7, 4(r4)
287
	addi r4, r4, 1
288
	stb r7, 4(r6)
289
	addi r6, r6, 1
290
	bdnz 6b
291
	subf r5, r0, r5
292
	rlwinm. r7, r5, 32-3, 3, 31
293
	beq 2b
294
	mtctr r7
295
	b 1b