]> git.karo-electronics.de Git - karo-tx-uboot.git/blob - arch/blackfin/lib/memset.S
ARM: AM43xx: GP-EVM: Correct GPIO used for VTT regulator control
[karo-tx-uboot.git] / arch / blackfin / lib / memset.S
1 /*
2  * File: memset.S
3  *
4  * Copyright 2004-2007 Analog Devices Inc.
5  * Enter bugs at http://blackfin.uclinux.org/
6  *
7  * SPDX-License-Identifier:     GPL-2.0+
8  */
9
10 .align 2
11
12 /*
13  * C Library function MEMSET
14  * R0 = address (leave unchanged to form result)
15  * R1 = filler byte
16  * R2 = count
17  * Favours word aligned data.
18  */
19
20 .globl _memset;
21 .type _memset, STT_FUNC;
22 _memset:
23         P0 = R0 ;              /* P0 = address */
24         P2 = R2 ;              /* P2 = count   */
25         R3 = R0 + R2;          /* end          */
26         CC = R2 <= 7(IU);
27         IF CC JUMP  .Ltoo_small;
28         R1 = R1.B (Z);         /* R1 = fill char */
29         R2 =  3;
30         R2 = R0 & R2;          /* addr bottom two bits */
31         CC =  R2 == 0;             /* AZ set if zero.   */
32         IF !CC JUMP  .Lforce_align ;  /* Jump if addr not aligned. */
33
34 .Laligned:
35         P1 = P2 >> 2;          /* count = n/4        */
36         R2 = R1 <<  8;         /* create quad filler */
37         R2.L = R2.L + R1.L(NS);
38         R2.H = R2.L + R1.H(NS);
39         P2 = R3;
40
41         LSETUP (.Lquad_loop , .Lquad_loop) LC0=P1;
42 .Lquad_loop:
43         [P0++] = R2;
44
45         CC = P0 == P2;
46         IF !CC JUMP .Lbytes_left;
47         RTS;
48
49 .Lbytes_left:
50         R2 = R3;                /* end point */
51         R3 = P0;                /* current position */
52         R2 = R2 - R3;           /* bytes left */
53         P2 = R2;
54
55 .Ltoo_small:
56         CC = P2 == 0;           /* Check zero count */
57         IF CC JUMP .Lfinished;    /* Unusual */
58
59 .Lbytes:
60         LSETUP (.Lbyte_loop , .Lbyte_loop) LC0=P2;
61 .Lbyte_loop:
62         B[P0++] = R1;
63
64 .Lfinished:
65         RTS;
66
67 .Lforce_align:
68         CC = BITTST (R0, 0);  /* odd byte */
69         R0 = 4;
70         R0 = R0 - R2;
71         P1 = R0;
72         R0 = P0;                    /* Recover return address */
73         IF !CC JUMP .Lskip1;
74         B[P0++] = R1;
75 .Lskip1:
76         CC = R2 <= 2;          /* 2 bytes */
77         P2 -= P1;              /* reduce count */
78         IF !CC JUMP .Laligned;
79         B[P0++] = R1;
80         B[P0++] = R1;
81         JUMP .Laligned;
82
83 .size _memset, .-_memset