source: cmedia/trunk/Lib32/spinlock.c@ 559

Last change on this file since 559 was 354, checked in by stevenhl, 17 years ago

Import untested baseline cmedia sources, work products and binaries
Binaries and work products should be deleted from repository.
once new builds are verified to work.

File size: 2.0 KB
Line 
1/* $Id: spinlock.c,v 1.1 2000/04/23 14:55:38 ktk Exp $ */
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
30
31unsigned long __lock(void);
32#pragma aux __lock = \
33 "pushfd" \
34 "cli" \
35 "pop eax" \
36 modify exact [eax] \
37 value [eax];
38
39
40void __unlock(unsigned long cpuflags);
41#if 0
42 #pragma aux __unlock = \
43 "test eax, 0x200" \
44 "jz nosti" \
45 "sti" \
46 "nosti:" \
47 modify exact [] \
48 parm [eax];
49
50#else
51 #pragma aux __unlock = \
52 "push eax" \
53 "popfd" \
54 modify exact [] \
55 parm [eax];
56
57#endif
58
59
60void spin_lock_init(spinlock_t *lock)
61{
62 *lock = 0;
63}
64
65void spin_lock(spinlock_t *lock)
66{
67 *lock = __lock();
68}
69
70void spin_lock_flag(spinlock_t *lock, unsigned long *flag)
71{
72 *lock = __lock();
73}
74
75#if 0
76int spin_trylock(spinlock_t *lock)
77{
78 return 0;
79}
80
81void spin_unlock_wait(spinlock_t *lock)
82{
83
84}
85#endif
86
87void spin_unlock(spinlock_t *lock)
88{
89 __unlock(*lock);
90}
91
92
Note: See TracBrowser for help on using the repository browser.