2 * Copyright (c) 2009 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 * This file implements the following functions for the Cortex-A9 processor:
25 * void bzero(void * destination,
28 * void __bzero(void * destination,
31 * zeros out a buffer length bytes long, beginning at the address destination.
33 * void *memset(void * destination,
37 * writes value converted to an unsigned char to n successive bytes, beginning
42 #if defined _ARM_ARCH_7
44 /*****************************************************************************
46 *****************************************************************************/
48 #define A9_ENTRY(name) \
50 .globl _ ## name ## $VARIANT$CortexA9;\
51 _ ## name ## $VARIANT$CortexA9:
53 #define ESTABLISH_FRAME \
57 #define CLEAR_FRAME_AND_RETURN \
60 #define ADDITIONAL_CALLEE_SAVE_REGISTERS {r5,r6,r8}
62 #define STORE_REGISTERS {r1,r3,r4,r5,r6,r8,r9,ip}
64 /*****************************************************************************
66 *****************************************************************************/
78 // Early out if fewer than four bytes are to be set. Otherwise, store up to
79 // three bytes to align the destination pointer to a word boundary.
83 orr r1, r1, r1, lsl #8
84 blo L_lengthLessThanFour
85 orr r1, r1, r1, lsl #16
97 1: CLEAR_FRAME_AND_RETURN
100 // Destination pointer has word alignment. Early out if fewer than 64 bytes
101 // are to be set. Otherwise, store up to 28 bytes to align the destination
102 // pointer to a cacheline boundary.
107 blo L_lengthLessThanSixtyFour
109 beq L_cachelineAligned
113 L_lengthLessThanSixtyFour:
116 0: stm r0!, {r1,r3,r4,r9}
128 2: CLEAR_FRAME_AND_RETURN
131 // Main unrolled loop; stores two complete cachelines per iteration.
132 push ADDITIONAL_CALLEE_SAVE_REGISTERS
138 0: stm r0!, STORE_REGISTERS
140 stm r0!, STORE_REGISTERS
142 pop ADDITIONAL_CALLEE_SAVE_REGISTERS
143 b L_lengthLessThanSixtyFour
145 #endif // defined _ARM_ARCH_7