netbsd060sp.S revision 1.4.2.2 1 1.4.2.2 thorpej #
2 1.4.2.2 thorpej # $NetBSD: netbsd060sp.S,v 1.4.2.2 1997/10/14 10:16:39 thorpej Exp $
3 1.4.2.2 thorpej #
4 1.4.2.2 thorpej #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 1.4.2.2 thorpej # MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
6 1.4.2.2 thorpej # M68000 Hi-Performance Microprocessor Division
7 1.4.2.2 thorpej # M68060 Software Package Production Release
8 1.4.2.2 thorpej #
9 1.4.2.2 thorpej # M68060 Software Package Copyright (C) 1993, 1994, 1995, 1996 Motorola Inc.
10 1.4.2.2 thorpej # All rights reserved.
11 1.4.2.2 thorpej #
12 1.4.2.2 thorpej # THE SOFTWARE is provided on an "AS IS" basis and without warranty.
13 1.4.2.2 thorpej # To the maximum extent permitted by applicable law,
14 1.4.2.2 thorpej # MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
15 1.4.2.2 thorpej # INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS
16 1.4.2.2 thorpej # FOR A PARTICULAR PURPOSE and any warranty against infringement with
17 1.4.2.2 thorpej # regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
18 1.4.2.2 thorpej # and any accompanying written materials.
19 1.4.2.2 thorpej #
20 1.4.2.2 thorpej # To the maximum extent permitted by applicable law,
21 1.4.2.2 thorpej # IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
22 1.4.2.2 thorpej # (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
23 1.4.2.2 thorpej # BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS)
24 1.4.2.2 thorpej # ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE.
25 1.4.2.2 thorpej #
26 1.4.2.2 thorpej # Motorola assumes no responsibility for the maintenance and support
27 1.4.2.2 thorpej # of the SOFTWARE.
28 1.4.2.2 thorpej #
29 1.4.2.2 thorpej # You are hereby granted a copyright license to use, modify, and distribute the
30 1.4.2.2 thorpej # SOFTWARE so long as this entire notice is retained without alteration
31 1.4.2.2 thorpej # in any modified and/or redistributed versions, and that such modified
32 1.4.2.2 thorpej # versions are clearly identified as such.
33 1.4.2.2 thorpej # No licenses are granted by implication, estoppel or otherwise under any
34 1.4.2.2 thorpej # patents or trademarks of Motorola, Inc.
35 1.4.2.2 thorpej #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36 1.4.2.2 thorpej #
37 1.4.2.2 thorpej # Derived from:
38 1.4.2.2 thorpej # os.s
39 1.4.2.2 thorpej #
40 1.4.2.2 thorpej # This file contains:
41 1.4.2.2 thorpej # - example "Call-Out"s required by both the ISP and FPSP.
42 1.4.2.2 thorpej #
43 1.4.2.2 thorpej
44 1.4.2.2 thorpej #
45 1.4.2.2 thorpej # make the copyright notice appear in the binary:
46 1.4.2.2 thorpej #
47 1.4.2.2 thorpej .include "copyright.S"
48 1.4.2.2 thorpej
49 1.4.2.2 thorpej #################################
50 1.4.2.2 thorpej # EXAMPLE CALL-OUTS #
51 1.4.2.2 thorpej # #
52 1.4.2.2 thorpej # _060_dmem_write() #
53 1.4.2.2 thorpej # _060_dmem_read() #
54 1.4.2.2 thorpej # _060_imem_read() #
55 1.4.2.2 thorpej # _060_dmem_read_byte() #
56 1.4.2.2 thorpej # _060_dmem_read_word() #
57 1.4.2.2 thorpej # _060_dmem_read_long() #
58 1.4.2.2 thorpej # _060_imem_read_word() #
59 1.4.2.2 thorpej # _060_imem_read_long() #
60 1.4.2.2 thorpej # _060_dmem_write_byte() #
61 1.4.2.2 thorpej # _060_dmem_write_word() #
62 1.4.2.2 thorpej # _060_dmem_write_long() #
63 1.4.2.2 thorpej # #
64 1.4.2.2 thorpej # _060_real_trace() #
65 1.4.2.2 thorpej # _060_real_access() #
66 1.4.2.2 thorpej #################################
67 1.4.2.2 thorpej
68 1.4.2.2 thorpej #
69 1.4.2.2 thorpej # Each IO routine checks to see if the memory write/read is to/from user
70 1.4.2.2 thorpej # or supervisor application space. The examples below use simple "move"
71 1.4.2.2 thorpej # instructions for supervisor mode applications and call _copyin()/_copyout()
72 1.4.2.2 thorpej # for user mode applications.
73 1.4.2.2 thorpej # When installing the 060SP, the _copyin()/_copyout() equivalents for a
74 1.4.2.2 thorpej # given operating system should be substituted.
75 1.4.2.2 thorpej #
76 1.4.2.2 thorpej # The addresses within the 060SP are guaranteed to be on the stack.
77 1.4.2.2 thorpej # The result is that Unix processes are allowed to sleep as a consequence
78 1.4.2.2 thorpej # of a page fault during a _copyout.
79 1.4.2.2 thorpej #
80 1.4.2.2 thorpej
81 1.4.2.2 thorpej #
82 1.4.2.2 thorpej # _060_dmem_write():
83 1.4.2.2 thorpej #
84 1.4.2.2 thorpej # Writes to data memory while in supervisor mode.
85 1.4.2.2 thorpej #
86 1.4.2.2 thorpej # INPUTS:
87 1.4.2.2 thorpej # a0 - supervisor source address
88 1.4.2.2 thorpej # a1 - user destination address
89 1.4.2.2 thorpej # d0 - number of bytes to write
90 1.4.2.2 thorpej # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
91 1.4.2.2 thorpej # OUTPUTS:
92 1.4.2.2 thorpej # d1 - 0 = success, !0 = failure
93 1.4.2.2 thorpej #
94 1.4.2.2 thorpej .global _060_dmem_write
95 1.4.2.2 thorpej _060_dmem_write:
96 1.4.2.2 thorpej btst #0x5,a6@(0x4) |# check for supervisor state
97 1.4.2.2 thorpej beqs user_write
98 1.4.2.2 thorpej super_write:
99 1.4.2.2 thorpej moveb a0@+,a1@+ |# copy 1 byte
100 1.4.2.2 thorpej subql #0x1,d0 |# decr byte counter
101 1.4.2.2 thorpej bnes super_write |# quit if ctr = 0
102 1.4.2.2 thorpej clrl d1 |# return success
103 1.4.2.2 thorpej rts
104 1.4.2.2 thorpej user_write:
105 1.4.2.2 thorpej movel d0,sp@- |# pass: counter
106 1.4.2.2 thorpej movel a1,sp@- |# pass: user dst
107 1.4.2.2 thorpej movel a0,sp@- |# pass: supervisor src
108 1.4.2.2 thorpej bsrl _copyout |# write byte to user mem
109 1.4.2.2 thorpej movel d0,d1 |# return success
110 1.4.2.2 thorpej addl #0xc,sp |# clear 3 lw params
111 1.4.2.2 thorpej rts
112 1.4.2.2 thorpej
113 1.4.2.2 thorpej #
114 1.4.2.2 thorpej # _060_imem_read(), _060_dmem_read():
115 1.4.2.2 thorpej #
116 1.4.2.2 thorpej # Reads from data/instruction memory while in supervisor mode.
117 1.4.2.2 thorpej #
118 1.4.2.2 thorpej # INPUTS:
119 1.4.2.2 thorpej # a0 - user source address
120 1.4.2.2 thorpej # a1 - supervisor destination address
121 1.4.2.2 thorpej # d0 - number of bytes to read
122 1.4.2.2 thorpej # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
123 1.4.2.2 thorpej # OUTPUTS:
124 1.4.2.2 thorpej # d1 - 0 = success, !0 = failure
125 1.4.2.2 thorpej #
126 1.4.2.2 thorpej .global _060_imem_read
127 1.4.2.2 thorpej .global _060_dmem_read
128 1.4.2.2 thorpej _060_imem_read:
129 1.4.2.2 thorpej _060_dmem_read:
130 1.4.2.2 thorpej btst #0x5,a6@(0x4) |# check for supervisor state
131 1.4.2.2 thorpej beqs user_read
132 1.4.2.2 thorpej super_read:
133 1.4.2.2 thorpej moveb a0@+,a1@+ |# copy 1 byte
134 1.4.2.2 thorpej subql #0x1,d0 |# decr byte counter
135 1.4.2.2 thorpej bnes super_read |# quit if ctr = 0
136 1.4.2.2 thorpej clrl d1 |# return success
137 1.4.2.2 thorpej rts
138 1.4.2.2 thorpej user_read:
139 1.4.2.2 thorpej movel d0,sp@- |# pass: counter
140 1.4.2.2 thorpej movel a1,sp@- |# pass: super dst
141 1.4.2.2 thorpej movel a0,sp@- |# pass: user src
142 1.4.2.2 thorpej bsrl _copyin |# read byte from user mem
143 1.4.2.2 thorpej movel d0,d1 |# return success
144 1.4.2.2 thorpej addl #0xc,sp |# clear 3 lw params
145 1.4.2.2 thorpej rts
146 1.4.2.2 thorpej
147 1.4.2.2 thorpej #
148 1.4.2.2 thorpej # _060_dmem_read_byte():
149 1.4.2.2 thorpej #
150 1.4.2.2 thorpej # Read a data byte from user memory.
151 1.4.2.2 thorpej #
152 1.4.2.2 thorpej # INPUTS:
153 1.4.2.2 thorpej # a0 - user source address
154 1.4.2.2 thorpej # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
155 1.4.2.2 thorpej # OUTPUTS:
156 1.4.2.2 thorpej # d0 - data byte in d0
157 1.4.2.2 thorpej # d1 - 0 = success, !0 = failure
158 1.4.2.2 thorpej #
159 1.4.2.2 thorpej .global _060_dmem_read_byte
160 1.4.2.2 thorpej _060_dmem_read_byte:
161 1.4.2.2 thorpej clrl d1 |# return success
162 1.4.2.2 thorpej clrl d0 |# clear whole longword
163 1.4.2.2 thorpej btst #0x5,a6@(0x4) |# check for supervisor state
164 1.4.2.2 thorpej bnes dmrbs |# supervisor
165 1.4.2.2 thorpej dmrbu:
166 1.4.2.2 thorpej movl _curpcb,a1 | fault handler
167 1.4.2.2 thorpej movl #Lferr,a1@(64) | set it
168 1.4.2.2 thorpej movsb a0@,d0
169 1.4.2.2 thorpej bra Lfdone
170 1.4.2.2 thorpej
171 1.4.2.2 thorpej dmrbs:
172 1.4.2.2 thorpej moveb a0@,d0 |# fetch super byte
173 1.4.2.2 thorpej clrl d1 |# return success
174 1.4.2.2 thorpej rts
175 1.4.2.2 thorpej
176 1.4.2.2 thorpej #
177 1.4.2.2 thorpej # _060_imem_read_word():
178 1.4.2.2 thorpej # Read an instruction word from user memory.
179 1.4.2.2 thorpej #
180 1.4.2.2 thorpej # _060_dmem_read_word():
181 1.4.2.2 thorpej # Read a data word from user memory.
182 1.4.2.2 thorpej #
183 1.4.2.2 thorpej # INPUTS:
184 1.4.2.2 thorpej # a0 - user source address
185 1.4.2.2 thorpej # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
186 1.4.2.2 thorpej # OUTPUTS:
187 1.4.2.2 thorpej # d0 - data word in d0
188 1.4.2.2 thorpej # d1 - 0 = success, !0 = failure
189 1.4.2.2 thorpej #
190 1.4.2.2 thorpej .global _060_imem_read_word
191 1.4.2.2 thorpej .global _060_dmem_read_word
192 1.4.2.2 thorpej
193 1.4.2.2 thorpej _060_imem_read_word:
194 1.4.2.2 thorpej _060_dmem_read_word:
195 1.4.2.2 thorpej clrl d1 |# return success
196 1.4.2.2 thorpej clrl d0 |# clear whole longword
197 1.4.2.2 thorpej btst #0x5,a6@(0x4) |# check for supervisor state
198 1.4.2.2 thorpej bnes dmrws |# supervisor
199 1.4.2.2 thorpej dmrwu:
200 1.4.2.2 thorpej movl _curpcb,a1 | fault handler
201 1.4.2.2 thorpej movl #Lferr,a1@(64) | set it
202 1.4.2.2 thorpej movsw a0@,d0
203 1.4.2.2 thorpej bra Lfdone
204 1.4.2.2 thorpej dmrws:
205 1.4.2.2 thorpej movew a0@,d0 |# fetch super word
206 1.4.2.2 thorpej rts
207 1.4.2.2 thorpej
208 1.4.2.2 thorpej #
209 1.4.2.2 thorpej # _060_imem_read_long():
210 1.4.2.2 thorpej # Read an instruction longword from user memory.
211 1.4.2.2 thorpej #
212 1.4.2.2 thorpej # _060_dmem_read_long():
213 1.4.2.2 thorpej # Read an data longword from user memory.
214 1.4.2.2 thorpej #
215 1.4.2.2 thorpej
216 1.4.2.2 thorpej #
217 1.4.2.2 thorpej # INPUTS:
218 1.4.2.2 thorpej # a0 - user source address
219 1.4.2.2 thorpej # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
220 1.4.2.2 thorpej # OUTPUTS:
221 1.4.2.2 thorpej # d0 - data longword in d0
222 1.4.2.2 thorpej # d1 - 0 = success, !0 = failure
223 1.4.2.2 thorpej #
224 1.4.2.2 thorpej
225 1.4.2.2 thorpej .global _060_dmem_read_long
226 1.4.2.2 thorpej .global _060_imem_read_long
227 1.4.2.2 thorpej
228 1.4.2.2 thorpej _060_imem_read_long:
229 1.4.2.2 thorpej _060_dmem_read_long:
230 1.4.2.2 thorpej clrl d1 |# return success
231 1.4.2.2 thorpej btst #0x5,a6@(0x4) |# check for supervisor state
232 1.4.2.2 thorpej bnes dmrls |# supervisor
233 1.4.2.2 thorpej dmrlu:
234 1.4.2.2 thorpej movl _curpcb,a1 | fault handler
235 1.4.2.2 thorpej movl #Lferr,a1@(64) | set it
236 1.4.2.2 thorpej movsl a0@,d0
237 1.4.2.2 thorpej bra Lfdone
238 1.4.2.2 thorpej dmrls:
239 1.4.2.2 thorpej movel a0@,d0 |# fetch super longword
240 1.4.2.2 thorpej clrl d1 |# return success
241 1.4.2.2 thorpej rts
242 1.4.2.2 thorpej
243 1.4.2.2 thorpej #
244 1.4.2.2 thorpej # _060_dmem_write_byte():
245 1.4.2.2 thorpej #
246 1.4.2.2 thorpej # Write a data byte to user memory.
247 1.4.2.2 thorpej #
248 1.4.2.2 thorpej # INPUTS:
249 1.4.2.2 thorpej # a0 - user destination address
250 1.4.2.2 thorpej # d0 - data byte in d0
251 1.4.2.2 thorpej # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
252 1.4.2.2 thorpej # OUTPUTS:
253 1.4.2.2 thorpej # d1 - 0 = success, !0 = failure
254 1.4.2.2 thorpej #
255 1.4.2.2 thorpej .global _060_dmem_write_byte
256 1.4.2.2 thorpej _060_dmem_write_byte:
257 1.4.2.2 thorpej clrl d1 |# return success
258 1.4.2.2 thorpej btst #0x5,a6@(0x4) |# check for supervisor state
259 1.4.2.2 thorpej bnes dmwbs |# supervisor
260 1.4.2.2 thorpej dmwbu:
261 1.4.2.2 thorpej movl _curpcb,a1 | fault handler
262 1.4.2.2 thorpej movl #Lferr,a1@(64) | set it
263 1.4.2.2 thorpej movsb d0,a0@
264 1.4.2.2 thorpej bra Lfdone
265 1.4.2.2 thorpej dmwbs:
266 1.4.2.2 thorpej moveb d0,a0@ |# store super byte
267 1.4.2.2 thorpej rts
268 1.4.2.2 thorpej
269 1.4.2.2 thorpej #
270 1.4.2.2 thorpej # _060_dmem_write_word():
271 1.4.2.2 thorpej #
272 1.4.2.2 thorpej # Write a data word to user memory.
273 1.4.2.2 thorpej #
274 1.4.2.2 thorpej # INPUTS:
275 1.4.2.2 thorpej # a0 - user destination address
276 1.4.2.2 thorpej # d0 - data word in d0
277 1.4.2.2 thorpej # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
278 1.4.2.2 thorpej # OUTPUTS:
279 1.4.2.2 thorpej # d1 - 0 = success, !0 = failure
280 1.4.2.2 thorpej #
281 1.4.2.2 thorpej .global _060_dmem_write_word
282 1.4.2.2 thorpej _060_dmem_write_word:
283 1.4.2.2 thorpej clrl d1 |# return success
284 1.4.2.2 thorpej btst #0x5,a6@(0x4) |# check for supervisor state
285 1.4.2.2 thorpej bnes dmwws |# supervisor
286 1.4.2.2 thorpej dmwwu:
287 1.4.2.2 thorpej movl _curpcb,a1 | fault handler
288 1.4.2.2 thorpej movl #Lferr,a1@(64) | set it
289 1.4.2.2 thorpej movsw d0,a0@
290 1.4.2.2 thorpej bra Lfdone
291 1.4.2.2 thorpej dmwws:
292 1.4.2.2 thorpej movew d0,a0@ |# store super word
293 1.4.2.2 thorpej rts
294 1.4.2.2 thorpej
295 1.4.2.2 thorpej #
296 1.4.2.2 thorpej # _060_dmem_write_long():
297 1.4.2.2 thorpej #
298 1.4.2.2 thorpej # Write a data longword to user memory.
299 1.4.2.2 thorpej #
300 1.4.2.2 thorpej # INPUTS:
301 1.4.2.2 thorpej # a0 - user destination address
302 1.4.2.2 thorpej # d0 - data longword in d0
303 1.4.2.2 thorpej # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
304 1.4.2.2 thorpej # OUTPUTS:
305 1.4.2.2 thorpej # d1 - 0 = success, !0 = failure
306 1.4.2.2 thorpej #
307 1.4.2.2 thorpej .global _060_dmem_write_long
308 1.4.2.2 thorpej _060_dmem_write_long:
309 1.4.2.2 thorpej clrl d1 |# return success
310 1.4.2.2 thorpej btst #0x5,a6@(0x4) |# check for supervisor state
311 1.4.2.2 thorpej bnes dmwls |# supervisor
312 1.4.2.2 thorpej dmwlu:
313 1.4.2.2 thorpej movl _curpcb,a1 | fault handler
314 1.4.2.2 thorpej movl #Lferr,a1@(64) | set it
315 1.4.2.2 thorpej movsl d0,a0@
316 1.4.2.2 thorpej bra Lfdone
317 1.4.2.2 thorpej dmwls:
318 1.4.2.2 thorpej movel d0,a0@ |# store super longword
319 1.4.2.2 thorpej rts
320 1.4.2.2 thorpej
321 1.4.2.2 thorpej ############################################################################
322 1.4.2.2 thorpej Lferr:
323 1.4.2.2 thorpej moveq #-1,d1
324 1.4.2.2 thorpej Lfdone:
325 1.4.2.2 thorpej clrl a1@(64) | clear fault handler
326 1.4.2.2 thorpej rts
327 1.4.2.2 thorpej
328 1.4.2.2 thorpej ############################################################################
329 1.4.2.2 thorpej
330 1.4.2.2 thorpej #
331 1.4.2.2 thorpej # _060_real_trace():
332 1.4.2.2 thorpej #
333 1.4.2.2 thorpej # This is the exit point for the 060FPSP when an instruction is being traced
334 1.4.2.2 thorpej # and there are no other higher priority exceptions pending for this instruction
335 1.4.2.2 thorpej # or they have already been processed.
336 1.4.2.2 thorpej #
337 1.4.2.2 thorpej # The sample code below simply executes an "rte".
338 1.4.2.2 thorpej #
339 1.4.2.2 thorpej .global _060_real_trace,_trace
340 1.4.2.2 thorpej _060_real_trace:
341 1.4.2.2 thorpej jra _trace
342 1.4.2.2 thorpej
343 1.4.2.2 thorpej #
344 1.4.2.2 thorpej # _060_real_access():
345 1.4.2.2 thorpej #
346 1.4.2.2 thorpej # This is the exit point for the 060FPSP when an access error exception
347 1.4.2.2 thorpej # is encountered. The routine below should point to the operating system
348 1.4.2.2 thorpej # handler for access error exceptions. The exception stack frame is an
349 1.4.2.2 thorpej # 8-word access error frame.
350 1.4.2.2 thorpej #
351 1.4.2.2 thorpej # We jump directly to the 68060 buserr handler.
352 1.4.2.2 thorpej # If we had a sane ld, we could use use that entry point directly...
353 1.4.2.2 thorpej #
354 1.4.2.2 thorpej .globl _060_real_access,_buserr60
355 1.4.2.2 thorpej _060_real_access:
356 1.4.2.2 thorpej jra _buserr60
357 1.4.2.2 thorpej
358 1.4.2.2 thorpej .include "inetbsd.S"
359 1.4.2.2 thorpej .include "fnetbsd.S"
360