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