Subversion Repositories HelenOS-historic

Rev

Rev 1007 | Rev 1277 | 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
210 decky 35
.global memsetb
36
.global memcpy
185 decky 37
 
1220 decky 38
userspace_asm:
39
 
40
	# r3 = uspace_uarg
41
	# r4 = stack
42
	# r5 = entry	
43
 
44
	mfmsr r31
45
	rlwinm r31, r31, 0, 17, 15
46
	mtmsr r31
47
 
48
	# set entry point
49
 
50
	mtsrr0 r5
51
 
52
	# set problem state, enable interrupts
53
 
54
	ori r31, r31, 1 << 14
55
	ori r31, r31, 1 << 15
56
	mtsrr1 r31
57
 
58
	# set stack
59
 
60
	mr sp, r4
61
 
62
	# jump to userspace
63
 
64
	rfi
65
 
1004 decky 66
iret:
67
	lwz r3, 144(sp)
68
	mtxer r3
69
 
70
	lwz r3, 140(sp)
71
	mtctr r3
72
 
73
	lwz r3, 136(sp)
74
	mtcr r3
75
 
76
	lwz r3, 132(sp)
77
	mtlr r3
78
 
79
	lwz r3, 128(sp)
80
	mtspr srr1, r3
81
 
82
	lwz r3, 124(sp)
83
	mtspr srr0, r3
84
 
85
	lwz r0, 0(sp)
86
	lwz r2, 4(sp)
87
	lwz r3, 8(sp)
88
	lwz r4, 12(sp)
89
	lwz r5, 16(sp)
90
	lwz r6, 20(sp)
91
	lwz r7, 24(sp)
92
	lwz r8, 28(sp)
93
	lwz r9, 32(sp)
94
	lwz r10, 36(sp)
95
	lwz r11, 40(sp)
96
	lwz r12, 44(sp)
97
	lwz r13, 48(sp)
98
	lwz r14, 52(sp)
99
	lwz r15, 56(sp)
100
	lwz r16, 60(sp)
101
	lwz r17, 64(sp)
102
	lwz r18, 68(sp)
103
	lwz r19, 72(sp)
104
	lwz r20, 76(sp)
105
	lwz r21, 80(sp)
106
	lwz r22, 84(sp)
107
	lwz r23, 88(sp)
108
	lwz r24, 92(sp)
109
	lwz r25, 96(sp)
110
	lwz r26, 100(sp)
111
	lwz r27, 104(sp)
112
	lwz r28, 108(sp)
113
	lwz r29, 112(sp)
114
	lwz r30, 116(sp)
115
	lwz r31, 120(sp)
116
 
117
	mfspr sp, sprg1
118
 
119
	rfi
120
 
210 decky 121
memsetb:
122
	rlwimi r5, r5, 8, 16, 23
123
	rlwimi r5, r5, 16, 0, 15
124
 
125
	addi r14, r3, -4
126
 
127
	cmplwi 0, r4, 4
128
	blt 7f
129
 
130
	stwu r5, 4(r14)
131
	beqlr
132
 
133
	andi. r15, r14, 3
134
	add r4, r15, r4
135
	subf r14, r15, r14
136
	srwi r15, r4, 2
137
	mtctr r15
138
 
139
	bdz 6f
140
 
141
	1:
142
		stwu r5, 4(r14)
143
		bdnz 1b
144
 
145
	6:
146
 
147
	andi. r4, r4, 3
148
 
149
	7:
150
 
151
	cmpwi 0, r4, 0
152
	beqlr
153
 
154
	mtctr r4
155
	addi r6, r6, 3
156
 
157
	8:
158
 
159
	stbu r5, 1(r14)
160
	bdnz 8b
161
 
162
	blr
163
 
164
memcpy:
860 decky 165
	srwi. r7, r5, 3
166
	addi r6, r3, -4
167
	addi r4, r4, -4
168
	beq	2f
169
 
170
	andi. r0, r6, 3
171
	mtctr r7
172
	bne 5f
173
 
174
	1:
175
 
176
	lwz r7, 4(r4)
177
	lwzu r8, 8(r4)
178
	stw r7, 4(r6)
179
	stwu r8, 8(r6)
180
	bdnz 1b
181
 
182
	andi. r5, r5, 7
183
 
184
	2:
185
 
186
	cmplwi 0, r5, 4
187
	blt 3f
188
 
189
	lwzu r0, 4(r4)
190
	addi r5, r5, -4
191
	stwu r0, 4(r6)
192
 
193
	3:
194
 
195
	cmpwi 0, r5, 0
196
	beqlr
197
	mtctr r5
198
	addi r4, r4, 3
199
	addi r6, r6, 3
200
 
201
	4:
202
 
203
	lbzu r0, 1(r4)
204
	stbu r0, 1(r6)
205
	bdnz 4b
210 decky 206
	blr
860 decky 207
 
208
	5:
209
 
210
	subfic r0, r0, 4
211
	mtctr r0
212
 
213
	6:
214
 
215
	lbz r7, 4(r4)
216
	addi r4, r4, 1
217
	stb r7, 4(r6)
218
	addi r6, r6, 1
219
	bdnz 6b
220
	subf r5, r0, r5
221
	rlwinm. r7, r5, 32-3, 3, 31
222
	beq 2b
223
	mtctr r7
224
	b 1b