2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
24 #include <sys/appleapiopts.h>
26 #include <machine/cpu_capabilities.h>
27 #include <machine/commpage.h>
30 * WARNING: this code is written for 32-bit mode, and ported by the kernel if necessary
31 * to 64-bit mode for use in the 64-bit commpage. This "port" consists of the following
32 * simple transformations:
33 * - all word compares are changed to doubleword
34 * - all "srwi[.]" opcodes are changed to "srdi[.]"
35 * Nothing else is done. For this to work, the following rules must be
37 * - do not use carry or overflow
38 * - only use record mode if you are sure the results are mode-invariant
39 * for example, all "andi." and almost all "rlwinm." are fine
40 * - do not use "slwi", "slw", or "srw"
41 * An imaginative programmer could break the porting model in other ways, but the above
42 * are the most likely problem areas. It is perhaps surprising how well in practice
43 * this simple method works.
50 /* *********************
51 * * M E M S E T _ 6 4 *
52 * *********************
54 * This is a subroutine called by Libc memset and _memset_pattern for large nonzero
55 * operands (zero operands are funneled into bzero.) This version is for a
56 * hypothetic processor that is 64-bit but not Altivec.
57 * It is not optimized, since it would only be used during bringup.
60 * r4 = count of bytes to store (must be >= 32)
61 * r8 = ptr to the 1st byte to store (16-byte aligned)
62 * r9 = ptr to 16-byte pattern to store (16-byte aligned)
64 * r3 = not changed, since memset returns it
65 * r4 = bytes remaining to store (will be <32)
67 * r8 = ptr to next byte to store (still 16-byte aligned)
68 * r12 = not changed (holds return value for memset)
72 srwi r0,r4,5 // get number of 32-byte chunks (>0)
73 ld r10,0(r9) // load pattern
75 rlwinm r4,r4,0,0x1F // mask down count
76 mtctr r0 // set up loop count
78 // Loop over 32-byte chunks.
90 COMMPAGE_DESCRIPTOR(memset_64,_COMM_PAGE_MEMSET_PATTERN,k64Bit,kHasAltivec, \
91 kCommPageBoth+kPort32to64)