Home | History | Annotate | Line # | Download | only in dev
hdfd_intr.s revision 1.6
      1 /*	$NetBSD: hdfd_intr.s,v 1.6 1999/03/24 05:50:58 mrg 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 "assym.h"
     41 #include <machine/asm.h>
     42 #define ASSEMBLER /* XXX */
     43 #include <atari/dev/hdfdreg.h>
     44 
     45 	.text
     46 	.globl	_fddmaaddr
     47 	.globl	_fdio_addr,_fddmalen
     48 	.globl	_mfp_hdfd_nf, _mfp_hdfd_fifo
     49 
     50 /*
     51  * Entry point when there is no fifo. Handles the read/write
     52  * interrupts a bit faster because it *knows* that there is only
     53  * one character waiting.
     54  */
     55 _mfp_hdfd_nf:
     56 	addql	#1,nintr		|  add another interrupt
     57 
     58 	moveml	d0-d1/a0-a1,sp@-	|  Save scratch registers
     59 	movl	_fdio_addr,a0		|  Get base of fdc registers
     60 	movb	a0@(fdsts),d0		|  Get fdsts
     61 	btst	#5,d0			|  Dma active?
     62 	jeq	hdfdc_norm		|  No, normal interrupt
     63 	tstl	_fddmalen		|  Bytecount zero?
     64 	jeq	hdfdc_norm		|  Yes -> normal interrupt
     65 
     66 	movl	_fddmaaddr, a1		|  a1 = dmabuffer
     67 	btst	#6,d0			|  Read?
     68 	jeq	hdfd_wrt_nf		|  No, write
     69 hdfd_rd_nf:
     70 	movb	a0@(fddata),a1@+	|  Get a byte
     71 1:
     72 	subql	#1, _fddmalen		|  decrement bytecount
     73 	movl	a1,_fddmaaddr		|  update dma pointer
     74 |	addql	#1,_cnt+V_INTR		|  chalk up another interrupt
     75 	moveml	sp@+,d0-d1/a0-a1
     76 	rte
     77 hdfd_wrt_nf:
     78 	movb	a1@+,a0@(fddata)	|  Push a byte
     79 	jra	1b			|  And get out...
     80 
     81 /*
     82  * Systems *with* fifo's enter here.
     83  */
     84 _mfp_hdfd_fifo:
     85 	addql	#1,_intrcnt_user+88	|  add another interrupt
     86 
     87 	moveml	d0-d1/a0-a1,sp@-	|  Save scratch registers
     88 	movl	_fdio_addr,a0		|  Get base of fdc registers
     89 	movb	a0@(fdsts),d0		|  Get fdsts
     90 	btst	#5,d0			|  Dma active?
     91 	jeq	hdfdc_norm		|  No, normal interrupt
     92 	movl	_fddmaaddr, a1		|  a1 = dmabuffer
     93 	btst	#6,d0			|  Read?
     94 	jeq	hdfd_wrt		|  No, write
     95 
     96 hdfd_rd:
     97 	tstl	_fddmalen		|  Bytecount zero?
     98 	jeq	hdfdc1			|  Yes -> done
     99 	movb	a0@(fddata),a1@+	|  Get a byte
    100 	subql	#1, _fddmalen		|  decrement bytecount
    101 	movb	a0@(fdsts),d0		|  Get fdsts
    102 	andb	#0xa0,d0		|  both NE7_NDM and NE7_RQM active?
    103 	cmpb	#0xa0,d0
    104 	jne	hdfdc1			|  No, end of this batch
    105 	jra	hdfd_rd
    106 
    107 hdfd_wrt:
    108 	tstl	_fddmalen		|  Bytecount zero?
    109 	jeq	hdfdc1			|  Yes -> done
    110 	movb	a1@+,a0@(fddata)	|  Push a byte
    111 	subql	#1, _fddmalen		|  decrement bytecount
    112 	jra	hdfdc1
    113 	movb	a0@(fdsts),d0		|  Get fdsts
    114 	andb	#0xa0,d0		|  both NE7_NDM and NE7_RQM active?
    115 	cmpb	#0xa0,d0
    116 	jne	hdfdc1			|  No, end of this batch
    117 	jra	hdfd_wrt
    118 
    119 hdfdc1:
    120 	movl	a1,_fddmaaddr		|  update buffer pointer
    121 	btst	#5,d0			|  Dma still active?
    122 	jeq	hdfdc_norm		|  No -> take normal interrupt
    123 
    124 	/*
    125 	 * Exit for read/write interrupts. Calling 'rei' this often
    126 	 * seems wrong....
    127 	 */
    128 hdfdc_xit:
    129 	addql	#1,_C_LABEL(uvmexp)+UVMEXP_INTRS
    130 	moveml	sp@+,d0-d1/a0-a1
    131 	rte
    132 
    133 	/*
    134 	 * No (more) data transfer interrupts. Do the normal
    135 	 * stuff.
    136 	 */
    137 hdfdc_norm:
    138 	tstl	nintr
    139 	jeq	0f
    140 	movl	nintr,d0
    141 	clrl	nintr
    142 	addl	d0, _intrcnt_user+88	|  add another interrupt
    143 	addl	d0,_C_LABEL(uvmexp)+UVMEXP_INTRS
    144 0:	jbsr	_fdc_ctrl_intr		|  handle interrupt
    145 	moveml	sp@+,d0-d1/a0-a1	|    and saved registers
    146 	jra	rei
    147 
    148 	.data
    149 nintr:
    150 	.long	0
    151