| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: bzero.S,v 1.9 2011/01/16 02:43:10 matt Exp $ */ | | 1 | /* $NetBSD: bzero.S,v 1.10 2011/01/19 02:47:01 matt Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (C) 2001 Martin J. Laubach <mjl@NetBSD.org> | | 4 | * Copyright (C) 2001 Martin J. Laubach <mjl@NetBSD.org> |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -22,27 +22,27 @@ | | | @@ -22,27 +22,27 @@ |
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | | 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | */ | | 28 | */ |
29 | /*----------------------------------------------------------------------*/ | | 29 | /*----------------------------------------------------------------------*/ |
30 | | | 30 | |
31 | #include <machine/asm.h> | | 31 | #include <machine/asm.h> |
32 | | | 32 | |
33 | | | 33 | |
34 | #if defined(LIBC_SCCS) && !defined(lint) | | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
35 | __RCSID("$NetBSD: bzero.S,v 1.9 2011/01/16 02:43:10 matt Exp $") | | 35 | __RCSID("$NetBSD: bzero.S,v 1.10 2011/01/19 02:47:01 matt Exp $") |
36 | #endif /* LIBC_SCCS && !lint */ | | 36 | #endif /* LIBC_SCCS && !lint */ |
37 | | | 37 | |
38 | #ifdef _KERNEL | | 38 | #ifdef _KERNEL |
39 | #include <assym.h> | | 39 | #include <assym.h> |
40 | #endif | | 40 | #endif |
41 | | | 41 | |
42 | #define USE_STSWX 0 /* don't. slower than trivial copy loop */ | | 42 | #define USE_STSWX 0 /* don't. slower than trivial copy loop */ |
43 | | | 43 | |
44 | /*----------------------------------------------------------------------*/ | | 44 | /*----------------------------------------------------------------------*/ |
45 | /* | | 45 | /* |
46 | void bzero(void *b %r3, size_t len %r4); | | 46 | void bzero(void *b %r3, size_t len %r4); |
47 | void * memset(void *b %r3, int c %r4, size_t len %r5); | | 47 | void * memset(void *b %r3, int c %r4, size_t len %r5); |
48 | */ | | 48 | */ |
| @@ -64,28 +64,28 @@ ENTRY(memset) | | | @@ -64,28 +64,28 @@ ENTRY(memset) |
64 | mr. %r0, %r4 | | 64 | mr. %r0, %r4 |
65 | mr %r8, %r3 | | 65 | mr %r8, %r3 |
66 | beqlr- cr1 /* Nothing to do */ | | 66 | beqlr- cr1 /* Nothing to do */ |
67 | | | 67 | |
68 | rlwimi %r0, %r4, 8, 16, 23 /* word extend fill value */ | | 68 | rlwimi %r0, %r4, 8, 16, 23 /* word extend fill value */ |
69 | rlwimi %r0, %r0, 16, 0, 15 | | 69 | rlwimi %r0, %r0, 16, 0, 15 |
70 | mr %r4, %r5 | | 70 | mr %r4, %r5 |
71 | bne- simple_fill /* =! 0, use trivial fill */ | | 71 | bne- simple_fill /* =! 0, use trivial fill */ |
72 | cb_memset: | | 72 | cb_memset: |
73 | | | 73 | |
74 | /*----------------------------------------------------------------------*/ | | 74 | /*----------------------------------------------------------------------*/ |
75 | #ifndef _KERNEL | | 75 | #ifndef _KERNEL |
76 | /* First find out cache line size */ | | 76 | /* First find out cache line size */ |
77 | #ifdef PIC | | | |
78 | mflr %r9 | | 77 | mflr %r9 |
| | | 78 | #ifdef PIC |
79 | PIC_GOTSETUP(%r10) | | 79 | PIC_GOTSETUP(%r10) |
80 | mtlr %r9 | | 80 | mtlr %r9 |
81 | lwz %r5,cache_info@got(%r10) | | 81 | lwz %r5,cache_info@got(%r10) |
82 | #else | | 82 | #else |
83 | lis %r5,cache_info@h | | 83 | lis %r5,cache_info@h |
84 | ori %r5,%r5,cache_info@l | | 84 | ori %r5,%r5,cache_info@l |
85 | #endif | | 85 | #endif |
86 | lwz %r6, 4(%r5) | | 86 | lwz %r6, 4(%r5) |
87 | cmpwi %r6, -1 | | 87 | cmpwi %r6, -1 |
88 | bne+ cb_cacheline_known | | 88 | bne+ cb_cacheline_known |
89 | | | 89 | |
90 | /*----------------------------------------------------------------------*/ | | 90 | /*----------------------------------------------------------------------*/ |
91 | #define CTL_MACHDEP 7 | | 91 | #define CTL_MACHDEP 7 |
| @@ -147,44 +147,47 @@ cb_memset: | | | @@ -147,44 +147,47 @@ cb_memset: |
147 | stw %r0, MIB+4(%r1) | | 147 | stw %r0, MIB+4(%r1) |
148 | | | 148 | |
149 | li %r0, 4 /* Oldlenp := 4 */ | | 149 | li %r0, 4 /* Oldlenp := 4 */ |
150 | stw %r0, OLDPLEN(%r1) | | 150 | stw %r0, OLDPLEN(%r1) |
151 | | | 151 | |
152 | addi %r3, %r1, MIB | | 152 | addi %r3, %r1, MIB |
153 | li %r4, 2 /* namelen */ | | 153 | li %r4, 2 /* namelen */ |
154 | addi %r5, %r31, 4 | | 154 | addi %r5, %r31, 4 |
155 | addi %r6, %r1, OLDPLEN | | 155 | addi %r6, %r1, OLDPLEN |
156 | li %r7, 0 | | 156 | li %r7, 0 |
157 | li %r8, 0 | | 157 | li %r8, 0 |
158 | bl PIC_PLT(_C_LABEL(sysctl)) | | 158 | bl PIC_PLT(_C_LABEL(sysctl)) |
159 | 1: | | 159 | 1: |
160 | lwz %r8, R8_SAVE(%r1) | | | |
161 | lwz %r3, R3_SAVE(%r1) | | 160 | lwz %r3, R3_SAVE(%r1) |
162 | lwz %r4, R4_SAVE(%r1) | | 161 | lwz %r4, R4_SAVE(%r1) |
| | | 162 | lwz %r8, R8_SAVE(%r1) |
163 | lwz %r0, R0_SAVE(%r1) | | 163 | lwz %r0, R0_SAVE(%r1) |
164 | lwz %r9, 4(%r31) | | 164 | lwz %r9, 4(%r31) |
165 | lwz %r31, R31_SAVE(%r1) | | 165 | lwz %r31, R31_SAVE(%r1) |
166 | #ifdef PIC | | 166 | #ifdef PIC |
167 | lwz %r30, R30_SAVE(%r1) | | 167 | lwz %r30, R30_SAVE(%r1) |
168 | #endif | | 168 | #endif |
169 | la %r1, STKFRAME_SZ(%r1) | | 169 | addi %r1, %r1, STKFRAME_SZ |
170 | lwz %r5, 4(%r1) | | 170 | lwz %r0, 4(%r1) |
171 | mtlr %r5 | | 171 | mtlr %r0 |
172 | | | 172 | |
173 | cntlzw %r6, %r9 /* compute shift value */ | | 173 | cntlzw %r6, %r9 /* compute shift value */ |
174 | li %r5, 31 | | 174 | li %r5, 31 |
175 | subf %r5, %r6, %r5 | | 175 | subf %r5, %r6, %r5 |
176 | | | 176 | |
177 | #ifdef PIC | | 177 | #ifdef PIC |
| | | 178 | mflr %r9 |
| | | 179 | PIC_GOTSETUP(%r10) |
| | | 180 | mtlr %r9 |
178 | lwz %r6, cache_sh@got(%r10) | | 181 | lwz %r6, cache_sh@got(%r10) |
179 | stw %r5, 0(%r6) | | 182 | stw %r5, 0(%r6) |
180 | #else | | 183 | #else |
181 | lis %r6, cache_sh@ha | | 184 | lis %r6, cache_sh@ha |
182 | stw %r5, cache_sh@l(%r6) | | 185 | stw %r5, cache_sh@l(%r6) |
183 | #endif | | 186 | #endif |
184 | /*----------------------------------------------------------------------*/ | | 187 | /*----------------------------------------------------------------------*/ |
185 | /* Okay, we know the cache line size (%r9) and shift value (%r10) */ | | 188 | /* Okay, we know the cache line size (%r9) and shift value (%r10) */ |
186 | cb_cacheline_known: | | 189 | cb_cacheline_known: |
187 | #ifdef PIC | | 190 | #ifdef PIC |
188 | lwz %r5, cache_info@got(%r10) | | 191 | lwz %r5, cache_info@got(%r10) |
189 | lwz %r9, 4(%r5) | | 192 | lwz %r9, 4(%r5) |
190 | lwz %r5, cache_sh@got(%r10) | | 193 | lwz %r5, cache_sh@got(%r10) |