Home | History | Annotate | Line # | Download | only in dev
      1 /*	$NetBSD: hdfd_intr.s,v 1.11 2023/01/06 10:28:28 tsutsui 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  *
     20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30  * SUCH DAMAGE.
     31  *
     32  */
     33 
     34 #include "assym.h"
     35 #include <machine/asm.h>
     36 #define ASSEMBLER /* XXX */
     37 #include <atari/dev/hdfdreg.h>
     38 
     39 	.text
     40 	.globl	_C_LABEL(fddmaaddr)
     41 	.globl	_C_LABEL(fdio_addr),_C_LABEL(fddmalen)
     42 
     43 /*
     44  * Entry point when there is no fifo. Handles the read/write
     45  * interrupts a bit faster because it *knows* that there is only
     46  * one character waiting.
     47  */
     48 ENTRY_NOPROFILE(mfp_hdfd_nf)
     49 	addql	#1,nintr		|  add another interrupt
     50 
     51 	INTERRUPT_SAVEREG		|  Save scratch registers
     52 	movl	_C_LABEL(fdio_addr),%a0	|  Get base of fdc registers
     53 	movb	%a0@(fdsts),%d0		|  Get fdsts
     54 	btst	#5,%d0			|  DMA active?
     55 	jeq	hdfdc_norm		|  No, normal interrupt
     56 	tstl	_C_LABEL(fddmalen)	|  Bytecount zero?
     57 	jeq	hdfdc_norm		|  Yes -> normal interrupt
     58 
     59 	movl	_C_LABEL(fddmaaddr),%a1	|  a1 = dmabuffer
     60 	btst	#6,%d0			|  Read?
     61 	jeq	hdfd_wrt_nf		|  No, write
     62 hdfd_rd_nf:
     63 	movb	%a0@(fddata),%a1@+	|  Get a byte
     64 1:
     65 	subql	#1, _C_LABEL(fddmalen)	|  decrement bytecount
     66 	movl	%a1,_C_LABEL(fddmaaddr)	|  update DMA pointer
     67 |	addql	#1,_cnt+V_INTR		|  chalk up another interrupt
     68 	INTERRUPT_RESTOREREG
     69 	rte
     70 hdfd_wrt_nf:
     71 	movb	%a1@+,%a0@(fddata)	|  Push a byte
     72 	jra	1b			|  And get out...
     73 
     74 /*
     75  * Systems *with* fifo's enter here.
     76  */
     77 ENTRY_NOPROFILE(mfp_hdfd_fifo)
     78 	addql	#1,_C_LABEL(intrcnt_user)+88	|  add another interrupt
     79 
     80 	INTERRUPT_SAVEREG		|  Save scratch registers
     81 	movl	_C_LABEL(fdio_addr),%a0	|  Get base of fdc registers
     82 	movb	%a0@(fdsts),%d0		|  Get fdsts
     83 	btst	#5,%d0			|  DMA active?
     84 	jeq	hdfdc_norm		|  No, normal interrupt
     85 	movl	_C_LABEL(fddmaaddr),%a1	|  a1 = dmabuffer
     86 	btst	#6,%d0			|  Read?
     87 	jeq	hdfd_wrt		|  No, write
     88 
     89 hdfd_rd:
     90 	tstl	_C_LABEL(fddmalen)	|  Bytecount zero?
     91 	jeq	hdfdc1			|  Yes -> done
     92 	movb	%a0@(fddata),%a1@+	|  Get a byte
     93 	subql	#1, _C_LABEL(fddmalen)	|  decrement bytecount
     94 	movb	%a0@(fdsts),%d0		|  Get fdsts
     95 	andb	#0xa0,%d0		|  both NE7_NDM and NE7_RQM active?
     96 	cmpb	#0xa0,%d0
     97 	jne	hdfdc1			|  No, end of this batch
     98 	jra	hdfd_rd
     99 
    100 hdfd_wrt:
    101 	tstl	_C_LABEL(fddmalen)	|  Bytecount zero?
    102 	jeq	hdfdc1			|  Yes -> done
    103 	movb	%a1@+,%a0@(fddata)	|  Push a byte
    104 	subql	#1, _C_LABEL(fddmalen)	|  decrement bytecount
    105 	jra	hdfdc1
    106 	movb	%a0@(fdsts),%d0		|  Get fdsts
    107 	andb	#0xa0,%d0		|  both NE7_NDM and NE7_RQM active?
    108 	cmpb	#0xa0,%d0
    109 	jne	hdfdc1			|  No, end of this batch
    110 	jra	hdfd_wrt
    111 
    112 hdfdc1:
    113 	movl	%a1,_C_LABEL(fddmaaddr)	|  update buffer pointer
    114 	btst	#5,%d0			|  DMA still active?
    115 	jeq	hdfdc_norm		|  No -> take normal interrupt
    116 
    117 	/*
    118 	 * Exit for read/write interrupts. Calling 'rei' this often
    119 	 * seems wrong....
    120 	 */
    121 hdfdc_xit:
    122 	CPUINFO_INCREMENT(CI_NINTR)
    123 	INTERRUPT_RESTOREREG
    124 	rte
    125 
    126 	/*
    127 	 * No (more) data transfer interrupts. Do the normal
    128 	 * stuff.
    129 	 */
    130 hdfdc_norm:
    131 	tstl	nintr
    132 	jeq	0f
    133 	movl	nintr,%d0
    134 	clrl	nintr
    135 	addl	%d0, _C_LABEL(intrcnt_user)+88	|  add another interrupt
    136 	CPUINFO_ADD(CI_NINTR, %d0)
    137 0:	jbsr	_C_LABEL(fdc_ctrl_intr)		|  handle interrupt
    138 	INTERRUPT_RESTOREREG			|    and saved registers
    139 	jra	_ASM_LABEL(rei)
    140 
    141 	.data
    142 nintr:
    143 	.long	0
    144