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