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