126373Sdfr/*-
226373Sdfr * Copyright (c) 1991 The Regents of the University of California.
326373Sdfr * All rights reserved.
426373Sdfr *
526373Sdfr * This code is derived from software contributed to Berkeley by
626373Sdfr * William Jolitz.
726373Sdfr *
826373Sdfr * Redistribution and use in source and binary forms, with or without
926373Sdfr * modification, are permitted provided that the following conditions
1026373Sdfr * are met:
1126373Sdfr * 1. Redistributions of source code must retain the above copyright
1226373Sdfr *    notice, this list of conditions and the following disclaimer.
1326373Sdfr * 2. Redistributions in binary form must reproduce the above copyright
1426373Sdfr *    notice, this list of conditions and the following disclaimer in the
1526373Sdfr *    documentation and/or other materials provided with the distribution.
1626373Sdfr * 4. Neither the name of the University nor the names of its contributors
1726373Sdfr *    may be used to endorse or promote products derived from this software
1826373Sdfr *    without specific prior written permission.
1926373Sdfr *
2026373Sdfr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2126373Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2226373Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2326373Sdfr * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2426373Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2526373Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2626373Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2726373Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2826373Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2926373Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3026373Sdfr * SUCH DAMAGE.
3126373Sdfr *
3226373Sdfr *	from: @(#)isa.c	7.2 (Berkeley) 5/13/91
3326373Sdfr */
3426373Sdfr
35115703Sobrien#include <sys/cdefs.h>
36115703Sobrien__FBSDID("$FreeBSD$");
37115703Sobrien
3871797Speter#include "opt_mca.h"
3926373Sdfr
40121980Sjhb#include <sys/types.h>
4176166Smarkm#include <sys/syslog.h>
4276166Smarkm#include <sys/systm.h>
4376166Smarkm
4426373Sdfr#include <machine/md_var.h>
4545897Speter
4671797Speter#ifdef DEV_MCA
47112551Smdodd#include <i386/bios/mca_machdep.h>
4850823Smdodd#endif
4950823Smdodd
5026373Sdfr#define NMI_PARITY (1 << 7)
5126373Sdfr#define NMI_IOCHAN (1 << 6)
5226373Sdfr#define ENMI_WATCHDOG (1 << 7)
5326373Sdfr#define ENMI_BUSTIMER (1 << 6)
5426373Sdfr#define ENMI_IOSTATUS (1 << 5)
5526373Sdfr
5626373Sdfr/*
5726373Sdfr * Handle a NMI, possibly a machine check.
5826373Sdfr * return true to panic system, false to ignore.
5926373Sdfr */
6026373Sdfrint
61121980Sjhbisa_nmi(int cd)
6226373Sdfr{
6364294Sps	int retval = 0;
6426373Sdfr	int isa_port = inb(0x61);
6526373Sdfr	int eisa_port = inb(0x461);
6629936Smckay
6764294Sps	log(LOG_CRIT, "NMI ISA %x, EISA %x\n", isa_port, eisa_port);
6871797Speter#ifdef DEV_MCA
6950823Smdodd	if (MCA_system && mca_bus_nmi())
7054967Seivind		return(0);
7150823Smdodd#endif
7250823Smdodd
7364294Sps	if (isa_port & NMI_PARITY) {
7464294Sps		log(LOG_CRIT, "RAM parity error, likely hardware failure.");
7564294Sps		retval = 1;
7664294Sps	}
7729936Smckay
7864294Sps	if (isa_port & NMI_IOCHAN) {
7964294Sps		log(LOG_CRIT, "I/O channel check, likely hardware failure.");
8064294Sps		retval = 1;
8164294Sps	}
8229936Smckay
8329936Smckay	/*
8429936Smckay	 * On a real EISA machine, this will never happen.  However it can
8529936Smckay	 * happen on ISA machines which implement XT style floating point
8629936Smckay	 * error handling (very rare).  Save them from a meaningless panic.
8729936Smckay	 */
8829936Smckay	if (eisa_port == 0xff)
8964294Sps		return(retval);
9029936Smckay
9164294Sps	if (eisa_port & ENMI_WATCHDOG) {
9264294Sps		log(LOG_CRIT, "EISA watchdog timer expired, likely hardware failure.");
9364294Sps		retval = 1;
9464294Sps	}
9529936Smckay
9664294Sps	if (eisa_port & ENMI_BUSTIMER) {
9764294Sps		log(LOG_CRIT, "EISA bus timeout, likely hardware failure.");
9864294Sps		retval = 1;
9964294Sps	}
10029936Smckay
10164294Sps	if (eisa_port & ENMI_IOSTATUS) {
10264294Sps		log(LOG_CRIT, "EISA I/O port status error.");
10364294Sps		retval = 1;
10464294Sps	}
105122048Snyan
10664294Sps	return(retval);
10726373Sdfr}
108