Home | History | Annotate | Line # | Download | only in 060sp
netbsd060sp.S revision 1.2
      1  1.1  is #
      2  1.2  is # $NetBSD: netbsd060sp.S,v 1.2 1997/06/26 22:28:42 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.2  is 	btst	#0x5,a6@(0x4)	|# check for supervisor state
    162  1.1  is 	bnes	dmrbs		|# supervisor
    163  1.1  is dmrbu:
    164  1.1  is 	clrl	sp@-		|# clear space on stack for result
    165  1.2  is 	movel	#0x1,sp@-	|# pass: # bytes to copy
    166  1.2  is 	pea	sp@(0x7)	|# pass: dst addr (stack)
    167  1.1  is 	movel	a0,sp@-		|# pass: src addr (user mem)
    168  1.1  is 	bsrl	_copyin		|# "copy in" the data
    169  1.1  is 	movel	d0,d1		|# return success
    170  1.1  is 	addl	#0xc,sp		|# delete params
    171  1.1  is 	movel	sp@+,d0		|# put answer in d0
    172  1.1  is 	rts
    173  1.1  is dmrbs:
    174  1.1  is 	clrl	d0		|# clear whole longword
    175  1.1  is 	moveb	a0@,d0		|# fetch super byte
    176  1.1  is 	clrl	d1		|# return success
    177  1.1  is 	rts
    178  1.1  is 
    179  1.1  is #
    180  1.1  is # _060_imem_read_word():
    181  1.1  is # Read an instruction word from user memory.
    182  1.1  is #
    183  1.1  is # _060_dmem_read_word():
    184  1.1  is # Read a data word from user memory.
    185  1.1  is #
    186  1.1  is # INPUTS:
    187  1.1  is #	a0 - user source address
    188  1.1  is # 	a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
    189  1.1  is # OUTPUTS:
    190  1.1  is #	d0 - data word in d0
    191  1.1  is #	d1 - 0 = success, !0 = failure
    192  1.1  is #
    193  1.1  is 	.global	_060_imem_read_word
    194  1.1  is 	.global	_060_dmem_read_word
    195  1.1  is 
    196  1.1  is _060_imem_read_word:
    197  1.1  is _060_dmem_read_word:
    198  1.2  is 	btst	#0x5,a6@(0x4)	|# check for supervisor state
    199  1.1  is 	bnes	dmrws		|# supervisor
    200  1.1  is dmrwu:
    201  1.1  is 	clrl	sp@-		|# clear result space on stack
    202  1.2  is 	movel	#0x2,sp@-	|# pass: # bytes to copy
    203  1.2  is 	pea	sp@(0x6)	|# pass: dst addr (stack)
    204  1.1  is 	movel	a0,sp@-		|# pass: src addr (user mem)
    205  1.1  is 	bsrl	_copyin		|# "copy in" the data
    206  1.1  is 	movel	d0,d1		|# return success
    207  1.1  is 	addl	#0xc,sp		|# delete params
    208  1.1  is 	movel	sp@+,d0		|# put answer in d0
    209  1.1  is 	rts
    210  1.1  is dmrws:
    211  1.1  is 	clrl	d0		|# clear whole longword
    212  1.1  is 	movew	a0@,d0		|# fetch super word
    213  1.1  is 	clrl	d1		|# return success
    214  1.1  is 	rts
    215  1.1  is 
    216  1.1  is #
    217  1.1  is # _060_imem_read_long():
    218  1.1  is # Read an instruction longword from user memory.
    219  1.1  is #
    220  1.1  is # _060_dmem_read_long():
    221  1.1  is # Read an data longword from user memory.
    222  1.1  is #
    223  1.1  is 
    224  1.1  is #
    225  1.1  is # INPUTS:
    226  1.1  is #	a0 - user source address
    227  1.1  is # 	a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
    228  1.1  is # OUTPUTS:
    229  1.1  is #	d0 - data longword in d0
    230  1.1  is #	d1 - 0 = success, !0 = failure
    231  1.1  is #
    232  1.1  is 
    233  1.1  is 	.global	_060_dmem_read_long
    234  1.1  is 	.global	_060_imem_read_long
    235  1.1  is 
    236  1.1  is _060_imem_read_long:
    237  1.1  is _060_dmem_read_long:
    238  1.2  is 	btst	#0x5,a6@(0x4)	|# check for supervisor state
    239  1.1  is 	bnes	dmrls		|# supervisor
    240  1.1  is dmrlu:
    241  1.1  is 	subql	#0x4,sp		|# clear result space on stack
    242  1.2  is 	movel	#0x4,sp@-	|# pass: # bytes to copy
    243  1.2  is 	pea	sp@(0x4)	|# pass: dst addr (stack)
    244  1.1  is 	movel	a0,sp@-		|# pass: src addr (user mem)
    245  1.1  is 	bsrl	_copyin		|# "copy in" the data
    246  1.1  is 	movel	d0,d1		|# return success
    247  1.1  is 	addl	#0xc,sp		|# delete params
    248  1.1  is 	movel	sp@+,d0		|# put answer in d0
    249  1.1  is 	rts
    250  1.1  is dmrls:
    251  1.1  is 	movel	a0@,d0		|# fetch super longword
    252  1.1  is 	clrl	d1		|# return success
    253  1.1  is 	rts
    254  1.1  is 
    255  1.1  is #
    256  1.1  is # _060_dmem_write_byte():
    257  1.1  is #
    258  1.1  is # Write a data byte to user memory.
    259  1.1  is #
    260  1.1  is # INPUTS:
    261  1.1  is #	a0 - user destination address
    262  1.1  is # 	d0 - data byte in d0
    263  1.1  is # 	a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
    264  1.1  is # OUTPUTS:
    265  1.1  is #	d1 - 0 = success, !0 = failure
    266  1.1  is #
    267  1.1  is 	.global	_060_dmem_write_byte
    268  1.1  is _060_dmem_write_byte:
    269  1.2  is 	btst	#0x5,a6@(0x4)	|# check for supervisor state
    270  1.1  is 	bnes	dmwbs		|# supervisor
    271  1.1  is dmwbu:
    272  1.1  is 	movel	d0,sp@-		|# put src on stack
    273  1.2  is 	movel	#0x1,sp@-	|# pass: # bytes to copy
    274  1.1  is 	movel	a0,sp@-		|# pass: dst addr (user mem)
    275  1.2  is 	pea	sp@(0xb)	|# pass: src addr (stack)
    276  1.2  is 	bsrl	_copyout	|# "copy out" the data
    277  1.1  is 	movel	d0,d1		|# return success
    278  1.2  is 	addl	#0x10,sp	|# delete params + src
    279  1.1  is 	rts
    280  1.1  is dmwbs:
    281  1.1  is 	moveb	d0,a0@		|# store super byte
    282  1.1  is 	clrl	d1		|# return success
    283  1.1  is 	rts
    284  1.1  is 
    285  1.1  is #
    286  1.1  is # _060_dmem_write_word():
    287  1.1  is #
    288  1.1  is # Write a data word to user memory.
    289  1.1  is #
    290  1.1  is # INPUTS:
    291  1.1  is #	a0 - user destination address
    292  1.1  is # 	d0 - data word in d0
    293  1.1  is # 	a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
    294  1.1  is # OUTPUTS:
    295  1.1  is #	d1 - 0 = success, !0 = failure
    296  1.1  is #
    297  1.1  is 	.global	_060_dmem_write_word
    298  1.1  is _060_dmem_write_word:
    299  1.2  is 	btst	#0x5,a6@(0x4)	|# check for supervisor state
    300  1.1  is 	bnes	dmwws		|# supervisor
    301  1.1  is dmwwu:
    302  1.1  is 	movel	d0,sp@-		|# put src on stack
    303  1.2  is 	movel	#0x2,sp@-	|# pass: # bytes to copy
    304  1.1  is 	movel	a0,sp@-		|# pass: dst addr (user mem)
    305  1.2  is 	pea	sp@(0xa)	|# pass: src addr (stack)
    306  1.2  is 	bsrl	_copyout	|# "copy out" the data
    307  1.1  is 	movel	d0,d1		|# return success
    308  1.2  is 	addl	#0x10,sp	|# delete params + src
    309  1.1  is 	rts
    310  1.1  is dmwws:
    311  1.1  is 	movew	d0,a0@		|# store super word
    312  1.1  is 	clrl	d1		|# return success
    313  1.1  is 	rts
    314  1.1  is 
    315  1.1  is #
    316  1.1  is # _060_dmem_write_long():
    317  1.1  is #
    318  1.1  is # Write a data longword to user memory.
    319  1.1  is #
    320  1.1  is # INPUTS:
    321  1.1  is #	a0 - user destination address
    322  1.1  is # 	d0 - data longword in d0
    323  1.1  is # 	a6@(0x4),bit5 - 1 = supervisor mode, 0 = user mode
    324  1.1  is # OUTPUTS:
    325  1.1  is #	d1 - 0 = success, !0 = failure
    326  1.1  is #
    327  1.1  is 	.global	_060_dmem_write_long
    328  1.1  is _060_dmem_write_long:
    329  1.2  is 	btst	#0x5,a6@(0x4)	|# check for supervisor state
    330  1.1  is 	bnes	dmwls		|# supervisor
    331  1.1  is dmwlu:
    332  1.1  is 	movel	d0,sp@-		|# put src on stack
    333  1.2  is 	movel	#0x4,sp@-	|# pass: # bytes to copy
    334  1.1  is 	movel	a0,sp@-		|# pass: dst addr (user mem)
    335  1.2  is 	pea	sp@(0x8)	|# pass: src addr (stack)
    336  1.2  is 	bsrl	_copyout	|# "copy out" the data
    337  1.1  is 	movel	d0,d1		|# return success
    338  1.2  is 	addl	#0x10,sp	|# delete params + src
    339  1.1  is 	rts
    340  1.1  is dmwls:
    341  1.1  is 	movel	d0,a0@		|# store super longword
    342  1.1  is 	clrl	d1		|# return success
    343  1.1  is 	rts
    344  1.1  is 
    345  1.1  is ############################################################################
    346  1.1  is 
    347  1.1  is #
    348  1.1  is # _060_real_trace():
    349  1.1  is #
    350  1.1  is # This is the exit point for the 060FPSP when an instruction is being traced
    351  1.1  is # and there are no other higher priority exceptions pending for this instruction
    352  1.1  is # or they have already been processed.
    353  1.1  is #
    354  1.1  is # The sample code below simply executes an "rte".
    355  1.1  is #
    356  1.1  is 	.global	_060_real_trace
    357  1.1  is _060_real_trace:
    358  1.1  is 	rte
    359  1.1  is 
    360  1.1  is #
    361  1.1  is # _060_real_access():
    362  1.1  is #
    363  1.1  is # This is the exit point for the 060FPSP when an access error exception
    364  1.1  is # is encountered. The routine below should point to the operating system
    365  1.1  is # handler for access error exceptions. The exception stack frame is an
    366  1.1  is # 8-word access error frame.
    367  1.1  is #
    368  1.2  is # We jump directly to the 68060 buserr handler.
    369  1.2  is # If we had a sane ld, we could use use that entry point directly...
    370  1.1  is #
    371  1.2  is 	.globl	_060_real_access,_buserr60
    372  1.1  is _060_real_access:
    373  1.2  is 	jra	_buserr60
    374  1.1  is 
    375  1.1  is 	.include	"inetbsd.S"
    376  1.1  is 	.include	"fnetbsd.S"
    377