]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
2d21ac55 | 2 | * Copyright (c) 2003-2006 Apple Computer, Inc. All rights reserved. |
1c79356b | 3 | * |
2d21ac55 A |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
5 | * | |
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. | |
14 | * | |
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. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
1c79356b | 27 | */ |
55e303ae | 28 | |
1c79356b | 29 | /*- |
55e303ae A |
30 | * Copyright (c) 1990 The Regents of the University of California. |
31 | * All rights reserved. | |
32 | * | |
33 | * This code is derived from locore.s. | |
1c79356b A |
34 | * |
35 | * Redistribution and use in source and binary forms, with or without | |
36 | * modification, are permitted provided that the following conditions | |
55e303ae | 37 | * are met: |
1c79356b A |
38 | * 1. Redistributions of source code must retain the above copyright |
39 | * notice, this list of conditions and the following disclaimer. | |
40 | * 2. Redistributions in binary form must reproduce the above copyright | |
41 | * notice, this list of conditions and the following disclaimer in the | |
42 | * documentation and/or other materials provided with the distribution. | |
43 | * 3. All advertising materials mentioning features or use of this software | |
44 | * must display the following acknowledgement: | |
55e303ae A |
45 | * This product includes software developed by the University of |
46 | * California, Berkeley and its contributors. | |
1c79356b A |
47 | * 4. Neither the name of the University nor the names of its contributors |
48 | * may be used to endorse or promote products derived from this software | |
49 | * without specific prior written permission. | |
50 | * | |
51 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
52 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
53 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
54 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
55 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
56 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
57 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
58 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
59 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
60 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
61 | * SUCH DAMAGE. | |
1c79356b | 62 | */ |
55e303ae | 63 | |
9bccf70c | 64 | #include <sys/appleapiopts.h> |
55e303ae A |
65 | #include <machine/cpu_capabilities.h> |
66 | #include <machine/commpage.h> | |
67 | #include <machine/asm.h> | |
9bccf70c | 68 | |
55e303ae A |
69 | /* |
70 | * (ov)bcopy (src,dst,cnt) | |
71 | * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 | |
72 | */ | |
73 | ||
b0d623f7 | 74 | COMMPAGE_FUNCTION_START(bcopy_scalar, 32, 5) |
0c530ab8 A |
75 | pushl %ebp /* set up a frame for backtraces */ |
76 | movl %esp,%ebp | |
55e303ae A |
77 | pushl %esi |
78 | pushl %edi | |
0c530ab8 A |
79 | movl 8(%ebp),%esi |
80 | movl 12(%ebp),%edi | |
55e303ae A |
81 | jmp 1f |
82 | /* | |
b0d623f7 A |
83 | * These need to be 32 bytes from Lbcopy_scalar |
84 | */ | |
85 | .align 5, 0x90 | |
55e303ae A |
86 | Lmemcpy_scalar: |
87 | Lmemmove_scalar: | |
0c530ab8 A |
88 | pushl %ebp /* set up a frame for backtraces */ |
89 | movl %esp,%ebp | |
55e303ae A |
90 | pushl %esi |
91 | pushl %edi | |
0c530ab8 A |
92 | movl 8(%ebp),%edi |
93 | movl 12(%ebp),%esi | |
55e303ae A |
94 | movl %edi,%eax |
95 | 1: | |
0c530ab8 | 96 | movl 16(%ebp),%ecx |
55e303ae A |
97 | movl %edi,%edx |
98 | subl %esi,%edx | |
99 | cmpl %ecx,%edx /* overlapping? */ | |
100 | jb 2f | |
101 | cld /* nope, copy forwards. */ | |
102 | movl %ecx,%edx | |
103 | shrl $2,%ecx /* copy by words */ | |
104 | rep | |
105 | movsl | |
106 | movl %edx,%ecx | |
107 | andl $3,%ecx /* any bytes left? */ | |
108 | rep | |
109 | movsb | |
110 | popl %edi | |
111 | popl %esi | |
0c530ab8 | 112 | popl %ebp |
55e303ae A |
113 | ret |
114 | 2: | |
115 | addl %ecx,%edi /* copy backwards. */ | |
116 | addl %ecx,%esi | |
117 | std | |
118 | movl %ecx,%edx | |
119 | andl $3,%ecx /* any fractional bytes? */ | |
120 | decl %edi | |
121 | decl %esi | |
122 | rep | |
123 | movsb | |
124 | movl %edx,%ecx /* copy remainder by words */ | |
125 | shrl $2,%ecx | |
126 | subl $3,%esi | |
127 | subl $3,%edi | |
128 | rep | |
129 | movsl | |
130 | popl %edi | |
131 | popl %esi | |
0c530ab8 | 132 | popl %ebp |
55e303ae A |
133 | cld |
134 | ret | |
1c79356b | 135 | |
b0d623f7 | 136 | COMMPAGE_DESCRIPTOR(bcopy_scalar,_COMM_PAGE_BCOPY,0,kHasSSE2+kHasSupplementalSSE3) |