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