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