No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / atari / dev / hdfd_intr.s
blobc517c0466c4366f751cbb17d9971d5e7965a20c5
1 /* $NetBSD: hdfd_intr.s,v 1.8 2003/05/03 18:10:46 wiz Exp $
3 /*
4 * Copyright (c) 1996 Leo Weppelman.
5 * All rights reserved.
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.
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.
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.
34 #include "assym.h"
35 #include <machine/asm.h>
36 #define ASSEMBLER /* XXX */
37 #include <atari/dev/hdfdreg.h>
39 .text
40 .globl _C_LABEL(fddmaaddr)
41 .globl _C_LABEL(fdio_addr),_C_LABEL(fddmalen)
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.
48 ENTRY_NOPROFILE(mfp_hdfd_nf)
49 addql #1,nintr | add another interrupt
51 moveml %d0-%d1/%a0-%a1,%sp@- | 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
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
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 moveml %sp@+,%d0-%d1/%a0-%a1
69 rte
70 hdfd_wrt_nf:
71 movb %a1@+,%a0@(fddata) | Push a byte
72 jra 1b | And get out...
75 * Systems *with* fifo's enter here.
77 ENTRY_NOPROFILE(mfp_hdfd_fifo)
78 addql #1,_C_LABEL(intrcnt_user)+88 | add another interrupt
80 moveml %d0-%d1/%a0-%a1,%sp@- | 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
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
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
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
118 * Exit for read/write interrupts. Calling 'rei' this often
119 * seems wrong....
121 hdfdc_xit:
122 addql #1,_C_LABEL(uvmexp)+UVMEXP_INTRS
123 moveml %sp@+,%d0-%d1/%a0-%a1
127 * No (more) data transfer interrupts. Do the normal
128 * stuff.
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 addl %d0,_C_LABEL(uvmexp)+UVMEXP_INTRS
137 0: jbsr _C_LABEL(fdc_ctrl_intr) | handle interrupt
138 moveml %sp@+,%d0-%d1/%a0-%a1 | and saved registers
139 jra _ASM_LABEL(rei)
141 .data
142 nintr:
143 .long 0