]>
Commit | Line | Data |
---|---|---|
91447636 A |
1 | /* |
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. | |
3 | * | |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
91447636 | 5 | * |
2d21ac55 A |
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. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
91447636 A |
27 | */ |
28 | ||
91447636 A |
29 | #include <sys/appleapiopts.h> |
30 | #include <ppc/asm.h> | |
31 | #include <machine/cpu_capabilities.h> | |
32 | #include <machine/commpage.h> | |
33 | ||
34 | /* | |
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 | |
41 | * carefully followed: | |
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. | |
49 | */ | |
50 | ||
51 | .text | |
52 | .align 2 | |
53 | ||
54 | ||
55 | /* ********************* | |
56 | * * M E M S E T _ 6 4 * | |
57 | * ********************* | |
58 | * | |
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. | |
63 | * | |
64 | * Registers at entry: | |
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) | |
68 | * When we return: | |
69 | * r3 = not changed, since memset returns it | |
70 | * r4 = bytes remaining to store (will be <32) | |
71 | * r7 = not changed | |
72 | * r8 = ptr to next byte to store (still 16-byte aligned) | |
73 | * r12 = not changed (holds return value for memset) | |
74 | */ | |
75 | ||
76 | memset_64: | |
77 | srwi r0,r4,5 // get number of 32-byte chunks (>0) | |
78 | ld r10,0(r9) // load pattern | |
79 | ld r11,8(r9) | |
80 | rlwinm r4,r4,0,0x1F // mask down count | |
81 | mtctr r0 // set up loop count | |
82 | ||
83 | // Loop over 32-byte chunks. | |
84 | 1: | |
85 | std r10,0(r8) | |
86 | std r11,8(r8) | |
87 | std r10,16(r8) | |
88 | std r11,24(r8) | |
89 | addi r8,r8,32 | |
90 | bdnz++ 1b | |
91 | ||
92 | blr | |
93 | ||
94 | ||
95 | COMMPAGE_DESCRIPTOR(memset_64,_COMM_PAGE_MEMSET_PATTERN,k64Bit,kHasAltivec, \ | |
96 | kCommPageBoth+kPort32to64) |