1 #ifndef _M68KNOMMU_SYSTEM_H
2 #define _M68KNOMMU_SYSTEM_H
4 #include <linux/linkage.h>
5 #include <linux/irqflags.h>
6 #include <asm/segment.h>
10 * switch_to(n) should switch tasks to task ptr, first checking that
11 * ptr isn't the current task, in which case it does nothing. This
12 * also clears the TS-flag if the task we switched to has used the
13 * math co-processor latest.
16 * switch_to() saves the extra registers, that are not saved
17 * automatically by SAVE_SWITCH_STACK in resume(), ie. d0-d5 and
18 * a0-a1. Some of these are used by schedule() and its predecessors
19 * and so we might get see unexpected behaviors when a task returns
20 * with unexpected register values.
22 * syscall stores these registers itself and none of them are used
23 * by syscall after the function in the syscall has been called.
25 * Beware that resume now expects *next to be in d1 and the offset of
26 * tss to be in a1. This saves a few instructions as we no longer have
27 * to push them onto the stack and read them back right after.
29 * 02/17/96 - Jes Sorensen (jds@kom.auc.dk)
31 * Changed 96/09/19 by Andreas Schwab
32 * pass prev in a0, next in a1, offset of tss in d1, and whether
33 * the mm structures are shared in d2 (to avoid atc flushing).
35 asmlinkage
void resume(void);
36 #define switch_to(prev,next,last) \
39 __asm__ __volatile__( \
40 "movel %1, %%a0\n\t" \
41 "movel %2, %%a1\n\t" \
43 "movel %%d1, %0\n\t" \
45 : "d" (prev), "d" (next) \
46 : "cc", "d0", "d1", "d2", "d3", "d4", "d5", "a0", "a1"); \
50 #define iret() __asm__ __volatile__ ("rte": : :"memory", "sp", "cc")
53 * Force strict CPU ordering.
54 * Not really required on m68k...
56 #define nop() asm volatile ("nop"::)
57 #define mb() asm volatile ("" : : :"memory")
58 #define rmb() asm volatile ("" : : :"memory")
59 #define wmb() asm volatile ("" : : :"memory")
60 #define set_mb(var, value) ({ (var) = (value); wmb(); })
62 #define smp_mb() barrier()
63 #define smp_rmb() barrier()
64 #define smp_wmb() barrier()
65 #define smp_read_barrier_depends() do { } while(0)
67 #define read_barrier_depends() ((void)0)
69 #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
71 struct __xchg_dummy
{ unsigned long a
[100]; };
72 #define __xg(x) ((volatile struct __xchg_dummy *)(x))
74 #ifndef CONFIG_RMW_INSNS
75 static inline unsigned long __xchg(unsigned long x
, volatile void * ptr
, int size
)
77 unsigned long tmp
, flags
;
79 local_irq_save(flags
);
86 : "=&d" (tmp
) : "d" (x
), "m" (*__xg(ptr
)) : "memory");
92 : "=&d" (tmp
) : "d" (x
), "m" (*__xg(ptr
)) : "memory");
98 : "=&d" (tmp
) : "d" (x
), "m" (*__xg(ptr
)) : "memory");
101 local_irq_restore(flags
);
105 static inline unsigned long __xchg(unsigned long x
, volatile void * ptr
, int size
)
114 : "=&d" (x
) : "d" (x
), "m" (*__xg(ptr
)) : "memory");
122 : "=&d" (x
) : "d" (x
), "m" (*__xg(ptr
)) : "memory");
130 : "=&d" (x
) : "d" (x
), "m" (*__xg(ptr
)) : "memory");
137 #include <asm-generic/cmpxchg-local.h>
140 * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
143 #define cmpxchg_local(ptr, o, n) \
144 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
145 (unsigned long)(n), sizeof(*(ptr))))
146 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
148 #include <asm-generic/cmpxchg.h>
150 #define arch_align_stack(x) (x)
153 #endif /* _M68KNOMMU_SYSTEM_H */