]>
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>
62 * Lock the lock pointed to by p. Spin (possibly forever) until
63 * the lock is available. Test and test and set logic used.
72 8: lwz a7
,0(a0
) // Get lock word
73 mr
. a7
,a7
// Is it held?
76 9: lwarx a7
,0,a0
// read the lock
77 mr
. a7
,a7
// Is it held?
78 bne
-- 7f
// yes, kill reservation
79 stwcx
. a6
,0,a0
// try to get the lock
80 bne
-- 9b
// failed, try again
84 7: li a7
,-4 // Point to a spot in the red zone
85 stwcx
. a7
,a7
,r1
// Kill reservation
86 b
8b
// Go wait some more...
95 8: lwz a7
,0(a0
) // Get lock word
96 mr
. a7
,a7
// Is it held?
99 9: lwarx a7
,0,a0
// read the lock
100 mr
. a7
,a7
// Is it held?
101 bne
-- 7f
// yes, kill reservation
102 stwcx
. a6
,0,a0
// try to get the lock
103 bne
-- 9b
// failed, try again
105 blr
// got it, return
107 7: li a7
,-4 // Point to a spot in the red zone
108 stwcx
. a7
,a7
,r1
// Kill reservation
109 b
8b
// Go wait some more...
118 * Unlock the lock pointed to by p.
140 * Try to lock p. Return TRUE if successful in obtaining lock.
144 li a6
,1 // lock value
146 lwz a7
,0(a0
) // Get lock word
147 mr
. a7
,a7
// Is it held?
150 9: lwarx a7
,0,a0
// read the lock
151 mr
. a7
,a7
// Is it held?
152 bne
-- 7f
// yes, kill reservation
153 stwcx
. a6
,0,a0
// try to get the lock
154 bne
-- 9b
// failed, try again
155 li a0
,1 // return TRUE
157 blr
// got it, return
159 7: li a7
,-4 // Point to a spot in the red zone
160 stwcx
. a7
,a7
,r1
// Kill reservation
163 li a0
,0 // return FALSE
169 li a6
,1 // lock value
171 lwz a7
,0(a0
) // Get lock word
172 mr
. a7
,a7
// Is it held?
175 9: lwarx a7
,0,a0
// read the lock
176 mr
. a7
,a7
// Is it held?
177 bne
-- 7f
// yes, kill reservation
178 stwcx
. a6
,0,a0
// try to get the lock
179 bne
-- 9b
// failed, try again
180 li a0
,1 // return TRUE
182 blr
// got it, return
184 7: li a7
,-4 // Point to a spot in the red zone
185 stwcx
. a7
,a7
,r1
// Kill reservation
188 li a0
,0 // return FALSE
193 #endif /* ! _IOKIT_IOSHAREDLOCKIMP_H */