2 * Copyright (c) 2003-2006 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
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
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
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.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 #include <machine/cpu_capabilities.h>
35 .globl __commpage_set_timestamp
36 /* extern void _commpage_set_timestamp(uint64_t abstime, uint64_t secs); */
37 __commpage_set_timestamp:
41 mov _commPagePtr32,%ecx
42 sub $ _COMM_PAGE32_BASE_ADDRESS,%ecx
43 mov _commPagePtr64,%edx /* point to 64-bit commpage too */
45 sub $ _COMM_PAGE32_START_ADDRESS,%edx /* because kernel is built 32-bit */
47 cmovz %ecx,%edx /* if no 64-bit commpage, point to 32 with both */
49 movl $0,_COMM_PAGE_TIMEENABLE(%ecx)
50 movl $0,_COMM_PAGE_TIMEENABLE(%edx)
57 mov %eax,_COMM_PAGE_TIMEBASE(%ecx)
58 mov %eax,_COMM_PAGE_TIMEBASE(%edx)
60 mov %eax,_COMM_PAGE_TIMEBASE+4(%ecx)
61 mov %eax,_COMM_PAGE_TIMEBASE+4(%edx)
64 mov %eax,_COMM_PAGE_TIMESTAMP(%ecx)
65 mov %eax,_COMM_PAGE_TIMESTAMP(%edx)
67 mov %eax,_COMM_PAGE_TIMESTAMP+4(%ecx)
68 mov %eax,_COMM_PAGE_TIMESTAMP+4(%edx)
70 movl $1,_COMM_PAGE_TIMEENABLE(%ecx)
71 movl $1,_COMM_PAGE_TIMEENABLE(%edx)
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:
84 mov _commPagePtr32,%ecx
88 sub $(_COMM_PAGE_BASE_ADDRESS),%ecx
89 mov _commPagePtr64,%edx /* point to 64-bit commpage too */
91 sub $ _COMM_PAGE32_START_ADDRESS,%edx /* because kernel is built 32-bit */
93 cmovz %ecx,%edx /* if no 64-bit commpage, point to 32 with both */
96 mov %eax,_COMM_PAGE_NT_TSC_BASE(%ecx)
97 mov %eax,_COMM_PAGE_NT_TSC_BASE(%edx)
99 mov %eax,_COMM_PAGE_NT_TSC_BASE+4(%ecx)
100 mov %eax,_COMM_PAGE_NT_TSC_BASE+4(%edx)
103 mov %eax,_COMM_PAGE_NT_SCALE(%ecx)
104 mov %eax,_COMM_PAGE_NT_SCALE(%edx)
107 mov %eax,_COMM_PAGE_NT_SHIFT(%ecx)
108 mov %eax,_COMM_PAGE_NT_SHIFT(%edx)
111 mov %eax,_COMM_PAGE_NT_NS_BASE(%ecx)
112 mov %eax,_COMM_PAGE_NT_NS_BASE(%edx)
114 mov %eax,_COMM_PAGE_NT_NS_BASE+4(%ecx)
115 mov %eax,_COMM_PAGE_NT_NS_BASE+4(%edx)
120 #define CPN(routine) _commpage_ ## routine
122 /* pointers to the 32-bit commpage routine descriptors */
123 /* WARNING: these must be sorted by commpage address! */
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)
162 /* pointers to the 64-bit commpage routine descriptors */
163 /* WARNING: these must be sorted by commpage address! */
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)