Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux...
[pandora-kernel.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 /*
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  */
30
31 /*
32  * 97/05/14 Andreas: Register %a2 is now set to the current task throughout
33  *                   the whole kernel.
34  */
35
36 /* the following macro is used when enabling interrupts */
37 #if defined(MACH_ATARI_ONLY)
38         /* block out HSYNC on the atari */
39 #define ALLOWINT        (~0x400)
40 #define MAX_NOINT_IPL   3
41 #else
42         /* portable version */
43 #define ALLOWINT        (~0x700)
44 #define MAX_NOINT_IPL   0
45 #endif /* machine compilation types */
46
47 #ifdef __ASSEMBLY__
48
49 #define curptr a2
50
51 LFLUSH_I_AND_D = 0x00000808
52
53 /* process bits for task_struct.ptrace */
54 PT_TRACESYS_OFF = 3
55 PT_TRACESYS_BIT = 1
56 PT_PTRACED_OFF = 3
57 PT_PTRACED_BIT = 0
58 PT_DTRACE_OFF = 3
59 PT_DTRACE_BIT = 2
60
61 #define SAVE_ALL_INT save_all_int
62 #define SAVE_ALL_SYS save_all_sys
63 #define RESTORE_ALL restore_all
64 /*
65  * This defines the normal kernel pt-regs layout.
66  *
67  * regs a3-a6 and d6-d7 are preserved by C code
68  * the kernel doesn't mess with usp unless it needs to
69  */
70
71 /*
72  * a -1 in the orig_d0 field signifies
73  * that the stack frame is NOT for syscall
74  */
75 .macro  save_all_int
76         clrl    %sp@-           | stk_adj
77         pea     -1:w            | orig d0
78         movel   %d0,%sp@-       | d0
79         moveml  %d1-%d5/%a0-%a1/%curptr,%sp@-
80 .endm
81
82 .macro  save_all_sys
83         clrl    %sp@-           | stk_adj
84         movel   %d0,%sp@-       | orig d0
85         movel   %d0,%sp@-       | d0
86         moveml  %d1-%d5/%a0-%a1/%curptr,%sp@-
87 .endm
88
89 .macro  restore_all
90         moveml  %sp@+,%a0-%a1/%curptr/%d1-%d5
91         movel   %sp@+,%d0
92         addql   #4,%sp          | orig d0
93         addl    %sp@+,%sp       | stk adj
94         rte
95 .endm
96
97 #define SWITCH_STACK_SIZE (6*4+4)       /* includes return address */
98
99 #define SAVE_SWITCH_STACK save_switch_stack
100 #define RESTORE_SWITCH_STACK restore_switch_stack
101 #define GET_CURRENT(tmp) get_current tmp
102
103 .macro  save_switch_stack
104         moveml  %a3-%a6/%d6-%d7,%sp@-
105 .endm
106
107 .macro  restore_switch_stack
108         moveml  %sp@+,%a3-%a6/%d6-%d7
109 .endm
110
111 .macro  get_current reg=%d0
112         movel   %sp,\reg
113         andw    #-THREAD_SIZE,\reg
114         movel   \reg,%curptr
115         movel   %curptr@,%curptr
116 .endm
117
118 #else /* C source */
119
120 #define STR(X) STR1(X)
121 #define STR1(X) #X
122
123 #define SAVE_ALL_INT                            \
124         "clrl   %%sp@-;"    /* stk_adj */       \
125         "pea    -1:w;"      /* orig d0 = -1 */  \
126         "movel  %%d0,%%sp@-;" /* d0 */          \
127         "moveml %%d1-%%d5/%%a0-%%a2,%%sp@-"
128 #define GET_CURRENT(tmp) \
129         "movel  %%sp,"#tmp"\n\t" \
130         "andw   #-"STR(THREAD_SIZE)","#tmp"\n\t" \
131         "movel  "#tmp",%%a2\n\t" \
132         "movel  %%a2@,%%a2"
133
134 #endif
135
136 #endif /* __M68K_ENTRY_H */