2 * Copyright (c) 2003-2009 Apple, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_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 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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #include <sys/appleapiopts.h>
30 #include <machine/cpu_capabilities.h>
32 #include <mach/i386/syscall_sw.h>
34 PLATFUNC_FUNCTION_START(OSSpinLockTry, up, 64, 4)
35 PLATFUNC_FUNCTION_START(_spin_lock_try, up, 64, 4)
42 PLATFUNC_DESCRIPTOR(OSSpinLockTry,up,kUP,0)
43 PLATFUNC_DESCRIPTOR(_spin_lock_try,up,kUP,0)
46 PLATFUNC_FUNCTION_START_GENERIC(OSSpinLockTry, mp, 64, 4)
47 PLATFUNC_FUNCTION_START_GENERIC(_spin_lock_try, mp, 64, 4)
55 PLATFUNC_DESCRIPTOR(OSSpinLockTry,mp,0,kUP)
56 PLATFUNC_DESCRIPTOR(_spin_lock_try,mp,0,kUP)
59 PLATFUNC_FUNCTION_START(OSSpinLockLock, up, 64, 4)
60 PLATFUNC_FUNCTION_START(_spin_lock, up, 64, 4)
61 PLATFUNC_FUNCTION_START(spin_lock, up, 64, 4)
70 /* failed to get lock so relinquish the processor immediately on UP */
71 xorl %edi,%edi /* THREAD_NULL */
72 movl $1,%esi /* SWITCH_OPTION_DEPRESS */
73 movl $1,%edx /* 1 ms */
74 movl $(SYSCALL_CONSTRUCT_MACH(61)),%eax /* 61 = thread_switch */
77 PLATFUNC_DESCRIPTOR(OSSpinLockLock,up,kUP,0)
78 PLATFUNC_DESCRIPTOR(_spin_lock,up,kUP,0)
79 PLATFUNC_DESCRIPTOR(spin_lock,up,kUP,0)
82 PLATFUNC_FUNCTION_START_GENERIC(OSSpinLockLock, mp, 64, 4)
83 PLATFUNC_FUNCTION_START_GENERIC(_spin_lock, mp, 64, 4)
84 PLATFUNC_FUNCTION_START_GENERIC(spin_lock, mp, 64, 4)
95 movl $(MP_SPIN_TRIES), %edx
96 2: /* spin for awhile before relinquish */
102 /* failed to get lock after spinning so relinquish */
103 xorl %edi,%edi /* THREAD_NULL */
104 movl $1,%esi /* SWITCH_OPTION_DEPRESS */
105 movl $1,%edx /* 1 ms */
106 movl $(SYSCALL_CONSTRUCT_MACH(61)),%eax /* 61 = thread_switch */
109 PLATFUNC_DESCRIPTOR(OSSpinLockLock,mp,0,kUP)
110 PLATFUNC_DESCRIPTOR(_spin_lock,mp,0,kUP)
111 PLATFUNC_DESCRIPTOR(spin_lock,mp,0,kUP)
113 // void OSSpinLockUnlock( OSSpinLock *lock );
115 .globl _OSSpinLockUnlock