3 # $NetBSD: netbsd060sp.S,v 1.6 2000/11/30 21:00:51 scw Exp $
5 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6 # MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
7 # M68000 Hi-Performance Microprocessor Division
8 # M68060 Software Package Production Release
10 # M68060 Software Package Copyright (C) 1993, 1994, 1995, 1996 Motorola Inc.
11 # All rights reserved.
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.
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.
27 # Motorola assumes no responsibility for the maintenance and support
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 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42 # - example "Call-Out"s required by both the ISP and FPSP.
46 #include <machine/asm.h>
52 # make the copyright notice appear in the binary:
55 #include "copyright.S"
58 #################################
64 # _060_dmem_read_byte() #
65 # _060_dmem_read_word() #
66 # _060_dmem_read_long() #
67 # _060_imem_read_word() #
68 # _060_imem_read_long() #
69 # _060_dmem_write_byte() #
70 # _060_dmem_write_word() #
71 # _060_dmem_write_long() #
74 # _060_real_access() #
75 #################################
80 # Each IO routine checks to see if the memory write/read is to/from user
81 # or supervisor application space. The examples below use simple "move"
82 # instructions for supervisor mode applications and call _copyin()/_copyout()
83 # for user mode applications.
84 # When installing the 060SP, the _copyin()/_copyout() equivalents for a
85 # given operating system should be substituted.
87 # The addresses within the 060SP are guaranteed to be on the stack.
88 # The result is that Unix processes are allowed to sleep as a consequence
89 # of a page fault during a _copyout.
97 # Writes to data memory while in supervisor mode.
100 # a0 - supervisor source address
101 # a1 - user destination address
102 # d0 - number of bytes to write
103 # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
105 # d1 - 0 = success, !0 = failure
108 ASENTRY_NOPROFILE(_060_dmem_write)
109 btst #0x5,%a6@(0x4) |# check for supervisor state
112 moveb %a0@+,%a1@+ |# copy 1 byte
113 subql #0x1,%d0 |# decr byte counter
114 bnes super_write |# quit if ctr = 0
115 clrl %d1 |# return success
118 movel %d0,%sp@- |# pass: counter
119 movel %a1,%sp@- |# pass: user dst
120 movel %a0,%sp@- |# pass: supervisor src
121 bsrl _C_LABEL(copyout) |# write byte to user mem
122 movel %d0,%d1 |# return success
123 addl #0xc,%sp |# clear 3 lw params
128 # _060_imem_read(), _060_dmem_read():
130 # Reads from data/instruction memory while in supervisor mode.
133 # a0 - user source address
134 # a1 - supervisor destination address
135 # d0 - number of bytes to read
136 # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
138 # d1 - 0 = success, !0 = failure
141 ASENTRY_NOPROFILE(_060_imem_read)
142 ASENTRY_NOPROFILE(_060_dmem_read)
143 btst #0x5,%a6@(0x4) |# check for supervisor state
146 moveb %a0@+,%a1@+ |# copy 1 byte
147 subql #0x1,%d0 |# decr byte counter
148 bnes super_read |# quit if ctr = 0
149 clrl %d1 |# return success
152 movel %d0,%sp@- |# pass: counter
153 movel %a1,%sp@- |# pass: super dst
154 movel %a0,%sp@- |# pass: user src
155 bsrl _C_LABEL(copyin) |# read byte from user mem
156 movel %d0,%d1 |# return success
157 addl #0xc,%sp |# clear 3 lw params
162 # _060_dmem_read_byte():
164 # Read a data byte from user memory.
167 # a0 - user source address
168 # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
170 # d0 - data byte in d0
171 # d1 - 0 = success, !0 = failure
174 ASENTRY_NOPROFILE(_060_dmem_read_byte)
175 clrl %d1 |# return success
176 clrl %d0 |# clear whole longword
177 btst #0x5,%a6@(0x4) |# check for supervisor state
178 bnes dmrbs |# supervisor
180 movl _C_LABEL(curpcb),%a1 | fault handler
181 movl #Lferr,%a1@(PCB_ONFAULT)| set it
186 moveb %a0@,%d0 |# fetch super byte
191 # _060_imem_read_word():
192 # Read an instruction word from user memory.
194 # _060_dmem_read_word():
195 # Read a data word from user memory.
198 # a0 - user source address
199 # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
201 # d0 - data word in d0
202 # d1 - 0 = success, !0 = failure
205 ASENTRY_NOPROFILE(_060_imem_read_word)
206 ASENTRY_NOPROFILE(_060_dmem_read_word)
207 clrl %d1 |# return success
208 clrl %d0 |# clear whole longword
209 btst #0x5,%a6@(0x4) |# check for supervisor state
210 bnes dmrws |# supervisor
212 movl _C_LABEL(curpcb),%a1 | fault handler
213 movl #Lferr,%a1@(PCB_ONFAULT)| set it
217 movew %a0@,%d0 |# fetch super word
222 # _060_imem_read_long():
223 # Read an instruction longword from user memory.
225 # _060_dmem_read_long():
226 # Read an data longword from user memory.
230 # a0 - user source address
231 # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
233 # d0 - data longword in d0
234 # d1 - 0 = success, !0 = failure
237 ASENTRY_NOPROFILE(_060_imem_read_long)
238 ASENTRY_NOPROFILE(_060_dmem_read_long)
239 clrl %d1 |# return success
240 btst #0x5,%a6@(0x4) |# check for supervisor state
241 bnes dmrls |# supervisor
243 movl _C_LABEL(curpcb),%a1 | fault handler
244 movl #Lferr,%a1@(PCB_ONFAULT)| set it
248 movel %a0@,%d0 |# fetch super longword
253 # _060_dmem_write_byte():
255 # Write a data byte to user memory.
258 # a0 - user destination address
259 # d0 - data byte in d0
260 # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
262 # d1 - 0 = success, !0 = failure
265 ASENTRY_NOPROFILE(_060_dmem_write_byte)
266 clrl %d1 |# return success
267 btst #0x5,%a6@(0x4) |# check for supervisor state
268 bnes dmwbs |# supervisor
270 movl _C_LABEL(curpcb),%a1 | fault handler
271 movl #Lferr,%a1@(PCB_ONFAULT)| set it
275 moveb %d0,%a0@ |# store super byte
280 # _060_dmem_write_word():
282 # Write a data word to user memory.
285 # a0 - user destination address
286 # d0 - data word in d0
287 # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
289 # d1 - 0 = success, !0 = failure
292 ASENTRY_NOPROFILE(_060_dmem_write_word)
293 clrl %d1 |# return success
294 btst #0x5,%a6@(0x4) |# check for supervisor state
295 bnes dmwws |# supervisor
297 movl _C_LABEL(curpcb),%a1 | fault handler
298 movl #Lferr,%a1@(PCB_ONFAULT)| set it
302 movew %d0,%a0@ |# store super word
307 # _060_dmem_write_long():
309 # Write a data longword to user memory.
312 # a0 - user destination address
313 # d0 - data longword in d0
314 # a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
316 # d1 - 0 = success, !0 = failure
319 ASENTRY_NOPROFILE(_060_dmem_write_long)
320 clrl %d1 |# return success
321 btst #0x5,%a6@(0x4) |# check for supervisor state
322 bnes dmwls |# supervisor
324 movl _C_LABEL(curpcb),%a1 | fault handler
325 movl #Lferr,%a1@(PCB_ONFAULT)| set it
329 movel %d0,%a0@ |# store super longword
332 |############################################################################
336 clrl %a1@(PCB_ONFAULT) | clear fault handler
339 |############################################################################
345 # This is the exit point for the 060FPSP when an instruction is being traced
346 # and there are no other higher priority exceptions pending for this instruction
347 # or they have already been processed.
349 # The sample code below simply executes an "rte".
352 ASENTRY_NOPROFILE(_060_real_trace)
357 # _060_real_access():
359 # This is the exit point for the 060FPSP when an access error exception
360 # is encountered. The routine below should point to the operating system
361 # handler for access error exceptions. The exception stack frame is an
362 # 8-word access error frame.
364 # We jump directly to the 68060 buserr handler.
365 # If we had a sane ld, we could use use that entry point directly...
368 ASENTRY_NOPROFILE(_060_real_access)
369 jra _C_LABEL(buserr60)