|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights ! 7: * Reserved. This file contains Original Code and/or Modifications of ! 8: * Original Code as defined in and that are subject to the Apple Public ! 9: * Source License Version 1.1 (the "License"). You may not use this file ! 10: * except in compliance with the License. Please obtain a copy of the ! 11: * License at http://www.apple.com/publicsource and read it before using ! 12: * this file. ! 13: * ! 14: * The Original Code and all software distributed under the License are ! 15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 19: * License for the specific language governing rights and limitations ! 20: * under the License. ! 21: * ! 22: * @APPLE_LICENSE_HEADER_END@ ! 23: */ ! 24: ! 25: /* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved. ! 26: * ! 27: * EventShmemLock.h - Shared memory area locks for use between the ! 28: * WindowServer and the Event Driver. ! 29: * ! 30: * HISTORY ! 31: * 30 Nov 1992 Ben Fathi ([email protected]) ! 32: * Ported to m98k. ! 33: * ! 34: * 29 April 1992 Mike Paquette at NeXT ! 35: * Created. ! 36: * ! 37: * Multiprocessor locks used within the shared memory area between the ! 38: * kernel and event system. These must work in both user and kernel mode. ! 39: * The locks are defined in an include file so they get exported to the local ! 40: * include file area. ! 41: */ ! 42: #ifdef KERNEL_PRIVATE ! 43: #import <architecture/ppc/asm_help.h> ! 44: #import <architecture/ppc/pseudo_inst.h> ! 45: ! 46: /* ! 47: * void ! 48: * ev_lock(p) ! 49: * register int *p; ! 50: * ! 51: * Lock the lock pointed to by p. Spin (possibly forever) until ! 52: * the lock is available. Test and test and set logic used. ! 53: */ ! 54: TEXT ! 55: ! 56: LEAF(_ev_lock) ! 57: li a6,1 // lock value ! 58: 9: ! 59: sync ! 60: lwarx a7,0,a0 // read the lock ! 61: cmpwi cr0,a7,0 // is it busy? ! 62: bne- 9b // yes, spin ! 63: sync ! 64: stwcx. a6,0,a0 // try to get the lock ! 65: bne- 9b // failed, try again ! 66: isync ! 67: blr // got it, return ! 68: END(_ev_lock) ! 69: ! 70: /* ! 71: * void ! 72: * spin_unlock(p) ! 73: * int *p; ! 74: * ! 75: * Unlock the lock pointed to by p. ! 76: */ ! 77: ! 78: LEAF(_ev_unlock) ! 79: sync ! 80: li a7,0 ! 81: stw a7,0(a0) ! 82: blr ! 83: END(_ev_unlock) ! 84: ! 85: ! 86: /* ! 87: * ev_try_lock(p) ! 88: * int *p; ! 89: * ! 90: * Try to lock p. Return TRUE if successful in obtaining lock. ! 91: */ ! 92: ! 93: LEAF(_ev_try_lock) ! 94: li a6,1 // lock value ! 95: 8: ! 96: sync ! 97: lwarx a7,0,a0 // read the lock ! 98: cmpwi cr0,a7,0 // is it busy? ! 99: bne- 9f // yes, give up ! 100: sync ! 101: stwcx. a6,0,a0 // try to get the lock ! 102: bne- 8b // failed, try again ! 103: li a0,1 // return TRUE ! 104: isync ! 105: blr ! 106: 9: ! 107: li a0,0 // return FALSE ! 108: blr ! 109: END(_ev_try_lock) ! 110: #endif /* KERNEL_PRIVATE */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.