[142] | 1 | /* $Id: spinlock.c 188 2001-09-09 15:31:35Z sandervl $ */
|
---|
| 2 |
|
---|
| 3 | //******************************************************************************
|
---|
| 4 | // OS/2 implementation of Linux spinlock kernel services
|
---|
| 5 | //
|
---|
| 6 | // Copyright 2000 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 | #include "hwaccess.h"
|
---|
| 25 | #include <linux/init.h>
|
---|
| 26 | #include <linux/poll.h>
|
---|
| 27 | #include <asm/uaccess.h>
|
---|
| 28 | #include <asm/hardirq.h>
|
---|
| 29 |
|
---|
[188] | 30 |
|
---|
| 31 | unsigned long __lock(void);
|
---|
| 32 | #pragma aux __lock = \
|
---|
| 33 | "pushfd" \
|
---|
| 34 | "cli" \
|
---|
| 35 | "pop eax" \
|
---|
| 36 | modify exact [eax] \
|
---|
| 37 | value [eax];
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 | void __unlock(unsigned long cpuflags);
|
---|
| 41 | #pragma aux __unlock = \
|
---|
| 42 | "push eax" \
|
---|
| 43 | "popfd" \
|
---|
| 44 | modify exact [] \
|
---|
| 45 | parm [eax];
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 |
|
---|
[142] | 49 | void spin_lock_init(spinlock_t *lock)
|
---|
| 50 | {
|
---|
| 51 | *lock = 0;
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | void spin_lock(spinlock_t *lock)
|
---|
| 55 | {
|
---|
[188] | 56 | *lock = __lock();
|
---|
[142] | 57 | }
|
---|
| 58 |
|
---|
| 59 | void spin_lock_flag(spinlock_t *lock, unsigned long *flag)
|
---|
| 60 | {
|
---|
[188] | 61 | *lock = __lock();
|
---|
[142] | 62 | }
|
---|
| 63 |
|
---|
| 64 | #if 0
|
---|
| 65 | int spin_trylock(spinlock_t *lock)
|
---|
| 66 | {
|
---|
| 67 | return 0;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | void spin_unlock_wait(spinlock_t *lock)
|
---|
| 71 | {
|
---|
| 72 |
|
---|
| 73 | }
|
---|
| 74 | #endif
|
---|
| 75 |
|
---|
| 76 | void spin_unlock(spinlock_t *lock)
|
---|
| 77 | {
|
---|
[188] | 78 | __unlock(*lock);
|
---|
| 79 | }
|
---|
[142] | 80 |
|
---|
[188] | 81 |
|
---|