2 Copyright (c) 2013, Raspberry Pi Foundation
3 Copyright (c) 2013, RISC OS Open Ltd
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of the copyright holder nor the
14 names of its contributors may be used to endorse or promote products
15 derived from this software without specific prior written permission.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <linux/linkage.h>
32 /* Prevent the stack from becoming executable */
33 #if defined(__linux__) && defined(__ELF__)
34 .section .note.GNU-stack,"",%progbits
45 * void *memset(void *s, int c, size_t n);
47 * a1 = pointer to buffer to fill
48 * a2 = byte pattern to fill with (caller-narrowed)
49 * a3 = number of bytes to fill
64 orr DAT0, DAT0, DAT0, lsl #8
65 orr DAT0, DAT0, DAT0, lsl #16
73 /* See if we're guaranteed to have at least one 16-byte aligned 16-byte write */
77 161: sub N, N, #16 /* simplifies inner loop termination */
78 /* Leading words and bytes */
81 rsb DAT3, S, #0 /* bits 0-3 = number of leading bytes until aligned */
82 movs DAT2, DAT3, lsl #31
87 movs DAT2, DAT3, lsl #29
91 stmcsia S!, {DAT0, DAT1}
92 164: /* Delayed set up of DAT2 and DAT3 so we could use them as scratch registers above */
95 /* Now the inner loop of 16-byte stores */
96 165: stmia S!, {DAT0, DAT1, DAT2, DAT3}
99 166: /* Trailing words and bytes */
101 stmcsia S!, {DAT0, DAT1}
108 170: /* Short case */
119 stmneia S!, {DAT0, DAT1, DAT2, DAT3}