move new files out from platform support patch
[openwrt/openwrt.git] / target / linux / ubicom32 / files / arch / ubicom32 / include / asm / system.h
1 /*
2 * arch/ubicom32/include/asm/system.h
3 * Low level switching definitions.
4 *
5 * (C) Copyright 2009, Ubicom, Inc.
6 *
7 * This file is part of the Ubicom32 Linux Kernel Port.
8 *
9 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
10 * it and/or modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation, either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
15 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 * the GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with the Ubicom32 Linux Kernel Port. If not,
21 * see <http://www.gnu.org/licenses/>.
22 *
23 * Ubicom32 implementation derived from (with many thanks):
24 * arch/m68knommu
25 * arch/blackfin
26 * arch/parisc
27 */
28 #ifndef _ASM_UBICOM32_SYSTEM_H
29 #define _ASM_UBICOM32_SYSTEM_H
30
31 #include <linux/irqflags.h>
32 #include <linux/linkage.h>
33 #include <asm/segment.h>
34 #include <asm/entry.h>
35 #include <asm/ldsr.h>
36 #include <asm/irq.h>
37 #include <asm/percpu.h>
38 #include <asm/ubicom32-common.h>
39 #include <asm/processor.h>
40
41 /*
42 * switch_to(n) should switch tasks to task ptr, first checking that
43 * ptr isn't the current task, in which case it does nothing.
44 */
45 asmlinkage void resume(void);
46 extern void *__switch_to(struct task_struct *prev,
47 struct thread_struct *prev_switch,
48 struct thread_struct *next_switch);
49
50 /*
51 * We will need a per linux thread sw_ksp for the switch_to macro to
52 * track the kernel stack pointer for the current thread on that linux thread.
53 */
54 #define switch_to(prev,next,last) \
55 ({ \
56 void *_last; \
57 _last = (void *) \
58 __switch_to(prev, &prev->thread, &next->thread); \
59 (last) = _last; \
60 })
61
62 /*
63 * Force strict CPU ordering.
64 * Not really required on ubicom32...
65 */
66 #define nop() asm volatile ("nop"::)
67 #define mb() asm volatile ("" : : :"memory")
68 #define rmb() asm volatile ("" : : :"memory")
69 #define wmb() asm volatile ("" : : :"memory")
70 #define set_mb(var, value) ({ (var) = (value); wmb(); })
71
72 #ifdef CONFIG_SMP
73 #define smp_mb() mb()
74 #define smp_rmb() rmb()
75 #define smp_wmb() wmb()
76 #define smp_read_barrier_depends() read_barrier_depends()
77 #else
78 #define smp_mb() mb()
79 #define smp_rmb() rmb()
80 #define smp_wmb() wmb()
81 #define smp_read_barrier_depends() do { } while(0)
82 #endif
83
84 #define read_barrier_depends() ((void)0)
85
86 /*
87 * The following defines change how the scheduler calls the switch_to()
88 * macro.
89 *
90 * 1) The first causes the runqueue to be unlocked on entry to
91 * switch_to(). Since our ctx code does not play with the runqueue
92 * we do not need it unlocked.
93 *
94 * 2) The later turns interrupts on during a ctxsw to reduce the latency of
95 * interrupts during ctx. At this point in the port, we believe that this
96 * latency is not a problem since we have very little code to perform a ctxsw.
97 */
98 // #define __ARCH_WANT_UNLOCKED_CTXSW
99 // #define __ARCH_WANT_INTERRUPTS_ON_CTXSW
100
101 #endif /* _ASM_UBICOM32_SYSTEM_H */