bcopy_page.S revision 1.2.6.3 1 1.2.6.3 thorpej /* $NetBSD: bcopy_page.S,v 1.2.6.3 2002/08/19 21:38:58 thorpej Exp $ */
2 1.2.6.2 nathanw
3 1.2.6.2 nathanw /*
4 1.2.6.2 nathanw * Copyright (c) 1995 Scott Stevens
5 1.2.6.2 nathanw * All rights reserved.
6 1.2.6.2 nathanw *
7 1.2.6.2 nathanw * Redistribution and use in source and binary forms, with or without
8 1.2.6.2 nathanw * modification, are permitted provided that the following conditions
9 1.2.6.2 nathanw * are met:
10 1.2.6.2 nathanw * 1. Redistributions of source code must retain the above copyright
11 1.2.6.2 nathanw * notice, this list of conditions and the following disclaimer.
12 1.2.6.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
13 1.2.6.2 nathanw * notice, this list of conditions and the following disclaimer in the
14 1.2.6.2 nathanw * documentation and/or other materials provided with the distribution.
15 1.2.6.2 nathanw * 3. All advertising materials mentioning features or use of this software
16 1.2.6.2 nathanw * must display the following acknowledgement:
17 1.2.6.2 nathanw * This product includes software developed by Scott Stevens.
18 1.2.6.2 nathanw * 4. The name of the author may not be used to endorse or promote products
19 1.2.6.2 nathanw * derived from this software without specific prior written permission.
20 1.2.6.2 nathanw *
21 1.2.6.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.2.6.2 nathanw * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.2.6.2 nathanw * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.2.6.2 nathanw * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.2.6.2 nathanw * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.2.6.2 nathanw * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.2.6.2 nathanw * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.2.6.2 nathanw * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.2.6.2 nathanw * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.2.6.2 nathanw * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.2.6.2 nathanw *
32 1.2.6.2 nathanw * RiscBSD kernel project
33 1.2.6.2 nathanw *
34 1.2.6.2 nathanw * bcopy_page.S
35 1.2.6.2 nathanw *
36 1.2.6.2 nathanw * page optimised bcopy and bzero routines
37 1.2.6.2 nathanw *
38 1.2.6.2 nathanw * Created : 08/04/95
39 1.2.6.2 nathanw */
40 1.2.6.2 nathanw
41 1.2.6.2 nathanw #include <machine/param.h>
42 1.2.6.2 nathanw #include <machine/asm.h>
43 1.2.6.2 nathanw
44 1.2.6.2 nathanw /* #define BIG_LOOPS */
45 1.2.6.2 nathanw
46 1.2.6.2 nathanw /*
47 1.2.6.2 nathanw * bcopy_page(src, dest)
48 1.2.6.2 nathanw *
49 1.2.6.2 nathanw * Optimised copy page routine.
50 1.2.6.2 nathanw *
51 1.2.6.2 nathanw * On entry:
52 1.2.6.2 nathanw * r0 - src address
53 1.2.6.2 nathanw * r1 - dest address
54 1.2.6.2 nathanw *
55 1.2.6.2 nathanw * Requires:
56 1.2.6.2 nathanw * number of bytes per page (NBPG) is a multiple of 512 (BIG_LOOPS), 128
57 1.2.6.2 nathanw * otherwise.
58 1.2.6.2 nathanw */
59 1.2.6.2 nathanw
60 1.2.6.2 nathanw #define CHUNK_SIZE 32
61 1.2.6.2 nathanw
62 1.2.6.2 nathanw #ifdef __XSCALE__
63 1.2.6.2 nathanw /* Conveniently, the chunk size is the XScale cache line size. */
64 1.2.6.2 nathanw #define PREFETCH_FIRST_CHUNK pld [r0]
65 1.2.6.2 nathanw #define PREFETCH_NEXT_CHUNK pld [r0, #(CHUNK_SIZE)]
66 1.2.6.2 nathanw #else
67 1.2.6.2 nathanw #define PREFETCH_FIRST_CHUNK /* nothing */
68 1.2.6.2 nathanw #define PREFETCH_NEXT_CHUNK /* nothing */
69 1.2.6.2 nathanw #endif
70 1.2.6.2 nathanw
71 1.2.6.2 nathanw #ifndef COPY_CHUNK
72 1.2.6.2 nathanw #define COPY_CHUNK \
73 1.2.6.2 nathanw PREFETCH_NEXT_CHUNK ; \
74 1.2.6.2 nathanw ldmia r0!, {r3-r8,ip,lr} ; \
75 1.2.6.2 nathanw stmia r1!, {r3-r8,ip,lr}
76 1.2.6.2 nathanw #endif /* ! COPY_CHUNK */
77 1.2.6.2 nathanw
78 1.2.6.2 nathanw #ifndef SAVE_REGS
79 1.2.6.2 nathanw #define SAVE_REGS stmfd sp!, {r4-r8, lr}
80 1.2.6.2 nathanw #define RESTORE_REGS ldmfd sp!, {r4-r8, pc}
81 1.2.6.2 nathanw #endif
82 1.2.6.2 nathanw
83 1.2.6.2 nathanw ENTRY(bcopy_page)
84 1.2.6.2 nathanw PREFETCH_FIRST_CHUNK
85 1.2.6.2 nathanw SAVE_REGS
86 1.2.6.2 nathanw #ifdef BIG_LOOPS
87 1.2.6.2 nathanw mov r2, #(NBPG >> 9)
88 1.2.6.2 nathanw #else
89 1.2.6.2 nathanw mov r2, #(NBPG >> 7)
90 1.2.6.2 nathanw #endif
91 1.2.6.2 nathanw
92 1.2.6.3 thorpej 1:
93 1.2.6.2 nathanw COPY_CHUNK
94 1.2.6.2 nathanw COPY_CHUNK
95 1.2.6.2 nathanw COPY_CHUNK
96 1.2.6.2 nathanw COPY_CHUNK
97 1.2.6.2 nathanw
98 1.2.6.2 nathanw #ifdef BIG_LOOPS
99 1.2.6.2 nathanw /* There is little point making the loop any larger; unless we are
100 1.2.6.2 nathanw running with the cache off, the load/store overheads will
101 1.2.6.2 nathanw completely dominate this loop. */
102 1.2.6.2 nathanw COPY_CHUNK
103 1.2.6.2 nathanw COPY_CHUNK
104 1.2.6.2 nathanw COPY_CHUNK
105 1.2.6.2 nathanw COPY_CHUNK
106 1.2.6.2 nathanw
107 1.2.6.2 nathanw COPY_CHUNK
108 1.2.6.2 nathanw COPY_CHUNK
109 1.2.6.2 nathanw COPY_CHUNK
110 1.2.6.2 nathanw COPY_CHUNK
111 1.2.6.2 nathanw
112 1.2.6.2 nathanw COPY_CHUNK
113 1.2.6.2 nathanw COPY_CHUNK
114 1.2.6.2 nathanw COPY_CHUNK
115 1.2.6.2 nathanw COPY_CHUNK
116 1.2.6.2 nathanw #endif
117 1.2.6.2 nathanw subs r2, r2, #1
118 1.2.6.3 thorpej bne 1b
119 1.2.6.2 nathanw
120 1.2.6.2 nathanw RESTORE_REGS /* ...and return. */
121 1.2.6.2 nathanw
122 1.2.6.2 nathanw /*
123 1.2.6.2 nathanw * bzero_page(dest)
124 1.2.6.2 nathanw *
125 1.2.6.2 nathanw * Optimised zero page routine.
126 1.2.6.2 nathanw *
127 1.2.6.2 nathanw * On entry:
128 1.2.6.2 nathanw * r0 - dest address
129 1.2.6.2 nathanw *
130 1.2.6.2 nathanw * Requires:
131 1.2.6.2 nathanw * number of bytes per page (NBPG) is a multiple of 512 (BIG_LOOPS), 128
132 1.2.6.2 nathanw * otherwise
133 1.2.6.2 nathanw */
134 1.2.6.2 nathanw
135 1.2.6.2 nathanw ENTRY(bzero_page)
136 1.2.6.2 nathanw stmfd sp!, {r4-r8, lr}
137 1.2.6.2 nathanw #ifdef BIG_LOOPS
138 1.2.6.2 nathanw mov r2, #(NBPG >> 9)
139 1.2.6.2 nathanw #else
140 1.2.6.2 nathanw mov r2, #(NBPG >> 7)
141 1.2.6.2 nathanw #endif
142 1.2.6.2 nathanw mov r3, #0
143 1.2.6.2 nathanw mov r4, #0
144 1.2.6.2 nathanw mov r5, #0
145 1.2.6.2 nathanw mov r6, #0
146 1.2.6.2 nathanw mov r7, #0
147 1.2.6.2 nathanw mov r8, #0
148 1.2.6.2 nathanw mov ip, #0
149 1.2.6.2 nathanw mov lr, #0
150 1.2.6.2 nathanw
151 1.2.6.3 thorpej 1:
152 1.2.6.2 nathanw stmia r0!, {r3-r8,ip,lr}
153 1.2.6.2 nathanw stmia r0!, {r3-r8,ip,lr}
154 1.2.6.2 nathanw stmia r0!, {r3-r8,ip,lr}
155 1.2.6.2 nathanw stmia r0!, {r3-r8,ip,lr}
156 1.2.6.2 nathanw
157 1.2.6.2 nathanw #ifdef BIG_LOOPS
158 1.2.6.2 nathanw /* There is little point making the loop any larger; unless we are
159 1.2.6.2 nathanw running with the cache off, the load/store overheads will
160 1.2.6.2 nathanw completely dominate this loop. */
161 1.2.6.2 nathanw stmia r0!, {r3-r8,ip,lr}
162 1.2.6.2 nathanw stmia r0!, {r3-r8,ip,lr}
163 1.2.6.2 nathanw stmia r0!, {r3-r8,ip,lr}
164 1.2.6.2 nathanw stmia r0!, {r3-r8,ip,lr}
165 1.2.6.2 nathanw
166 1.2.6.2 nathanw stmia r0!, {r3-r8,ip,lr}
167 1.2.6.2 nathanw stmia r0!, {r3-r8,ip,lr}
168 1.2.6.2 nathanw stmia r0!, {r3-r8,ip,lr}
169 1.2.6.2 nathanw stmia r0!, {r3-r8,ip,lr}
170 1.2.6.2 nathanw
171 1.2.6.2 nathanw stmia r0!, {r3-r8,ip,lr}
172 1.2.6.2 nathanw stmia r0!, {r3-r8,ip,lr}
173 1.2.6.2 nathanw stmia r0!, {r3-r8,ip,lr}
174 1.2.6.2 nathanw stmia r0!, {r3-r8,ip,lr}
175 1.2.6.2 nathanw
176 1.2.6.2 nathanw #endif
177 1.2.6.2 nathanw
178 1.2.6.2 nathanw subs r2, r2, #1
179 1.2.6.3 thorpej bne 1b
180 1.2.6.2 nathanw
181 1.2.6.2 nathanw ldmfd sp!, {r4-r8, pc}
182