diff options
Diffstat (limited to 'include/asm-m32r/system.h')
-rw-r--r-- | include/asm-m32r/system.h | 71 |
1 files changed, 23 insertions, 48 deletions
diff --git a/include/asm-m32r/system.h b/include/asm-m32r/system.h index d6a2c613be68..e55013f378e5 100644 --- a/include/asm-m32r/system.h +++ b/include/asm-m32r/system.h | |||
@@ -6,8 +6,8 @@ | |||
6 | * License. See the file "COPYING" in the main directory of this archive | 6 | * License. See the file "COPYING" in the main directory of this archive |
7 | * for more details. | 7 | * for more details. |
8 | * | 8 | * |
9 | * Copyright (C) 2001 by Hiroyuki Kondo, Hirokazu Takata, and Hitoshi Yamamoto | 9 | * Copyright (C) 2001 Hiroyuki Kondo, Hirokazu Takata, and Hitoshi Yamamoto |
10 | * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org> | 10 | * Copyright (C) 2004, 2006 Hirokazu Takata <takata at linux-m32r.org> |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/config.h> | 13 | #include <linux/config.h> |
@@ -19,53 +19,28 @@ | |||
19 | * switch_to(prev, next) should switch from task `prev' to `next' | 19 | * switch_to(prev, next) should switch from task `prev' to `next' |
20 | * `prev' will never be the same as `next'. | 20 | * `prev' will never be the same as `next'. |
21 | * | 21 | * |
22 | * `next' and `prev' should be struct task_struct, but it isn't always defined | 22 | * `next' and `prev' should be task_t, but it isn't always defined |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #ifndef CONFIG_SMP | ||
26 | #define prepare_to_switch() do { } while(0) | ||
27 | #endif /* not CONFIG_SMP */ | ||
28 | |||
29 | #define switch_to(prev, next, last) do { \ | 25 | #define switch_to(prev, next, last) do { \ |
30 | register unsigned long arg0 __asm__ ("r0") = (unsigned long)prev; \ | ||
31 | register unsigned long arg1 __asm__ ("r1") = (unsigned long)next; \ | ||
32 | register unsigned long *oldsp __asm__ ("r2") = &(prev->thread.sp); \ | ||
33 | register unsigned long *newsp __asm__ ("r3") = &(next->thread.sp); \ | ||
34 | register unsigned long *oldlr __asm__ ("r4") = &(prev->thread.lr); \ | ||
35 | register unsigned long *newlr __asm__ ("r5") = &(next->thread.lr); \ | ||
36 | register struct task_struct *__last __asm__ ("r6"); \ | ||
37 | __asm__ __volatile__ ( \ | 26 | __asm__ __volatile__ ( \ |
38 | "st r8, @-r15 \n\t" \ | 27 | " seth lr, #high(1f) \n" \ |
39 | "st r9, @-r15 \n\t" \ | 28 | " or3 lr, lr, #low(1f) \n" \ |
40 | "st r10, @-r15 \n\t" \ | 29 | " st lr, @%4 ; store old LR \n" \ |
41 | "st r11, @-r15 \n\t" \ | 30 | " ld lr, @%5 ; load new LR \n" \ |
42 | "st r12, @-r15 \n\t" \ | 31 | " st sp, @%2 ; store old SP \n" \ |
43 | "st r13, @-r15 \n\t" \ | 32 | " ld sp, @%3 ; load new SP \n" \ |
44 | "st r14, @-r15 \n\t" \ | 33 | " push %1 ; store `prev' on new stack \n" \ |
45 | "seth r14, #high(1f) \n\t" \ | 34 | " jmp lr \n" \ |
46 | "or3 r14, r14, #low(1f) \n\t" \ | 35 | " .fillinsn \n" \ |
47 | "st r14, @r4 ; store old LR \n\t" \ | 36 | "1: \n" \ |
48 | "st r15, @r2 ; store old SP \n\t" \ | 37 | " pop %0 ; restore `__last' from new stack \n" \ |
49 | "ld r15, @r3 ; load new SP \n\t" \ | 38 | : "=r" (last) \ |
50 | "st r0, @-r15 ; store 'prev' onto new stack \n\t" \ | 39 | : "0" (prev), \ |
51 | "ld r14, @r5 ; load new LR \n\t" \ | 40 | "r" (&(prev->thread.sp)), "r" (&(next->thread.sp)), \ |
52 | "jmp r14 \n\t" \ | 41 | "r" (&(prev->thread.lr)), "r" (&(next->thread.lr)) \ |
53 | ".fillinsn \n " \ | 42 | : "memory", "lr" \ |
54 | "1: \n\t" \ | ||
55 | "ld r6, @r15+ ; load 'prev' from new stack \n\t" \ | ||
56 | "ld r14, @r15+ \n\t" \ | ||
57 | "ld r13, @r15+ \n\t" \ | ||
58 | "ld r12, @r15+ \n\t" \ | ||
59 | "ld r11, @r15+ \n\t" \ | ||
60 | "ld r10, @r15+ \n\t" \ | ||
61 | "ld r9, @r15+ \n\t" \ | ||
62 | "ld r8, @r15+ \n\t" \ | ||
63 | : "=&r" (__last) \ | ||
64 | : "r" (arg0), "r" (arg1), "r" (oldsp), "r" (newsp), \ | ||
65 | "r" (oldlr), "r" (newlr) \ | ||
66 | : "memory" \ | ||
67 | ); \ | 43 | ); \ |
68 | last = __last; \ | ||
69 | } while(0) | 44 | } while(0) |
70 | 45 | ||
71 | /* | 46 | /* |
@@ -171,8 +146,8 @@ extern void __xchg_called_with_bad_pointer(void); | |||
171 | #define DCACHE_CLEAR(reg0, reg1, addr) | 146 | #define DCACHE_CLEAR(reg0, reg1, addr) |
172 | #endif /* CONFIG_CHIP_M32700_TS1 */ | 147 | #endif /* CONFIG_CHIP_M32700_TS1 */ |
173 | 148 | ||
174 | static __inline__ unsigned long __xchg(unsigned long x, volatile void * ptr, | 149 | static inline unsigned long |
175 | int size) | 150 | __xchg(unsigned long x, volatile void * ptr, int size) |
176 | { | 151 | { |
177 | unsigned long flags; | 152 | unsigned long flags; |
178 | unsigned long tmp = 0; | 153 | unsigned long tmp = 0; |
@@ -224,7 +199,7 @@ static __inline__ unsigned long __xchg(unsigned long x, volatile void * ptr, | |||
224 | 199 | ||
225 | #define __HAVE_ARCH_CMPXCHG 1 | 200 | #define __HAVE_ARCH_CMPXCHG 1 |
226 | 201 | ||
227 | static __inline__ unsigned long | 202 | static inline unsigned long |
228 | __cmpxchg_u32(volatile unsigned int *p, unsigned int old, unsigned int new) | 203 | __cmpxchg_u32(volatile unsigned int *p, unsigned int old, unsigned int new) |
229 | { | 204 | { |
230 | unsigned long flags; | 205 | unsigned long flags; |
@@ -258,7 +233,7 @@ __cmpxchg_u32(volatile unsigned int *p, unsigned int old, unsigned int new) | |||
258 | if something tries to do an invalid cmpxchg(). */ | 233 | if something tries to do an invalid cmpxchg(). */ |
259 | extern void __cmpxchg_called_with_bad_pointer(void); | 234 | extern void __cmpxchg_called_with_bad_pointer(void); |
260 | 235 | ||
261 | static __inline__ unsigned long | 236 | static inline unsigned long |
262 | __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) | 237 | __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) |
263 | { | 238 | { |
264 | switch (size) { | 239 | switch (size) { |