]>
git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/ppc/IOSharedLockImp.h
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
29 /* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved.
31 * EventShmemLock.h - Shared memory area locks for use between the
32 * WindowServer and the Event Driver.
35 * 30 Nov 1992 Ben Fathi (benf@next.com)
38 * 29 April 1992 Mike Paquette at NeXT
41 * Multiprocessor locks used within the shared memory area between the
42 * kernel and event system. These must work in both user and kernel mode.
43 * The locks are defined in an include file so they get exported to the local
48 #ifndef _IOKIT_IOSHAREDLOCKIMP_H
49 #define _IOKIT_IOSHAREDLOCKIMP_H
51 #include <architecture/ppc/asm_help.h>
54 #include <mach/ppc/asm.h>
57 .macro DISABLE_PREEMPTION
59 stwu r1
,-(FM_SIZE
)(r1
)
62 stw r0
,(FM_SIZE
+FM_LR_SAVE
)(r1
)
63 bl
EXT(_disable_preemption
)
70 .macro ENABLE_PREEMPTION
72 stwu r1
,-(FM_SIZE
)(r1
)
75 stw r0
,(FM_SIZE
+FM_LR_SAVE
)(r1
)
76 bl
EXT(_enable_preemption
)
89 * Lock the lock pointed to by p. Spin (possibly forever) until
90 * the lock is available. Test and test and set logic used.
97 lwarx a7
,0,a0
// CEMV10
100 lwarx a7
,0,a0
// read the lock
101 cmpwi cr0
,a7
,0 // is it busy?
104 stwcx
. a6
,0,a0
// try to get the lock
105 bne
- 9b
// failed, try again
107 blr
// got it, return
111 li a6
,1 // lock value
112 lwarx a7
,0,a0
// CEMV10
115 lwarx a7
,0,a0
// read the lock
116 cmpwi cr0
,a7
,0 // is it busy?
119 stwcx
. a6
,0,a0
// try to get the lock
120 bne
- 9b
// failed, try again
122 blr
// got it, return
131 * Unlock the lock pointed to by p.
155 * Try to lock p. Return TRUE if successful in obtaining lock.
159 li a6
,1 // lock value
161 lwarx a7
,0,a0
// CEMV10
164 lwarx a7
,0,a0
// read the lock
165 cmpwi cr0
,a7
,0 // is it busy?
166 bne
- 9f
// yes, give up
168 stwcx
. a6
,0,a0
// try to get the lock
169 bne
- 8b
// failed, try again
170 li a0
,1 // return TRUE
175 li a0
,0 // return FALSE
180 li a6
,1 // lock value
182 lwarx a7
,0,a0
// CEMV10
185 lwarx a7
,0,a0
// read the lock
186 cmpwi cr0
,a7
,0 // is it busy?
187 bne
- 9f
// yes, give up
189 stwcx
. a6
,0,a0
// try to get the lock
190 bne
- 8b
// failed, try again
191 li a0
,1 // return TRUE
196 li a0
,0 // return FALSE
200 #endif /* ! _IOKIT_IOSHAREDLOCKIMP_H */