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