1#
2# $NetBSD: iskeletn.s,v 1.2 2024/05/13 00:10:06 msaitoh Exp $
3#
4
5#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6# MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
7# M68000 Hi-Performance Microprocessor Division
8# M68060 Software Package Production Release
9#
10# M68060 Software Package Copyright (C) 1993, 1994, 1995, 1996 Motorola Inc.
11# All rights reserved.
12#
13# THE SOFTWARE is provided on an "AS IS" basis and without warranty.
14# To the maximum extent permitted by applicable law,
15# MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
16# INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS
17# FOR A PARTICULAR PURPOSE and any warranty against infringement with
18# regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
19# and any accompanying written materials.
20#
21# To the maximum extent permitted by applicable law,
22# IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
23# (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
24# BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS)
25# ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE.
26#
27# Motorola assumes no responsibility for the maintenance and support
28# of the SOFTWARE.
29#
30# You are hereby granted a copyright license to use, modify, and distribute the
31# SOFTWARE so long as this entire notice is retained without alteration
32# in any modified and/or redistributed versions, and that such modified
33# versions are clearly identified as such.
34# No licenses are granted by implication, estoppel or otherwise under any
35# patents or trademarks of Motorola, Inc.
36#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37
38#
39# iskeleton.s
40#
41# This file contains:
42#	(1) example "Call-out"s
43#	(2) example package entry code
44#	(3) example "Call-out" table
45#
46
47
48#################################
49# (1) EXAMPLE CALL-OUTS 	#
50#				#
51# _060_isp_done()		#
52# _060_real_chk()		#
53# _060_real_divbyzero()		#
54#				#
55# _060_real_cas()		#
56# _060_real_cas2()		#
57# _060_real_lock_page()		#
58# _060_real_unlock_page()	#
59#################################
60
61#
62# _060_isp_done():
63#
64# This is and example main exit point for the Unimplemented Integer
65# Instruction exception handler. For a normal exit, the
66# _isp_unimp() branches to here so that the operating system
67# can do any clean-up desired. The stack frame is the
68# Unimplemented Integer Instruction stack frame with
69# the PC pointing to the instruction following the instruction
70# just emulated.
71# To simply continue execution at the next instruction, just
72# do an "rte".
73#
74	global		_060_isp_done
75_060_isp_done:
76	rte
77
78#
79# _060_real_chk():
80#
81# This is an alternate exit point for the Unimplemented Integer
82# Instruction exception handler. If the instruction was a "chk2"
83# and the operand was out of bounds, then _isp_unimp() creates
84# a CHK exception stack frame from the Unimplemented Integer Instruction
85# stack frame and branches to this routine.
86#
87	global		_060_real_chk
88_060_real_chk:
89	tst.b		(%sp)			# is tracing enabled?
90	bpl.b		real_chk_end		# no
91
92#
93#	    CHK FRAME		   TRACE FRAME
94#	*****************	*****************
95#	*   Current PC	*	*   Current PC	*
96#	*****************	*****************
97#	* 0x2 *  0x018	*	* 0x2 *  0x024	*
98#	*****************	*****************
99#	*     Next	*	*     Next	*
100#	*      PC	*	*      PC	*
101#	*****************	*****************
102#	*      SR	*	*      SR	*
103#	*****************	*****************
104#
105	mov.b		&0x24,0x7(%sp)		# set trace vecno
106	bra.l		_060_real_trace
107
108real_chk_end:
109	rte
110
111#
112# _060_real_divbyzero:
113#
114# This is an alternate exit point for the Unimplemented Integer
115# Instruction exception handler isp_unimp(). If the instruction is a 64-bit
116# integer divide where the source operand is a zero, then the _isp_unimp()
117# creates a Divide-by-zero exception stack frame from the Unimplemented
118# Integer Instruction stack frame and branches to this routine.
119#
120# Remember that a trace exception may be pending. The code below performs
121# no action associated with the "chk" exception. If tracing is enabled,
122# then it create a Trace exception stack frame from the "chk" exception
123# stack frame and branches to the _real_trace() entry point.
124#
125	global		_060_real_divbyzero
126_060_real_divbyzero:
127	tst.b		(%sp)			# is tracing enabled?
128	bpl.b		real_divbyzero_end	# no
129
130#
131#	 DIVBYZERO FRAME	   TRACE FRAME
132#	*****************	*****************
133#	*   Current PC	*	*   Current PC	*
134#	*****************	*****************
135#	* 0x2 *  0x014	*	* 0x2 *  0x024	*
136#	*****************	*****************
137#	*     Next	*	*     Next	*
138#	*      PC	*	*      PC	*
139#	*****************	*****************
140#	*      SR	*	*      SR	*
141#	*****************	*****************
142#
143	mov.b		&0x24,0x7(%sp)		# set trace vecno
144	bra.l		_060_real_trace
145
146real_divbyzero_end:
147	rte
148
149###########################
150
151#
152# _060_real_cas():
153#
154# Entry point for the selected cas emulation code implementation.
155# If the implementation provided by the 68060ISP is sufficient,
156# then this routine simply re-enters the package through _isp_cas.
157#
158	global		_060_real_cas
159_060_real_cas:
160	bra.l		_I_CALL_TOP+0x80+0x08
161
162#
163# _060_real_cas2():
164#
165# Entry point for the selected cas2 emulation code implementation.
166# If the implementation provided by the 68060ISP is sufficient,
167# then this routine simply re-enters the package through _isp_cas2.
168#
169	global		_060_real_cas2
170_060_real_cas2:
171	bra.l		_I_CALL_TOP+0x80+0x10
172
173#
174# _060_lock_page():
175#
176# Entry point for the operating system's routine to "lock" a page
177# from being paged out. This routine is needed by the cas/cas2
178# algorithms so that no page faults occur within the "core" code
179# region. Note: the routine must lock two pages if the operand
180# spans two pages.
181# NOTE: THE ROUTINE SHOULD RETURN AN FSLW VALUE IN D0 ON FAILURE
182# SO THAT THE 060SP CAN CREATE A PROPER ACCESS ERROR FRAME.
183# Arguments:
184#	a0 = operand address
185#	d0 = `xxxxxxff -> supervisor; `xxxxxx00 -> user
186#	d1 = `xxxxxxff -> longword; `xxxxxx00 -> word
187# Expected outputs:
188#	d0 = 0 -> success; non-zero -> failure
189#
190	global		_060_real_lock_page
191_060_real_lock_page:
192	clr.l		%d0
193	rts
194
195#
196# _060_unlock_page():
197#
198# Entry point for the operating system's routine to "unlock" a
199# page that has been "locked" previously with _real_lock_page.
200# Note: the routine must unlock two pages if the operand spans
201# two pages.
202# Arguments:
203# 	a0 = operand address
204#	d0 = `xxxxxxff -> supervisor; `xxxxxx00 -> user
205#	d1 = `xxxxxxff -> longword; `xxxxxx00 -> word
206#
207	global		_060_real_unlock_page
208_060_real_unlock_page:
209	clr.l		%d0
210	rts
211
212############################################################################
213
214##################################
215# (2) EXAMPLE PACKAGE ENTRY CODE #
216##################################
217
218	global		_060_isp_unimp
219_060_isp_unimp:
220	bra.l		_I_CALL_TOP+0x80+0x00
221
222	global		_060_isp_cas
223_060_isp_cas:
224	bra.l		_I_CALL_TOP+0x80+0x08
225
226	global		_060_isp_cas2
227_060_isp_cas2:
228	bra.l		_I_CALL_TOP+0x80+0x10
229
230	global		_060_isp_cas_finish
231_060_isp_cas_finish:
232	bra.l		_I_CALL_TOP+0x80+0x18
233
234	global		_060_isp_cas2_finish
235_060_isp_cas2_finish:
236	bra.l		_I_CALL_TOP+0x80+0x20
237
238	global		_060_isp_cas_inrange
239_060_isp_cas_inrange:
240	bra.l		_I_CALL_TOP+0x80+0x28
241
242	global		_060_isp_cas_terminate
243_060_isp_cas_terminate:
244	bra.l		_I_CALL_TOP+0x80+0x30
245
246	global		_060_isp_cas_restart
247_060_isp_cas_restart:
248	bra.l		_I_CALL_TOP+0x80+0x38
249
250############################################################################
251
252################################
253# (3) EXAMPLE CALL-OUT SECTION #
254################################
255
256# The size of this section MUST be 128 bytes!!!
257
258	global	_I_CALL_TOP
259_I_CALL_TOP:
260	long	_060_real_chk		- _I_CALL_TOP
261	long	_060_real_divbyzero	- _I_CALL_TOP
262	long	_060_real_trace		- _I_CALL_TOP
263	long	_060_real_access	- _I_CALL_TOP
264	long	_060_isp_done		- _I_CALL_TOP
265
266	long	_060_real_cas		- _I_CALL_TOP
267	long	_060_real_cas2		- _I_CALL_TOP
268	long	_060_real_lock_page	- _I_CALL_TOP
269	long	_060_real_unlock_page	- _I_CALL_TOP
270
271	long	0x00000000, 0x00000000, 0x00000000, 0x00000000
272	long	0x00000000, 0x00000000, 0x00000000
273
274	long	_060_imem_read		- _I_CALL_TOP
275	long	_060_dmem_read		- _I_CALL_TOP
276	long	_060_dmem_write		- _I_CALL_TOP
277	long	_060_imem_read_word	- _I_CALL_TOP
278	long	_060_imem_read_long	- _I_CALL_TOP
279	long	_060_dmem_read_byte	- _I_CALL_TOP
280	long	_060_dmem_read_word	- _I_CALL_TOP
281	long	_060_dmem_read_long	- _I_CALL_TOP
282	long	_060_dmem_write_byte	- _I_CALL_TOP
283	long	_060_dmem_write_word	- _I_CALL_TOP
284	long	_060_dmem_write_long	- _I_CALL_TOP
285
286	long	0x00000000
287	long	0x00000000, 0x00000000, 0x00000000, 0x00000000
288
289############################################################################
290
291# 060 INTEGER KERNEL PACKAGE MUST GO HERE!!!
292