]>
Commit | Line | Data |
---|---|---|
5d5c5d0d A |
1 | /* |
2 | * Copyright (c) 2003-2006 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_OSREFERENCE_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 | |
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@ | |
29 | */ | |
30 | ||
31 | #include <machine/cpu_capabilities.h> | |
32 | ||
33 | .text | |
34 | .align 2, 0x90 | |
35 | .globl __commpage_set_timestamp | |
36 | /* extern void _commpage_set_timestamp(uint64_t abstime, uint64_t secs); */ | |
37 | __commpage_set_timestamp: | |
38 | push %ebp | |
39 | mov %esp,%ebp | |
40 | ||
41 | mov _commPagePtr32,%ecx | |
42 | sub $ _COMM_PAGE32_BASE_ADDRESS,%ecx | |
43 | mov _commPagePtr64,%edx /* point to 64-bit commpage too */ | |
44 | mov %edx,%eax | |
45 | sub $ _COMM_PAGE32_START_ADDRESS,%edx /* because kernel is built 32-bit */ | |
46 | test %eax,%eax | |
47 | cmovz %ecx,%edx /* if no 64-bit commpage, point to 32 with both */ | |
48 | ||
49 | movl $0,_COMM_PAGE_TIMEENABLE(%ecx) | |
50 | movl $0,_COMM_PAGE_TIMEENABLE(%edx) | |
51 | ||
52 | mov 8(%ebp),%eax | |
53 | or 12(%ebp),%eax | |
54 | je 1f | |
55 | ||
56 | mov 8(%ebp),%eax | |
57 | mov %eax,_COMM_PAGE_TIMEBASE(%ecx) | |
58 | mov %eax,_COMM_PAGE_TIMEBASE(%edx) | |
59 | mov 12(%ebp),%eax | |
60 | mov %eax,_COMM_PAGE_TIMEBASE+4(%ecx) | |
61 | mov %eax,_COMM_PAGE_TIMEBASE+4(%edx) | |
62 | ||
63 | mov 16(%ebp),%eax | |
64 | mov %eax,_COMM_PAGE_TIMESTAMP(%ecx) | |
65 | mov %eax,_COMM_PAGE_TIMESTAMP(%edx) | |
66 | mov 20(%ebp),%eax | |
67 | mov %eax,_COMM_PAGE_TIMESTAMP+4(%ecx) | |
68 | mov %eax,_COMM_PAGE_TIMESTAMP+4(%edx) | |
69 | ||
70 | movl $1,_COMM_PAGE_TIMEENABLE(%ecx) | |
71 | movl $1,_COMM_PAGE_TIMEENABLE(%edx) | |
72 | 1: | |
73 | pop %ebp | |
74 | ret | |
75 | ||
76 | .text | |
77 | .align 2, 0x90 | |
78 | .globl _commpage_set_nanotime | |
79 | /* extern void commpage_set_nanotime(uint64_t tsc_base, uint64_t ns_base, uint32_t scale, uint32_t shift); */ | |
80 | _commpage_set_nanotime: | |
81 | push %ebp | |
82 | mov %esp,%ebp | |
83 | ||
84 | mov _commPagePtr32,%ecx | |
85 | testl %ecx,%ecx | |
86 | je 1f | |
87 | ||
88 | sub $(_COMM_PAGE_BASE_ADDRESS),%ecx | |
89 | mov _commPagePtr64,%edx /* point to 64-bit commpage too */ | |
90 | mov %edx,%eax | |
91 | sub $ _COMM_PAGE32_START_ADDRESS,%edx /* because kernel is built 32-bit */ | |
92 | test %eax,%eax | |
93 | cmovz %ecx,%edx /* if no 64-bit commpage, point to 32 with both */ | |
94 | ||
95 | mov 8(%ebp),%eax | |
96 | mov %eax,_COMM_PAGE_NT_TSC_BASE(%ecx) | |
97 | mov %eax,_COMM_PAGE_NT_TSC_BASE(%edx) | |
98 | mov 12(%ebp),%eax | |
99 | mov %eax,_COMM_PAGE_NT_TSC_BASE+4(%ecx) | |
100 | mov %eax,_COMM_PAGE_NT_TSC_BASE+4(%edx) | |
101 | ||
102 | mov 24(%ebp),%eax | |
103 | mov %eax,_COMM_PAGE_NT_SCALE(%ecx) | |
104 | mov %eax,_COMM_PAGE_NT_SCALE(%edx) | |
105 | ||
106 | mov 28(%ebp),%eax | |
107 | mov %eax,_COMM_PAGE_NT_SHIFT(%ecx) | |
108 | mov %eax,_COMM_PAGE_NT_SHIFT(%edx) | |
109 | ||
110 | mov 16(%ebp),%eax | |
111 | mov %eax,_COMM_PAGE_NT_NS_BASE(%ecx) | |
112 | mov %eax,_COMM_PAGE_NT_NS_BASE(%edx) | |
113 | mov 20(%ebp),%eax | |
114 | mov %eax,_COMM_PAGE_NT_NS_BASE+4(%ecx) | |
115 | mov %eax,_COMM_PAGE_NT_NS_BASE+4(%edx) | |
116 | 1: | |
117 | pop %ebp | |
118 | ret | |
119 | ||
120 | #define CPN(routine) _commpage_ ## routine | |
121 | ||
122 | /* pointers to the 32-bit commpage routine descriptors */ | |
123 | /* WARNING: these must be sorted by commpage address! */ | |
124 | .const_data | |
125 | .align 2 | |
126 | .globl _commpage_32_routines | |
127 | _commpage_32_routines: | |
128 | .long CPN(compare_and_swap32_mp) | |
129 | .long CPN(compare_and_swap32_up) | |
130 | .long CPN(compare_and_swap64_mp) | |
131 | .long CPN(compare_and_swap64_up) | |
132 | .long CPN(atomic_add32_mp) | |
133 | .long CPN(atomic_add32_up) | |
134 | .long CPN(mach_absolute_time) | |
135 | .long CPN(spin_lock_try_mp) | |
136 | .long CPN(spin_lock_try_up) | |
137 | .long CPN(spin_lock_mp) | |
138 | .long CPN(spin_lock_up) | |
139 | .long CPN(spin_unlock) | |
140 | .long CPN(pthread_getspecific) | |
141 | .long CPN(gettimeofday) | |
142 | .long CPN(sys_flush_dcache) | |
143 | .long CPN(sys_icache_invalidate) | |
144 | .long CPN(pthread_self) | |
145 | // .long CPN(relinquish) | |
146 | .long CPN(bit_test_and_set_mp) | |
147 | .long CPN(bit_test_and_set_up) | |
148 | .long CPN(bit_test_and_clear_mp) | |
149 | .long CPN(bit_test_and_clear_up) | |
150 | .long CPN(bzero_scalar) | |
151 | .long CPN(bzero_sse3) | |
152 | .long CPN(bcopy_scalar) | |
153 | .long CPN(bcopy_sse3) | |
154 | .long CPN(bcopy_sse4) | |
155 | .long CPN(old_nanotime) | |
156 | .long CPN(memset_pattern_sse3) | |
157 | .long CPN(longcopy_sse4) | |
158 | .long CPN(nanotime) | |
159 | .long 0 | |
160 | ||
161 | ||
162 | /* pointers to the 64-bit commpage routine descriptors */ | |
163 | /* WARNING: these must be sorted by commpage address! */ | |
164 | .const_data | |
165 | .align 2 | |
166 | .globl _commpage_64_routines | |
167 | _commpage_64_routines: | |
168 | .long CPN(compare_and_swap32_mp_64) | |
169 | .long CPN(compare_and_swap32_up_64) | |
170 | .long CPN(compare_and_swap64_mp_64) | |
171 | .long CPN(compare_and_swap64_up_64) | |
172 | .long CPN(atomic_add32_mp_64) | |
173 | .long CPN(atomic_add32_up_64) | |
174 | .long CPN(atomic_add64_mp_64) | |
175 | .long CPN(atomic_add64_up_64) | |
176 | .long CPN(mach_absolute_time) | |
177 | .long CPN(spin_lock_try_mp_64) | |
178 | .long CPN(spin_lock_try_up_64) | |
179 | .long CPN(spin_lock_mp_64) | |
180 | .long CPN(spin_lock_up_64) | |
181 | .long CPN(spin_unlock_64) | |
182 | .long CPN(pthread_getspecific_64) | |
183 | .long CPN(gettimeofday_64) | |
184 | .long CPN(sys_flush_dcache_64) | |
185 | .long CPN(sys_icache_invalidate) /* same routine as 32-bit version, just a "ret" */ | |
186 | .long CPN(pthread_self_64) | |
187 | .long CPN(bit_test_and_set_mp_64) | |
188 | .long CPN(bit_test_and_set_up_64) | |
189 | .long CPN(bit_test_and_clear_mp_64) | |
190 | .long CPN(bit_test_and_clear_up_64) | |
191 | .long CPN(bzero_sse3_64) | |
192 | .long CPN(bcopy_sse4_64) | |
193 | .long CPN(old_nanotime_64) | |
194 | .long CPN(memset_pattern_sse3_64) | |
195 | .long CPN(longcopy_sse4_64) | |
196 | .long CPN(nanotime_64) | |
197 | .long 0 | |
198 |