···22#define __ARCH_M68K_ATOMIC__3344#include <linux/types.h>55-#include <asm/system.h>55+#include <linux/irqflags.h>6677/*88 * Atomic operations that C can't guarantee us. Useful for
+20
arch/m68k/include/asm/barrier.h
···11+#ifndef _M68K_BARRIER_H22+#define _M68K_BARRIER_H33+44+/*55+ * Force strict CPU ordering.66+ * Not really required on m68k...77+ */88+#define nop() do { asm volatile ("nop"); barrier(); } while (0)99+#define mb() barrier()1010+#define rmb() barrier()1111+#define wmb() barrier()1212+#define read_barrier_depends() ((void)0)1313+#define set_mb(var, value) ({ (var) = (value); wmb(); })1414+1515+#define smp_mb() barrier()1616+#define smp_rmb() barrier()1717+#define smp_wmb() barrier()1818+#define smp_read_barrier_depends() ((void)0)1919+2020+#endif /* _M68K_BARRIER_H */
+141
arch/m68k/include/asm/cmpxchg.h
···11+#ifndef __ARCH_M68K_CMPXCHG__22+#define __ARCH_M68K_CMPXCHG__33+44+#include <linux/irqflags.h>55+66+struct __xchg_dummy { unsigned long a[100]; };77+#define __xg(x) ((volatile struct __xchg_dummy *)(x))88+99+extern unsigned long __invalid_xchg_size(unsigned long, volatile void *, int);1010+1111+#ifndef CONFIG_RMW_INSNS1212+static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)1313+{1414+ unsigned long flags, tmp;1515+1616+ local_irq_save(flags);1717+1818+ switch (size) {1919+ case 1:2020+ tmp = *(u8 *)ptr;2121+ *(u8 *)ptr = x;2222+ x = tmp;2323+ break;2424+ case 2:2525+ tmp = *(u16 *)ptr;2626+ *(u16 *)ptr = x;2727+ x = tmp;2828+ break;2929+ case 4:3030+ tmp = *(u32 *)ptr;3131+ *(u32 *)ptr = x;3232+ x = tmp;3333+ break;3434+ default:3535+ tmp = __invalid_xchg_size(x, ptr, size);3636+ break;3737+ }3838+3939+ local_irq_restore(flags);4040+ return x;4141+}4242+#else4343+static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)4444+{4545+ switch (size) {4646+ case 1:4747+ __asm__ __volatile__4848+ ("moveb %2,%0\n\t"4949+ "1:\n\t"5050+ "casb %0,%1,%2\n\t"5151+ "jne 1b"5252+ : "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");5353+ break;5454+ case 2:5555+ __asm__ __volatile__5656+ ("movew %2,%0\n\t"5757+ "1:\n\t"5858+ "casw %0,%1,%2\n\t"5959+ "jne 1b"6060+ : "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");6161+ break;6262+ case 4:6363+ __asm__ __volatile__6464+ ("movel %2,%0\n\t"6565+ "1:\n\t"6666+ "casl %0,%1,%2\n\t"6767+ "jne 1b"6868+ : "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");6969+ break;7070+ default:7171+ x = __invalid_xchg_size(x, ptr, size);7272+ break;7373+ }7474+ return x;7575+}7676+#endif7777+7878+#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))7979+8080+#include <asm-generic/cmpxchg-local.h>8181+8282+#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))8383+8484+extern unsigned long __invalid_cmpxchg_size(volatile void *,8585+ unsigned long, unsigned long, int);8686+8787+/*8888+ * Atomic compare and exchange. Compare OLD with MEM, if identical,8989+ * store NEW in MEM. Return the initial value in MEM. Success is9090+ * indicated by comparing RETURN with OLD.9191+ */9292+#ifdef CONFIG_RMW_INSNS9393+#define __HAVE_ARCH_CMPXCHG 19494+9595+static inline unsigned long __cmpxchg(volatile void *p, unsigned long old,9696+ unsigned long new, int size)9797+{9898+ switch (size) {9999+ case 1:100100+ __asm__ __volatile__ ("casb %0,%2,%1"101101+ : "=d" (old), "=m" (*(char *)p)102102+ : "d" (new), "0" (old), "m" (*(char *)p));103103+ break;104104+ case 2:105105+ __asm__ __volatile__ ("casw %0,%2,%1"106106+ : "=d" (old), "=m" (*(short *)p)107107+ : "d" (new), "0" (old), "m" (*(short *)p));108108+ break;109109+ case 4:110110+ __asm__ __volatile__ ("casl %0,%2,%1"111111+ : "=d" (old), "=m" (*(int *)p)112112+ : "d" (new), "0" (old), "m" (*(int *)p));113113+ break;114114+ default:115115+ old = __invalid_cmpxchg_size(p, old, new, size);116116+ break;117117+ }118118+ return old;119119+}120120+121121+#define cmpxchg(ptr, o, n) \122122+ ((__typeof__(*(ptr)))__cmpxchg((ptr), (unsigned long)(o), \123123+ (unsigned long)(n), sizeof(*(ptr))))124124+#define cmpxchg_local(ptr, o, n) \125125+ ((__typeof__(*(ptr)))__cmpxchg((ptr), (unsigned long)(o), \126126+ (unsigned long)(n), sizeof(*(ptr))))127127+#else128128+129129+/*130130+ * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make131131+ * them available.132132+ */133133+#define cmpxchg_local(ptr, o, n) \134134+ ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\135135+ (unsigned long)(n), sizeof(*(ptr))))136136+137137+#include <asm-generic/cmpxchg.h>138138+139139+#endif140140+141141+#endif /* __ARCH_M68K_CMPXCHG__ */
···11+#ifndef _M68K_SWITCH_TO_H22+#define _M68K_SWITCH_TO_H33+44+/*55+ * switch_to(n) should switch tasks to task ptr, first checking that66+ * ptr isn't the current task, in which case it does nothing. This77+ * also clears the TS-flag if the task we switched to has used the88+ * math co-processor latest.99+ */1010+/*1111+ * switch_to() saves the extra registers, that are not saved1212+ * automatically by SAVE_SWITCH_STACK in resume(), ie. d0-d5 and1313+ * a0-a1. Some of these are used by schedule() and its predecessors1414+ * and so we might get see unexpected behaviors when a task returns1515+ * with unexpected register values.1616+ *1717+ * syscall stores these registers itself and none of them are used1818+ * by syscall after the function in the syscall has been called.1919+ *2020+ * Beware that resume now expects *next to be in d1 and the offset of2121+ * tss to be in a1. This saves a few instructions as we no longer have2222+ * to push them onto the stack and read them back right after.2323+ *2424+ * 02/17/96 - Jes Sorensen (jds@kom.auc.dk)2525+ *2626+ * Changed 96/09/19 by Andreas Schwab2727+ * pass prev in a0, next in a12828+ */2929+asmlinkage void resume(void);3030+#define switch_to(prev,next,last) do { \3131+ register void *_prev __asm__ ("a0") = (prev); \3232+ register void *_next __asm__ ("a1") = (next); \3333+ register void *_last __asm__ ("d1"); \3434+ __asm__ __volatile__("jbsr resume" \3535+ : "=a" (_prev), "=a" (_next), "=d" (_last) \3636+ : "0" (_prev), "1" (_next) \3737+ : "d0", "d2", "d3", "d4", "d5"); \3838+ (last) = _last; \3939+} while (0)4040+4141+#endif /* _M68K_SWITCH_TO_H */
+5-205
arch/m68k/include/asm/system.h
···11-#ifndef _M68K_SYSTEM_H22-#define _M68K_SYSTEM_H33-44-#include <linux/linkage.h>55-#include <linux/kernel.h>66-#include <linux/irqflags.h>77-#include <asm/segment.h>88-#include <asm/entry.h>99-1010-#ifdef __KERNEL__1111-1212-/*1313- * switch_to(n) should switch tasks to task ptr, first checking that1414- * ptr isn't the current task, in which case it does nothing. This1515- * also clears the TS-flag if the task we switched to has used the1616- * math co-processor latest.1717- */1818-/*1919- * switch_to() saves the extra registers, that are not saved2020- * automatically by SAVE_SWITCH_STACK in resume(), ie. d0-d5 and2121- * a0-a1. Some of these are used by schedule() and its predecessors2222- * and so we might get see unexpected behaviors when a task returns2323- * with unexpected register values.2424- *2525- * syscall stores these registers itself and none of them are used2626- * by syscall after the function in the syscall has been called.2727- *2828- * Beware that resume now expects *next to be in d1 and the offset of2929- * tss to be in a1. This saves a few instructions as we no longer have3030- * to push them onto the stack and read them back right after.3131- *3232- * 02/17/96 - Jes Sorensen (jds@kom.auc.dk)3333- *3434- * Changed 96/09/19 by Andreas Schwab3535- * pass prev in a0, next in a13636- */3737-asmlinkage void resume(void);3838-#define switch_to(prev,next,last) do { \3939- register void *_prev __asm__ ("a0") = (prev); \4040- register void *_next __asm__ ("a1") = (next); \4141- register void *_last __asm__ ("d1"); \4242- __asm__ __volatile__("jbsr resume" \4343- : "=a" (_prev), "=a" (_next), "=d" (_last) \4444- : "0" (_prev), "1" (_next) \4545- : "d0", "d2", "d3", "d4", "d5"); \4646- (last) = _last; \4747-} while (0)4848-4949-5050-/*5151- * Force strict CPU ordering.5252- * Not really required on m68k...5353- */5454-#define nop() do { asm volatile ("nop"); barrier(); } while (0)5555-#define mb() barrier()5656-#define rmb() barrier()5757-#define wmb() barrier()5858-#define read_barrier_depends() ((void)0)5959-#define set_mb(var, value) ({ (var) = (value); wmb(); })6060-6161-#define smp_mb() barrier()6262-#define smp_rmb() barrier()6363-#define smp_wmb() barrier()6464-#define smp_read_barrier_depends() ((void)0)6565-6666-#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))6767-6868-struct __xchg_dummy { unsigned long a[100]; };6969-#define __xg(x) ((volatile struct __xchg_dummy *)(x))7070-7171-extern unsigned long __invalid_xchg_size(unsigned long, volatile void *, int);7272-7373-#ifndef CONFIG_RMW_INSNS7474-static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)7575-{7676- unsigned long flags, tmp;7777-7878- local_irq_save(flags);7979-8080- switch (size) {8181- case 1:8282- tmp = *(u8 *)ptr;8383- *(u8 *)ptr = x;8484- x = tmp;8585- break;8686- case 2:8787- tmp = *(u16 *)ptr;8888- *(u16 *)ptr = x;8989- x = tmp;9090- break;9191- case 4:9292- tmp = *(u32 *)ptr;9393- *(u32 *)ptr = x;9494- x = tmp;9595- break;9696- default:9797- tmp = __invalid_xchg_size(x, ptr, size);9898- break;9999- }100100-101101- local_irq_restore(flags);102102- return x;103103-}104104-#else105105-static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)106106-{107107- switch (size) {108108- case 1:109109- __asm__ __volatile__110110- ("moveb %2,%0\n\t"111111- "1:\n\t"112112- "casb %0,%1,%2\n\t"113113- "jne 1b"114114- : "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");115115- break;116116- case 2:117117- __asm__ __volatile__118118- ("movew %2,%0\n\t"119119- "1:\n\t"120120- "casw %0,%1,%2\n\t"121121- "jne 1b"122122- : "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");123123- break;124124- case 4:125125- __asm__ __volatile__126126- ("movel %2,%0\n\t"127127- "1:\n\t"128128- "casl %0,%1,%2\n\t"129129- "jne 1b"130130- : "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");131131- break;132132- default:133133- x = __invalid_xchg_size(x, ptr, size);134134- break;135135- }136136- return x;137137-}138138-#endif139139-140140-#include <asm-generic/cmpxchg-local.h>141141-142142-#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))143143-144144-extern unsigned long __invalid_cmpxchg_size(volatile void *,145145- unsigned long, unsigned long, int);146146-147147-/*148148- * Atomic compare and exchange. Compare OLD with MEM, if identical,149149- * store NEW in MEM. Return the initial value in MEM. Success is150150- * indicated by comparing RETURN with OLD.151151- */152152-#ifdef CONFIG_RMW_INSNS153153-#define __HAVE_ARCH_CMPXCHG 1154154-155155-static inline unsigned long __cmpxchg(volatile void *p, unsigned long old,156156- unsigned long new, int size)157157-{158158- switch (size) {159159- case 1:160160- __asm__ __volatile__ ("casb %0,%2,%1"161161- : "=d" (old), "=m" (*(char *)p)162162- : "d" (new), "0" (old), "m" (*(char *)p));163163- break;164164- case 2:165165- __asm__ __volatile__ ("casw %0,%2,%1"166166- : "=d" (old), "=m" (*(short *)p)167167- : "d" (new), "0" (old), "m" (*(short *)p));168168- break;169169- case 4:170170- __asm__ __volatile__ ("casl %0,%2,%1"171171- : "=d" (old), "=m" (*(int *)p)172172- : "d" (new), "0" (old), "m" (*(int *)p));173173- break;174174- default:175175- old = __invalid_cmpxchg_size(p, old, new, size);176176- break;177177- }178178- return old;179179-}180180-181181-#define cmpxchg(ptr, o, n) \182182- ((__typeof__(*(ptr)))__cmpxchg((ptr), (unsigned long)(o), \183183- (unsigned long)(n), sizeof(*(ptr))))184184-#define cmpxchg_local(ptr, o, n) \185185- ((__typeof__(*(ptr)))__cmpxchg((ptr), (unsigned long)(o), \186186- (unsigned long)(n), sizeof(*(ptr))))187187-#else188188-189189-/*190190- * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make191191- * them available.192192- */193193-#define cmpxchg_local(ptr, o, n) \194194- ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\195195- (unsigned long)(n), sizeof(*(ptr))))196196-197197-#include <asm-generic/cmpxchg.h>198198-199199-#endif200200-201201-#define arch_align_stack(x) (x)202202-203203-#endif /* __KERNEL__ */204204-205205-#endif /* _M68K_SYSTEM_H */11+/* FILE TO BE DELETED. DO NOT ADD STUFF HERE! */22+#include <asm/barrier.h>33+#include <asm/cmpxchg.h>44+#include <asm/exec.h>55+#include <asm/switch_to.h>
···1010#include <linux/sched.h>1111#include <asm/openprom.h>1212#include <asm/oplib.h>1313-#include <asm/system.h>1413#include <linux/string.h>15141615/* Non blocking get character from console input device, returns -1