relayd: move the interface fixup to the right place
[openwrt/staging/lynxis/omap.git] / target / linux / coldfire / files-2.6.31 / arch / m68k / include / asm / cf_entry.h
1 #ifndef __CF_M68K_ENTRY_H
2 #define __CF_M68K_ENTRY_H
3
4 #include <asm/setup.h>
5 #include <asm/page.h>
6 #include <asm/coldfire.h>
7 #include <asm/cfmmu.h>
8 #include <asm/asm-offsets.h>
9
10 /*
11 * Stack layout in 'ret_from_exception':
12 *
13 * This allows access to the syscall arguments in registers d1-d5
14 *
15 * 0(sp) - d1
16 * 4(sp) - d2
17 * 8(sp) - d3
18 * C(sp) - d4
19 * 10(sp) - d5
20 * 14(sp) - a0
21 * 18(sp) - a1
22 * 1C(sp) - a2
23 * 20(sp) - d0
24 * 24(sp) - orig_d0
25 * 28(sp) - stack adjustment
26 * 2C(sp) - sr
27 * 2E(sp) - pc
28 * 32(sp) - format & vector
29 * 36(sp) - MMUSR
30 * 3A(sp) - MMUAR
31 */
32
33 /*
34 * 97/05/14 Andreas: Register %a2 is now set to the current task throughout
35 * the whole kernel.
36 */
37
38 /* the following macro is used when enabling interrupts */
39 /* portable version */
40 #define ALLOWINT (~0x700)
41 #define MAX_NOINT_IPL 0
42
43 #ifdef __ASSEMBLY__
44
45 #define curptr a2
46
47 LFLUSH_I_AND_D = 0x00000808
48 LSIGTRAP = 5
49
50 /* process bits for task_struct.ptrace */
51 PT_TRACESYS_OFF = 3
52 PT_TRACESYS_BIT = 1
53 PT_PTRACED_OFF = 3
54 PT_PTRACED_BIT = 0
55 PT_DTRACE_OFF = 3
56 PT_DTRACE_BIT = 2
57
58 #define SAVE_ALL_INT save_all_int
59 #define SAVE_ALL_SYS save_all_sys
60 #define RESTORE_ALL restore_all
61 /*
62 * This defines the normal kernel pt-regs layout.
63 *
64 * regs a3-a6 and d6-d7 are preserved by C code
65 * the kernel doesn't mess with usp unless it needs to
66 */
67
68 /*
69 * a -1 in the orig_d0 field signifies
70 * that the stack frame is NOT for syscall
71 */
72 .macro save_all_int
73 movel MMUSR,%sp@-
74 movel MMUAR,%sp@-
75 clrl %sp@- | stk_adj
76 pea -1:w | orig d0
77 movel %d0,%sp@- | d0
78 subal #(8*4), %sp
79 moveml %d1-%d5/%a0-%a1/%curptr,%sp@
80 .endm
81
82 .macro save_all_sys
83 movel MMUSR,%sp@-
84 movel MMUAR,%sp@-
85 clrl %sp@- | stk_adj
86 movel %d0,%sp@- | orig d0
87 movel %d0,%sp@- | d0
88 subal #(8*4), %sp
89 moveml %d1-%d5/%a0-%a1/%curptr,%sp@
90 .endm
91
92 .macro restore_all
93 moveml %sp@,%a0-%a1/%curptr/%d1-%d5
94 addal #(8*4), %sp
95 movel %sp@+,%d0 | d0
96 addql #4,%sp | orig d0
97 addl %sp@+,%sp | stk_adj
98 addql #8,%sp | MMUAR & MMUSR
99 rte
100 .endm
101
102 #define SWITCH_STACK_SIZE (6*4+4) /* includes return address */
103
104 #define SAVE_SWITCH_STACK save_switch_stack
105 #define RESTORE_SWITCH_STACK restore_switch_stack
106 #define GET_CURRENT(tmp) get_current tmp
107
108 .macro save_switch_stack
109 subal #(6*4), %sp
110 moveml %a3-%a6/%d6-%d7,%sp@
111 .endm
112
113 .macro restore_switch_stack
114 moveml %sp@,%a3-%a6/%d6-%d7
115 addal #(6*4), %sp
116 .endm
117
118 .macro get_current reg=%d0
119 movel %sp,\reg
120 andl #-THREAD_SIZE,\reg
121 movel \reg,%curptr
122 movel %curptr@,%curptr
123 .endm
124
125 #else /* C source */
126
127 #define STR(X) STR1(X)
128 #define STR1(X) #X
129
130 #define PT_OFF_ORIG_D0 0x24
131 #define PT_OFF_FORMATVEC 0x32
132 #define PT_OFF_SR 0x2C
133 #define SAVE_ALL_INT \
134 "clrl %%sp@-;" /* stk_adj */ \
135 "pea -1:w;" /* orig d0 = -1 */ \
136 "movel %%d0,%%sp@-;" /* d0 */ \
137 "subal #(8*4),%sp" \
138 "moveml %%d1-%%d5/%%a0-%%a2,%%sp@"
139 #define GET_CURRENT(tmp) \
140 "movel %%sp,"#tmp"\n\t" \
141 "andw #-"STR(THREAD_SIZE)","#tmp"\n\t" \
142 "movel "#tmp",%%a2\n\t"
143
144 #endif
145
146 #endif /* __CF_M68K_ENTRY_H */