bcopy_page.S revision 1.2 1 /* $NetBSD: bcopy_page.S,v 1.2 2001/08/11 12:44:42 chris 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/param.h>
42 #include <machine/asm.h>
43
44 /* #define BIG_LOOPS */
45
46 /*
47 * bcopy_page(src, dest)
48 *
49 * Optimised copy page routine.
50 *
51 * On entry:
52 * r0 - src address
53 * r1 - dest address
54 *
55 * Requires:
56 * number of bytes per page (NBPG) is a multiple of 512 (BIG_LOOPS), 128
57 * otherwise.
58 */
59
60 ENTRY(bcopy_page)
61 stmfd sp!, {r4-r8, lr}
62 #ifdef BIG_LOOPS
63 mov r2, #(NBPG >> 9)
64 #else
65 mov r2, #(NBPG >> 7)
66 #endif
67
68 Lloopcopy:
69 ldmia r0!, {r3-r8,ip,lr}
70 stmia r1!, {r3-r8,ip,lr}
71 ldmia r0!, {r3-r8,ip,lr}
72 stmia r1!, {r3-r8,ip,lr}
73 ldmia r0!, {r3-r8,ip,lr}
74 stmia r1!, {r3-r8,ip,lr}
75 ldmia r0!, {r3-r8,ip,lr}
76 stmia r1!, {r3-r8,ip,lr}
77
78 #ifdef BIG_LOOPS
79 /* There is little point making the loop any larger; unless we are
80 running with the cache off, the load/store overheads will
81 completely dominate this loop. */
82 ldmia r0!, {r3-r8,ip,lr}
83 stmia r1!, {r3-r8,ip,lr}
84 ldmia r0!, {r3-r8,ip,lr}
85 stmia r1!, {r3-r8,ip,lr}
86 ldmia r0!, {r3-r8,ip,lr}
87 stmia r1!, {r3-r8,ip,lr}
88 ldmia r0!, {r3-r8,ip,lr}
89 stmia r1!, {r3-r8,ip,lr}
90
91 ldmia r0!, {r3-r8,ip,lr}
92 stmia r1!, {r3-r8,ip,lr}
93 ldmia r0!, {r3-r8,ip,lr}
94 stmia r1!, {r3-r8,ip,lr}
95 ldmia r0!, {r3-r8,ip,lr}
96 stmia r1!, {r3-r8,ip,lr}
97 ldmia r0!, {r3-r8,ip,lr}
98 stmia r1!, {r3-r8,ip,lr}
99
100 ldmia r0!, {r3-r8,ip,lr}
101 stmia r1!, {r3-r8,ip,lr}
102 ldmia r0!, {r3-r8,ip,lr}
103 stmia r1!, {r3-r8,ip,lr}
104 ldmia r0!, {r3-r8,ip,lr}
105 stmia r1!, {r3-r8,ip,lr}
106 ldmia r0!, {r3-r8,ip,lr}
107 stmia r1!, {r3-r8,ip,lr}
108 #endif
109 subs r2, r2, #1
110 bne Lloopcopy
111
112 ldmfd sp!, {r4-r8, pc}
113
114 /*
115 * bzero_page(dest)
116 *
117 * Optimised zero page routine.
118 *
119 * On entry:
120 * r0 - dest address
121 *
122 * Requires:
123 * number of bytes per page (NBPG) is a multiple of 512 (BIG_LOOPS), 128
124 * otherwise
125 */
126
127 ENTRY(bzero_page)
128 stmfd sp!, {r4-r8, lr}
129 #ifdef BIG_LOOPS
130 mov r2, #(NBPG >> 9)
131 #else
132 mov r2, #(NBPG >> 7)
133 #endif
134 mov r3, #0
135 mov r4, #0
136 mov r5, #0
137 mov r6, #0
138 mov r7, #0
139 mov r8, #0
140 mov ip, #0
141 mov lr, #0
142
143 Lloopzero:
144 stmia r0!, {r3-r8,ip,lr}
145 stmia r0!, {r3-r8,ip,lr}
146 stmia r0!, {r3-r8,ip,lr}
147 stmia r0!, {r3-r8,ip,lr}
148
149 #ifdef BIG_LOOPS
150 /* There is little point making the loop any larger; unless we are
151 running with the cache off, the load/store overheads will
152 completely dominate this loop. */
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 stmia r0!, {r3-r8,ip,lr}
159 stmia r0!, {r3-r8,ip,lr}
160 stmia r0!, {r3-r8,ip,lr}
161 stmia r0!, {r3-r8,ip,lr}
162
163 stmia r0!, {r3-r8,ip,lr}
164 stmia r0!, {r3-r8,ip,lr}
165 stmia r0!, {r3-r8,ip,lr}
166 stmia r0!, {r3-r8,ip,lr}
167
168 #endif
169
170 subs r2, r2, #1
171 bne Lloopzero
172
173 ldmfd sp!, {r4-r8, pc}
174