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