1 /* $NetBSD: bcopy_page.S,v 1.7 2003/10/13 21:03:13 scw Exp $ */
4 * Copyright (c) 1995 Scott Stevens
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Scott Stevens.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * RiscBSD kernel project
36 * page optimised bcopy and bzero routines
41 #include <machine/asm.h>
43 __FBSDID("$FreeBSD$");
49 /* #define BIG_LOOPS */
52 * bcopy_page(src, dest)
54 * Optimised copy page routine.
61 * number of bytes per page (PAGE_SIZE) is a multiple of 512 (BIG_LOOPS), 128
67 #define PREFETCH_FIRST_CHUNK /* nothing */
68 #define PREFETCH_NEXT_CHUNK /* nothing */
72 PREFETCH_NEXT_CHUNK ; \
73 ldmia r0!, {r3-r8,ip,lr} ; \
74 stmia r1!, {r3-r8,ip,lr}
75 #endif /* ! COPY_CHUNK */
78 #define SAVE_REGS stmfd sp!, {r4-r8, lr}
79 #define RESTORE_REGS ldmfd sp!, {r4-r8, pc}
86 mov r2, #(PAGE_SIZE >> 9)
88 mov r2, #(PAGE_SIZE >> 7)
98 /* There is little point making the loop any larger; unless we are
99 running with the cache off, the load/store overheads will
100 completely dominate this loop. */
119 RESTORE_REGS /* ...and return. */
125 * Optimised zero page routine.
131 * number of bytes per page (PAGE_SIZE) is a multiple of 512 (BIG_LOOPS), 128
136 stmfd sp!, {r4-r8, lr}
138 mov r2, #(PAGE_SIZE >> 9)
140 mov r2, #(PAGE_SIZE >> 7)
152 stmia r0!, {r3-r8,ip,lr}
153 stmia r0!, {r3-r8,ip,lr}
154 stmia r0!, {r3-r8,ip,lr}
155 stmia r0!, {r3-r8,ip,lr}
158 /* There is little point making the loop any larger; unless we are
159 running with the cache off, the load/store overheads will
160 completely dominate this loop. */
161 stmia r0!, {r3-r8,ip,lr}
162 stmia r0!, {r3-r8,ip,lr}
163 stmia r0!, {r3-r8,ip,lr}
164 stmia r0!, {r3-r8,ip,lr}
166 stmia r0!, {r3-r8,ip,lr}
167 stmia r0!, {r3-r8,ip,lr}
168 stmia r0!, {r3-r8,ip,lr}
169 stmia r0!, {r3-r8,ip,lr}
171 stmia r0!, {r3-r8,ip,lr}
172 stmia r0!, {r3-r8,ip,lr}
173 stmia r0!, {r3-r8,ip,lr}
174 stmia r0!, {r3-r8,ip,lr}
181 ldmfd sp!, {r4-r8, pc}
184 #else /* _ARM_ARCH_5E */
187 * armv5e version of bcopy_page
193 ldr r2, [r0], #0x04 /* 0x00 */
194 ldr r3, [r0], #0x04 /* 0x04 */
195 1: pld [r0, #0x18] /* Prefetch 0x20 */
196 ldr r4, [r0], #0x04 /* 0x08 */
197 ldr r5, [r0], #0x04 /* 0x0c */
199 ldr r2, [r0], #0x04 /* 0x10 */
200 ldr r3, [r0], #0x04 /* 0x14 */
202 ldr r4, [r0], #0x04 /* 0x18 */
203 ldr r5, [r0], #0x04 /* 0x1c */
205 ldr r2, [r0], #0x04 /* 0x20 */
206 ldr r3, [r0], #0x04 /* 0x24 */
207 pld [r0, #0x18] /* Prefetch 0x40 */
209 ldr r4, [r0], #0x04 /* 0x28 */
210 ldr r5, [r0], #0x04 /* 0x2c */
212 ldr r2, [r0], #0x04 /* 0x30 */
213 ldr r3, [r0], #0x04 /* 0x34 */
215 ldr r4, [r0], #0x04 /* 0x38 */
216 ldr r5, [r0], #0x04 /* 0x3c */
218 ldr r2, [r0], #0x04 /* 0x40 */
219 ldr r3, [r0], #0x04 /* 0x44 */
220 pld [r0, #0x18] /* Prefetch 0x60 */
222 ldr r4, [r0], #0x04 /* 0x48 */
223 ldr r5, [r0], #0x04 /* 0x4c */
225 ldr r2, [r0], #0x04 /* 0x50 */
226 ldr r3, [r0], #0x04 /* 0x54 */
228 ldr r4, [r0], #0x04 /* 0x58 */
229 ldr r5, [r0], #0x04 /* 0x5c */
231 ldr r2, [r0], #0x04 /* 0x60 */
232 ldr r3, [r0], #0x04 /* 0x64 */
233 pld [r0, #0x18] /* Prefetch 0x80 */
235 ldr r4, [r0], #0x04 /* 0x68 */
236 ldr r5, [r0], #0x04 /* 0x6c */
238 ldr r2, [r0], #0x04 /* 0x70 */
239 ldr r3, [r0], #0x04 /* 0x74 */
241 ldr r4, [r0], #0x04 /* 0x78 */
242 ldr r5, [r0], #0x04 /* 0x7c */
245 ldrgt r2, [r0], #0x04 /* 0x80 */
246 ldrgt r3, [r0], #0x04 /* 0x84 */
254 * armv5e version of bzero_page
260 1: strd r2, [r0], #8 /* 32 */
264 strd r2, [r0], #8 /* 64 */
268 strd r2, [r0], #8 /* 96 */
272 strd r2, [r0], #8 /* 128 */
280 #endif /* _ARM_ARCH_5E */