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