Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
awilliam
GitHub Repository: awilliam/linux-vfio
Path: blob/master/arch/m68k/platform/68360/entry.S
10818 views
1
/*
2
* linux/arch/m68knommu/platform/68360/entry.S
3
*
4
* Copyright (C) 1991, 1992 Linus Torvalds
5
* Copyright (C) 2001 SED Systems, a Division of Calian Ltd.
6
*
7
* This file is subject to the terms and conditions of the GNU General Public
8
* License. See the file README.legal in the main directory of this archive
9
* for more details.
10
*
11
* Linux/m68k support by Hamish Macdonald
12
* M68360 Port by SED Systems, and Lineo.
13
*/
14
15
#include <linux/linkage.h>
16
#include <asm/thread_info.h>
17
#include <asm/unistd.h>
18
#include <asm/errno.h>
19
#include <asm/setup.h>
20
#include <asm/segment.h>
21
#include <asm/traps.h>
22
#include <asm/asm-offsets.h>
23
#include <asm/entry.h>
24
25
.text
26
27
.globl system_call
28
.globl resume
29
.globl ret_from_exception
30
.globl ret_from_signal
31
.globl sys_call_table
32
.globl ret_from_interrupt
33
.globl bad_interrupt
34
.globl inthandler
35
36
badsys:
37
movel #-ENOSYS,%sp@(PT_OFF_D0)
38
jra ret_from_exception
39
40
do_trace:
41
movel #-ENOSYS,%sp@(PT_OFF_D0) /* needed for strace*/
42
subql #4,%sp
43
SAVE_SWITCH_STACK
44
jbsr syscall_trace_enter
45
RESTORE_SWITCH_STACK
46
addql #4,%sp
47
movel %sp@(PT_OFF_ORIG_D0),%d1
48
movel #-ENOSYS,%d0
49
cmpl #NR_syscalls,%d1
50
jcc 1f
51
lsl #2,%d1
52
lea sys_call_table, %a0
53
jbsr %a0@(%d1)
54
55
1: movel %d0,%sp@(PT_OFF_D0) /* save the return value */
56
subql #4,%sp /* dummy return address */
57
SAVE_SWITCH_STACK
58
jbsr syscall_trace_leave
59
60
ret_from_signal:
61
RESTORE_SWITCH_STACK
62
addql #4,%sp
63
jra ret_from_exception
64
65
ENTRY(system_call)
66
SAVE_ALL
67
68
/* save top of frame*/
69
pea %sp@
70
jbsr set_esp0
71
addql #4,%sp
72
73
movel %sp@(PT_OFF_ORIG_D0),%d0
74
75
movel %sp,%d1 /* get thread_info pointer */
76
andl #-THREAD_SIZE,%d1
77
movel %d1,%a2
78
btst #(TIF_SYSCALL_TRACE%8),%a2@(TINFO_FLAGS+(31-TIF_SYSCALL_TRACE)/8)
79
jne do_trace
80
cmpl #NR_syscalls,%d0
81
jcc badsys
82
lsl #2,%d0
83
lea sys_call_table,%a0
84
movel %a0@(%d0), %a0
85
jbsr %a0@
86
movel %d0,%sp@(PT_OFF_D0) /* save the return value*/
87
88
ret_from_exception:
89
btst #5,%sp@(PT_OFF_SR) /* check if returning to kernel*/
90
jeq Luser_return /* if so, skip resched, signals*/
91
92
Lkernel_return:
93
RESTORE_ALL
94
95
Luser_return:
96
/* only allow interrupts when we are really the last one on the*/
97
/* kernel stack, otherwise stack overflow can occur during*/
98
/* heavy interrupt load*/
99
andw #ALLOWINT,%sr
100
101
movel %sp,%d1 /* get thread_info pointer */
102
andl #-THREAD_SIZE,%d1
103
movel %d1,%a2
104
1:
105
move %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */
106
jne Lwork_to_do
107
RESTORE_ALL
108
109
Lwork_to_do:
110
movel %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */
111
btst #TIF_NEED_RESCHED,%d1
112
jne reschedule
113
114
Lsignal_return:
115
subql #4,%sp /* dummy return address*/
116
SAVE_SWITCH_STACK
117
pea %sp@(SWITCH_STACK_SIZE)
118
bsrw do_signal
119
addql #4,%sp
120
RESTORE_SWITCH_STACK
121
addql #4,%sp
122
jra 1b
123
124
/*
125
* This is the main interrupt handler, responsible for calling do_IRQ()
126
*/
127
inthandler:
128
SAVE_ALL
129
movew %sp@(PT_OFF_FORMATVEC), %d0
130
and.l #0x3ff, %d0
131
lsr.l #0x02, %d0
132
133
movel %sp,%sp@-
134
movel %d0,%sp@- /* put vector # on stack*/
135
jbsr do_IRQ /* process the IRQ*/
136
3: addql #8,%sp /* pop parameters off stack*/
137
bra ret_from_interrupt
138
139
ret_from_interrupt:
140
jeq 1f
141
2:
142
RESTORE_ALL
143
1:
144
moveb %sp@(PT_OFF_SR), %d0
145
and #7, %d0
146
jhi 2b
147
/* check if we need to do software interrupts */
148
149
movel irq_stat+CPUSTAT_SOFTIRQ_PENDING,%d0
150
jeq ret_from_exception
151
152
pea ret_from_exception
153
jra do_softirq
154
155
156
/*
157
* Handler for uninitialized and spurious interrupts.
158
*/
159
bad_interrupt:
160
addql #1,num_spurious
161
rte
162
163
/*
164
* Beware - when entering resume, prev (the current task) is
165
* in a0, next (the new task) is in a1,so don't change these
166
* registers until their contents are no longer needed.
167
*/
168
ENTRY(resume)
169
movel %a0,%d1 /* save prev thread in d1 */
170
movew %sr,%a0@(TASK_THREAD+THREAD_SR) /* save sr */
171
movel %usp,%a2 /* save usp */
172
movel %a2,%a0@(TASK_THREAD+THREAD_USP)
173
174
SAVE_SWITCH_STACK
175
movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */
176
movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */
177
RESTORE_SWITCH_STACK
178
179
movel %a1@(TASK_THREAD+THREAD_USP),%a0 /* restore user stack */
180
movel %a0,%usp
181
movew %a1@(TASK_THREAD+THREAD_SR),%sr /* restore thread status reg */
182
rts
183
184
185