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