netbsd060sp.S revision 1.5.18.1 1 /*
2 #
3 # $NetBSD: netbsd060sp.S,v 1.5.18.1 2001/04/24 22:32:08 he Exp $
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 # Derived from:
39 # os.s
40 #
41 # This file contains:
42 # - example "Call-Out"s required by both the ISP and FPSP.
43 #
44 */
45
46 #include <machine/asm.h>
47
48 /*
49 #
50 # make the copyright notice appear in the binary:
51 #
52 */
53 #include "copyright.S"
54
55 /*
56 #################################
57 # EXAMPLE CALL-OUTS #
58 # #
59 # _060_dmem_write() #
60 # _060_dmem_read() #
61 # _060_imem_read() #
62 # _060_dmem_read_byte() #
63 # _060_dmem_read_word() #
64 # _060_dmem_read_long() #
65 # _060_imem_read_word() #
66 # _060_imem_read_long() #
67 # _060_dmem_write_byte() #
68 # _060_dmem_write_word() #
69 # _060_dmem_write_long() #
70 # #
71 # _060_real_trace() #
72 # _060_real_access() #
73 #################################
74 */
75
76 /*
77 #
78 # Each IO routine checks to see if the memory write/read is to/from user
79 # or supervisor application space. The examples below use simple "move"
80 # instructions for supervisor mode applications and call _copyin()/_copyout()
81 # for user mode applications.
82 # When installing the 060SP, the _copyin()/_copyout() equivalents for a
83 # given operating system should be substituted.
84 #
85 # The addresses within the 060SP are guaranteed to be on the stack.
86 # The result is that Unix processes are allowed to sleep as a consequence
87 # of a page fault during a _copyout.
88 #
89 */
90
91 /*
92 #
93 # _060_dmem_write():
94 #
95 # Writes to data memory while in supervisor mode.
96 #
97 # INPUTS:
98 # a0 - supervisor source address
99 # a1 - user destination address
100 # d0 - number of bytes to write
101 # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
102 # OUTPUTS:
103 # d1 - 0 = success, !0 = failure
104 #
105 */
106 ASENTRY_NOPROFILE(_060_dmem_write)
107 btst #0x5,%a6@(0x4) |# check for supervisor state
108 beqs user_write
109 super_write:
110 moveb %a0@+,%a1@+ |# copy 1 byte
111 subql #0x1,%d0 |# decr byte counter
112 bnes super_write |# quit if ctr = 0
113 clrl %d1 |# return success
114 rts
115 user_write:
116 movel %d0,%sp@- |# pass: counter
117 movel %a1,%sp@- |# pass: user dst
118 movel %a0,%sp@- |# pass: supervisor src
119 bsrl _C_LABEL(copyout) |# write byte to user mem
120 movel %d0,%d1 |# return success
121 addl #0xc,%sp |# clear 3 lw params
122 rts
123
124 /*
125 #
126 # _060_imem_read(), _060_dmem_read():
127 #
128 # Reads from data/instruction memory while in supervisor mode.
129 #
130 # INPUTS:
131 # a0 - user source address
132 # a1 - supervisor destination address
133 # d0 - number of bytes to read
134 # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
135 # OUTPUTS:
136 # d1 - 0 = success, !0 = failure
137 #
138 */
139 ASENTRY_NOPROFILE(_060_imem_read)
140 ASENTRY_NOPROFILE(_060_dmem_read)
141 btst #0x5,%a6@(0x4) |# check for supervisor state
142 beqs user_read
143 super_read:
144 moveb %a0@+,%a1@+ |# copy 1 byte
145 subql #0x1,%d0 |# decr byte counter
146 bnes super_read |# quit if ctr = 0
147 clrl %d1 |# return success
148 rts
149 user_read:
150 movel %d0,%sp@- |# pass: counter
151 movel %a1,%sp@- |# pass: super dst
152 movel %a0,%sp@- |# pass: user src
153 bsrl _C_LABEL(copyin) |# read byte from user mem
154 movel %d0,%d1 |# return success
155 addl #0xc,%sp |# clear 3 lw params
156 rts
157
158 /*
159 #
160 # _060_dmem_read_byte():
161 #
162 # Read a data byte from user memory.
163 #
164 # INPUTS:
165 # a0 - user source address
166 # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
167 # OUTPUTS:
168 # d0 - data byte in d0
169 # d1 - 0 = success, !0 = failure
170 #
171 */
172 ASENTRY_NOPROFILE(_060_dmem_read_byte)
173 clrl %d1 |# return success
174 clrl %d0 |# clear whole longword
175 btst #0x5,%a6@(0x4) |# check for supervisor state
176 bnes dmrbs |# supervisor
177 dmrbu:
178 movl _C_LABEL(curpcb),%a1 | fault handler
179 movl #Lferr,%a1@(64) | set it
180 movsb %a0@,%d0
181 bra Lfdone
182
183 dmrbs:
184 moveb %a0@,%d0 |# fetch super byte
185 rts
186
187 /*
188 #
189 # _060_imem_read_word():
190 # Read an instruction word from user memory.
191 #
192 # _060_dmem_read_word():
193 # Read a data word from user memory.
194 #
195 # INPUTS:
196 # a0 - user source address
197 # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
198 # OUTPUTS:
199 # d0 - data word in d0
200 # d1 - 0 = success, !0 = failure
201 #
202 */
203 ASENTRY_NOPROFILE(_060_imem_read_word)
204 ASENTRY_NOPROFILE(_060_dmem_read_word)
205 clrl %d1 |# return success
206 clrl %d0 |# clear whole longword
207 btst #0x5,%a6@(0x4) |# check for supervisor state
208 bnes dmrws |# supervisor
209 dmrwu:
210 movl _C_LABEL(curpcb),%a1 | fault handler
211 movl #Lferr,%a1@(64) | set it
212 movsw %a0@,%d0
213 bra Lfdone
214 dmrws:
215 movew %a0@,%d0 |# fetch super word
216 rts
217
218 /*
219 #
220 # _060_imem_read_long():
221 # Read an instruction longword from user memory.
222 #
223 # _060_dmem_read_long():
224 # Read an data longword from user memory.
225 #
226 #
227 # INPUTS:
228 # a0 - user source address
229 # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
230 # OUTPUTS:
231 # d0 - data longword in d0
232 # d1 - 0 = success, !0 = failure
233 #
234 */
235 ASENTRY_NOPROFILE(_060_imem_read_long)
236 ASENTRY_NOPROFILE(_060_dmem_read_long)
237 clrl %d1 |# return success
238 btst #0x5,%a6@(0x4) |# check for supervisor state
239 bnes dmrls |# supervisor
240 dmrlu:
241 movl _C_LABEL(curpcb),%a1 | fault handler
242 movl #Lferr,%a1@(64) | set it
243 movsl %a0@,%d0
244 bra Lfdone
245 dmrls:
246 movel %a0@,%d0 |# fetch super longword
247 rts
248
249 /*
250 #
251 # _060_dmem_write_byte():
252 #
253 # Write a data byte to user memory.
254 #
255 # INPUTS:
256 # a0 - user destination address
257 # d0 - data byte in d0
258 # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
259 # OUTPUTS:
260 # d1 - 0 = success, !0 = failure
261 #
262 */
263 ASENTRY_NOPROFILE(_060_dmem_write_byte)
264 clrl %d1 |# return success
265 btst #0x5,%a6@(0x4) |# check for supervisor state
266 bnes dmwbs |# supervisor
267 dmwbu:
268 movl _C_LABEL(curpcb),%a1 | fault handler
269 movl #Lferr,%a1@(64) | set it
270 movsb %d0,%a0@
271 bra Lfdone
272 dmwbs:
273 moveb %d0,%a0@ |# store super byte
274 rts
275
276 /*
277 #
278 # _060_dmem_write_word():
279 #
280 # Write a data word to user memory.
281 #
282 # INPUTS:
283 # a0 - user destination address
284 # d0 - data word in d0
285 # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
286 # OUTPUTS:
287 # d1 - 0 = success, !0 = failure
288 #
289 */
290 ASENTRY_NOPROFILE(_060_dmem_write_word)
291 clrl %d1 |# return success
292 btst #0x5,%a6@(0x4) |# check for supervisor state
293 bnes dmwws |# supervisor
294 dmwwu:
295 movl _C_LABEL(curpcb),%a1 | fault handler
296 movl #Lferr,%a1@(64) | set it
297 movsw %d0,%a0@
298 bra Lfdone
299 dmwws:
300 movew %d0,%a0@ |# store super word
301 rts
302
303 /*
304 #
305 # _060_dmem_write_long():
306 #
307 # Write a data longword to user memory.
308 #
309 # INPUTS:
310 # a0 - user destination address
311 # d0 - data longword in d0
312 # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
313 # OUTPUTS:
314 # d1 - 0 = success, !0 = failure
315 #
316 */
317 ASENTRY_NOPROFILE(_060_dmem_write_long)
318 clrl %d1 |# return success
319 btst #0x5,%a6@(0x4) |# check for supervisor state
320 bnes dmwls |# supervisor
321 dmwlu:
322 movl _C_LABEL(curpcb),%a1 | fault handler
323 movl #Lferr,%a1@(64) | set it
324 movsl %d0,%a0@
325 bra Lfdone
326 dmwls:
327 movel %d0,%a0@ |# store super longword
328 rts
329
330 |############################################################################
331 Lferr:
332 moveq #-1,%d1
333 Lfdone:
334 clrl %a1@(64) | clear fault handler
335 rts
336
337 |############################################################################
338
339 /*
340 #
341 # _060_real_trace():
342 #
343 # This is the exit point for the 060FPSP when an instruction is being traced
344 # and there are no other higher priority exceptions pending for this instruction
345 # or they have already been processed.
346 #
347 # The sample code below simply executes an "rte".
348 #
349 */
350 ASENTRY_NOPROFILE(_060_real_trace)
351 jra _C_LABEL(trace)
352
353 /*
354 #
355 # _060_real_access():
356 #
357 # This is the exit point for the 060FPSP when an access error exception
358 # is encountered. The routine below should point to the operating system
359 # handler for access error exceptions. The exception stack frame is an
360 # 8-word access error frame.
361 #
362 # We jump directly to the 68060 buserr handler.
363 # If we had a sane ld, we could use use that entry point directly...
364 #
365 */
366 ASENTRY_NOPROFILE(_060_real_access)
367 jra _C_LABEL(buserr60)
368
369 #include "inetbsd.S"
370 #include "fnetbsd.S"
371