xref: /openbmc/linux/arch/m68k/ifpsp060/iskeleton.S (revision 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2)
1|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2|MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
3|M68000 Hi-Performance Microprocessor Division
4|M68060 Software Package
5|Production Release P1.00 -- October 10, 1994
6|
7|M68060 Software Package Copyright1993, 1994 Motorola Inc.  All rights reserved.
8|
9|THE SOFTWARE is provided on an "AS IS" basis and without warranty.
10|To the maximum extent permitted by applicable law,
11|MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
12|INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
13|and any warranty against infringement with regard to the SOFTWARE
14|(INCLUDING ANY MODIFIED VERSIONS THEREOF) and any accompanying written materials.
15|
16|To the maximum extent permitted by applicable law,
17|IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
18|(INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
19|BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS)
20|ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE.
21|Motorola assumes no responsibility for the maintenance and support of the SOFTWARE.
22|
23|You are hereby granted a copyright license to use, modify, and distribute the SOFTWARE
24|so long as this entire notice is retained without alteration in any modified and/or
25|redistributed versions, and that such modified versions are clearly identified as such.
26|No licenses are granted by implication, estoppel or otherwise under any patents
27|or trademarks of Motorola, Inc.
28|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29| iskeleton.s
30|
31| This file contains:
32|	(1) example "Call-out"s
33|	(2) example package entry code
34|	(3) example "Call-out" table
35|
36
37#include <linux/linkage.h>
38#include <asm/entry.h>
39#include <asm/offsets.h>
40
41
42|################################
43| (1) EXAMPLE CALL-OUTS		#
44|				#
45| _060_isp_done()		#
46| _060_real_chk()		#
47| _060_real_divbyzero()		#
48|				#
49| _060_real_cas()		#
50| _060_real_cas2()		#
51| _060_real_lock_page()		#
52| _060_real_unlock_page()	#
53|################################
54
55|
56| _060_isp_done():
57|
58| This is and example main exit point for the Unimplemented Integer
59| Instruction exception handler. For a normal exit, the
60| _isp_unimp() branches to here so that the operating system
61| can do any clean-up desired. The stack frame is the
62| Unimplemented Integer Instruction stack frame with
63| the PC pointing to the instruction following the instruction
64| just emulated.
65| To simply continue execution at the next instruction, just
66| do an "rte".
67|
68| Linux/68k: If returning to user space, check for needed reselections.
69
70	.global		_060_isp_done
71_060_isp_done:
72	btst	#0x5,%sp@		| supervisor bit set in saved SR?
73	beq	.Lnotkern
74	rte
75.Lnotkern:
76	SAVE_ALL_INT
77	GET_CURRENT(%d0)
78	tstb	%curptr@(TASK_NEEDRESCHED)
79	jne	ret_from_exception	| deliver signals,
80					| reschedule etc..
81	RESTORE_ALL
82
83|
84| _060_real_chk():
85|
86| This is an alternate exit point for the Unimplemented Integer
87| Instruction exception handler. If the instruction was a "chk2"
88| and the operand was out of bounds, then _isp_unimp() creates
89| a CHK exception stack frame from the Unimplemented Integer Instrcution
90| stack frame and branches to this routine.
91|
92| Linux/68k: commented out test for tracing
93
94	.global		_060_real_chk
95_060_real_chk:
96|	tst.b		(%sp)			| is tracing enabled?
97|	bpls		real_chk_end		| no
98
99|
100|	    CHK FRAME		   TRACE FRAME
101|	*****************	*****************
102|	*   Current PC	*	*   Current PC	*
103|	*****************	*****************
104|	* 0x2 *  0x018	*	* 0x2 *  0x024	*
105|	*****************	*****************
106|	*     Next	*	*     Next	*
107|	*      PC	*	*      PC	*
108|	*****************	*****************
109|	*      SR	*	*      SR	*
110|	*****************	*****************
111|
112|	move.b		#0x24,0x7(%sp)		| set trace vecno
113|	bral		_060_real_trace
114
115real_chk_end:
116	bral		trap			| jump to trap handler
117
118|
119| _060_real_divbyzero:
120|
121| This is an alternate exit point for the Unimplemented Integer
122| Instruction exception handler isp_unimp(). If the instruction is a 64-bit
123| integer divide where the source operand is a zero, then the _isp_unimp()
124| creates a Divide-by-zero exception stack frame from the Unimplemented
125| Integer Instruction stack frame and branches to this routine.
126|
127| Remember that a trace exception may be pending. The code below performs
128| no action associated with the "chk" exception. If tracing is enabled,
129| then it create a Trace exception stack frame from the "chk" exception
130| stack frame and branches to the _real_trace() entry point.
131|
132| Linux/68k: commented out test for tracing
133
134	.global		_060_real_divbyzero
135_060_real_divbyzero:
136|	tst.b		(%sp)			| is tracing enabled?
137|	bpls		real_divbyzero_end	| no
138
139|
140|	 DIVBYZERO FRAME	   TRACE FRAME
141|	*****************	*****************
142|	*   Current PC	*	*   Current PC	*
143|	*****************	*****************
144|	* 0x2 *  0x014	*	* 0x2 *  0x024	*
145|	*****************	*****************
146|	*     Next	*	*     Next	*
147|	*      PC	*	*      PC	*
148|	*****************	*****************
149|	*      SR	*	*      SR	*
150|	*****************	*****************
151|
152|	move.b		#0x24,0x7(%sp)		| set trace vecno
153|	bral		_060_real_trace
154
155real_divbyzero_end:
156	bral		trap			| jump to trap handler
157
158|##########################
159
160|
161| _060_real_cas():
162|
163| Entry point for the selected cas emulation code implementation.
164| If the implementation provided by the 68060ISP is sufficient,
165| then this routine simply re-enters the package through _isp_cas.
166|
167	.global		_060_real_cas
168_060_real_cas:
169	bral		_I_CALL_TOP+0x80+0x08
170
171|
172| _060_real_cas2():
173|
174| Entry point for the selected cas2 emulation code implementation.
175| If the implementation provided by the 68060ISP is sufficient,
176| then this routine simply re-enters the package through _isp_cas2.
177|
178	.global		_060_real_cas2
179_060_real_cas2:
180	bral		_I_CALL_TOP+0x80+0x10
181
182|
183| _060_lock_page():
184|
185| Entry point for the operating system`s routine to "lock" a page
186| from being paged out. This routine is needed by the cas/cas2
187| algorithms so that no page faults occur within the "core" code
188| region. Note: the routine must lock two pages if the operand
189| spans two pages.
190| NOTE: THE ROUTINE SHOULD RETURN AN FSLW VALUE IN D0 ON FAILURE
191| SO THAT THE 060SP CAN CREATE A PROPER ACCESS ERROR FRAME.
192| Arguments:
193|	a0 = operand address
194|	d0 = `xxxxxxff -> supervisor; `xxxxxx00 -> user
195|	d1 = `xxxxxxff -> longword; `xxxxxx00 -> word
196| Expected outputs:
197|	d0 = 0 -> success; non-zero -> failure
198|
199| Linux/m68k: Make sure the page is properly paged in, so we use
200| plpaw and handle any exception here. The kernel must not be
201| preempted until _060_unlock_page(), so that the page stays mapped.
202|
203	.global		_060_real_lock_page
204_060_real_lock_page:
205	move.l	%d2,-(%sp)
206	| load sfc/dfc
207	tst.b	%d0
208	jne	1f
209	moveq	#1,%d0
210	jra	2f
2111:	moveq	#5,%d0
2122:	movec.l	%dfc,%d2
213	movec.l	%d0,%dfc
214	movec.l	%d0,%sfc
215
216	clr.l	%d0
217	| prefetch address
218	.chip	68060
219	move.l	%a0,%a1
2201:	plpaw	(%a1)
221	addq.w	#1,%a0
222	tst.b	%d1
223	jeq	2f
224	addq.w	#2,%a0
2252:	plpaw	(%a0)
2263:	.chip	68k
227
228	| restore sfc/dfc
229	movec.l	%d2,%dfc
230	movec.l	%d2,%sfc
231	move.l	(%sp)+,%d2
232	rts
233
234.section __ex_table,"a"
235	.align	4
236	.long	1b,11f
237	.long	2b,21f
238.previous
239.section .fixup,"ax"
240	.even
24111:	move.l	#0x020003c0,%d0
242	or.l	%d2,%d0
243	swap	%d0
244	jra	3b
24521:	move.l	#0x02000bc0,%d0
246	or.l	%d2,%d0
247	swap	%d0
248	jra	3b
249.previous
250
251|
252| _060_unlock_page():
253|
254| Entry point for the operating system`s routine to "unlock" a
255| page that has been "locked" previously with _real_lock_page.
256| Note: the routine must unlock two pages if the operand spans
257| two pages.
258| Arguments:
259|	a0 = operand address
260|	d0 = `xxxxxxff -> supervisor; `xxxxxx00 -> user
261|	d1 = `xxxxxxff -> longword; `xxxxxx00 -> word
262|
263| Linux/m68k: perhaps reenable preemption here...
264
265	.global		_060_real_unlock_page
266_060_real_unlock_page:
267	clr.l		%d0
268	rts
269
270|###########################################################################
271
272|#################################
273| (2) EXAMPLE PACKAGE ENTRY CODE #
274|#################################
275
276	.global		_060_isp_unimp
277_060_isp_unimp:
278	bral		_I_CALL_TOP+0x80+0x00
279
280	.global		_060_isp_cas
281_060_isp_cas:
282	bral		_I_CALL_TOP+0x80+0x08
283
284	.global		_060_isp_cas2
285_060_isp_cas2:
286	bral		_I_CALL_TOP+0x80+0x10
287
288	.global		_060_isp_cas_finish
289_060_isp_cas_finish:
290	bra.l		_I_CALL_TOP+0x80+0x18
291
292	.global		_060_isp_cas2_finish
293_060_isp_cas2_finish:
294	bral		_I_CALL_TOP+0x80+0x20
295
296	.global		_060_isp_cas_inrange
297_060_isp_cas_inrange:
298	bral		_I_CALL_TOP+0x80+0x28
299
300	.global		_060_isp_cas_terminate
301_060_isp_cas_terminate:
302	bral		_I_CALL_TOP+0x80+0x30
303
304	.global		_060_isp_cas_restart
305_060_isp_cas_restart:
306	bral		_I_CALL_TOP+0x80+0x38
307
308|###########################################################################
309
310|###############################
311| (3) EXAMPLE CALL-OUT SECTION #
312|###############################
313
314| The size of this section MUST be 128 bytes!!!
315
316_I_CALL_TOP:
317	.long	_060_real_chk		- _I_CALL_TOP
318	.long	_060_real_divbyzero	- _I_CALL_TOP
319	.long	_060_real_trace		- _I_CALL_TOP
320	.long	_060_real_access	- _I_CALL_TOP
321	.long	_060_isp_done		- _I_CALL_TOP
322
323	.long	_060_real_cas		- _I_CALL_TOP
324	.long	_060_real_cas2		- _I_CALL_TOP
325	.long	_060_real_lock_page	- _I_CALL_TOP
326	.long	_060_real_unlock_page	- _I_CALL_TOP
327
328	.long	0x00000000, 0x00000000, 0x00000000, 0x00000000
329	.long	0x00000000, 0x00000000, 0x00000000
330
331	.long	_060_imem_read		- _I_CALL_TOP
332	.long	_060_dmem_read		- _I_CALL_TOP
333	.long	_060_dmem_write		- _I_CALL_TOP
334	.long	_060_imem_read_word	- _I_CALL_TOP
335	.long	_060_imem_read_long	- _I_CALL_TOP
336	.long	_060_dmem_read_byte	- _I_CALL_TOP
337	.long	_060_dmem_read_word	- _I_CALL_TOP
338	.long	_060_dmem_read_long	- _I_CALL_TOP
339	.long	_060_dmem_write_byte	- _I_CALL_TOP
340	.long	_060_dmem_write_word	- _I_CALL_TOP
341	.long	_060_dmem_write_long	- _I_CALL_TOP
342
343	.long	0x00000000
344	.long	0x00000000, 0x00000000, 0x00000000, 0x00000000
345
346|###########################################################################
347
348| 060 INTEGER KERNEL PACKAGE MUST GO HERE!!!
349#include "isp.sa"
350