1/* 2 * Copyright (c) 2015 ARM Ltd 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. 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 * 3. The name of the company may not be used to endorse or promote 14 * products derived from this software without specific prior written 15 * permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED 18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include "arm_asm.h" 30 31 .thumb 32 .syntax unified 33 .global memset 34 .type memset, %function 35 .p2align 1 36memset: 37 .fnstart 38 .cfi_sections .debug_frame 39 .cfi_startproc 40 prologue 4 6 push_ip=HAVE_PAC_LEAF 41 lsls r4, r0, #30 42 beq 10f 43 subs r4, r2, #1 44 cmp r2, #0 45 beq 9f 46 uxtb r5, r1 47 mov r3, r0 48 b 2f 491: 50 subs r2, r4, #1 51 cbz r4, 9f 52 mov r4, r2 532: 54 strb r5, [r3], #1 55 lsls r2, r3, #30 56 bne 1b 573: 58 cmp r4, #3 59 bls 7f 60 uxtb r5, r1 61 orr r5, r5, r5, lsl #8 62 cmp r4, #15 63 orr r5, r5, r5, lsl #16 64 bls 5f 65 mov r6, r4 66 add r2, r3, #16 674: 68 subs r6, r6, #16 69 cmp r6, #15 70 str r5, [r2, #-16] 71 str r5, [r2, #-12] 72 str r5, [r2, #-8] 73 str r5, [r2, #-4] 74 add r2, r2, #16 75 bhi 4b 76 sub r2, r4, #16 77 bic r2, r2, #15 78 and r4, r4, #15 79 adds r2, r2, #16 80 cmp r4, #3 81 add r3, r3, r2 82 bls 7f 835: 84 mov r6, r3 85 mov r2, r4 866: 87 subs r2, r2, #4 88 cmp r2, #3 89 str r5, [r6], #4 90 bhi 6b 91 subs r2, r4, #4 92 bic r2, r2, #3 93 adds r2, r2, #4 94 add r3, r3, r2 95 and r4, r4, #3 967: 97 cbz r4, 9f 98 uxtb r1, r1 99 add r4, r4, r3 1008: 101 strb r1, [r3], #1 102 cmp r3, r4 103 bne 8b 1049: 105 .cfi_remember_state 106 epilogue 4 6 push_ip=HAVE_PAC_LEAF 107 .cfi_restore_state 10810: 109 mov r4, r2 110 mov r3, r0 111 b 3b 112 .cfi_endproc 113 .cantunwind 114 .fnend 115 .size memset, . - memset 116 117#if defined(__linux__) && defined(__ELF__) 118.section .note.GNU-stack,"",%progbits 119#endif 120