Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[pandora-kernel.git] / arch / m68k / include / asm / entry_no.h
1 #ifndef __M68KNOMMU_ENTRY_H
2 #define __M68KNOMMU_ENTRY_H
3
4 #include <asm/setup.h>
5 #include <asm/page.h>
6
7 /*
8  * Stack layout in 'ret_from_exception':
9  *
10  * This allows access to the syscall arguments in registers d1-d5
11  *
12  *       0(sp) - d1
13  *       4(sp) - d2
14  *       8(sp) - d3
15  *       C(sp) - d4
16  *      10(sp) - d5
17  *      14(sp) - a0
18  *      18(sp) - a1
19  *      1C(sp) - a2
20  *      20(sp) - d0
21  *      24(sp) - orig_d0
22  *      28(sp) - stack adjustment
23  *      2C(sp) - [ sr              ] [ format & vector ]
24  *      2E(sp) - [ pc-hiword       ] [ sr              ]
25  *      30(sp) - [ pc-loword       ] [ pc-hiword       ]
26  *      32(sp) - [ format & vector ] [ pc-loword       ]
27  *                ^^^^^^^^^^^^^^^^^   ^^^^^^^^^^^^^^^^^
28  *                      M68K              COLDFIRE
29  */
30
31 #define ALLOWINT (~0x700)
32
33 #ifdef __ASSEMBLY__
34
35 #define SWITCH_STACK_SIZE (6*4+4)       /* Includes return address */
36
37 /*
38  * This defines the normal kernel pt-regs layout.
39  *
40  * regs are a2-a6 and d6-d7 preserved by C code
41  * the kernel doesn't mess with usp unless it needs to
42  */
43
44 #ifdef CONFIG_COLDFIRE
45 /*
46  * This is made a little more tricky on the ColdFire. There is no
47  * separate kernel and user stack pointers. Need to artificially
48  * construct a usp in software... When doing this we need to disable
49  * interrupts, otherwise bad things could happen.
50  */
51 .macro SAVE_ALL
52         move    #0x2700,%sr             /* disable intrs */
53         btst    #5,%sp@(2)              /* from user? */
54         bnes    6f                      /* no, skip */
55         movel   %sp,sw_usp              /* save user sp */
56         addql   #8,sw_usp               /* remove exception */
57         movel   sw_ksp,%sp              /* kernel sp */
58         subql   #8,%sp                  /* room for exception */
59         clrl    %sp@-                   /* stkadj */
60         movel   %d0,%sp@-               /* orig d0 */
61         movel   %d0,%sp@-               /* d0 */
62         lea     %sp@(-32),%sp           /* space for 8 regs */
63         moveml  %d1-%d5/%a0-%a2,%sp@
64         movel   sw_usp,%a0              /* get usp */
65         movel   %a0@-,%sp@(PT_OFF_PC)   /* copy exception program counter */
66         movel   %a0@-,%sp@(PT_OFF_FORMATVEC)/*copy exception format/vector/sr */
67         bra     7f
68         6:
69         clrl    %sp@-                   /* stkadj */
70         movel   %d0,%sp@-               /* orig d0 */
71         movel   %d0,%sp@-               /* d0 */
72         lea     %sp@(-32),%sp           /* space for 8 regs */
73         moveml  %d1-%d5/%a0-%a2,%sp@
74         7:
75 .endm
76
77 .macro RESTORE_ALL
78         btst    #5,%sp@(PT_SR)          /* going user? */
79         bnes    8f                      /* no, skip */
80         move    #0x2700,%sr             /* disable intrs */
81         movel   sw_usp,%a0              /* get usp */
82         movel   %sp@(PT_OFF_PC),%a0@-   /* copy exception program counter */
83         movel   %sp@(PT_OFF_FORMATVEC),%a0@-/*copy exception format/vector/sr */
84         moveml  %sp@,%d1-%d5/%a0-%a2
85         lea     %sp@(32),%sp            /* space for 8 regs */
86         movel   %sp@+,%d0
87         addql   #4,%sp                  /* orig d0 */
88         addl    %sp@+,%sp               /* stkadj */
89         addql   #8,%sp                  /* remove exception */
90         movel   %sp,sw_ksp              /* save ksp */
91         subql   #8,sw_usp               /* set exception */
92         movel   sw_usp,%sp              /* restore usp */
93         rte
94         8:
95         moveml  %sp@,%d1-%d5/%a0-%a2
96         lea     %sp@(32),%sp            /* space for 8 regs */
97         movel   %sp@+,%d0
98         addql   #4,%sp                  /* orig d0 */
99         addl    %sp@+,%sp               /* stkadj */
100         rte
101 .endm
102
103 /*
104  * Quick exception save, use current stack only.
105  */
106 .macro SAVE_LOCAL
107         move    #0x2700,%sr             /* disable intrs */
108         clrl    %sp@-                   /* stkadj */
109         movel   %d0,%sp@-               /* orig d0 */
110         movel   %d0,%sp@-               /* d0 */
111         lea     %sp@(-32),%sp           /* space for 8 regs */
112         moveml  %d1-%d5/%a0-%a2,%sp@
113 .endm
114
115 .macro RESTORE_LOCAL
116         moveml  %sp@,%d1-%d5/%a0-%a2
117         lea     %sp@(32),%sp            /* space for 8 regs */
118         movel   %sp@+,%d0
119         addql   #4,%sp                  /* orig d0 */
120         addl    %sp@+,%sp               /* stkadj */
121         rte
122 .endm
123
124 .macro SAVE_SWITCH_STACK
125         lea     %sp@(-24),%sp           /* 6 regs */
126         moveml  %a3-%a6/%d6-%d7,%sp@
127 .endm
128
129 .macro RESTORE_SWITCH_STACK
130         moveml  %sp@,%a3-%a6/%d6-%d7
131         lea     %sp@(24),%sp            /* 6 regs */
132 .endm
133
134 /*
135  * Software copy of the user and kernel stack pointers... Ugh...
136  * Need these to get around ColdFire not having separate kernel
137  * and user stack pointers.
138  */
139 .globl sw_usp
140 .globl sw_ksp
141
142 #else /* !CONFIG_COLDFIRE */
143
144 /*
145  * Standard 68k interrupt entry and exit macros.
146  */
147 .macro SAVE_ALL
148         clrl    %sp@-                   /* stkadj */
149         movel   %d0,%sp@-               /* orig d0 */
150         movel   %d0,%sp@-               /* d0 */
151         moveml  %d1-%d5/%a0-%a2,%sp@-
152 .endm
153
154 .macro RESTORE_ALL
155         moveml  %sp@+,%a0-%a2/%d1-%d5
156         movel   %sp@+,%d0
157         addql   #4,%sp                  /* orig d0 */
158         addl    %sp@+,%sp               /* stkadj */
159         rte
160 .endm
161
162 .macro SAVE_SWITCH_STACK
163         moveml  %a3-%a6/%d6-%d7,%sp@-
164 .endm
165
166 .macro RESTORE_SWITCH_STACK
167         moveml  %sp@+,%a3-%a6/%d6-%d7
168 .endm
169
170 #endif /* !CONFIG_COLDFIRE */
171 #endif /* __ASSEMBLY__ */
172 #endif /* __M68KNOMMU_ENTRY_H */