1/* $NetBSD: amd7930intr.s,v 1.23 2010/12/20 00:25:43 matt Exp $ */ 2/* 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This software was developed by the Computer Systems Engineering group 7 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 8 * contributed to Berkeley. 9 * 10 * All advertising materials mentioning features or use of this software 11 * must display the following acknowledgement: 12 * This product includes software developed by the University of 13 * California, Lawrence Berkeley Laboratory. 14 * 15 * Redistribution and use in source and binary forms, with or without 16 * modification, are permitted provided that the following conditions 17 * are met: 18 * 1. Redistributions of source code must retain the above copyright 19 * notice, this list of conditions and the following disclaimer. 20 * 2. Redistributions in binary form must reproduce the above copyright 21 * notice, this list of conditions and the following disclaimer in the 22 * documentation and/or other materials provided with the distribution. 23 * 3. Neither the name of the University nor the names of its contributors 24 * may be used to endorse or promote products derived from this software 25 * without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#)bsd_audiointr.s 8.1 (Berkeley) 6/11/93 40 */ 41 42/* 43 * Copyright (c) 1995 Rolf Grossmann. 44 * 45 * This software was developed by the Computer Systems Engineering group 46 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 47 * contributed to Berkeley. 48 * 49 * All advertising materials mentioning features or use of this software 50 * must display the following acknowledgement: 51 * This product includes software developed by the University of 52 * California, Lawrence Berkeley Laboratory. 53 * 54 * Redistribution and use in source and binary forms, with or without 55 * modification, are permitted provided that the following conditions 56 * are met: 57 * 1. Redistributions of source code must retain the above copyright 58 * notice, this list of conditions and the following disclaimer. 59 * 2. Redistributions in binary form must reproduce the above copyright 60 * notice, this list of conditions and the following disclaimer in the 61 * documentation and/or other materials provided with the distribution. 62 * 3. All advertising materials mentioning features or use of this software 63 * must display the following acknowledgement: 64 * This product includes software developed by the University of 65 * California, Berkeley and its contributors. 66 * 4. Neither the name of the University nor the names of its contributors 67 * may be used to endorse or promote products derived from this software 68 * without specific prior written permission. 69 * 70 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 71 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 72 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 73 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 74 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 75 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 76 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 77 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 78 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 79 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 80 * SUCH DAMAGE. 81 * 82 * @(#)bsd_audiointr.s 8.1 (Berkeley) 6/11/93 83 */ 84 85#ifndef AUDIO_C_HANDLER 86#include "assym.h" 87#include <machine/param.h> 88#include <machine/asm.h> 89#include <sparc/sparc/intreg.h> 90#include <machine/intr.h> 91#include <machine/psl.h> 92#include <dev/ic/am7930reg.h> 93 94#define AUDIO_SET_SWINTR_4C \ 95 sethi %hi(INTRREG_VA), %l5; \ 96 ldub [%l5 + %lo(INTRREG_VA)], %l6; \ 97 or %l6, IE_L4, %l6; \ 98 stb %l6, [%l5 + %lo(INTRREG_VA)] 99 100! raise(0,IPL_SOFTAUDIO) ! NOTE: CPU#0 101#define AUDIO_SET_SWINTR_4M \ 102 sethi %hi(PINTR_SINTRLEV(IPL_SOFTAUDIO)), %l5;\ 103 set ICR_PI_SET, %l6; \ 104 st %l5, [%l6] 105 106/* set software interrupt */ 107#if (defined(SUN4) || defined(SUN4C)) && !defined(SUN4M) 108#define AUDIO_SET_SWINTR AUDIO_SET_SWINTR_4C 109#elif !(defined(SUN4) || defined(SUN4C)) && defined(SUN4M) 110#define AUDIO_SET_SWINTR AUDIO_SET_SWINTR_4M 111#else 112#define AUDIO_SET_SWINTR \ 113 sethi %hi(_C_LABEL(cputyp)), %l5; \ 114 ld [%l5 + %lo(_C_LABEL(cputyp))], %l5; \ 115 cmp %l5, CPU_SUN4M; \ 116 be 8f; \ 117 AUDIO_SET_SWINTR_4C; \ 118 ba,a 9f; \ 1198: \ 120 AUDIO_SET_SWINTR_4M; \ 1219: 122#endif 123 124#define R_amd %l2 125#define R_data %l3 126#define R_end %l4 127 128 .seg "data" 129 .align 8 130savepc: 131 .word 0 132 133 .seg "text" 134 .align 4 135 136_ENTRY(_C_LABEL(amd7930_trap)) 137 sethi %hi(savepc), %l7 138 st %l2, [%l7 + %lo(savepc)] 139 140 ! tally interrupt (curcpu()->cpu_data.cpu_nintr++) 141 INCR64X(CPUINFO_VA + CPUINFO_NINTR, %l4, %l5, %l7) 142 143 sethi %hi(_C_LABEL(auiop)), %l7 144 ld [%l7 + %lo(_C_LABEL(auiop))], %l7 145 146 ! tally interrupt (au_intrcnt.ev_count++) 147 ldd [%l7 + AU_EVCNT], %l4 148 inccc %l5 149 addx %l4, 0, %l4 150 std %l4, [%l7 + AU_EVCNT] 151 152 ld [%l7 + AU_BH], R_amd 153 ldub [R_amd + AM7930_DREG_IR], %g0 ! clear interrupt 154 155 ! receive incoming data 156 ld [%l7 + AU_RDATA], R_data 157 ld [%l7 + AU_REND], R_end 158 159 cmp R_data, 0 ! if (d && d <= e) 160 be 1f 161 cmp R_data, R_end 162 bgu 1f 163 nop 164 165 ldub [R_amd + AM7930_DREG_BBRB], %l6 ! *d = amd->bbrb 166 stb %l6, [R_data] 167 168 cmp R_data, R_end 169 inc R_data ! au->au_rdata++ 170 bne 1f ! if (d == e) 171 st R_data, [%l7 + AU_RDATA] 172 173 AUDIO_SET_SWINTR 174 1751: 176 ! write outgoing data 177 ld [%l7 + AU_PDATA], R_data 178 ld [%l7 + AU_PEND], R_end 179 180 cmp R_data, 0 ! if (d && d <= e) 181 be 2f 182 cmp R_data, R_end 183 bgu 2f 184 nop 185 186 ldub [R_data], %l6 ! amd->bbtb = *d 187 stb %l6, [R_amd + AM7930_DREG_BBTB] 188 189 cmp R_data, R_end 190 inc R_data ! au->au_pdata++ 191 bne 2f ! if (d == e) 192 st R_data, [%l7 + AU_PDATA] 193 194 AUDIO_SET_SWINTR 195 1962: 197 /* 198 * Restore psr -- note: psr delay honored by pc restore loads. 199 */ 200 mov %l0, %psr 201 sethi %hi(savepc), %l7 202 ld [%l7 + %lo(savepc)], %l2 203 jmp %l1 204 rett %l2 205#endif /* !AUDIO_C_HANDLER */ 206