diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-04-12 23:31:52 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-04-12 23:31:52 -0400 |
commit | 60dd9a5ff55f32cf34041218818307a4c7b5d78a (patch) | |
tree | 900ccf2e81f9136a875720d54dad7e322b66c4dd | |
parent | 05b2ec2ab620b102a2d2fb92dac95ddbc1e09143 (diff) |
Add cli() and sti() wrappers... use with care...
-rw-r--r-- | include/asm_x86.h | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/include/asm_x86.h b/include/asm_x86.h index b5bf166..6636abb 100644 --- a/include/asm_x86.h +++ b/include/asm_x86.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* Intel ia32 assembly. | 1 | /* Intel ia32 assembly. |
2 | * Don't include directly, use asm.h instead. | 2 | * Don't include directly, use asm.h instead. |
3 | * | 3 | * |
4 | * Most of this code comes straight out of the Linux kernel. | 4 | * Most of this code comes straight out of the Linux kernel. |
@@ -16,6 +16,16 @@ static __inline__ void cpu_relax(void) | |||
16 | __asm__ __volatile("pause"); | 16 | __asm__ __volatile("pause"); |
17 | } | 17 | } |
18 | 18 | ||
19 | /* please, use these only if you _really_ know what you're doing | ||
20 | * ... and remember iopl(3) first!! (include sys/io.h) | ||
21 | */ | ||
22 | static inline void cli(void) { | ||
23 | asm volatile("cli": : :"memory"); | ||
24 | } | ||
25 | |||
26 | static inline void sti(void) { | ||
27 | asm volatile("sti": : :"memory"); | ||
28 | } | ||
19 | 29 | ||
20 | #ifdef __i386__ | 30 | #ifdef __i386__ |
21 | 31 | ||
@@ -26,18 +36,18 @@ typedef struct { int counter; } atomic_t; | |||
26 | /** | 36 | /** |
27 | * atomic_read - read atomic variable | 37 | * atomic_read - read atomic variable |
28 | * @v: pointer of type atomic_t | 38 | * @v: pointer of type atomic_t |
29 | * | 39 | * |
30 | * Atomically reads the value of @v. | 40 | * Atomically reads the value of @v. |
31 | */ | 41 | */ |
32 | #define atomic_read(v) ((v)->counter) | 42 | #define atomic_read(v) ((v)->counter) |
33 | 43 | ||
34 | /** | 44 | /** |
35 | * atomic_set - set atomic variable | 45 | * atomic_set - set atomic variable |
36 | * @v: pointer of type atomic_t | 46 | * @v: pointer of type atomic_t |
37 | * @i: required value | 47 | * @i: required value |
38 | * | 48 | * |
39 | * Atomically sets the value of @v to @i. | 49 | * Atomically sets the value of @v to @i. |
40 | */ | 50 | */ |
41 | #define atomic_set(v,i) (((v)->counter) = (i)) | 51 | #define atomic_set(v,i) (((v)->counter) = (i)) |
42 | 52 | ||
43 | static __inline__ void atomic_add(int i, atomic_t *v) | 53 | static __inline__ void atomic_add(int i, atomic_t *v) |
@@ -65,7 +75,7 @@ static __inline__ int atomic_add_return(int i, atomic_t *v) | |||
65 | : : "memory"); | 75 | : : "memory"); |
66 | return i + __i; | 76 | return i + __i; |
67 | } | 77 | } |
68 | 78 | ||
69 | #define atomic_inc_return(v) (atomic_add_return(1,v)) | 79 | #define atomic_inc_return(v) (atomic_add_return(1,v)) |
70 | 80 | ||
71 | 81 | ||