Home | History | Annotate | Line # | Download | only in fpsp
netbsd.sa revision 1.2
      1  1.2      cgd *	$NetBSD: netbsd.sa,v 1.2 1994/10/26 07:49:19 cgd Exp $
      2  1.2      cgd 
      3  1.1  mycroft *	MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
      4  1.1  mycroft *	M68000 Hi-Performance Microprocessor Division
      5  1.1  mycroft *	M68040 Software Package 
      6  1.1  mycroft *
      7  1.1  mycroft *	M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
      8  1.1  mycroft *	All rights reserved.
      9  1.1  mycroft *
     10  1.1  mycroft *	THE SOFTWARE is provided on an "AS IS" basis and without warranty.
     11  1.1  mycroft *	To the maximum extent permitted by applicable law,
     12  1.1  mycroft *	MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
     13  1.1  mycroft *	INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
     14  1.1  mycroft *	PARTICULAR PURPOSE and any warranty against infringement with
     15  1.1  mycroft *	regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
     16  1.1  mycroft *	and any accompanying written materials. 
     17  1.1  mycroft *
     18  1.1  mycroft *	To the maximum extent permitted by applicable law,
     19  1.1  mycroft *	IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
     20  1.1  mycroft *	(INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
     21  1.1  mycroft *	PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
     22  1.1  mycroft *	OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
     23  1.1  mycroft *	SOFTWARE.  Motorola assumes no responsibility for the maintenance
     24  1.1  mycroft *	and support of the SOFTWARE.  
     25  1.1  mycroft *
     26  1.1  mycroft *	You are hereby granted a copyright license to use, modify, and
     27  1.1  mycroft *	distribute the SOFTWARE so long as this entire notice is retained
     28  1.1  mycroft *	without alteration in any modified and/or redistributed versions,
     29  1.1  mycroft *	and that such modified versions are clearly identified as such.
     30  1.1  mycroft *	No licenses are granted by implication, estoppel or otherwise
     31  1.1  mycroft *	under any patents or trademarks of Motorola, Inc.
     32  1.1  mycroft 
     33  1.1  mycroft *
     34  1.1  mycroft *	skeleton.sa 3.2 4/26/91
     35  1.1  mycroft *
     36  1.1  mycroft *	This file contains code that is system dependent and will
     37  1.1  mycroft *	need to be modified to install the FPSP.
     38  1.1  mycroft *
     39  1.1  mycroft *	Each entry point for exception 'xxxx' begins with a 'jmp fpsp_xxxx'.
     40  1.1  mycroft *	Put any target system specific handling that must be done immediately
     41  1.1  mycroft *	before the jump instruction.  If there no handling necessary, then
     42  1.1  mycroft *	the 'fpsp_xxxx' handler entry point should be placed in the exception
     43  1.1  mycroft *	table so that the 'jmp' can be eliminated. If the FPSP determines that the
     44  1.1  mycroft *	exception is one that must be reported then there will be a
     45  1.1  mycroft *	return from the package by a 'jmp real_xxxx'.  At that point
     46  1.1  mycroft *	the machine state will be identical to the state before
     47  1.1  mycroft *	the FPSP was entered.  In particular, whatever condition
     48  1.1  mycroft *	that caused the exception will still be pending when the FPSP
     49  1.1  mycroft *	package returns.  Thus, there will be system specific code
     50  1.1  mycroft *	to handle the exception.
     51  1.1  mycroft *
     52  1.1  mycroft *	If the exception was completely handled by the package, then
     53  1.1  mycroft *	the return will be via a 'jmp fpsp_done'.  Unless there is 
     54  1.1  mycroft *	OS specific work to be done (such as handling a context switch or
     55  1.1  mycroft *	interrupt) the user program can be resumed via 'rte'.
     56  1.1  mycroft *
     57  1.1  mycroft *	In the following skeleton code, some typical 'real_xxxx' handling
     58  1.1  mycroft *	code is shown.  This code may need to be moved to an appropriate
     59  1.1  mycroft *	place in the target system, or rewritten.
     60  1.1  mycroft *	
     61  1.1  mycroft 
     62  1.1  mycroft SKELETON	IDNT    2,1 Motorola 040 Floating Point Software Package
     63  1.1  mycroft 
     64  1.1  mycroft 	section 15
     65  1.1  mycroft *
     66  1.1  mycroft *	The following counters are used for standalone testing
     67  1.1  mycroft *
     68  1.1  mycroft 
     69  1.1  mycroft 	section 8
     70  1.1  mycroft 
     71  1.1  mycroft 	include	fpsp.h
     72  1.1  mycroft 
     73  1.1  mycroft 	xref	b1238_fix
     74  1.1  mycroft 	xref	_mmutype
     75  1.1  mycroft 
     76  1.1  mycroft *
     77  1.1  mycroft *	Divide by Zero exception
     78  1.1  mycroft *
     79  1.1  mycroft *	All dz exceptions are 'real', hence no fpsp_dz entry point.
     80  1.1  mycroft *
     81  1.1  mycroft 	xdef	dz
     82  1.1  mycroft 	xdef	real_dz
     83  1.1  mycroft dz:
     84  1.1  mycroft 	cmp.l		#-2,_mmutype
     85  1.1  mycroft 	bne.l		_fpfault
     86  1.1  mycroft real_dz:
     87  1.1  mycroft 	link		a6,#-LOCAL_SIZE
     88  1.1  mycroft 	fsave		-(sp)
     89  1.1  mycroft 	bclr.b		#E1,E_BYTE(a6)
     90  1.1  mycroft 	frestore	(sp)+
     91  1.1  mycroft 	unlk		a6
     92  1.1  mycroft 	jmp		_fpfault
     93  1.1  mycroft 
     94  1.1  mycroft *
     95  1.1  mycroft *	Inexact exception
     96  1.1  mycroft *
     97  1.1  mycroft *	All inexact exceptions are real, but the 'real' handler
     98  1.1  mycroft *	will probably want to clear the pending exception.
     99  1.1  mycroft *	The provided code will clear the E3 exception (if pending), 
    100  1.1  mycroft *	otherwise clear the E1 exception.  The frestore is not really
    101  1.1  mycroft *	necessary for E1 exceptions.
    102  1.1  mycroft *
    103  1.1  mycroft * Code following the 'inex' label is to handle bug #1232.  In this
    104  1.1  mycroft * bug, if an E1 snan, ovfl, or unfl occured, and the process was
    105  1.1  mycroft * swapped out before taking the exception, the exception taken on
    106  1.1  mycroft * return was inex, rather than the correct exception.  The snan, ovfl,
    107  1.1  mycroft * and unfl exception to be taken must not have been enabled.  The
    108  1.1  mycroft * fix is to check for E1, and the existence of one of snan, ovfl,
    109  1.1  mycroft * or unfl bits set in the fpsr.  If any of these are set, branch
    110  1.1  mycroft * to the appropriate  handler for the exception in the fpsr.  Note
    111  1.1  mycroft * that this fix is only for d43b parts, and is skipped if the
    112  1.1  mycroft * version number is not $40.
    113  1.1  mycroft * 
    114  1.1  mycroft *
    115  1.1  mycroft 	xdef	real_inex
    116  1.1  mycroft 	xdef	inex
    117  1.1  mycroft inex:
    118  1.1  mycroft 	cmp.l		#-2,_mmutype
    119  1.1  mycroft 	bne.l		_fpfault
    120  1.1  mycroft 	link		a6,#-LOCAL_SIZE
    121  1.1  mycroft 	fsave		-(sp)
    122  1.1  mycroft 	cmpi.b		#VER_40,(sp)		;test version number
    123  1.1  mycroft 	bne.b		not_fmt40
    124  1.1  mycroft 	fmove.l		fpsr,-(sp)
    125  1.1  mycroft 	btst.b		#E1,E_BYTE(a6)		;test for E1 set
    126  1.1  mycroft 	beq.b		not_b1232
    127  1.1  mycroft 	btst.b		#snan_bit,2(sp) ;test for snan
    128  1.1  mycroft 	beq		inex_ckofl
    129  1.1  mycroft 	addq.l		#4,sp
    130  1.1  mycroft 	frestore	(sp)+
    131  1.1  mycroft 	unlk		a6
    132  1.1  mycroft 	bra		snan
    133  1.1  mycroft inex_ckofl:
    134  1.1  mycroft 	btst.b		#ovfl_bit,2(sp) ;test for ovfl
    135  1.1  mycroft 	beq		inex_ckufl 
    136  1.1  mycroft 	addq.l		#4,sp
    137  1.1  mycroft 	frestore	(sp)+
    138  1.1  mycroft 	unlk		a6
    139  1.1  mycroft 	bra		ovfl
    140  1.1  mycroft inex_ckufl:
    141  1.1  mycroft 	btst.b		#unfl_bit,2(sp) ;test for unfl
    142  1.1  mycroft 	beq		not_b1232
    143  1.1  mycroft 	addq.l		#4,sp
    144  1.1  mycroft 	frestore	(sp)+
    145  1.1  mycroft 	unlk		a6
    146  1.1  mycroft 	bra		unfl
    147  1.1  mycroft 
    148  1.1  mycroft *
    149  1.1  mycroft * We do not have the bug 1232 case.  Clean up the stack and call
    150  1.1  mycroft * real_inex.
    151  1.1  mycroft *
    152  1.1  mycroft not_b1232:
    153  1.1  mycroft 	addq.l		#4,sp
    154  1.1  mycroft 	frestore	(sp)+
    155  1.1  mycroft 	unlk		a6
    156  1.1  mycroft 
    157  1.1  mycroft real_inex:
    158  1.1  mycroft 	link		a6,#-LOCAL_SIZE
    159  1.1  mycroft 	fsave		-(sp)
    160  1.1  mycroft not_fmt40:
    161  1.1  mycroft 	bclr.b		#E3,E_BYTE(a6)		;clear and test E3 flag
    162  1.1  mycroft 	beq.b		inex_cke1
    163  1.1  mycroft *
    164  1.1  mycroft * Clear dirty bit on dest resister in the frame before branching
    165  1.1  mycroft * to b1238_fix.
    166  1.1  mycroft *
    167  1.1  mycroft 	movem.l		d0/d1,USER_DA(a6)
    168  1.1  mycroft 	bfextu		CMDREG1B(a6){6:3},d0		;get dest reg no
    169  1.1  mycroft 	bclr.b		d0,FPR_DIRTY_BITS(a6)	;clr dest dirty bit
    170  1.1  mycroft 	bsr.l		b1238_fix		;test for bug1238 case
    171  1.1  mycroft 	movem.l		USER_DA(a6),d0/d1
    172  1.1  mycroft 	bra.b		inex_done
    173  1.1  mycroft inex_cke1:
    174  1.1  mycroft 	bclr.b		#E1,E_BYTE(a6)
    175  1.1  mycroft inex_done:
    176  1.1  mycroft 	frestore	(sp)+
    177  1.1  mycroft 	unlk		a6
    178  1.1  mycroft 	jmp		_fpfault
    179  1.1  mycroft 	
    180  1.1  mycroft *
    181  1.1  mycroft *	Overflow exception
    182  1.1  mycroft *
    183  1.1  mycroft 	xref	fpsp_ovfl
    184  1.1  mycroft 	xdef	real_ovfl
    185  1.1  mycroft 	xdef	ovfl
    186  1.1  mycroft ovfl:
    187  1.1  mycroft 	cmp.l		#-2,_mmutype
    188  1.1  mycroft 	beq.l		fpsp_ovfl
    189  1.1  mycroft 	jmp		_fpfault
    190  1.1  mycroft real_ovfl:
    191  1.1  mycroft 	link		a6,#-LOCAL_SIZE
    192  1.1  mycroft 	fsave		-(sp)
    193  1.1  mycroft 	bclr.b		#E3,E_BYTE(a6)		;clear and test E3 flag
    194  1.1  mycroft 	bne.b		ovfl_done
    195  1.1  mycroft 	bclr.b		#E1,E_BYTE(a6)
    196  1.1  mycroft ovfl_done:
    197  1.1  mycroft 	frestore	(sp)+
    198  1.1  mycroft 	unlk		a6
    199  1.1  mycroft 	jmp		_fpfault
    200  1.1  mycroft 	
    201  1.1  mycroft *
    202  1.1  mycroft *	Underflow exception
    203  1.1  mycroft *
    204  1.1  mycroft 	xref	fpsp_unfl
    205  1.1  mycroft 	xdef	real_unfl
    206  1.1  mycroft 	xdef	unfl
    207  1.1  mycroft unfl:
    208  1.1  mycroft 	cmp.l		#-2,_mmutype
    209  1.1  mycroft 	beq.l		fpsp_unfl
    210  1.1  mycroft 	jmp		_fpfault
    211  1.1  mycroft real_unfl:
    212  1.1  mycroft 	link		a6,#-LOCAL_SIZE
    213  1.1  mycroft 	fsave		-(sp)
    214  1.1  mycroft 	bclr.b		#E3,E_BYTE(a6)		;clear and test E3 flag
    215  1.1  mycroft 	bne.b		unfl_done
    216  1.1  mycroft 	bclr.b		#E1,E_BYTE(a6)
    217  1.1  mycroft unfl_done:
    218  1.1  mycroft 	frestore	(sp)+
    219  1.1  mycroft 	unlk		a6
    220  1.1  mycroft 	jmp		_fpfault
    221  1.1  mycroft 	
    222  1.1  mycroft *
    223  1.1  mycroft *	Signalling NAN exception
    224  1.1  mycroft *
    225  1.1  mycroft 	xref	fpsp_snan
    226  1.1  mycroft 	xdef	real_snan
    227  1.1  mycroft 	xdef	snan
    228  1.1  mycroft snan:
    229  1.1  mycroft 	cmp.l		#-2,_mmutype
    230  1.1  mycroft 	beq.l		fpsp_snan
    231  1.1  mycroft 	jmp		_fpfault
    232  1.1  mycroft real_snan:
    233  1.1  mycroft 	link		a6,#-LOCAL_SIZE
    234  1.1  mycroft 	fsave		-(sp)
    235  1.1  mycroft 	bclr.b		#E1,E_BYTE(a6)	;snan is always an E1 exception
    236  1.1  mycroft 	frestore	(sp)+
    237  1.1  mycroft 	unlk		a6
    238  1.1  mycroft 	jmp		_fpfault
    239  1.1  mycroft 	
    240  1.1  mycroft *
    241  1.1  mycroft *	Operand Error exception
    242  1.1  mycroft *
    243  1.1  mycroft 	xref	fpsp_operr
    244  1.1  mycroft 	xdef	real_operr
    245  1.1  mycroft 	xdef	operr
    246  1.1  mycroft operr:
    247  1.1  mycroft 	cmp.l		#-2,_mmutype
    248  1.1  mycroft 	beq.l		fpsp_operr
    249  1.1  mycroft 	jmp		_fpfault
    250  1.1  mycroft real_operr:
    251  1.1  mycroft 	link		a6,#-LOCAL_SIZE
    252  1.1  mycroft 	fsave		-(sp)
    253  1.1  mycroft 	bclr.b		#E1,E_BYTE(a6)	;operr is always an E1 exception
    254  1.1  mycroft 	frestore	(sp)+
    255  1.1  mycroft 	unlk		a6
    256  1.1  mycroft 	jmp		_fpfault
    257  1.1  mycroft 	
    258  1.1  mycroft *
    259  1.1  mycroft *	BSUN exception
    260  1.1  mycroft *
    261  1.1  mycroft *	This sample handler simply clears the nan bit in the FPSR.
    262  1.1  mycroft *
    263  1.1  mycroft 	xref	fpsp_bsun
    264  1.1  mycroft 	xdef	real_bsun
    265  1.1  mycroft 	xdef	bsun
    266  1.1  mycroft bsun:
    267  1.1  mycroft 	cmp.l		#-2,_mmutype
    268  1.1  mycroft 	beq.l		fpsp_bsun
    269  1.1  mycroft 	jmp		_fpfault
    270  1.1  mycroft real_bsun:
    271  1.1  mycroft 	link		a6,#-LOCAL_SIZE
    272  1.1  mycroft 	fsave		-(sp)
    273  1.1  mycroft 	bclr.b		#E1,E_BYTE(a6)	;bsun is always an E1 exception
    274  1.1  mycroft 	fmove.l		FPSR,-(sp)
    275  1.1  mycroft 	bclr.b		#nan_bit,(sp)
    276  1.1  mycroft 	fmove.l		(sp)+,FPSR
    277  1.1  mycroft 	frestore	(sp)+
    278  1.1  mycroft 	unlk		a6
    279  1.1  mycroft 	jmp		_fpfault
    280  1.1  mycroft 
    281  1.1  mycroft *
    282  1.1  mycroft *	F-line exception
    283  1.1  mycroft *
    284  1.1  mycroft *	A 'real' F-line exception is one that the FPSP isn't supposed to 
    285  1.1  mycroft *	handle. E.g. an instruction with a co-processor ID that is not 1.
    286  1.1  mycroft *
    287  1.1  mycroft *
    288  1.1  mycroft 	xref	fpsp_fline
    289  1.1  mycroft 	xdef	real_fline
    290  1.1  mycroft 	xdef	fline
    291  1.1  mycroft fline:
    292  1.1  mycroft 	cmp.l		#-2,_mmutype
    293  1.1  mycroft 	beq.l		fpsp_fline
    294  1.1  mycroft 	jmp		_fpfault
    295  1.1  mycroft real_fline:
    296  1.1  mycroft 	jmp		_fpfault
    297  1.1  mycroft 
    298  1.1  mycroft *
    299  1.1  mycroft *	Unsupported data type exception
    300  1.1  mycroft *
    301  1.1  mycroft 	xref	fpsp_unsupp
    302  1.1  mycroft 	xdef	real_unsupp
    303  1.1  mycroft 	xdef	unsupp
    304  1.1  mycroft unsupp:
    305  1.1  mycroft 	cmp.l		#-2,_mmutype
    306  1.1  mycroft 	beq.l		fpsp_unsupp
    307  1.1  mycroft 	jmp		_fpfault
    308  1.1  mycroft real_unsupp:
    309  1.1  mycroft 	link		a6,#-LOCAL_SIZE
    310  1.1  mycroft 	fsave		-(sp)
    311  1.1  mycroft 	bclr.b		#E1,E_BYTE(a6)	;unsupp is always an E1 exception
    312  1.1  mycroft 	frestore	(sp)+
    313  1.1  mycroft 	unlk		a6
    314  1.1  mycroft 	jmp		_fpfault
    315  1.1  mycroft 
    316  1.1  mycroft *
    317  1.1  mycroft *	Trace exception
    318  1.1  mycroft *
    319  1.1  mycroft 	xdef	real_trace
    320  1.1  mycroft real_trace:
    321  1.1  mycroft 	rte
    322  1.1  mycroft 
    323  1.1  mycroft *
    324  1.1  mycroft *	fpsp_fmt_error --- exit point for frame format error
    325  1.1  mycroft *
    326  1.1  mycroft *	The fpu stack frame does not match the frames existing
    327  1.1  mycroft *	or planned at the time of this writing.  The fpsp is
    328  1.1  mycroft *	unable to handle frame sizes not in the following
    329  1.1  mycroft *	version:size pairs:
    330  1.1  mycroft *
    331  1.1  mycroft *	{4060, 4160} - busy frame
    332  1.1  mycroft *	{4028, 4130} - unimp frame
    333  1.1  mycroft *	{4000, 4100} - idle frame
    334  1.1  mycroft *
    335  1.1  mycroft *	This entry point simply holds an f-line illegal value.  
    336  1.1  mycroft *	Replace this with a call to your kernel panic code or
    337  1.1  mycroft *	code to handle future revisions of the fpu.
    338  1.1  mycroft *
    339  1.1  mycroft 	xdef	fpsp_fmt_error
    340  1.1  mycroft fpsp_fmt_error:
    341  1.1  mycroft 	pea		1f
    342  1.1  mycroft 	jsr		_panic
    343  1.1  mycroft 	dc.l		$f27f0000	;f-line illegal
    344  1.1  mycroft 1:
    345  1.1  mycroft 	.asciz		"bad floating point stack frame"
    346  1.1  mycroft 	.even
    347  1.1  mycroft 
    348  1.1  mycroft *
    349  1.1  mycroft *	fpsp_done --- FPSP exit point
    350  1.1  mycroft *
    351  1.1  mycroft *	The exception has been handled by the package and we are ready
    352  1.1  mycroft *	to return to user mode, but there may be OS specific code
    353  1.1  mycroft *	to execute before we do.  If there is, do it now.
    354  1.1  mycroft *
    355  1.1  mycroft *
    356  1.1  mycroft 	xref	rei
    357  1.1  mycroft 	xdef	fpsp_done
    358  1.1  mycroft fpsp_done:
    359  1.1  mycroft 	jmp		rei
    360  1.1  mycroft 
    361  1.1  mycroft *
    362  1.1  mycroft *	mem_write --- write to user or supervisor address space
    363  1.1  mycroft *
    364  1.1  mycroft * Writes to memory while in supervisor mode.  copyout accomplishes
    365  1.1  mycroft * this via a 'moves' instruction.  copyout is a UNIX SVR3 (and later) function.
    366  1.1  mycroft * If you don't have copyout, use the local copy of the function below.
    367  1.1  mycroft *
    368  1.1  mycroft *	a0 - supervisor source address
    369  1.1  mycroft *	a1 - user destination address
    370  1.1  mycroft *	d0 - number of bytes to write (maximum count is 12)
    371  1.1  mycroft *
    372  1.1  mycroft * The supervisor source address is guaranteed to point into the supervisor
    373  1.1  mycroft * stack.  The result is that a UNIX
    374  1.1  mycroft * process is allowed to sleep as a consequence of a page fault during
    375  1.1  mycroft * copyout.  The probability of a page fault is exceedingly small because
    376  1.1  mycroft * the 68040 always reads the destination address and thus the page
    377  1.1  mycroft * faults should have already been handled.
    378  1.1  mycroft *
    379  1.1  mycroft * If the EXC_SR shows that the exception was from supervisor space,
    380  1.1  mycroft * then just do a dumb (and slow) memory move.  In a UNIX environment
    381  1.1  mycroft * there shouldn't be any supervisor mode floating point exceptions.
    382  1.1  mycroft *
    383  1.1  mycroft 	xdef	mem_write
    384  1.1  mycroft mem_write:
    385  1.1  mycroft 	btst.b	#5,EXC_SR(a6)	;check for supervisor state
    386  1.1  mycroft 	beq.b	user_write
    387  1.1  mycroft super_write:
    388  1.1  mycroft 	move.b	(a0)+,(a1)+
    389  1.1  mycroft 	subq.l	#1,d0
    390  1.1  mycroft 	bne.b	super_write
    391  1.1  mycroft 	rts
    392  1.1  mycroft user_write:
    393  1.1  mycroft 	move.l	d1,-(sp)	;preserve d1 just in case
    394  1.1  mycroft 	move.l	d0,-(sp)
    395  1.1  mycroft 	move.l	a1,-(sp)
    396  1.1  mycroft 	move.l	a0,-(sp)
    397  1.1  mycroft 	jsr	_copyout
    398  1.1  mycroft 	add.l	#12,sp
    399  1.1  mycroft 	move.l	(sp)+,d1
    400  1.1  mycroft 	rts
    401  1.1  mycroft 
    402  1.1  mycroft *
    403  1.1  mycroft *	mem_read --- read from user or supervisor address space
    404  1.1  mycroft *
    405  1.1  mycroft * Reads from memory while in supervisor mode.  copyin accomplishes
    406  1.1  mycroft * this via a 'moves' instruction.  copyin is a UNIX SVR3 (and later) function.
    407  1.1  mycroft * If you don't have copyin, use the local copy of the function below.
    408  1.1  mycroft *
    409  1.1  mycroft * The FPSP calls mem_read to read the original F-line instruction in order
    410  1.1  mycroft * to extract the data register number when the 'Dn' addressing mode is
    411  1.1  mycroft * used.
    412  1.1  mycroft *
    413  1.1  mycroft *Input:
    414  1.1  mycroft *	a0 - user source address
    415  1.1  mycroft *	a1 - supervisor destination address
    416  1.1  mycroft *	d0 - number of bytes to read (maximum count is 12)
    417  1.1  mycroft *
    418  1.1  mycroft * Like mem_write, mem_read always reads with a supervisor 
    419  1.1  mycroft * destination address on the supervisor stack.  Also like mem_write,
    420  1.1  mycroft * the EXC_SR is checked and a simple memory copy is done if reading
    421  1.1  mycroft * from supervisor space is indicated.
    422  1.1  mycroft *
    423  1.1  mycroft 	xdef	mem_read
    424  1.1  mycroft mem_read:
    425  1.1  mycroft 	btst.b	#5,EXC_SR(a6)	;check for supervisor state
    426  1.1  mycroft 	beq.b	user_read
    427  1.1  mycroft super_read:
    428  1.1  mycroft 	move.b	(a0)+,(a1)+
    429  1.1  mycroft 	subq.l	#1,d0
    430  1.1  mycroft 	bne.b	super_read
    431  1.1  mycroft 	rts
    432  1.1  mycroft user_read:
    433  1.1  mycroft 	move.l	d1,-(sp)	;preserve d1 just in case
    434  1.1  mycroft 	move.l	d0,-(sp)
    435  1.1  mycroft 	move.l	a1,-(sp)
    436  1.1  mycroft 	move.l	a0,-(sp)
    437  1.1  mycroft 	jsr	_copyin
    438  1.1  mycroft 	add.l	#12,sp
    439  1.1  mycroft 	move.l	(sp)+,d1
    440  1.1  mycroft 	rts
    441  1.1  mycroft 
    442  1.1  mycroft 	end
    443