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