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