sd-as3525.c: disable wide bus, it corrupts writes
[kugel-rb.git] / firmware / target / arm / memset16-arm.S
blob5c787b1bed5d2dd408fa2b94435aeab8ad030220
1 /***************************************************************************
2  *             __________               __   ___.
3  *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
4  *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
5  *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
6  *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
7  *                     \/            \/     \/    \/            \/
8  * $Id$
9  *
10  * Copyright (C) 2006 by Thom Johansen
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18  * KIND, either express or implied.
19  *
20  ****************************************************************************/
21 #include "config.h"
23     .section    .icode,"ax",%progbits
25     .align      2
27 /*  The following code is based on code from the Linux kernel version 2.6.15.3,
28  *  linux/arch/arm/lib/memset.S
29  *
30  *  Copyright (C) 1995-2000 Russell King
31  */
33         .global     memset16
34         .type       memset16,%function
35 memset16:
36         tst     r0, #2                  @ unaligned?
37         cmpne   r2, #0
38         strneh  r1, [r0], #2            @ store one halfword to align
39         subne   r2, r2, #1
42  * we know that the pointer in r0 is aligned to a word boundary.
43  */
44         orr     r1, r1, r1, lsl #16
45         mov     r3, r1
46         cmp     r2, #8
47         blt     4f
49  * We need an extra register for this loop - save the return address and
50  * use the LR
51  */
52         str     lr, [sp, #-4]!
53         mov     ip, r1
54         mov     lr, r1
56 2:      subs    r2, r2, #32
57         stmgeia r0!, {r1, r3, ip, lr}   @ 64 bytes at a time.
58         stmgeia r0!, {r1, r3, ip, lr}
59         stmgeia r0!, {r1, r3, ip, lr}
60         stmgeia r0!, {r1, r3, ip, lr}
61         bgt     2b
62         ldrpc   cond=eq                 @ Now <64 bytes to go.
64  * No need to correct the count; we're only testing bits from now on
65  */
66         tst     r2, #16
67         stmneia r0!, {r1, r3, ip, lr}
68         stmneia r0!, {r1, r3, ip, lr}
69         tst     r2, #8
70         stmneia r0!, {r1, r3, ip, lr}
71         ldr     lr, [sp], #4
73 4:      tst     r2, #4
74         stmneia r0!, {r1, r3}
75         tst     r2, #2
76         strne   r1, [r0], #4
78         tst     r2, #1
79         strneh  r1, [r0], #2
80         bx      lr
81 .end:
82         .size   memset16,.end-memset16