| 1 | /* $Id: spinlock.c,v 1.1.1.1 2003/07/02 13:57:02 eleph Exp $ */ | 
|---|
| 2 | /* | 
|---|
| 3 | * OS/2 implementation of Linux spinlock kernel services | 
|---|
| 4 | * | 
|---|
| 5 | * (C) 2000-2002 InnoTek Systemberatung GmbH | 
|---|
| 6 | * (C) 2000-2001 Sander van Leeuwen (sandervl@xs4all.nl) | 
|---|
| 7 | * | 
|---|
| 8 | * This program is free software; you can redistribute it and/or | 
|---|
| 9 | * modify it under the terms of the GNU General Public License as | 
|---|
| 10 | * published by the Free Software Foundation; either version 2 of | 
|---|
| 11 | * the License, or (at your option) any later version. | 
|---|
| 12 | * | 
|---|
| 13 | * This program is distributed in the hope that it will be useful, | 
|---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 16 | * GNU General Public License for more details. | 
|---|
| 17 | * | 
|---|
| 18 | * You should have received a copy of the GNU General Public | 
|---|
| 19 | * License along with this program; if not, write to the Free | 
|---|
| 20 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, | 
|---|
| 21 | * USA. | 
|---|
| 22 | * | 
|---|
| 23 | */ | 
|---|
| 24 |  | 
|---|
| 25 | #include "linux.h" | 
|---|
| 26 | #include <linux/init.h> | 
|---|
| 27 | #include <linux/poll.h> | 
|---|
| 28 | #include <asm/uaccess.h> | 
|---|
| 29 | #include <asm/hardirq.h> | 
|---|
| 30 |  | 
|---|
| 31 |  | 
|---|
| 32 | unsigned long __lock(void); | 
|---|
| 33 | #pragma aux __lock =            \ | 
|---|
| 34 | "pushfd"                \ | 
|---|
| 35 | "cli"                   \ | 
|---|
| 36 | "pop eax"               \ | 
|---|
| 37 | modify exact [eax]      \ | 
|---|
| 38 | value [eax]; | 
|---|
| 39 |  | 
|---|
| 40 |  | 
|---|
| 41 | void __unlock(unsigned long cpuflags); | 
|---|
| 42 | #pragma aux __unlock =          \ | 
|---|
| 43 | "push eax"              \ | 
|---|
| 44 | "popfd"                 \ | 
|---|
| 45 | modify exact []         \ | 
|---|
| 46 | parm [eax]; | 
|---|
| 47 |  | 
|---|
| 48 |  | 
|---|
| 49 |  | 
|---|
| 50 | void spin_lock_init(spinlock_t *lock) | 
|---|
| 51 | { | 
|---|
| 52 | *lock = 0; | 
|---|
| 53 | } | 
|---|
| 54 |  | 
|---|
| 55 | void spin_lock(spinlock_t *lock) | 
|---|
| 56 | { | 
|---|
| 57 | *lock = __lock(); | 
|---|
| 58 | } | 
|---|
| 59 |  | 
|---|
| 60 | void spin_lock_flag(spinlock_t *lock, unsigned long *flag) | 
|---|
| 61 | { | 
|---|
| 62 | *lock = __lock(); | 
|---|
| 63 | } | 
|---|
| 64 |  | 
|---|
| 65 | int spin_trylock(spinlock_t *lock) | 
|---|
| 66 | { | 
|---|
| 67 | return 0; | 
|---|
| 68 | } | 
|---|
| 69 |  | 
|---|
| 70 | #if 0 | 
|---|
| 71 | void spin_unlock_wait(spinlock_t *lock) | 
|---|
| 72 | { | 
|---|
| 73 |  | 
|---|
| 74 | } | 
|---|
| 75 | #endif | 
|---|
| 76 |  | 
|---|
| 77 | void spin_unlock(spinlock_t *lock) | 
|---|
| 78 | { | 
|---|
| 79 | __unlock(*lock); | 
|---|
| 80 | } | 
|---|