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
19 #include <linux/types.h>
20 #include <linux/irqflags.h>
22 #include <asm/barrier.h>
23 #include <asm/cmpxchg.h>
27 /* context switching is now performed out-of-line in switch_to.S */
28 extern struct task_struct *__switch_to(struct task_struct *,
29 struct task_struct *);
30 #define switch_to(prev, next, last) \
32 ((last) = __switch_to((prev), (next))); \
35 #define arch_align_stack(x) (x)
38 * we make sure local_irq_enable() doesn't cause priority inversion
41 /* This function doesn't exist, so you'll get a linker error
42 * if something tries to do an invalid xchg(). */
43 extern void __xchg_called_with_bad_pointer(void);
46 unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
48 unsigned long ret, flags;
53 return __xchg_u8(x, ptr);
55 local_irq_save(flags);
56 ret = *(volatile u8 *)ptr;
57 *(volatile u8 *)ptr = x;
58 local_irq_restore(flags);
60 #endif /* __xchg_u8 */
64 return __xchg_u16(x, ptr);
66 local_irq_save(flags);
67 ret = *(volatile u16 *)ptr;
68 *(volatile u16 *)ptr = x;
69 local_irq_restore(flags);
71 #endif /* __xchg_u16 */
75 return __xchg_u32(x, ptr);
77 local_irq_save(flags);
78 ret = *(volatile u32 *)ptr;
79 *(volatile u32 *)ptr = x;
80 local_irq_restore(flags);
82 #endif /* __xchg_u32 */
87 return __xchg_u64(x, ptr);
89 local_irq_save(flags);
90 ret = *(volatile u64 *)ptr;
91 *(volatile u64 *)ptr = x;
92 local_irq_restore(flags);
94 #endif /* __xchg_u64 */
95 #endif /* CONFIG_64BIT */
98 __xchg_called_with_bad_pointer();
103 #define xchg(ptr, x) \
104 ((__typeof__(*(ptr))) __xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
106 #endif /* !__ASSEMBLY__ */
108 #endif /* __ASM_GENERIC_SYSTEM_H */