4 #include <linux/config.h> /* get configuration macros */
5 #include <linux/linkage.h>
6 #include <asm/segment.h>
8 extern inline unsigned long rdusp(void) {
11 __asm__
__volatile__("move %/usp,%0" : "=a" (usp
));
15 extern inline void wrusp(unsigned long usp
) {
16 __asm__
__volatile__("move %0,%/usp" : : "a" (usp
));
20 * switch_to(n) should switch tasks to task ptr, first checking that
21 * ptr isn't the current task, in which case it does nothing. This
22 * also clears the TS-flag if the task we switched to has used the
23 * math co-processor latest.
26 * switch_to() saves the extra registers, that are not saved
27 * automatically by SAVE_SWITCH_STACK in resume(), ie. d0-d5 and
28 * a0-a1. Some of these are used by schedule() and its predecessors
29 * and so we might get see unexpected behaviors when a task returns
30 * with unexpected register values.
32 * syscall stores these registers itself and none of them are used
33 * by syscall after the function in the syscall has been called.
35 * Beware that resume now expects *next to be in d1 and the offset of
36 * tss to be in a1. This saves a few instructions as we no longer have
37 * to push them onto the stack and read them back right after.
39 * 02/17/96 - Jes Sorensen (jds@kom.auc.dk)
41 * Changed 96/09/19 by Andreas Schwab
42 * pass prev in a0, next in a1, offset of tss in d1, and whether
43 * the mm structures are shared in d2 (to avoid atc flushing).
45 asmlinkage
void resume(void);
46 #define switch_to(prev,next) { \
47 register void *_prev __asm__ ("a0") = (prev); \
48 register void *_next __asm__ ("a1") = (next); \
49 __asm__ __volatile__("jbsr " SYMBOL_NAME_STR(resume) \
50 : : "a" (_prev), "a" (_next) \
51 : "d0", "d1", "d2", "d3", "d4", "d5", "a0", "a1"); \
54 #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
55 #define tas(ptr) (xchg((ptr),1))
57 struct __xchg_dummy
{ unsigned long a
[100]; };
58 #define __xg(x) ((volatile struct __xchg_dummy *)(x))
60 #if defined(MACH_ATARI_ONLY) && !defined(CONFIG_HADES)
61 /* block out HSYNC on the atari */
62 #define __sti() __asm__ __volatile__ ("andiw #0xfbff,%/sr": : : "memory")
63 #else /* portable version */
64 #define __sti() __asm__ __volatile__ ("andiw #0xf8ff,%/sr": : : "memory")
65 #endif /* machine compilation types */
66 #define __cli() __asm__ __volatile__ ("oriw #0x0700,%/sr": : : "memory")
67 #define nop() __asm__ __volatile__ ("nop"::)
68 #define mb() __asm__ __volatile__ ("" : : :"memory")
70 #define __save_flags(x) \
71 __asm__ __volatile__("movew %/sr,%0":"=d" (x) : /* no input */ :"memory")
73 #define __restore_flags(x) \
74 __asm__ __volatile__("movew %0,%/sr": /* no outputs */ :"d" (x) : "memory")
78 #define save_flags(x) __save_flags(x)
79 #define restore_flags(x) __restore_flags(x)
80 #define save_and_cli(flags) do { save_flags(flags); cli(); } while(0)
82 #ifndef CONFIG_RMW_INSNS
83 static inline unsigned long __xchg(unsigned long x
, volatile void * ptr
, int size
)
85 unsigned long tmp
, flags
;
95 : "=&d" (tmp
) : "d" (x
), "m" (*__xg(ptr
)) : "memory");
101 : "=&d" (tmp
) : "d" (x
), "m" (*__xg(ptr
)) : "memory");
107 : "=&d" (tmp
) : "d" (x
), "m" (*__xg(ptr
)) : "memory");
110 restore_flags(flags
);
114 static inline unsigned long __xchg(unsigned long x
, volatile void * ptr
, int size
)
123 : "=&d" (x
) : "d" (x
), "m" (*__xg(ptr
)) : "memory");
131 : "=&d" (x
) : "d" (x
), "m" (*__xg(ptr
)) : "memory");
139 : "=&d" (x
) : "d" (x
), "m" (*__xg(ptr
)) : "memory");
146 #endif /* _M68K_SYSTEM_H */