]>
git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/ppc/IOSharedLockImp.h
44ae776b11b94e9a74aa192e15aefec36b8e36be
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
32 /* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved.
34 * EventShmemLock.h - Shared memory area locks for use between the
35 * WindowServer and the Event Driver.
38 * 30 Nov 1992 Ben Fathi (benf@next.com)
41 * 29 April 1992 Mike Paquette at NeXT
44 * Multiprocessor locks used within the shared memory area between the
45 * kernel and event system. These must work in both user and kernel mode.
46 * The locks are defined in an include file so they get exported to the local
51 #ifndef _IOKIT_IOSHAREDLOCKIMP_H
52 #define _IOKIT_IOSHAREDLOCKIMP_H
54 #include <architecture/ppc/asm_help.h>
57 #include <mach/ppc/asm.h>
60 .macro DISABLE_PREEMPTION
62 stwu r1
,-(FM_SIZE
)(r1
)
65 stw r0
,(FM_SIZE
+FM_LR_SAVE
)(r1
)
66 bl
EXT(_disable_preemption
)
73 .macro ENABLE_PREEMPTION
75 stwu r1
,-(FM_SIZE
)(r1
)
78 stw r0
,(FM_SIZE
+FM_LR_SAVE
)(r1
)
79 bl
EXT(_enable_preemption
)
92 * Lock the lock pointed to by p. Spin (possibly forever) until
93 * the lock is available. Test and test and set logic used.
100 lwarx a7
,0,a0
// CEMV10
103 lwarx a7
,0,a0
// read the lock
104 cmpwi cr0
,a7
,0 // is it busy?
107 stwcx
. a6
,0,a0
// try to get the lock
108 bne
- 9b
// failed, try again
110 blr
// got it, return
114 li a6
,1 // lock value
115 lwarx a7
,0,a0
// CEMV10
118 lwarx a7
,0,a0
// read the lock
119 cmpwi cr0
,a7
,0 // is it busy?
122 stwcx
. a6
,0,a0
// try to get the lock
123 bne
- 9b
// failed, try again
125 blr
// got it, return
134 * Unlock the lock pointed to by p.
158 * Try to lock p. Return TRUE if successful in obtaining lock.
162 li a6
,1 // lock value
164 lwarx a7
,0,a0
// CEMV10
167 lwarx a7
,0,a0
// read the lock
168 cmpwi cr0
,a7
,0 // is it busy?
169 bne
- 9f
// yes, give up
171 stwcx
. a6
,0,a0
// try to get the lock
172 bne
- 8b
// failed, try again
173 li a0
,1 // return TRUE
178 li a0
,0 // return FALSE
183 li a6
,1 // lock value
185 lwarx a7
,0,a0
// CEMV10
188 lwarx a7
,0,a0
// read the lock
189 cmpwi cr0
,a7
,0 // is it busy?
190 bne
- 9f
// yes, give up
192 stwcx
. a6
,0,a0
// try to get the lock
193 bne
- 8b
// failed, try again
194 li a0
,1 // return TRUE
199 li a0
,0 // return FALSE
203 #endif /* ! _IOKIT_IOSHAREDLOCKIMP_H */