1 /* Generic system definitions, based on MN10300 definitions.
3 * It should be possible to use these on really simple architectures,
4 * but it serves more as a starting point for new ports.
6 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
7 * Written by David Howells (dhowells@redhat.com)
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public Licence
11 * as published by the Free Software Foundation; either version
12 * 2 of the Licence, or (at your option) any later version.
14 #ifndef __ASM_GENERIC_SYSTEM_H
15 #define __ASM_GENERIC_SYSTEM_H
20 #include <linux/types.h>
21 #include <linux/irqflags.h>
23 #include <asm/cmpxchg-local.h>
24 #include <asm/cmpxchg.h>
28 /* context switching is now performed out-of-line in switch_to.S */
29 extern struct task_struct *__switch_to(struct task_struct *,
30 struct task_struct *);
31 #define switch_to(prev, next, last) \
33 ((last) = __switch_to((prev), (next))); \
36 #define arch_align_stack(x) (x)
38 #define nop() asm volatile ("nop")
40 #endif /* !__ASSEMBLY__ */
43 * Force strict CPU ordering.
44 * And yes, this is required on UP too when we're talking
47 * This implementation only contains a compiler barrier.
50 #define mb() asm volatile ("": : :"memory")
52 #define wmb() asm volatile ("": : :"memory")
56 #define smp_rmb() rmb()
57 #define smp_wmb() wmb()
59 #define smp_mb() barrier()
60 #define smp_rmb() barrier()
61 #define smp_wmb() barrier()
64 #define set_mb(var, value) do { var = value; mb(); } while (0)
65 #define set_wmb(var, value) do { var = value; wmb(); } while (0)
67 #define read_barrier_depends() do {} while (0)
68 #define smp_read_barrier_depends() do {} while (0)
71 * we make sure local_irq_enable() doesn't cause priority inversion
75 /* This function doesn't exist, so you'll get a linker error
76 * if something tries to do an invalid xchg(). */
77 extern void __xchg_called_with_bad_pointer(void);
80 unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
82 unsigned long ret, flags;
87 return __xchg_u8(x, ptr);
89 local_irq_save(flags);
90 ret = *(volatile u8 *)ptr;
91 *(volatile u8 *)ptr = x;
92 local_irq_restore(flags);
94 #endif /* __xchg_u8 */
98 return __xchg_u16(x, ptr);
100 local_irq_save(flags);
101 ret = *(volatile u16 *)ptr;
102 *(volatile u16 *)ptr = x;
103 local_irq_restore(flags);
105 #endif /* __xchg_u16 */
109 return __xchg_u32(x, ptr);
111 local_irq_save(flags);
112 ret = *(volatile u32 *)ptr;
113 *(volatile u32 *)ptr = x;
114 local_irq_restore(flags);
116 #endif /* __xchg_u32 */
121 return __xchg_u64(x, ptr);
123 local_irq_save(flags);
124 ret = *(volatile u64 *)ptr;
125 *(volatile u64 *)ptr = x;
126 local_irq_restore(flags);
128 #endif /* __xchg_u64 */
129 #endif /* CONFIG_64BIT */
132 __xchg_called_with_bad_pointer();
137 #define xchg(ptr, x) \
138 ((__typeof__(*(ptr))) __xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
140 #endif /* !__ASSEMBLY__ */
142 #endif /* __KERNEL__ */
143 #endif /* __ASM_GENERIC_SYSTEM_H */