dec_3min.c revision 1.58
11.58Sad/* $NetBSD: dec_3min.c,v 1.58 2007/12/03 15:34:10 ad Exp $ */ 21.1Sjonathan 31.1Sjonathan/* 41.1Sjonathan * Copyright (c) 1998 Jonathan Stone. All rights reserved. 51.1Sjonathan * 61.1Sjonathan * Redistribution and use in source and binary forms, with or without 71.1Sjonathan * modification, are permitted provided that the following conditions 81.1Sjonathan * are met: 91.1Sjonathan * 1. Redistributions of source code must retain the above copyright 101.1Sjonathan * notice, this list of conditions and the following disclaimer. 111.1Sjonathan * 2. Redistributions in binary form must reproduce the above copyright 121.1Sjonathan * notice, this list of conditions and the following disclaimer in the 131.1Sjonathan * documentation and/or other materials provided with the distribution. 141.1Sjonathan * 3. All advertising materials mentioning features or use of this software 151.1Sjonathan * must display the following acknowledgement: 161.1Sjonathan * This product includes software developed by Jonathan Stone for 171.1Sjonathan * the NetBSD Project. 181.1Sjonathan * 4. The name of the author may not be used to endorse or promote products 191.1Sjonathan * derived from this software without specific prior written permission. 201.1Sjonathan * 211.1Sjonathan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 221.1Sjonathan * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 231.1Sjonathan * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 241.1Sjonathan * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 251.1Sjonathan * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 261.1Sjonathan * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 271.1Sjonathan * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 281.1Sjonathan * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 291.1Sjonathan * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 301.1Sjonathan * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 311.1Sjonathan */ 321.1Sjonathan 331.1Sjonathan/* 341.1Sjonathan * Copyright (c) 1992, 1993 351.1Sjonathan * The Regents of the University of California. All rights reserved. 361.1Sjonathan * 371.1Sjonathan * This code is derived from software contributed to Berkeley by 381.1Sjonathan * the Systems Programming Group of the University of Utah Computer 391.1Sjonathan * Science Department, The Mach Operating System project at 401.1Sjonathan * Carnegie-Mellon University and Ralph Campbell. 411.1Sjonathan * 421.1Sjonathan * Redistribution and use in source and binary forms, with or without 431.1Sjonathan * modification, are permitted provided that the following conditions 441.1Sjonathan * are met: 451.1Sjonathan * 1. Redistributions of source code must retain the above copyright 461.1Sjonathan * notice, this list of conditions and the following disclaimer. 471.1Sjonathan * 2. Redistributions in binary form must reproduce the above copyright 481.1Sjonathan * notice, this list of conditions and the following disclaimer in the 491.1Sjonathan * documentation and/or other materials provided with the distribution. 501.50Sagc * 3. Neither the name of the University nor the names of its contributors 511.50Sagc * may be used to endorse or promote products derived from this software 521.50Sagc * without specific prior written permission. 531.50Sagc * 541.50Sagc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 551.50Sagc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 561.50Sagc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 571.50Sagc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 581.50Sagc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 591.50Sagc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 601.50Sagc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 611.50Sagc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 621.50Sagc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 631.50Sagc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 641.50Sagc * SUCH DAMAGE. 651.50Sagc * 661.50Sagc * @(#)machdep.c 8.3 (Berkeley) 1/12/94 671.50Sagc */ 681.50Sagc/* 691.50Sagc * Copyright (c) 1988 University of Utah. 701.50Sagc * 711.50Sagc * This code is derived from software contributed to Berkeley by 721.50Sagc * the Systems Programming Group of the University of Utah Computer 731.50Sagc * Science Department, The Mach Operating System project at 741.50Sagc * Carnegie-Mellon University and Ralph Campbell. 751.50Sagc * 761.50Sagc * Redistribution and use in source and binary forms, with or without 771.50Sagc * modification, are permitted provided that the following conditions 781.50Sagc * are met: 791.50Sagc * 1. Redistributions of source code must retain the above copyright 801.50Sagc * notice, this list of conditions and the following disclaimer. 811.50Sagc * 2. Redistributions in binary form must reproduce the above copyright 821.50Sagc * notice, this list of conditions and the following disclaimer in the 831.50Sagc * documentation and/or other materials provided with the distribution. 841.1Sjonathan * 3. All advertising materials mentioning features or use of this software 851.1Sjonathan * must display the following acknowledgement: 861.1Sjonathan * This product includes software developed by the University of 871.1Sjonathan * California, Berkeley and its contributors. 881.1Sjonathan * 4. Neither the name of the University nor the names of its contributors 891.1Sjonathan * may be used to endorse or promote products derived from this software 901.1Sjonathan * without specific prior written permission. 911.1Sjonathan * 921.1Sjonathan * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 931.1Sjonathan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 941.1Sjonathan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 951.1Sjonathan * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 961.1Sjonathan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 971.1Sjonathan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 981.1Sjonathan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 991.1Sjonathan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 1001.1Sjonathan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 1011.1Sjonathan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1021.1Sjonathan * SUCH DAMAGE. 1031.1Sjonathan * 1041.1Sjonathan * @(#)machdep.c 8.3 (Berkeley) 1/12/94 1051.1Sjonathan */ 1061.1Sjonathan 1071.1Sjonathan#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 1081.1Sjonathan 1091.58Sad__KERNEL_RCSID(0, "$NetBSD: dec_3min.c,v 1.58 2007/12/03 15:34:10 ad Exp $"); 1101.1Sjonathan 1111.34Snisimura#include <sys/param.h> 1121.1Sjonathan#include <sys/systm.h> 1131.34Snisimura#include <sys/device.h> 1141.1Sjonathan 1151.1Sjonathan#include <machine/cpu.h> 1161.1Sjonathan#include <machine/intr.h> 1171.1Sjonathan#include <machine/sysconf.h> 1181.1Sjonathan 1191.1Sjonathan#include <mips/mips/mips_mcclock.h> /* mcclock CPUspeed estimation */ 1201.2Sjonathan 1211.2Sjonathan/* all these to get ioasic_base */ 1221.2Sjonathan#include <dev/tc/tcvar.h> /* tc type definitions for.. */ 1231.7Sjonathan#include <dev/tc/ioasicreg.h> /* ioasic interrrupt masks */ 1241.2Sjonathan#include <dev/tc/ioasicvar.h> /* ioasic_base */ 1251.1Sjonathan 1261.20Ssimonb#include <pmax/pmax/machdep.h> 1271.1Sjonathan#include <pmax/pmax/kmin.h> /* 3min baseboard addresses */ 1281.15Snisimura#include <pmax/pmax/memc.h> /* 3min/maxine memory errors */ 1291.51Sad 1301.51Sad#include <pmax/pmax/cons.h> 1311.51Sad#include <dev/ic/z8530sc.h> 1321.51Sad#include <dev/tc/zs_ioasicvar.h> 1331.51Sad#include "wsdisplay.h" 1341.1Sjonathan 1351.31Ssimonbvoid dec_3min_init __P((void)); /* XXX */ 1361.31Ssimonbstatic void dec_3min_bus_reset __P((void)); 1371.33Ssimonbstatic void dec_3min_cons_init __P((void)); 1381.42Snisimurastatic void dec_3min_intr __P((unsigned, unsigned, unsigned, unsigned)); 1391.33Ssimonbstatic void dec_3min_intr_establish __P((struct device *, void *, 1401.33Ssimonb int, int (*)(void *), void *)); 1411.1Sjonathan 1421.31Ssimonbstatic void kn02ba_wbflush __P((void)); 1431.31Ssimonbstatic unsigned kn02ba_clkread __P((void)); 1441.1Sjonathan 1451.1Sjonathan 1461.1Sjonathan/* 1471.1Sjonathan * Local declarations. 1481.1Sjonathan */ 1491.22Snisimurastatic u_int32_t kmin_tc3_imask; 1501.18Snisimura 1511.18Snisimura#ifdef MIPS3 1521.31Ssimonbstatic unsigned latched_cycle_cnt; 1531.18Snisimura#endif 1541.18Snisimura 1551.57Syamtstatic const int dec_3min_ipl2spl_table[] = { 1561.57Syamt [IPL_NONE] = 0, 1571.57Syamt [IPL_SOFTCLOCK] = _SPL_SOFTCLOCK, 1581.57Syamt [IPL_SOFTNET] = _SPL_SOFTNET, 1591.57Syamt /* 1601.57Syamt * Since all the motherboard interrupts come through the 1611.57Syamt * IOASIC, it has to be turned off for all the spls and 1621.57Syamt * since we don't know what kinds of devices are in the 1631.57Syamt * TURBOchannel option slots, just splhigh(). 1641.57Syamt */ 1651.57Syamt [IPL_VM] = MIPS_SPL_0_1_2_3, 1661.58Sad [IPL_SCHED] = MIPS_SPL_0_1_2_3, 1671.58Sad [IPL_HIGH] = MIPS_SPL_0_1_2_3, 1681.57Syamt}; 1691.1Sjonathan 1701.1Sjonathanvoid 1711.1Sjonathandec_3min_init() 1721.1Sjonathan{ 1731.24Snisimura platform.iobus = "tcbus"; 1741.1Sjonathan platform.bus_reset = dec_3min_bus_reset; 1751.1Sjonathan platform.cons_init = dec_3min_cons_init; 1761.22Snisimura platform.iointr = dec_3min_intr; 1771.33Ssimonb platform.intr_establish = dec_3min_intr_establish; 1781.47Smhitch platform.memsize = memsize_bitmap; 1791.22Snisimura platform.clkread = kn02ba_clkread; 1801.1Sjonathan 1811.22Snisimura /* clear any memory errors */ 1821.17Snisimura *(u_int32_t *)MIPS_PHYS_TO_KSEG1(KMIN_REG_TIMEOUT) = 0; 1831.14Snisimura kn02ba_wbflush(); 1841.1Sjonathan 1851.1Sjonathan ioasic_base = MIPS_PHYS_TO_KSEG1(KMIN_SYS_ASIC); 1861.1Sjonathan 1871.57Syamt ipl2spl_table = dec_3min_ipl2spl_table; 1881.16Snisimura 1891.28Snisimura /* enable posting of MIPS_INT_MASK_3 to CAUSE register */ 1901.28Snisimura *(u_int32_t *)(ioasic_base + IOASIC_IMSK) = KMIN_INTR_CLOCK; 1911.44Stsutsui /* calibrate cpu_mhz value */ 1921.29Snisimura mc_cpuspeed(ioasic_base+IOASIC_SLOT_8_START, MIPS_INT_MASK_3); 1931.1Sjonathan 1941.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_LANCE_DECODE) = 0x3; 1951.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_SCSI_DECODE) = 0xe; 1961.44Stsutsui#if 0 1971.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_SCC0_DECODE) = (0x10|4); 1981.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_SCC1_DECODE) = (0x10|6); 1991.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_CSR) = 0x00000f00; 2001.44Stsutsui#endif 2011.44Stsutsui 2021.22Snisimura /* sanitize interrupt mask */ 2031.22Snisimura kmin_tc3_imask = (KMIN_INTR_CLOCK|KMIN_INTR_PSWARN|KMIN_INTR_TIMEOUT); 2041.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_INTR) = 0; 2051.22Snisimura *(u_int32_t *)(ioasic_base + IOASIC_IMSK) = kmin_tc3_imask; 2061.1Sjonathan 2071.1Sjonathan /* 2081.22Snisimura * The kmin memory hardware seems to wrap memory addresses 2091.1Sjonathan * with 4Mbyte SIMMs, which causes the physmem computation 2101.1Sjonathan * to lose. Find out how big the SIMMS are and set 2111.22Snisimura * max_ physmem accordingly. 2121.22Snisimura * XXX Do MAXINEs lose the same way? 2131.1Sjonathan */ 2141.1Sjonathan physmem_boardmax = KMIN_PHYS_MEMORY_END + 1; 2151.22Snisimura if ((KMIN_MSR_SIZE_16Mb & *(int *)MIPS_PHYS_TO_KSEG1(KMIN_REG_MSR)) 2161.22Snisimura == 0) 2171.1Sjonathan physmem_boardmax = physmem_boardmax >> 2; 2181.1Sjonathan physmem_boardmax = MIPS_PHYS_TO_KSEG1(physmem_boardmax); 2191.10Sjonathan 2201.22Snisimura sprintf(cpu_model, "DECstation 5000/1%d (3MIN)", cpu_mhz); 2211.22Snisimura} 2221.22Snisimura 2231.22Snisimura/* 2241.49Stsutsui * Initialize the memory system and I/O buses. 2251.22Snisimura */ 2261.31Ssimonbstatic void 2271.22Snisimuradec_3min_bus_reset() 2281.22Snisimura{ 2291.22Snisimura 2301.22Snisimura /* 2311.22Snisimura * Reset interrupts, clear any errors from newconf probes 2321.22Snisimura */ 2331.22Snisimura 2341.17Snisimura *(u_int32_t *)MIPS_PHYS_TO_KSEG1(KMIN_REG_TIMEOUT) = 0; 2351.17Snisimura kn02ba_wbflush(); 2361.17Snisimura 2371.22Snisimura *(u_int32_t *)(ioasic_base + IOASIC_INTR) = 0; 2381.22Snisimura kn02ba_wbflush(); 2391.1Sjonathan} 2401.1Sjonathan 2411.31Ssimonbstatic void 2421.1Sjonathandec_3min_cons_init() 2431.1Sjonathan{ 2441.34Snisimura int kbd, crt, screen; 2451.34Snisimura 2461.34Snisimura kbd = crt = screen = 0; 2471.34Snisimura prom_findcons(&kbd, &crt, &screen); 2481.34Snisimura 2491.34Snisimura if (screen > 0) { 2501.51Sad#if NWSDISPLAY > 0 2511.51Sad if (tcfb_cnattach(crt) > 0) { 2521.51Sad zs_ioasic_lk201_cnattach(ioasic_base, 0x180000, 0); 2531.51Sad return; 2541.51Sad } 2551.34Snisimura#endif 2561.34Snisimura printf("No framebuffer device configured for slot %d: ", crt); 2571.34Snisimura printf("using serial console\n"); 2581.34Snisimura } 2591.34Snisimura /* 2601.34Snisimura * Delay to allow PROM putchars to complete. 2611.34Snisimura * FIFO depth * character time, 2621.34Snisimura * character time = (1000000 / (defaultrate / 10)) 2631.34Snisimura */ 2641.34Snisimura DELAY(160000000 / 9600); /* XXX */ 2651.34Snisimura 2661.51Sad zs_ioasic_cnattach(ioasic_base, 0x180000, 1); 2671.1Sjonathan} 2681.1Sjonathan 2691.31Ssimonbstatic void 2701.33Ssimonbdec_3min_intr_establish(dev, cookie, level, handler, arg) 2711.33Ssimonb struct device *dev; 2721.33Ssimonb void *cookie; 2731.33Ssimonb int level; 2741.24Snisimura int (*handler) __P((void *)); 2751.33Ssimonb void *arg; 2761.1Sjonathan{ 2771.13Ssimonb unsigned mask; 2781.1Sjonathan 2791.35Snisimura switch ((int)cookie) { 2801.1Sjonathan /* slots 0-2 don't interrupt through the IOASIC. */ 2811.35Snisimura case SYS_DEV_OPT0: 2821.33Ssimonb mask = MIPS_INT_MASK_0; 2831.33Ssimonb break; 2841.35Snisimura case SYS_DEV_OPT1: 2851.33Ssimonb mask = MIPS_INT_MASK_1; 2861.33Ssimonb break; 2871.35Snisimura case SYS_DEV_OPT2: 2881.33Ssimonb mask = MIPS_INT_MASK_2; 2891.33Ssimonb break; 2901.1Sjonathan 2911.35Snisimura case SYS_DEV_SCSI: 2921.7Sjonathan mask = (IOASIC_INTR_SCSI | IOASIC_INTR_SCSI_PTR_LOAD | 2931.7Sjonathan IOASIC_INTR_SCSI_OVRUN | IOASIC_INTR_SCSI_READ_E); 2941.1Sjonathan break; 2951.35Snisimura case SYS_DEV_LANCE: 2961.1Sjonathan mask = KMIN_INTR_LANCE; 2971.1Sjonathan break; 2981.35Snisimura case SYS_DEV_SCC0: 2991.1Sjonathan mask = KMIN_INTR_SCC_0; 3001.1Sjonathan break; 3011.35Snisimura case SYS_DEV_SCC1: 3021.1Sjonathan mask = KMIN_INTR_SCC_1; 3031.1Sjonathan break; 3041.33Ssimonb default: 3051.33Ssimonb#ifdef DIAGNOSTIC 3061.35Snisimura printf("warning: enabling unknown intr %x\n", (int)cookie); 3071.33Ssimonb#endif 3081.1Sjonathan return; 3091.1Sjonathan } 3101.1Sjonathan 3111.38Sad#if defined(DEBUG) 3121.36Sad printf("3MIN: imask %x, enabling slot %d, dev %p handler %p\n", 3131.36Sad kmin_tc3_imask, (int)cookie, dev, handler); 3141.1Sjonathan#endif 3151.1Sjonathan 3161.1Sjonathan /* 3171.1Sjonathan * Enable the interrupt handler, and if it's an IOASIC 3181.1Sjonathan * slot, set the IOASIC interrupt mask. 3191.1Sjonathan * Otherwise, set the appropriate spl level in the R3000 3201.1Sjonathan * register. 3211.35Snisimura * Be careful to set handlers before enabling, and disable 3221.1Sjonathan * interrupts before clearing handlers. 3231.1Sjonathan */ 3241.1Sjonathan 3251.33Ssimonb /* Set the interrupt handler and argument ... */ 3261.35Snisimura intrtab[(int)cookie].ih_func = handler; 3271.35Snisimura intrtab[(int)cookie].ih_arg = arg; 3281.33Ssimonb /* ... and set the relevant mask */ 3291.35Snisimura switch ((int)cookie) { 3301.35Snisimura case SYS_DEV_OPT0: 3311.35Snisimura case SYS_DEV_OPT1: 3321.35Snisimura case SYS_DEV_OPT2: 3331.33Ssimonb /* it's an option slot */ 3341.35Snisimura { 3351.33Ssimonb int s = splhigh(); 3361.33Ssimonb s |= mask; 3371.33Ssimonb splx(s); 3381.35Snisimura } 3391.35Snisimura break; 3401.35Snisimura default: 3411.35Snisimura /* it's a baseboard device going via the IOASIC */ 3421.33Ssimonb kmin_tc3_imask |= mask; 3431.35Snisimura break; 3441.1Sjonathan } 3451.33Ssimonb 3461.25Snisimura *(u_int32_t *)(ioasic_base + IOASIC_IMSK) = kmin_tc3_imask; 3471.25Snisimura kn02ba_wbflush(); 3481.1Sjonathan} 3491.1Sjonathan 3501.1Sjonathan 3511.44Stsutsui#define CHECKINTR(slot, bits) \ 3521.35Snisimura do { \ 3531.44Stsutsui if (can_serve & (bits)) { \ 3541.52Ssimonb intrtab[slot].ih_count.ev_count++; \ 3551.44Stsutsui (*intrtab[slot].ih_func)(intrtab[slot].ih_arg); \ 3561.44Stsutsui } \ 3571.35Snisimura } while (0) 3581.1Sjonathan 3591.42Snisimurastatic void 3601.39Snisimuradec_3min_intr(status, cause, pc, ipending) 3611.17Snisimura unsigned status; 3621.17Snisimura unsigned cause; 3631.39Snisimura unsigned pc; 3641.39Snisimura unsigned ipending; 3651.1Sjonathan{ 3661.1Sjonathan static int user_warned = 0; 3671.17Snisimura static int intr_depth = 0; 3681.17Snisimura u_int32_t old_mask; 3691.1Sjonathan 3701.10Sjonathan intr_depth++; 3711.17Snisimura old_mask = *(u_int32_t *)(ioasic_base + IOASIC_IMSK); 3721.10Sjonathan 3731.39Snisimura if (ipending & MIPS_INT_MASK_4) 3741.1Sjonathan prom_haltbutton(); 3751.1Sjonathan 3761.39Snisimura if (ipending & MIPS_INT_MASK_3) { 3771.10Sjonathan /* NB: status & MIPS_INT_MASK3 must also be set */ 3781.10Sjonathan /* masked interrupts are still observable */ 3791.35Snisimura u_int32_t intr, imsk, can_serve, turnoff; 3801.17Snisimura 3811.17Snisimura turnoff = 0; 3821.17Snisimura intr = *(u_int32_t *)(ioasic_base + IOASIC_INTR); 3831.17Snisimura imsk = *(u_int32_t *)(ioasic_base + IOASIC_IMSK); 3841.35Snisimura can_serve = intr & imsk; 3851.1Sjonathan 3861.7Sjonathan if (intr & IOASIC_INTR_SCSI_PTR_LOAD) { 3871.17Snisimura turnoff |= IOASIC_INTR_SCSI_PTR_LOAD; 3881.1Sjonathan#ifdef notdef 3891.1Sjonathan asc_dma_intr(); 3901.1Sjonathan#endif 3911.1Sjonathan } 3921.12Ssimonb 3931.7Sjonathan if (intr & (IOASIC_INTR_SCSI_OVRUN | IOASIC_INTR_SCSI_READ_E)) 3941.17Snisimura turnoff |= IOASIC_INTR_SCSI_OVRUN | IOASIC_INTR_SCSI_READ_E; 3951.1Sjonathan 3961.7Sjonathan if (intr & IOASIC_INTR_LANCE_READ_E) 3971.17Snisimura turnoff |= IOASIC_INTR_LANCE_READ_E; 3981.17Snisimura 3991.17Snisimura if (turnoff) 4001.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_INTR) = ~turnoff; 4011.1Sjonathan 4021.48Snisimura if (intr & KMIN_INTR_TIMEOUT) { 4031.1Sjonathan kn02ba_errintr(); 4041.48Snisimura pmax_memerr_evcnt.ev_count++; 4051.48Snisimura } 4061.12Ssimonb 4071.1Sjonathan if (intr & KMIN_INTR_CLOCK) { 4081.17Snisimura struct clockframe cf; 4091.17Snisimura 4101.54Sperry __asm volatile("lbu $0,48(%0)" :: 4111.22Snisimura "r"(ioasic_base + IOASIC_SLOT_8_START)); 4121.6Sjonathan#ifdef MIPS3 4131.6Sjonathan if (CPUISMIPS3) { 4141.43Scgd latched_cycle_cnt = mips3_cp0_count_read(); 4151.6Sjonathan } 4161.6Sjonathan#endif 4171.17Snisimura cf.pc = pc; 4181.17Snisimura cf.sr = status; 4191.1Sjonathan hardclock(&cf); 4201.46Snisimura pmax_clock_evcnt.ev_count++; 4211.1Sjonathan } 4221.10Sjonathan 4231.55Swiz /* If clock interrupts were enabled, re-enable them ASAP. */ 4241.10Sjonathan if (old_mask & KMIN_INTR_CLOCK) { 4251.17Snisimura /* ioctl interrupt mask to splclock and higher */ 4261.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_IMSK) 4271.17Snisimura = old_mask & 4281.17Snisimura ~(KMIN_INTR_SCC_0|KMIN_INTR_SCC_1 | 4291.17Snisimura IOASIC_INTR_LANCE|IOASIC_INTR_SCSI); 4301.14Snisimura kn02ba_wbflush(); 4311.17Snisimura _splset(MIPS_SR_INT_IE | (status & MIPS_INT_MASK_3)); 4321.10Sjonathan } 4331.10Sjonathan 4341.11Sjonathan if (intr_depth > 1) 4351.11Sjonathan goto done; 4361.11Sjonathan 4371.35Snisimura CHECKINTR(SYS_DEV_SCC0, IOASIC_INTR_SCC_0); 4381.35Snisimura CHECKINTR(SYS_DEV_SCC1, IOASIC_INTR_SCC_1); 4391.10Sjonathan 4401.10Sjonathan#ifdef notyet /* untested */ 4411.10Sjonathan /* If tty interrupts were enabled, re-enable them ASAP. */ 4421.10Sjonathan if ((old_mask & (KMIN_INTR_SCC_1|KMIN_INTR_SCC_0)) == 4431.10Sjonathan (KMIN_INTR_SCC_1|KMIN_INTR_SCC_0)) { 4441.12Ssimonb *imaskp = old_mask & 4451.10Sjonathan ~(KMIN_INTR_SCC_0|KMIN_INTR_SCC_1 | 4461.10Sjonathan IOASIC_INTR_LANCE|IOASIC_INTR_SCSI); 4471.14Snisimura kn02ba_wbflush(); 4481.10Sjonathan } 4491.10Sjonathan 4501.10Sjonathan /* XXX until we know about SPLs of TC options. */ 4511.10Sjonathan if (intr_depth > 1) 4521.10Sjonathan goto done; 4531.10Sjonathan#endif 4541.35Snisimura CHECKINTR(SYS_DEV_LANCE, IOASIC_INTR_LANCE); 4551.35Snisimura CHECKINTR(SYS_DEV_SCSI, IOASIC_INTR_SCSI); 4561.1Sjonathan 4571.1Sjonathan if (user_warned && ((intr & KMIN_INTR_PSWARN) == 0)) { 4581.1Sjonathan printf("%s\n", "Power supply ok now."); 4591.1Sjonathan user_warned = 0; 4601.1Sjonathan } 4611.1Sjonathan if ((intr & KMIN_INTR_PSWARN) && (user_warned < 3)) { 4621.1Sjonathan user_warned++; 4631.1Sjonathan printf("%s\n", "Power supply overheating"); 4641.1Sjonathan } 4651.1Sjonathan } 4661.39Snisimura if ((ipending & MIPS_INT_MASK_0) && intrtab[SYS_DEV_OPT0].ih_func) { 4671.35Snisimura (*intrtab[SYS_DEV_OPT0].ih_func)(intrtab[SYS_DEV_OPT0].ih_arg); 4681.52Ssimonb intrtab[SYS_DEV_OPT0].ih_count.ev_count++; 4691.1Sjonathan } 4701.12Ssimonb 4711.39Snisimura if ((ipending & MIPS_INT_MASK_1) && intrtab[SYS_DEV_OPT1].ih_func) { 4721.35Snisimura (*intrtab[SYS_DEV_OPT1].ih_func)(intrtab[SYS_DEV_OPT1].ih_arg); 4731.52Ssimonb intrtab[SYS_DEV_OPT1].ih_count.ev_count++; 4741.1Sjonathan } 4751.39Snisimura if ((ipending & MIPS_INT_MASK_2) && intrtab[SYS_DEV_OPT2].ih_func) { 4761.35Snisimura (*intrtab[SYS_DEV_OPT2].ih_func)(intrtab[SYS_DEV_OPT2].ih_arg); 4771.52Ssimonb intrtab[SYS_DEV_OPT2].ih_count.ev_count++; 4781.1Sjonathan } 4791.1Sjonathan 4801.10Sjonathandone: 4811.10Sjonathan /* restore entry state */ 4821.10Sjonathan splhigh(); 4831.10Sjonathan intr_depth--; 4841.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_IMSK) = old_mask; 4851.10Sjonathan 4861.42Snisimura _splset(MIPS_SR_INT_IE | (status & ~cause & MIPS_HARD_INT_MASK)); 4871.1Sjonathan} 4881.1Sjonathan 4891.1Sjonathan 4901.1Sjonathan 4911.1Sjonathan/* 4921.1Sjonathan ************************************************************************ 4931.1Sjonathan * Extra functions 4941.1Sjonathan ************************************************************************ 4951.1Sjonathan */ 4961.14Snisimura 4971.31Ssimonbstatic void 4981.14Snisimurakn02ba_wbflush() 4991.14Snisimura{ 5001.21Snisimura /* read twice IOASIC_IMSK */ 5011.54Sperry __asm volatile("lw $0,%0; lw $0,%0" :: 5021.27Ssimonb "i"(MIPS_PHYS_TO_KSEG1(KMIN_REG_IMSK))); 5031.14Snisimura} 5041.14Snisimura 5051.31Ssimonbstatic unsigned 5061.14Snisimurakn02ba_clkread() 5071.14Snisimura{ 5081.14Snisimura#ifdef MIPS3 5091.14Snisimura if (CPUISMIPS3) { 5101.14Snisimura u_int32_t mips3_cycles; 5111.14Snisimura 5121.43Scgd mips3_cycles = mips3_cp0_count_read() - latched_cycle_cnt; 5131.14Snisimura /* XXX divides take 78 cycles: approximate with * 41/2048 */ 5141.14Snisimura return((mips3_cycles >> 6) + (mips3_cycles >> 8) + 5151.14Snisimura (mips3_cycles >> 11)); 5161.14Snisimura } 5171.14Snisimura#endif 5181.14Snisimura return 0; 5191.1Sjonathan} 520