1dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project/*
2dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * Copyright (C) 2006 The Android Open Source Project
3dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *
4dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
5dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * you may not use this file except in compliance with the License.
6dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * You may obtain a copy of the License at
7dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *
8dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
9dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *
10dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * Unless required by applicable law or agreed to in writing, software
11dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
12dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * See the License for the specific language governing permissions and
14dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * limitations under the License.
15dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project */
16dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project/*
17dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *  memset32.S
18dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *
19dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project */
20dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
21dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    .text
22dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    .align
23dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
24dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    .global android_memset32
25dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    .type   android_memset32, %function
26dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    .global android_memset16
27dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    .type   android_memset16, %function
28dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
29dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        /*
30dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project         * Optimized memset32 and memset16 for ARM.
31dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project         *
32dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project         * void android_memset16(uint16_t* dst, uint16_t value, size_t size);
33dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project         * void android_memset32(uint32_t* dst, uint32_t value, size_t size);
34dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project         *
35dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project         */
36dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
37dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectandroid_memset16:
38dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        .fnstart
39dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        cmp         r2, #1
40dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        bxle        lr
41dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
42dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        /* expand the data to 32 bits */
43dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        mov         r1, r1, lsl #16
44dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        orr         r1, r1, r1, lsr #16
45dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
46dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        /* align to 32 bits */
47dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        tst         r0, #2
48dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        strneh      r1, [r0], #2
49dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        subne       r2, r2, #2
50dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        .fnend
51dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
52dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectandroid_memset32:
53dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        .fnstart
54d660d895c1401fa96d65a397d0667664bca60b58Christopher Ferris        .cfi_startproc
55dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        str         lr, [sp, #-4]!
56d660d895c1401fa96d65a397d0667664bca60b58Christopher Ferris        .cfi_def_cfa_offset 4
57d660d895c1401fa96d65a397d0667664bca60b58Christopher Ferris        .cfi_rel_offset lr, 0
58dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
59dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        /* align the destination to a cache-line */
60dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        mov         r12, r1
61dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        mov         lr, r1
62dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        rsb         r3, r0, #0
63dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        ands        r3, r3, #0x1C
64dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        beq         .Laligned32
65dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        cmp         r3, r2
66dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        andhi       r3, r2, #0x1C
67dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        sub         r2, r2, r3
68dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
69dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        /* conditionally writes 0 to 7 words (length in r3) */
70dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        movs        r3, r3, lsl #28
71dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        stmcsia     r0!, {r1, lr}
72dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        stmcsia     r0!, {r1, lr}
73dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        stmmiia     r0!, {r1, lr}
74dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        movs        r3, r3, lsl #2
75dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        strcs       r1, [r0], #4
76dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
77dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project.Laligned32:
78dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        mov         r3, r1
79dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project1:      subs        r2, r2, #32
80dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        stmhsia     r0!, {r1,r3,r12,lr}
81dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        stmhsia     r0!, {r1,r3,r12,lr}
82dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        bhs         1b
83dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        add         r2, r2, #32
84dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
85dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        /* conditionally stores 0 to 30 bytes */
86dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        movs        r2, r2, lsl #28
87dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        stmcsia     r0!, {r1,r3,r12,lr}
88dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        stmmiia     r0!, {r1,lr}
89dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        movs        r2, r2, lsl #2
90dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        strcs       r1, [r0], #4
91dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        strmih      lr, [r0], #2
92dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
93dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        ldr         lr, [sp], #4
94d660d895c1401fa96d65a397d0667664bca60b58Christopher Ferris        .cfi_def_cfa_offset 0
95d660d895c1401fa96d65a397d0667664bca60b58Christopher Ferris        .cfi_restore lr
96dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        bx          lr
97d660d895c1401fa96d65a397d0667664bca60b58Christopher Ferris        .cfi_endproc
98dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project        .fnend
99