add port definition for mcf UART driver
[linux-2.6/next.git] / arch / blackfin / lib / memset.S
blob8159136a29ea2e355ee183d189607d232d14aac2
1 /*
2  * File:         arch/blackfin/lib/memset.S
3  * Based on:
4  * Author:
5  *
6  * Created:
7  * Description:
8  *
9  * Modified:
10  *               Copyright 2004-2006 Analog Devices Inc.
11  *
12  * Bugs:         Enter bugs at http://blackfin.uclinux.org/
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, see the file COPYING, or write
26  * to the Free Software Foundation, Inc.,
27  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28  */
30 #include <linux/linkage.h>
32 .align 2
34 #ifdef CONFIG_MEMSET_L1
35 .section .l1.text
36 #else
37 .text
38 #endif
41  * C Library function MEMSET
42  * R0 = address (leave unchanged to form result)
43  * R1 = filler byte
44  * R2 = count
45  * Favours word aligned data.
46  */
48 ENTRY(_memset)
49         P0 = R0 ;              /* P0 = address */
50         P2 = R2 ;              /* P2 = count   */
51         R3 = R0 + R2;          /* end          */
52         CC = R2 <= 7(IU);
53         IF CC JUMP  .Ltoo_small;
54         R1 = R1.B (Z);         /* R1 = fill char */
55         R2 =  3;
56         R2 = R0 & R2;          /* addr bottom two bits */
57         CC =  R2 == 0;             /* AZ set if zero.   */
58         IF !CC JUMP  .Lforce_align ;  /* Jump if addr not aligned. */
60 .Laligned:
61         P1 = P2 >> 2;          /* count = n/4        */
62         R2 = R1 <<  8;         /* create quad filler */
63         R2.L = R2.L + R1.L(NS);
64         R2.H = R2.L + R1.H(NS);
65         P2 = R3;
67         LSETUP (.Lquad_loop , .Lquad_loop) LC0=P1;
68 .Lquad_loop:
69         [P0++] = R2;
71         CC = P0 == P2;
72         IF !CC JUMP .Lbytes_left;
73         RTS;
75 .Lbytes_left:
76         R2 = R3;                /* end point */
77         R3 = P0;                /* current position */
78         R2 = R2 - R3;           /* bytes left */
79         P2 = R2;
81 .Ltoo_small:
82         CC = P2 == 0;           /* Check zero count */
83         IF CC JUMP .Lfinished;    /* Unusual */
85 .Lbytes:
86         LSETUP (.Lbyte_loop , .Lbyte_loop) LC0=P2;
87 .Lbyte_loop:
88         B[P0++] = R1;
90 .Lfinished:
91         RTS;
93 .Lforce_align:
94         CC = BITTST (R0, 0);  /* odd byte */
95         R0 = 4;
96         R0 = R0 - R2;
97         P1 = R0;
98         R0 = P0;                    /* Recover return address */
99         IF !CC JUMP .Lskip1;
100         B[P0++] = R1;
101 .Lskip1:
102         CC = R2 <= 2;          /* 2 bytes */
103         P2 -= P1;              /* reduce count */
104         IF !CC JUMP .Laligned;
105         B[P0++] = R1;
106         B[P0++] = R1;
107         JUMP .Laligned;
109 ENDPROC(_memset)