Subversion Repositories HelenOS-historic

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1160 decky 1
#
2
# Copyright (C) 2006 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
 
29
#include <arch/asm/regname.h>
30
 
31
.text
32
 
33
.global iret
34
.global memsetb
35
.global memcpy
36
 
37
iret:
38
	lwz r3, 144(sp)
39
	mtxer r3
40
 
41
	lwz r3, 140(sp)
42
	mtctr r3
43
 
44
	lwz r3, 136(sp)
45
	mtcr r3
46
 
47
	lwz r3, 132(sp)
48
	mtlr r3
49
 
50
	lwz r3, 128(sp)
51
	mtspr srr1, r3
52
 
53
	lwz r3, 124(sp)
54
	mtspr srr0, r3
55
 
56
	lwz r0, 0(sp)
57
	lwz r2, 4(sp)
58
	lwz r3, 8(sp)
59
	lwz r4, 12(sp)
60
	lwz r5, 16(sp)
61
	lwz r6, 20(sp)
62
	lwz r7, 24(sp)
63
	lwz r8, 28(sp)
64
	lwz r9, 32(sp)
65
	lwz r10, 36(sp)
66
	lwz r11, 40(sp)
67
	lwz r12, 44(sp)
68
	lwz r13, 48(sp)
69
	lwz r14, 52(sp)
70
	lwz r15, 56(sp)
71
	lwz r16, 60(sp)
72
	lwz r17, 64(sp)
73
	lwz r18, 68(sp)
74
	lwz r19, 72(sp)
75
	lwz r20, 76(sp)
76
	lwz r21, 80(sp)
77
	lwz r22, 84(sp)
78
	lwz r23, 88(sp)
79
	lwz r24, 92(sp)
80
	lwz r25, 96(sp)
81
	lwz r26, 100(sp)
82
	lwz r27, 104(sp)
83
	lwz r28, 108(sp)
84
	lwz r29, 112(sp)
85
	lwz r30, 116(sp)
86
	lwz r31, 120(sp)
87
 
88
	mfspr sp, sprg1
89
 
90
	rfi
91
 
92
memsetb:
93
	rlwimi r5, r5, 8, 16, 23
94
	rlwimi r5, r5, 16, 0, 15
95
 
96
	addi r14, r3, -4
97
 
98
	cmplwi 0, r4, 4
99
	blt 7f
100
 
101
	stwu r5, 4(r14)
102
	beqlr
103
 
104
	andi. r15, r14, 3
105
	add r4, r15, r4
106
	subf r14, r15, r14
107
	srwi r15, r4, 2
108
	mtctr r15
109
 
110
	bdz 6f
111
 
112
	1:
113
		stwu r5, 4(r14)
114
		bdnz 1b
115
 
116
	6:
117
 
118
	andi. r4, r4, 3
119
 
120
	7:
121
 
122
	cmpwi 0, r4, 0
123
	beqlr
124
 
125
	mtctr r4
126
	addi r6, r6, 3
127
 
128
	8:
129
 
130
	stbu r5, 1(r14)
131
	bdnz 8b
132
 
133
	blr
134
 
135
memcpy:
136
	srwi. r7, r5, 3
137
	addi r6, r3, -4
138
	addi r4, r4, -4
139
	beq	2f
140
 
141
	andi. r0, r6, 3
142
	mtctr r7
143
	bne 5f
144
 
145
	1:
146
 
147
	lwz r7, 4(r4)
148
	lwzu r8, 8(r4)
149
	stw r7, 4(r6)
150
	stwu r8, 8(r6)
151
	bdnz 1b
152
 
153
	andi. r5, r5, 7
154
 
155
	2:
156
 
157
	cmplwi 0, r5, 4
158
	blt 3f
159
 
160
	lwzu r0, 4(r4)
161
	addi r5, r5, -4
162
	stwu r0, 4(r6)
163
 
164
	3:
165
 
166
	cmpwi 0, r5, 0
167
	beqlr
168
	mtctr r5
169
	addi r4, r4, 3
170
	addi r6, r6, 3
171
 
172
	4:
173
 
174
	lbzu r0, 1(r4)
175
	stbu r0, 1(r6)
176
	bdnz 4b
177
	blr
178
 
179
	5:
180
 
181
	subfic r0, r0, 4
182
	mtctr r0
183
 
184
	6:
185
 
186
	lbz r7, 4(r4)
187
	addi r4, r4, 1
188
	stb r7, 4(r6)
189
	addi r6, r6, 1
190
	bdnz 6b
191
	subf r5, r0, r5
192
	rlwinm. r7, r5, 32-3, 3, 31
193
	beq 2b
194
	mtctr r7
195
	b 1b