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