dec_3min.c revision 1.2
11.2Sjonathan/*	$NetBSD: dec_3min.c,v 1.2 1998/03/25 06:22:19 jonathan 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) 1988 University of Utah.
351.1Sjonathan * Copyright (c) 1992, 1993
361.1Sjonathan *	The Regents of the University of California.  All rights reserved.
371.1Sjonathan *
381.1Sjonathan * This code is derived from software contributed to Berkeley by
391.1Sjonathan * the Systems Programming Group of the University of Utah Computer
401.1Sjonathan * Science Department, The Mach Operating System project at
411.1Sjonathan * Carnegie-Mellon University and Ralph Campbell.
421.1Sjonathan *
431.1Sjonathan * Redistribution and use in source and binary forms, with or without
441.1Sjonathan * modification, are permitted provided that the following conditions
451.1Sjonathan * are met:
461.1Sjonathan * 1. Redistributions of source code must retain the above copyright
471.1Sjonathan *    notice, this list of conditions and the following disclaimer.
481.1Sjonathan * 2. Redistributions in binary form must reproduce the above copyright
491.1Sjonathan *    notice, this list of conditions and the following disclaimer in the
501.1Sjonathan *    documentation and/or other materials provided with the distribution.
511.1Sjonathan * 3. All advertising materials mentioning features or use of this software
521.1Sjonathan *    must display the following acknowledgement:
531.1Sjonathan *	This product includes software developed by the University of
541.1Sjonathan *	California, Berkeley and its contributors.
551.1Sjonathan * 4. Neither the name of the University nor the names of its contributors
561.1Sjonathan *    may be used to endorse or promote products derived from this software
571.1Sjonathan *    without specific prior written permission.
581.1Sjonathan *
591.1Sjonathan * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
601.1Sjonathan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
611.1Sjonathan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
621.1Sjonathan * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
631.1Sjonathan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
641.1Sjonathan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
651.1Sjonathan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
661.1Sjonathan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
671.1Sjonathan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
681.1Sjonathan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
691.1Sjonathan * SUCH DAMAGE.
701.1Sjonathan *
711.1Sjonathan *	@(#)machdep.c	8.3 (Berkeley) 1/12/94
721.1Sjonathan */
731.1Sjonathan
741.1Sjonathan#include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
751.1Sjonathan
761.2Sjonathan__KERNEL_RCSID(0, "$NetBSD: dec_3min.c,v 1.2 1998/03/25 06:22:19 jonathan Exp $");
771.1Sjonathan
781.1Sjonathan
791.1Sjonathan#include <sys/types.h>
801.1Sjonathan#include <sys/systm.h>
811.1Sjonathan
821.1Sjonathan#include <machine/cpu.h>
831.1Sjonathan#include <machine/intr.h>
841.1Sjonathan#include <machine/reg.h>
851.1Sjonathan#include <machine/psl.h>
861.1Sjonathan#include <machine/locore.h>		/* wbflush() */
871.1Sjonathan#include <machine/autoconf.h>		/* intr_arg_t */
881.1Sjonathan#include <machine/sysconf.h>
891.1Sjonathan
901.1Sjonathan#include <mips/mips_param.h>		/* hokey spl()s */
911.1Sjonathan#include <mips/mips/mips_mcclock.h>	/* mcclock CPUspeed estimation */
921.2Sjonathan
931.2Sjonathan/* all these to get ioasic_base */
941.2Sjonathan#include <sys/device.h>			/* struct cfdata for.. */
951.2Sjonathan#include <dev/tc/tcvar.h>		/* tc type definitions for.. */
961.2Sjonathan#include <dev/tc/ioasicvar.h>		/* ioasic_base */
971.1Sjonathan
981.1Sjonathan#include <pmax/pmax/clockreg.h>
991.1Sjonathan#include <pmax/pmax/asic.h>
1001.1Sjonathan#include <pmax/pmax/turbochannel.h>
1011.1Sjonathan#include <pmax/pmax/pmaxtype.h>
1021.1Sjonathan#include <pmax/pmax/trap.h>		/* mboard-specific interrupt fns */
1031.1Sjonathan#include <pmax/pmax/cons.h>
1041.1Sjonathan
1051.1Sjonathan#include <pmax/pmax/machdep.h>		/* XXXjrs replace with vectors */
1061.1Sjonathan
1071.1Sjonathan#include <pmax/pmax/kmin.h>		/* 3min baseboard addresses */
1081.1Sjonathan#include <pmax/pmax/dec_kn02_subr.h>	/* 3min/maxine memory errors */
1091.1Sjonathan
1101.1Sjonathan
1111.1Sjonathan/*
1121.1Sjonathan * forward declarations
1131.1Sjonathan */
1141.1Sjonathanvoid		dec_3min_init __P((void));
1151.1Sjonathanvoid		dec_3min_os_init __P((void));
1161.1Sjonathanvoid		dec_3min_bus_reset __P((void));
1171.1Sjonathanvoid		dec_3maxplus_device_register __P((struct device *, void *));
1181.1Sjonathan
1191.1Sjonathanvoid		dec_3min_enable_intr
1201.1Sjonathan		   __P ((u_int slotno, int (*handler) __P((intr_arg_t sc)),
1211.1Sjonathan			 intr_arg_t sc, int onoff));
1221.1Sjonathanint		dec_3min_intr __P((u_int mask, u_int pc,
1231.1Sjonathan			      u_int statusReg, u_int causeReg));
1241.1Sjonathan
1251.1Sjonathanvoid		dec_3min_device_register __P((struct device *, void *));
1261.1Sjonathanvoid		dec_3min_cons_init __P((void));
1271.1Sjonathanconst char*	dec_3min_model_name __P((void));
1281.1Sjonathan
1291.1Sjonathan
1301.1Sjonathan/*
1311.1Sjonathan * Local declarations.
1321.1Sjonathan */
1331.1Sjonathanvoid dec_3min_mcclock_cpuspeed __P((volatile struct chiptime *mcclock_addr,
1341.1Sjonathan			       int clockmask));
1351.1Sjonathanu_long	kmin_tc3_imask;
1361.1Sjonathan
1371.1Sjonathan
1381.1Sjonathan/*
1391.1Sjonathan * Fill in platform struct.
1401.1Sjonathan */
1411.1Sjonathanvoid
1421.1Sjonathandec_3min_init()
1431.1Sjonathan{
1441.1Sjonathan
1451.1Sjonathan	platform.family = "Decstation 5000";
1461.1Sjonathan
1471.1Sjonathan	platform.model = "5000/1xx";
1481.1Sjonathan
1491.1Sjonathan	platform.iobus = "tcbus";
1501.1Sjonathan
1511.1Sjonathan	platform.os_init = dec_3min_os_init;
1521.1Sjonathan	platform.bus_reset = dec_3min_bus_reset;
1531.1Sjonathan	platform.cons_init = dec_3min_cons_init;
1541.1Sjonathan	platform.device_register = dec_3min_device_register;
1551.1Sjonathan
1561.1Sjonathan	dec_3min_os_init();
1571.1Sjonathan
1581.1Sjonathan}
1591.1Sjonathan
1601.1Sjonathan
1611.1Sjonathan/*
1621.1Sjonathan * Initalize the memory system and I/O buses.
1631.1Sjonathan */
1641.1Sjonathanvoid
1651.1Sjonathandec_3min_bus_reset()
1661.1Sjonathan{
1671.1Sjonathan
1681.1Sjonathan	/*
1691.1Sjonathan	 * Reset interrupts, clear any errors from newconf probes
1701.1Sjonathan	 */
1711.1Sjonathan
1721.1Sjonathan	*(volatile u_int *)MIPS_PHYS_TO_KSEG1(KMIN_REG_TIMEOUT) = 0;
1731.1Sjonathan	wbflush();
1741.1Sjonathan
1751.1Sjonathan	*(volatile u_int *)IOASIC_REG_INTR(ioasic_base) = 0;
1761.1Sjonathan	wbflush();
1771.1Sjonathan
1781.1Sjonathan}
1791.1Sjonathan
1801.1Sjonathan
1811.1Sjonathanvoid
1821.1Sjonathandec_3min_os_init()
1831.1Sjonathan{
1841.1Sjonathan	ioasic_base = MIPS_PHYS_TO_KSEG1(KMIN_SYS_ASIC);
1851.1Sjonathan	mips_hardware_intr = dec_3min_intr;
1861.1Sjonathan	tc_enable_interrupt = dec_3min_enable_intr;
1871.1Sjonathan	kmin_tc3_imask = (KMIN_INTR_CLOCK | KMIN_INTR_PSWARN |
1881.1Sjonathan		KMIN_INTR_TIMEOUT);
1891.1Sjonathan
1901.1Sjonathan	/*
1911.1Sjonathan	 * Since all the motherboard interrupts come through the
1921.1Sjonathan	 * I/O ASIC, it has to be turned off for all the spls and
1931.1Sjonathan	 * since we don't know what kinds of devices are in the
1941.1Sjonathan	 * turbochannel option slots, just splhigh().
1951.1Sjonathan	 */
1961.1Sjonathan	Mach_splbio = splhigh;
1971.1Sjonathan	Mach_splnet = splhigh;
1981.1Sjonathan	Mach_spltty = splhigh;
1991.1Sjonathan	Mach_splimp = splhigh;
2001.1Sjonathan	Mach_splclock = splhigh;
2011.1Sjonathan	Mach_splstatclock = splhigh;
2021.1Sjonathan	mcclock_addr = (volatile struct chiptime *)
2031.1Sjonathan		MIPS_PHYS_TO_KSEG1(KMIN_SYS_CLOCK);
2041.1Sjonathan	dec_3min_mcclock_cpuspeed(mcclock_addr, MIPS_INT_MASK_3);
2051.1Sjonathan
2061.1Sjonathan	/*
2071.1Sjonathan	 * Initialize interrupts.
2081.1Sjonathan	 */
2091.1Sjonathan	*(u_int *)IOASIC_REG_IMSK(ioasic_base) = KMIN_IM0;
2101.1Sjonathan	*(u_int *)IOASIC_REG_INTR(ioasic_base) = 0;
2111.1Sjonathan
2121.1Sjonathan	/* clear any memory errors from probes */
2131.1Sjonathan
2141.1Sjonathan	*(volatile u_int *)MIPS_PHYS_TO_KSEG1(KMIN_REG_TIMEOUT) = 0;
2151.1Sjonathan	wbflush();
2161.1Sjonathan
2171.1Sjonathan
2181.1Sjonathan	sprintf(cpu_model, "5000/1%d", cpu_mhz);
2191.1Sjonathan
2201.1Sjonathan	/*
2211.1Sjonathan	 * The kmin memory hardware seems to wrap  memory addresses
2221.1Sjonathan	 * with 4Mbyte SIMMs, which causes the physmem computation
2231.1Sjonathan	 * to lose.  Find out how big the SIMMS are and set
2241.1Sjonathan	 * max_	physmem accordingly.
2251.1Sjonathan	 * XXX Do MAXINEs lose the same way?
2261.1Sjonathan	 */
2271.1Sjonathan	physmem_boardmax = KMIN_PHYS_MEMORY_END + 1;
2281.1Sjonathan	if ((*(int*)(MIPS_PHYS_TO_KSEG1(KMIN_REG_MSR)) &
2291.1Sjonathan	     KMIN_MSR_SIZE_16Mb) == 0)
2301.1Sjonathan		physmem_boardmax = physmem_boardmax >> 2;
2311.1Sjonathan	physmem_boardmax = MIPS_PHYS_TO_KSEG1(physmem_boardmax);
2321.1Sjonathan}
2331.1Sjonathan
2341.1Sjonathan
2351.1Sjonathanvoid
2361.1Sjonathandec_3min_cons_init()
2371.1Sjonathan{
2381.1Sjonathan	/* notyet */
2391.1Sjonathan}
2401.1Sjonathan
2411.1Sjonathan
2421.1Sjonathanconst char*
2431.1Sjonathandec_3min_model_name()
2441.1Sjonathan{
2451.1Sjonathan	return ("Decstation 5000/1xx");
2461.1Sjonathan}
2471.1Sjonathan
2481.1Sjonathan
2491.1Sjonathanvoid
2501.1Sjonathandec_3min_device_register(dev, aux)
2511.1Sjonathan	struct device *dev;
2521.1Sjonathan	void *aux;
2531.1Sjonathan{
2541.1Sjonathan	panic("dec_3min_device_register unimplemented");
2551.1Sjonathan}
2561.1Sjonathan
2571.1Sjonathan
2581.1Sjonathanvoid
2591.1Sjonathandec_3min_enable_intr(slotno, handler, sc, on)
2601.1Sjonathan	register unsigned int slotno;
2611.1Sjonathan	int (*handler) __P((void* softc));
2621.1Sjonathan	void *sc;
2631.1Sjonathan	int on;
2641.1Sjonathan{
2651.1Sjonathan	register unsigned mask;
2661.1Sjonathan
2671.1Sjonathan	switch (slotno) {
2681.1Sjonathan		/* slots 0-2 don't interrupt through the IOASIC. */
2691.1Sjonathan	case 0:
2701.1Sjonathan		mask = MIPS_INT_MASK_0;	break;
2711.1Sjonathan	case 1:
2721.1Sjonathan		mask = MIPS_INT_MASK_1; break;
2731.1Sjonathan	case 2:
2741.1Sjonathan		mask = MIPS_INT_MASK_2; break;
2751.1Sjonathan
2761.1Sjonathan	case KMIN_SCSI_SLOT:
2771.1Sjonathan		mask = (KMIN_INTR_SCSI | KMIN_INTR_SCSI_PTR_LOAD |
2781.1Sjonathan			KMIN_INTR_SCSI_OVRUN | KMIN_INTR_SCSI_READ_E);
2791.1Sjonathan		break;
2801.1Sjonathan
2811.1Sjonathan	case KMIN_LANCE_SLOT:
2821.1Sjonathan		mask = KMIN_INTR_LANCE;
2831.1Sjonathan		break;
2841.1Sjonathan	case KMIN_SCC0_SLOT:
2851.1Sjonathan		mask = KMIN_INTR_SCC_0;
2861.1Sjonathan		break;
2871.1Sjonathan	case KMIN_SCC1_SLOT:
2881.1Sjonathan		mask = KMIN_INTR_SCC_1;
2891.1Sjonathan		break;
2901.1Sjonathan	case KMIN_ASIC_SLOT:
2911.1Sjonathan		mask = KMIN_INTR_ASIC;
2921.1Sjonathan		break;
2931.1Sjonathan	default:
2941.1Sjonathan		return;
2951.1Sjonathan	}
2961.1Sjonathan
2971.1Sjonathan#if defined(DEBUG) || defined(DIAGNOSTIC)
2981.1Sjonathan	printf("3MIN: imask %lx, %sabling slot %d, sc %p handler %p\n",
2991.1Sjonathan	       kmin_tc3_imask, (on? "en" : "dis"), slotno, sc, handler);
3001.1Sjonathan#endif
3011.1Sjonathan
3021.1Sjonathan	/*
3031.1Sjonathan	 * Enable the interrupt  handler, and if it's an IOASIC
3041.1Sjonathan	 * slot, set the IOASIC interrupt mask.
3051.1Sjonathan	 * Otherwise, set the appropriate spl level in the R3000
3061.1Sjonathan	 * register.
3071.1Sjonathan	 * Be careful to set handlers  before enabling, and disable
3081.1Sjonathan	 * interrupts before clearing handlers.
3091.1Sjonathan	 */
3101.1Sjonathan
3111.1Sjonathan	if (on) {
3121.1Sjonathan		/* Set the interrupt handler and argument ... */
3131.1Sjonathan		tc_slot_info[slotno].intr = handler;
3141.1Sjonathan		tc_slot_info[slotno].sc = sc;
3151.1Sjonathan
3161.1Sjonathan		/* ... and set the relevant mask */
3171.1Sjonathan		if (slotno <= 2) {
3181.1Sjonathan			/* it's an option slot */
3191.1Sjonathan			int s = splhigh();
3201.1Sjonathan			s  |= mask;
3211.1Sjonathan			splx(s);
3221.1Sjonathan		} else {
3231.1Sjonathan			/* it's a baseboard device going via the ASIC */
3241.1Sjonathan			kmin_tc3_imask |= mask;
3251.1Sjonathan		}
3261.1Sjonathan	} else {
3271.1Sjonathan		/* Clear the relevant mask... */
3281.1Sjonathan		if (slotno <= 2) {
3291.1Sjonathan			/* it's an option slot */
3301.1Sjonathan			int s = splhigh();
3311.1Sjonathan			printf("kmin_intr: cannot disable option slot %d\n",
3321.1Sjonathan			    slotno);
3331.1Sjonathan			s &= ~mask;
3341.1Sjonathan			splx(s);
3351.1Sjonathan		} else {
3361.1Sjonathan			/* it's a baseboard device going via the ASIC */
3371.1Sjonathan			kmin_tc3_imask &= ~mask;
3381.1Sjonathan		}
3391.1Sjonathan		/* ... and clear the handler */
3401.1Sjonathan		tc_slot_info[slotno].intr = 0;
3411.1Sjonathan		tc_slot_info[slotno].sc = 0;
3421.1Sjonathan	}
3431.1Sjonathan}
3441.1Sjonathan
3451.1Sjonathan
3461.1Sjonathan
3471.1Sjonathan/*
3481.1Sjonathan * 3min hardware interrupts. (DECstation 5000/1xx)
3491.1Sjonathan */
3501.1Sjonathanint
3511.1Sjonathandec_3min_intr(mask, pc, statusReg, causeReg)
3521.1Sjonathan	unsigned mask;
3531.1Sjonathan	unsigned pc;
3541.1Sjonathan	unsigned statusReg;
3551.1Sjonathan	unsigned causeReg;
3561.1Sjonathan{
3571.1Sjonathan	register u_int intr;
3581.1Sjonathan	register volatile struct chiptime *c =
3591.1Sjonathan	    (volatile struct chiptime *) MIPS_PHYS_TO_KSEG1(KMIN_SYS_CLOCK);
3601.1Sjonathan	volatile u_int *imaskp =
3611.1Sjonathan		(volatile u_int *)MIPS_PHYS_TO_KSEG1(KMIN_REG_IMSK);
3621.1Sjonathan	volatile u_int *intrp =
3631.1Sjonathan		(volatile u_int *)MIPS_PHYS_TO_KSEG1(KMIN_REG_INTR);
3641.1Sjonathan	unsigned int old_mask;
3651.1Sjonathan	struct clockframe cf;
3661.1Sjonathan	int temp;
3671.1Sjonathan	static int user_warned = 0;
3681.1Sjonathan
3691.1Sjonathan	old_mask = *imaskp & kmin_tc3_imask;
3701.1Sjonathan	*imaskp = kmin_tc3_imask |
3711.1Sjonathan		 (KMIN_IM0 & ~(KN03_INTR_TC_0|KN03_INTR_TC_1|KN03_INTR_TC_2));
3721.1Sjonathan
3731.1Sjonathan	if (mask & MIPS_INT_MASK_4)
3741.1Sjonathan		prom_haltbutton();
3751.1Sjonathan
3761.1Sjonathan	if (mask & MIPS_INT_MASK_3) {
3771.1Sjonathan		intr = *intrp;
3781.1Sjonathan
3791.1Sjonathan		/* masked interrupts are still observable */
3801.1Sjonathan		intr &= old_mask;
3811.1Sjonathan
3821.1Sjonathan		if (intr & KMIN_INTR_SCSI_PTR_LOAD) {
3831.1Sjonathan			*intrp &= ~KMIN_INTR_SCSI_PTR_LOAD;
3841.1Sjonathan#ifdef notdef
3851.1Sjonathan			asc_dma_intr();
3861.1Sjonathan#endif
3871.1Sjonathan		}
3881.1Sjonathan
3891.1Sjonathan		if (intr & (KMIN_INTR_SCSI_OVRUN | KMIN_INTR_SCSI_READ_E))
3901.1Sjonathan			*intrp &= ~(KMIN_INTR_SCSI_OVRUN | KMIN_INTR_SCSI_READ_E);
3911.1Sjonathan
3921.1Sjonathan		if (intr & KMIN_INTR_LANCE_READ_E)
3931.1Sjonathan			*intrp &= ~KMIN_INTR_LANCE_READ_E;
3941.1Sjonathan
3951.1Sjonathan		if (intr & KMIN_INTR_TIMEOUT)
3961.1Sjonathan			kn02ba_errintr();
3971.1Sjonathan
3981.1Sjonathan		if (intr & KMIN_INTR_CLOCK) {
3991.1Sjonathan			temp = c->regc;	/* XXX clear interrupt bits */
4001.1Sjonathan			cf.pc = pc;
4011.1Sjonathan			cf.sr = statusReg;
4021.1Sjonathan			hardclock(&cf);
4031.1Sjonathan			intrcnt[HARDCLOCK]++;
4041.1Sjonathan		}
4051.1Sjonathan
4061.1Sjonathan		if ((intr & KMIN_INTR_SCC_0) &&
4071.1Sjonathan		    tc_slot_info[KMIN_SCC0_SLOT].intr) {
4081.1Sjonathan			(*(tc_slot_info[KMIN_SCC0_SLOT].intr))
4091.1Sjonathan			  (tc_slot_info[KMIN_SCC0_SLOT].sc);
4101.1Sjonathan			intrcnt[SERIAL0_INTR]++;
4111.1Sjonathan		}
4121.1Sjonathan
4131.1Sjonathan		if ((intr & KMIN_INTR_SCC_1) &&
4141.1Sjonathan		    tc_slot_info[KMIN_SCC1_SLOT].intr) {
4151.1Sjonathan			(*(tc_slot_info[KMIN_SCC1_SLOT].intr))
4161.1Sjonathan			  (tc_slot_info[KMIN_SCC1_SLOT].sc);
4171.1Sjonathan			intrcnt[SERIAL1_INTR]++;
4181.1Sjonathan		}
4191.1Sjonathan
4201.1Sjonathan		if ((intr & KMIN_INTR_SCSI) &&
4211.1Sjonathan		    tc_slot_info[KMIN_SCSI_SLOT].intr) {
4221.1Sjonathan			(*(tc_slot_info[KMIN_SCSI_SLOT].intr))
4231.1Sjonathan			  (tc_slot_info[KMIN_SCSI_SLOT].sc);
4241.1Sjonathan			intrcnt[SCSI_INTR]++;
4251.1Sjonathan		}
4261.1Sjonathan
4271.1Sjonathan		if ((intr & KMIN_INTR_LANCE) &&
4281.1Sjonathan		    tc_slot_info[KMIN_LANCE_SLOT].intr) {
4291.1Sjonathan			(*(tc_slot_info[KMIN_LANCE_SLOT].intr))
4301.1Sjonathan			  (tc_slot_info[KMIN_LANCE_SLOT].sc);
4311.1Sjonathan			intrcnt[LANCE_INTR]++;
4321.1Sjonathan		}
4331.1Sjonathan
4341.1Sjonathan		if (user_warned && ((intr & KMIN_INTR_PSWARN) == 0)) {
4351.1Sjonathan			printf("%s\n", "Power supply ok now.");
4361.1Sjonathan			user_warned = 0;
4371.1Sjonathan		}
4381.1Sjonathan		if ((intr & KMIN_INTR_PSWARN) && (user_warned < 3)) {
4391.1Sjonathan			user_warned++;
4401.1Sjonathan			printf("%s\n", "Power supply overheating");
4411.1Sjonathan		}
4421.1Sjonathan	}
4431.1Sjonathan	if ((mask & MIPS_INT_MASK_0) && tc_slot_info[0].intr) {
4441.1Sjonathan		(*tc_slot_info[0].intr)(tc_slot_info[0].sc);
4451.1Sjonathan		intrcnt[SLOT0_INTR]++;
4461.1Sjonathan 	}
4471.1Sjonathan
4481.1Sjonathan	if ((mask & MIPS_INT_MASK_1) && tc_slot_info[1].intr) {
4491.1Sjonathan		(*tc_slot_info[1].intr)(tc_slot_info[1].sc);
4501.1Sjonathan		intrcnt[SLOT1_INTR]++;
4511.1Sjonathan	}
4521.1Sjonathan	if ((mask & MIPS_INT_MASK_2) && tc_slot_info[2].intr) {
4531.1Sjonathan		(*tc_slot_info[2].intr)(tc_slot_info[2].sc);
4541.1Sjonathan		intrcnt[SLOT2_INTR]++;
4551.1Sjonathan	}
4561.1Sjonathan
4571.1Sjonathan#if 0 /*XXX*/
4581.1Sjonathan	if (mask & (MIPS_INT_MASK_2|MIPS_INT_MASK_1|MIPS_INT_MASK_0))
4591.1Sjonathan		printf("kmin: slot intr, mask 0x%x\n",
4601.1Sjonathan			mask &
4611.1Sjonathan			(MIPS_INT_MASK_2|MIPS_INT_MASK_1|MIPS_INT_MASK_0));
4621.1Sjonathan#endif
4631.1Sjonathan
4641.1Sjonathan	return ((statusReg & ~causeReg & MIPS_HARD_INT_MASK) |
4651.1Sjonathan		MIPS_SR_INT_ENA_CUR);
4661.1Sjonathan}
4671.1Sjonathan
4681.1Sjonathan
4691.1Sjonathan
4701.1Sjonathan/*
4711.1Sjonathan ************************************************************************
4721.1Sjonathan * Extra functions
4731.1Sjonathan ************************************************************************
4741.1Sjonathan */
4751.1Sjonathan
4761.1Sjonathan
4771.1Sjonathan
4781.1Sjonathan
4791.1Sjonathan/*
4801.1Sjonathan * Count instructions between 4ms mcclock interrupt requests,
4811.1Sjonathan * using the ioasic clock-interrupt-pending bit to determine
4821.1Sjonathan * when clock ticks occur.
4831.1Sjonathan * Set up iosiac to allow only clock interrupts, then
4841.1Sjonathan * call
4851.1Sjonathan */
4861.1Sjonathanvoid
4871.1Sjonathandec_3min_mcclock_cpuspeed(mcclock_addr, clockmask)
4881.1Sjonathan	volatile struct chiptime *mcclock_addr;
4891.1Sjonathan	int clockmask;
4901.1Sjonathan{
4911.1Sjonathan	register volatile u_int * ioasic_intrmaskp =
4921.1Sjonathan		(volatile u_int *)MIPS_PHYS_TO_KSEG1(KMIN_REG_IMSK);
4931.1Sjonathan
4941.1Sjonathan	register int saved_imask = *ioasic_intrmaskp;
4951.1Sjonathan
4961.1Sjonathan	/* Allow only clock interrupts through ioasic. */
4971.1Sjonathan	*ioasic_intrmaskp = KMIN_INTR_CLOCK;
4981.1Sjonathan	wbflush();
4991.1Sjonathan
5001.1Sjonathan	mc_cpuspeed(mcclock_addr, clockmask);
5011.1Sjonathan
5021.1Sjonathan	*ioasic_intrmaskp = saved_imask;
5031.1Sjonathan	wbflush();
5041.1Sjonathan}
5051.1Sjonathan
506