Home | History | Annotate | Line # | Download | only in 060sp
      1 /*
      2 #
      3 # $NetBSD: netbsd060sp.S,v 1.8 2024/09/08 09:36:49 rillig 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 #include "assym.h"
     49 
     50 /*
     51 #
     52 # make the copyright notice appear in the binary:
     53 #
     54 */
     55 #include "copyright.S"
     56 
     57 /*
     58 #################################
     59 # EXAMPLE CALL-OUTS 		#
     60 # 				#
     61 # _060_dmem_write()		#
     62 # _060_dmem_read()		#
     63 # _060_imem_read()		#
     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()	#
     72 #				#
     73 # _060_real_trace()		#
     74 # _060_real_access()		#
     75 #################################
     76 */
     77 
     78 /*
     79 #
     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.
     86 #
     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.
     90 #
     91 */
     92 
     93 /*
     94 #
     95 # _060_dmem_write():
     96 #
     97 # Writes to data memory while in supervisor mode.
     98 #
     99 # INPUTS:
    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
    104 # OUTPUTS:
    105 #	d1 - 0 = success, !0 = failure
    106 #
    107 */
    108 ASENTRY_NOPROFILE(_060_dmem_write)
    109 	btst	#0x5,%a6@(0x4)	|# check for supervisor state
    110 	beqs	user_write
    111 super_write:
    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
    116 	rts
    117 user_write:
    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
    124 	rts
    125 
    126 /*
    127 #
    128 # _060_imem_read(), _060_dmem_read():
    129 #
    130 # Reads from data/instruction memory while in supervisor mode.
    131 #
    132 # INPUTS:
    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
    137 # OUTPUTS:
    138 #	d1 - 0 = success, !0 = failure
    139 #
    140 */
    141 ASENTRY_NOPROFILE(_060_imem_read)
    142 ASENTRY_NOPROFILE(_060_dmem_read)
    143 	btst	#0x5,%a6@(0x4)	|# check for supervisor state
    144 	beqs	user_read
    145 super_read:
    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
    150 	rts
    151 user_read:
    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
    158 	rts
    159 
    160 /*
    161 #
    162 # _060_dmem_read_byte():
    163 #
    164 # Read a data byte from user memory.
    165 #
    166 # INPUTS:
    167 #	a0 - user source address
    168 # 	a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
    169 # OUTPUTS:
    170 #	d0 - data byte in d0
    171 #	d1 - 0 = success, !0 = failure
    172 #
    173 */
    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
    179 dmrbu:
    180 	movl	_C_LABEL(curpcb),%a1	| fault handler
    181 	movl	#Lferr,%a1@(PCB_ONFAULT)| set it
    182 	movsb	%a0@,%d0
    183 	bra	Lfdone
    184 
    185 dmrbs:
    186 	moveb	%a0@,%d0		|# fetch super byte
    187 	rts
    188 
    189 /*
    190 #
    191 # _060_imem_read_word():
    192 # Read an instruction word from user memory.
    193 #
    194 # _060_dmem_read_word():
    195 # Read a data word from user memory.
    196 #
    197 # INPUTS:
    198 #	a0 - user source address
    199 # 	a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
    200 # OUTPUTS:
    201 #	d0 - data word in d0
    202 #	d1 - 0 = success, !0 = failure
    203 #
    204 */
    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
    211 dmrwu:
    212 	movl	_C_LABEL(curpcb),%a1	| fault handler
    213 	movl	#Lferr,%a1@(PCB_ONFAULT)| set it
    214 	movsw	%a0@,%d0
    215 	bra	Lfdone
    216 dmrws:
    217 	movew	%a0@,%d0		|# fetch super word
    218 	rts
    219 
    220 /*
    221 #
    222 # _060_imem_read_long():
    223 # Read an instruction longword from user memory.
    224 #
    225 # _060_dmem_read_long():
    226 # Read a data longword from user memory.
    227 #
    228 #
    229 # INPUTS:
    230 #	a0 - user source address
    231 # 	a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
    232 # OUTPUTS:
    233 #	d0 - data longword in d0
    234 #	d1 - 0 = success, !0 = failure
    235 #
    236 */
    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
    242 dmrlu:
    243 	movl	_C_LABEL(curpcb),%a1	| fault handler
    244 	movl	#Lferr,%a1@(PCB_ONFAULT)| set it
    245 	movsl	%a0@,%d0
    246 	bra	Lfdone
    247 dmrls:
    248 	movel	%a0@,%d0		|# fetch super longword
    249 	rts
    250 
    251 /*
    252 #
    253 # _060_dmem_write_byte():
    254 #
    255 # Write a data byte to user memory.
    256 #
    257 # INPUTS:
    258 #	a0 - user destination address
    259 # 	d0 - data byte in d0
    260 # 	a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
    261 # OUTPUTS:
    262 #	d1 - 0 = success, !0 = failure
    263 #
    264 */
    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
    269 dmwbu:
    270 	movl	_C_LABEL(curpcb),%a1	| fault handler
    271 	movl	#Lferr,%a1@(PCB_ONFAULT)| set it
    272 	movsb	%d0,%a0@
    273 	bra	Lfdone
    274 dmwbs:
    275 	moveb	%d0,%a0@		|# store super byte
    276 	rts
    277 
    278 /*
    279 #
    280 # _060_dmem_write_word():
    281 #
    282 # Write a data word to user memory.
    283 #
    284 # INPUTS:
    285 #	a0 - user destination address
    286 # 	d0 - data word in d0
    287 # 	a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
    288 # OUTPUTS:
    289 #	d1 - 0 = success, !0 = failure
    290 #
    291 */
    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
    296 dmwwu:
    297 	movl	_C_LABEL(curpcb),%a1	| fault handler
    298 	movl	#Lferr,%a1@(PCB_ONFAULT)| set it
    299 	movsw	%d0,%a0@
    300 	bra	Lfdone
    301 dmwws:
    302 	movew	%d0,%a0@		|# store super word
    303 	rts
    304 
    305 /*
    306 #
    307 # _060_dmem_write_long():
    308 #
    309 # Write a data longword to user memory.
    310 #
    311 # INPUTS:
    312 #	a0 - user destination address
    313 # 	d0 - data longword in d0
    314 # 	a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
    315 # OUTPUTS:
    316 #	d1 - 0 = success, !0 = failure
    317 #
    318 */
    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
    323 dmwlu:
    324 	movl	_C_LABEL(curpcb),%a1	| fault handler
    325 	movl	#Lferr,%a1@(PCB_ONFAULT)| set it
    326 	movsl	%d0,%a0@
    327 	bra	Lfdone
    328 dmwls:
    329 	movel	%d0,%a0@		|# store super longword
    330 	rts
    331 
    332 |############################################################################
    333 Lferr:
    334 	moveq	#-1,%d1
    335 Lfdone:
    336 	clrl	%a1@(PCB_ONFAULT)	| clear fault handler
    337 	rts
    338 
    339 |############################################################################
    340 
    341 /*
    342 #
    343 # _060_real_trace():
    344 #
    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.
    348 #
    349 # The sample code below simply executes an "rte".
    350 #
    351 */
    352 ASENTRY_NOPROFILE(_060_real_trace)
    353 	jra	_C_LABEL(trace)
    354 
    355 /*
    356 #
    357 # _060_real_access():
    358 #
    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.
    363 #
    364 # We jump directly to the 68060 buserr handler.
    365 # If we had a sane ld, we could use use that entry point directly...
    366 #
    367 */
    368 ASENTRY_NOPROFILE(_060_real_access)
    369 	jra	_C_LABEL(buserr60)
    370 
    371 #include "inetbsd.S"
    372 #include "fnetbsd.S"
    373