Home | History | Annotate | Line # | Download | only in dev
hdfd_intr.s revision 1.5
      1 /*	$NetBSD: hdfd_intr.s,v 1.5 1998/05/12 21:09:23 leo Exp $
      2 
      3 /*
      4  * Copyright (c) 1996 Leo Weppelman.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to Berkeley by
      8  * the Systems Programming Group of the University of Utah Computer
      9  * Science Department.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. All advertising materials mentioning features or use of this software
     20  *    must display the following acknowledgement:
     21  *	This product includes software developed by Leo Weppelman.
     22  * 4. Neither the name of the University nor the names of its contributors
     23  *    may be used to endorse or promote products derived from this software
     24  *    without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  * SUCH DAMAGE.
     37  *
     38  */
     39 
     40 #include "opt_uvm.h"
     41 #include "assym.h"
     42 #include <machine/asm.h>
     43 #define ASSEMBLER /* XXX */
     44 #include <atari/dev/hdfdreg.h>
     45 
     46 	.text
     47 	.globl	_fddmaaddr
     48 	.globl	_fdio_addr,_fddmalen
     49 	.globl	_mfp_hdfd_nf, _mfp_hdfd_fifo
     50 
     51 /*
     52  * Entry point when there is no fifo. Handles the read/write
     53  * interrupts a bit faster because it *knows* that there is only
     54  * one character waiting.
     55  */
     56 _mfp_hdfd_nf:
     57 	addql	#1,nintr		|  add another interrupt
     58 
     59 	moveml	d0-d1/a0-a1,sp@-	|  Save scratch registers
     60 	movl	_fdio_addr,a0		|  Get base of fdc registers
     61 	movb	a0@(fdsts),d0		|  Get fdsts
     62 	btst	#5,d0			|  Dma active?
     63 	jeq	hdfdc_norm		|  No, normal interrupt
     64 	tstl	_fddmalen		|  Bytecount zero?
     65 	jeq	hdfdc_norm		|  Yes -> normal interrupt
     66 
     67 	movl	_fddmaaddr, a1		|  a1 = dmabuffer
     68 	btst	#6,d0			|  Read?
     69 	jeq	hdfd_wrt_nf		|  No, write
     70 hdfd_rd_nf:
     71 	movb	a0@(fddata),a1@+	|  Get a byte
     72 1:
     73 	subql	#1, _fddmalen		|  decrement bytecount
     74 	movl	a1,_fddmaaddr		|  update dma pointer
     75 |	addql	#1,_cnt+V_INTR		|  chalk up another interrupt
     76 	moveml	sp@+,d0-d1/a0-a1
     77 	rte
     78 hdfd_wrt_nf:
     79 	movb	a1@+,a0@(fddata)	|  Push a byte
     80 	jra	1b			|  And get out...
     81 
     82 /*
     83  * Systems *with* fifo's enter here.
     84  */
     85 _mfp_hdfd_fifo:
     86 	addql	#1,_intrcnt_user+88	|  add another interrupt
     87 
     88 	moveml	d0-d1/a0-a1,sp@-	|  Save scratch registers
     89 	movl	_fdio_addr,a0		|  Get base of fdc registers
     90 	movb	a0@(fdsts),d0		|  Get fdsts
     91 	btst	#5,d0			|  Dma active?
     92 	jeq	hdfdc_norm		|  No, normal interrupt
     93 	movl	_fddmaaddr, a1		|  a1 = dmabuffer
     94 	btst	#6,d0			|  Read?
     95 	jeq	hdfd_wrt		|  No, write
     96 
     97 hdfd_rd:
     98 	tstl	_fddmalen		|  Bytecount zero?
     99 	jeq	hdfdc1			|  Yes -> done
    100 	movb	a0@(fddata),a1@+	|  Get a byte
    101 	subql	#1, _fddmalen		|  decrement bytecount
    102 	movb	a0@(fdsts),d0		|  Get fdsts
    103 	andb	#0xa0,d0		|  both NE7_NDM and NE7_RQM active?
    104 	cmpb	#0xa0,d0
    105 	jne	hdfdc1			|  No, end of this batch
    106 	jra	hdfd_rd
    107 
    108 hdfd_wrt:
    109 	tstl	_fddmalen		|  Bytecount zero?
    110 	jeq	hdfdc1			|  Yes -> done
    111 	movb	a1@+,a0@(fddata)	|  Push a byte
    112 	subql	#1, _fddmalen		|  decrement bytecount
    113 	jra	hdfdc1
    114 	movb	a0@(fdsts),d0		|  Get fdsts
    115 	andb	#0xa0,d0		|  both NE7_NDM and NE7_RQM active?
    116 	cmpb	#0xa0,d0
    117 	jne	hdfdc1			|  No, end of this batch
    118 	jra	hdfd_wrt
    119 
    120 hdfdc1:
    121 	movl	a1,_fddmaaddr		|  update buffer pointer
    122 	btst	#5,d0			|  Dma still active?
    123 	jeq	hdfdc_norm		|  No -> take normal interrupt
    124 
    125 	/*
    126 	 * Exit for read/write interrupts. Calling 'rei' this often
    127 	 * seems wrong....
    128 	 */
    129 hdfdc_xit:
    130 #if defined(UVM)
    131 	addql	#1,_C_LABEL(uvmexp)+UVMEXP_INTRS
    132 #else
    133 	addql	#1,_C_LABEL(cnt)+V_INTR
    134 #endif
    135 	moveml	sp@+,d0-d1/a0-a1
    136 	rte
    137 
    138 	/*
    139 	 * No (more) data transfer interrupts. Do the normal
    140 	 * stuff.
    141 	 */
    142 hdfdc_norm:
    143 	tstl	nintr
    144 	jeq	0f
    145 	movl	nintr,d0
    146 	clrl	nintr
    147 	addl	d0, _intrcnt_user+88	|  add another interrupt
    148 #if defined(UVM)
    149 	addl	d0,_C_LABEL(uvmexp)+UVMEXP_INTRS
    150 #else
    151 	addl	d0,_C_LABEL(cnt)+V_INTR
    152 #endif
    153 0:	jbsr	_fdc_ctrl_intr		|  handle interrupt
    154 	moveml	sp@+,d0-d1/a0-a1	|    and saved registers
    155 	jra	rei
    156 
    157 	.data
    158 nintr:
    159 	.long	0
    160