2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_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. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #include <sys/appleapiopts.h>
31 #include <machine/cpu_capabilities.h>
32 #include <machine/commpage.h>
35 * WARNING: this code is written for 32-bit mode, and ported by the kernel if necessary
36 * to 64-bit mode for use in the 64-bit commpage. This "port" consists of the following
37 * simple transformations:
38 * - all word compares are changed to doubleword
39 * - all "srwi[.]" opcodes are changed to "srdi[.]"
40 * Nothing else is done. For this to work, the following rules must be
42 * - do not use carry or overflow
43 * - only use record mode if you are sure the results are mode-invariant
44 * for example, all "andi." and almost all "rlwinm." are fine
45 * - do not use "slwi", "slw", or "srw"
46 * An imaginative programmer could break the porting model in other ways, but the above
47 * are the most likely problem areas. It is perhaps surprising how well in practice
48 * this simple method works.
55 /* *********************
56 * * M E M S E T _ 6 4 *
57 * *********************
59 * This is a subroutine called by Libc memset and _memset_pattern for large nonzero
60 * operands (zero operands are funneled into bzero.) This version is for a
61 * hypothetic processor that is 64-bit but not Altivec.
62 * It is not optimized, since it would only be used during bringup.
65 * r4 = count of bytes to store (must be >= 32)
66 * r8 = ptr to the 1st byte to store (16-byte aligned)
67 * r9 = ptr to 16-byte pattern to store (16-byte aligned)
69 * r3 = not changed, since memset returns it
70 * r4 = bytes remaining to store (will be <32)
72 * r8 = ptr to next byte to store (still 16-byte aligned)
73 * r12 = not changed (holds return value for memset)
77 srwi r0,r4,5 // get number of 32-byte chunks (>0)
78 ld r10,0(r9) // load pattern
80 rlwinm r4,r4,0,0x1F // mask down count
81 mtctr r0 // set up loop count
83 // Loop over 32-byte chunks.
95 COMMPAGE_DESCRIPTOR(memset_64,_COMM_PAGE_MEMSET_PATTERN,k64Bit,kHasAltivec, \
96 kCommPageBoth+kPort32to64)