bcopy_page.S revision 1.6 1 /* $NetBSD: bcopy_page.S,v 1.6 2003/04/08 22:57:53 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1995 Scott Stevens
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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.
20 *
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.
31 *
32 * RiscBSD kernel project
33 *
34 * bcopy_page.S
35 *
36 * page optimised bcopy and bzero routines
37 *
38 * Created : 08/04/95
39 */
40
41 #include <machine/asm.h>
42
43 #include "assym.h"
44
45 /* #define BIG_LOOPS */
46
47 /*
48 * bcopy_page(src, dest)
49 *
50 * Optimised copy page routine.
51 *
52 * On entry:
53 * r0 - src address
54 * r1 - dest address
55 *
56 * Requires:
57 * number of bytes per page (PAGE_SIZE) is a multiple of 512 (BIG_LOOPS), 128
58 * otherwise.
59 */
60
61 #define CHUNK_SIZE 32
62
63 #ifdef __XSCALE__
64 /* Conveniently, the chunk size is the XScale cache line size. */
65 #define PREFETCH_FIRST_CHUNK pld [r0]
66 #define PREFETCH_NEXT_CHUNK pld [r0, #(CHUNK_SIZE)]
67 #else
68 #define PREFETCH_FIRST_CHUNK /* nothing */
69 #define PREFETCH_NEXT_CHUNK /* nothing */
70 #endif
71
72 #ifndef COPY_CHUNK
73 #define COPY_CHUNK \
74 PREFETCH_NEXT_CHUNK ; \
75 ldmia r0!, {r3-r8,ip,lr} ; \
76 stmia r1!, {r3-r8,ip,lr}
77 #endif /* ! COPY_CHUNK */
78
79 #ifndef SAVE_REGS
80 #define SAVE_REGS stmfd sp!, {r4-r8, lr}
81 #define RESTORE_REGS ldmfd sp!, {r4-r8, pc}
82 #endif
83
84 ENTRY(bcopy_page)
85 PREFETCH_FIRST_CHUNK
86 SAVE_REGS
87 #ifdef BIG_LOOPS
88 mov r2, #(PAGE_SIZE >> 9)
89 #else
90 mov r2, #(PAGE_SIZE >> 7)
91 #endif
92
93 1:
94 COPY_CHUNK
95 COPY_CHUNK
96 COPY_CHUNK
97 COPY_CHUNK
98
99 #ifdef BIG_LOOPS
100 /* There is little point making the loop any larger; unless we are
101 running with the cache off, the load/store overheads will
102 completely dominate this loop. */
103 COPY_CHUNK
104 COPY_CHUNK
105 COPY_CHUNK
106 COPY_CHUNK
107
108 COPY_CHUNK
109 COPY_CHUNK
110 COPY_CHUNK
111 COPY_CHUNK
112
113 COPY_CHUNK
114 COPY_CHUNK
115 COPY_CHUNK
116 COPY_CHUNK
117 #endif
118 subs r2, r2, #1
119 bne 1b
120
121 RESTORE_REGS /* ...and return. */
122
123 /*
124 * bzero_page(dest)
125 *
126 * Optimised zero page routine.
127 *
128 * On entry:
129 * r0 - dest address
130 *
131 * Requires:
132 * number of bytes per page (PAGE_SIZE) is a multiple of 512 (BIG_LOOPS), 128
133 * otherwise
134 */
135
136 ENTRY(bzero_page)
137 stmfd sp!, {r4-r8, lr}
138 #ifdef BIG_LOOPS
139 mov r2, #(PAGE_SIZE >> 9)
140 #else
141 mov r2, #(PAGE_SIZE >> 7)
142 #endif
143 mov r3, #0
144 mov r4, #0
145 mov r5, #0
146 mov r6, #0
147 mov r7, #0
148 mov r8, #0
149 mov ip, #0
150 mov lr, #0
151
152 1:
153 stmia r0!, {r3-r8,ip,lr}
154 stmia r0!, {r3-r8,ip,lr}
155 stmia r0!, {r3-r8,ip,lr}
156 stmia r0!, {r3-r8,ip,lr}
157
158 #ifdef BIG_LOOPS
159 /* There is little point making the loop any larger; unless we are
160 running with the cache off, the load/store overheads will
161 completely dominate this loop. */
162 stmia r0!, {r3-r8,ip,lr}
163 stmia r0!, {r3-r8,ip,lr}
164 stmia r0!, {r3-r8,ip,lr}
165 stmia r0!, {r3-r8,ip,lr}
166
167 stmia r0!, {r3-r8,ip,lr}
168 stmia r0!, {r3-r8,ip,lr}
169 stmia r0!, {r3-r8,ip,lr}
170 stmia r0!, {r3-r8,ip,lr}
171
172 stmia r0!, {r3-r8,ip,lr}
173 stmia r0!, {r3-r8,ip,lr}
174 stmia r0!, {r3-r8,ip,lr}
175 stmia r0!, {r3-r8,ip,lr}
176
177 #endif
178
179 subs r2, r2, #1
180 bne 1b
181
182 ldmfd sp!, {r4-r8, pc}
183