diff options
| author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-11-06 16:46:55 -0400 |
|---|---|---|
| committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-11-09 16:35:33 -0500 |
| commit | 1e82ca830c3ad2fd057b4c4fc5243b0622526473 (patch) | |
| tree | facb2c86e48525b28619f3050a635184b6ecbddf | |
| parent | f8585fe1fc6f0830f900dad7c8ccc40e17f79644 (diff) | |
refactor: remove all architecture-dependent code from include/
Move the architecture-dependent code to the arch/ subtree.
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | arch/sparc/include/asm/cycles.h (renamed from arch/sparc64/include/asm/cycles.h) | 0 | ||||
| -rw-r--r-- | arch/sparc64/include/asm/atomic.h (renamed from include/asm_sparc.h) | 19 | ||||
| -rw-r--r-- | arch/x86/include/asm/atomic.h (renamed from include/asm_x86.h) | 20 | ||||
| -rw-r--r-- | arch/x86/include/asm/irq.h | 15 | ||||
| -rw-r--r-- | include/asm.h | 15 | ||||
| -rw-r--r-- | src/kernel_iface.c | 2 |
7 files changed, 33 insertions, 40 deletions
| @@ -149,8 +149,6 @@ obj-runtests = $(patsubst tests/%.c,%.o,${src-runtests}) | |||
| 149 | test_catalog.inc: $(filter-out tests/runner.c,${src-runtests}) | 149 | test_catalog.inc: $(filter-out tests/runner.c,${src-runtests}) |
| 150 | tests/make_catalog.py $+ > $@ | 150 | tests/make_catalog.py $+ > $@ |
| 151 | 151 | ||
| 152 | .SECONDARY: test_catalog.inc | ||
| 153 | |||
| 154 | tests/runner.c: test_catalog.inc | 152 | tests/runner.c: test_catalog.inc |
| 155 | 153 | ||
| 156 | 154 | ||
diff --git a/arch/sparc64/include/asm/cycles.h b/arch/sparc/include/asm/cycles.h index ce0e8ce..ce0e8ce 100644 --- a/arch/sparc64/include/asm/cycles.h +++ b/arch/sparc/include/asm/cycles.h | |||
diff --git a/include/asm_sparc.h b/arch/sparc64/include/asm/atomic.h index 96c8049..cabaa5a 100644 --- a/include/asm_sparc.h +++ b/arch/sparc64/include/asm/atomic.h | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | #ifndef ASM_ATOMIC_H | ||
| 2 | #define ASM_ATOMIC_H | ||
| 3 | |||
| 1 | /* sparc64 assembly. | 4 | /* sparc64 assembly. |
| 2 | * Don't include directly, use asm.h instead. | ||
| 3 | * | 5 | * |
| 4 | * Most of this code comes straight out of the Linux kernel. | 6 | * Most of this code comes straight out of the Linux kernel. |
| 5 | * | 7 | * |
| @@ -46,18 +48,18 @@ typedef struct { int counter; } atomic_t; | |||
| 46 | /** | 48 | /** |
| 47 | * atomic_read - read atomic variable | 49 | * atomic_read - read atomic variable |
| 48 | * @v: pointer of type atomic_t | 50 | * @v: pointer of type atomic_t |
| 49 | * | 51 | * |
| 50 | * Atomically reads the value of @v. | 52 | * Atomically reads the value of @v. |
| 51 | */ | 53 | */ |
| 52 | #define atomic_read(v) ((v)->counter) | 54 | #define atomic_read(v) ((v)->counter) |
| 53 | 55 | ||
| 54 | /** | 56 | /** |
| 55 | * atomic_set - set atomic variable | 57 | * atomic_set - set atomic variable |
| 56 | * @v: pointer of type atomic_t | 58 | * @v: pointer of type atomic_t |
| 57 | * @i: required value | 59 | * @i: required value |
| 58 | * | 60 | * |
| 59 | * Atomically sets the value of @v to @i. | 61 | * Atomically sets the value of @v to @i. |
| 60 | */ | 62 | */ |
| 61 | #define atomic_set(v,i) (((v)->counter) = (i)) | 63 | #define atomic_set(v,i) (((v)->counter) = (i)) |
| 62 | 64 | ||
| 63 | 65 | ||
| @@ -70,18 +72,18 @@ typedef struct { int counter; } atomic_t; | |||
| 70 | */ | 72 | */ |
| 71 | static __inline__ int atomic_add_return(int i, atomic_t *v) | 73 | static __inline__ int atomic_add_return(int i, atomic_t *v) |
| 72 | { | 74 | { |
| 73 | int old; | 75 | int old; |
| 74 | int ret; | 76 | int ret; |
| 75 | goto first; | 77 | goto first; |
| 76 | do { | 78 | do { |
| 77 | cpu_relax(); | 79 | cpu_relax(); |
| 78 | first: | 80 | first: |
| 79 | old = atomic_read(v); | 81 | old = atomic_read(v); |
| 80 | ret = cmpxchg(&v->counter, old, old + i); | 82 | ret = cmpxchg(&v->counter, old, old + i); |
| 81 | } while (ret != old); | 83 | } while (ret != old); |
| 82 | return old + i; | 84 | return old + i; |
| 83 | } | 85 | } |
| 84 | 86 | ||
| 85 | static __inline__ void atomic_add(int i, atomic_t *v) | 87 | static __inline__ void atomic_add(int i, atomic_t *v) |
| 86 | { | 88 | { |
| 87 | atomic_add_return(i, v); | 89 | atomic_add_return(i, v); |
| @@ -90,3 +92,4 @@ static __inline__ void atomic_add(int i, atomic_t *v) | |||
| 90 | #define atomic_inc_return(v) (atomic_add_return(1,v)) | 92 | #define atomic_inc_return(v) (atomic_add_return(1,v)) |
| 91 | 93 | ||
| 92 | 94 | ||
| 95 | #endif | ||
diff --git a/include/asm_x86.h b/arch/x86/include/asm/atomic.h index ccc6cce..4bd1fe2 100644 --- a/include/asm_x86.h +++ b/arch/x86/include/asm/atomic.h | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | /* Intel ia32 assembly. | 1 | #ifndef ASM_ATOMIC_H |
| 2 | * Don't include directly, use asm.h instead. | 2 | #define ASM_ATOMIC_H |
| 3 | * | 3 | |
| 4 | /* | ||
| 4 | * Most of this code comes straight out of the Linux kernel. | 5 | * Most of this code comes straight out of the Linux kernel. |
| 5 | * | 6 | * |
| 6 | * The terms of the GPL v2 apply. | 7 | * The terms of the GPL v2 apply. |
| @@ -16,17 +17,6 @@ static __inline__ void cpu_relax(void) | |||
| 16 | __asm__ __volatile("pause"); | 17 | __asm__ __volatile("pause"); |
| 17 | } | 18 | } |
| 18 | 19 | ||
| 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 | } | ||
| 29 | |||
| 30 | typedef struct { int counter; } atomic_t; | 20 | typedef struct { int counter; } atomic_t; |
| 31 | 21 | ||
| 32 | #ifdef __i386__ | 22 | #ifdef __i386__ |
| @@ -142,3 +132,5 @@ static inline int atomic_add_return(int i, atomic_t *v) | |||
| 142 | #define atomic_inc_return(v) (atomic_add_return(1, v)) | 132 | #define atomic_inc_return(v) (atomic_add_return(1, v)) |
| 143 | 133 | ||
| 144 | #endif | 134 | #endif |
| 135 | |||
| 136 | #endif | ||
diff --git a/arch/x86/include/asm/irq.h b/arch/x86/include/asm/irq.h new file mode 100644 index 0000000..23f47fd --- /dev/null +++ b/arch/x86/include/asm/irq.h | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | #ifndef ASM_IRQ_H | ||
| 2 | #define ASM_IRQ_H | ||
| 3 | |||
| 4 | /* please, use these only if you _really_ know what you're doing | ||
| 5 | * ... and remember iopl(3) first!! (include sys/io.h) | ||
| 6 | */ | ||
| 7 | static inline void cli(void) { | ||
| 8 | asm volatile("cli": : :"memory"); | ||
| 9 | } | ||
| 10 | |||
| 11 | static inline void sti(void) { | ||
| 12 | asm volatile("sti": : :"memory"); | ||
| 13 | } | ||
| 14 | |||
| 15 | #endif | ||
diff --git a/include/asm.h b/include/asm.h deleted file mode 100644 index bc15fae..0000000 --- a/include/asm.h +++ /dev/null | |||
| @@ -1,15 +0,0 @@ | |||
| 1 | /* liblitmus platform dependent includes */ | ||
| 2 | |||
| 3 | #ifndef ASM_H | ||
| 4 | #define ASM_H | ||
| 5 | |||
| 6 | #if defined(__i386__) || defined(__x86_64__) | ||
| 7 | #include "asm_x86.h" | ||
| 8 | #endif | ||
| 9 | |||
| 10 | |||
| 11 | #ifdef __sparc__ | ||
| 12 | #include "asm_sparc.h" | ||
| 13 | #endif | ||
| 14 | |||
| 15 | #endif | ||
diff --git a/src/kernel_iface.c b/src/kernel_iface.c index afb6202..25e0cea 100644 --- a/src/kernel_iface.c +++ b/src/kernel_iface.c | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | #include "litmus.h" | 9 | #include "litmus.h" |
| 10 | #include "internal.h" | 10 | #include "internal.h" |
| 11 | #include "asm.h" | 11 | #include "asm/atomic.h" |
| 12 | 12 | ||
| 13 | #define LITMUS_CTRL_DEVICE "/dev/litmus/ctrl" | 13 | #define LITMUS_CTRL_DEVICE "/dev/litmus/ctrl" |
| 14 | #define CTRL_PAGES 1 | 14 | #define CTRL_PAGES 1 |
