blob: 47412588621839d963e0b2e2cb1ef772a49a5990 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __M68K_ENTRY_H
2#define __M68K_ENTRY_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#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
24 * 2E(sp) - pc
25 * 32(sp) - format & vector
26 */
27
28/*
29 * 97/05/14 Andreas: Register %a2 is now set to the current task throughout
30 * the whole kernel.
31 */
32
33/* the following macro is used when enabling interrupts */
Adrian Bunk29c8a242008-10-13 21:58:59 +020034#if defined(MACH_ATARI_ONLY)
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 /* block out HSYNC on the atari */
36#define ALLOWINT (~0x400)
37#define MAX_NOINT_IPL 3
38#else
39 /* portable version */
40#define ALLOWINT (~0x700)
41#define MAX_NOINT_IPL 0
42#endif /* machine compilation types */
43
44#ifdef __ASSEMBLY__
45
46#define curptr a2
47
48LFLUSH_I_AND_D = 0x00000808
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50/* process bits for task_struct.ptrace */
51PT_TRACESYS_OFF = 3
52PT_TRACESYS_BIT = 1
53PT_PTRACED_OFF = 3
54PT_PTRACED_BIT = 0
55PT_DTRACE_OFF = 3
56PT_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 clrl %sp@- | stk_adj
74 pea -1:w | orig d0
75 movel %d0,%sp@- | d0
76 moveml %d1-%d5/%a0-%a1/%curptr,%sp@-
77.endm
78
79.macro save_all_sys
80 clrl %sp@- | stk_adj
81 movel %d0,%sp@- | orig d0
82 movel %d0,%sp@- | d0
83 moveml %d1-%d5/%a0-%a1/%curptr,%sp@-
84.endm
85
86.macro restore_all
87 moveml %sp@+,%a0-%a1/%curptr/%d1-%d5
88 movel %sp@+,%d0
89 addql #4,%sp | orig d0
90 addl %sp@+,%sp | stk adj
91 rte
92.endm
93
94#define SWITCH_STACK_SIZE (6*4+4) /* includes return address */
95
96#define SAVE_SWITCH_STACK save_switch_stack
97#define RESTORE_SWITCH_STACK restore_switch_stack
98#define GET_CURRENT(tmp) get_current tmp
99
100.macro save_switch_stack
101 moveml %a3-%a6/%d6-%d7,%sp@-
102.endm
103
104.macro restore_switch_stack
105 moveml %sp@+,%a3-%a6/%d6-%d7
106.endm
107
108.macro get_current reg=%d0
109 movel %sp,\reg
110 andw #-THREAD_SIZE,\reg
111 movel \reg,%curptr
112 movel %curptr@,%curptr
113.endm
114
115#else /* C source */
116
117#define STR(X) STR1(X)
118#define STR1(X) #X
119
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120#define SAVE_ALL_INT \
121 "clrl %%sp@-;" /* stk_adj */ \
122 "pea -1:w;" /* orig d0 = -1 */ \
123 "movel %%d0,%%sp@-;" /* d0 */ \
124 "moveml %%d1-%%d5/%%a0-%%a2,%%sp@-"
125#define GET_CURRENT(tmp) \
126 "movel %%sp,"#tmp"\n\t" \
127 "andw #-"STR(THREAD_SIZE)","#tmp"\n\t" \
128 "movel "#tmp",%%a2\n\t" \
129 "movel %%a2@,%%a2"
130
131#endif
132
133#endif /* __M68K_ENTRY_H */