xref: /freebsd/sys/x86/isa/nmi.c (revision 32580301441a6c4f89a20c20f53e45e5557a8b64)
132580301SAttilio Rao /*-
232580301SAttilio Rao  * Copyright (c) 1991 The Regents of the University of California.
332580301SAttilio Rao  * All rights reserved.
432580301SAttilio Rao  *
532580301SAttilio Rao  * This code is derived from software contributed to Berkeley by
632580301SAttilio Rao  * William Jolitz.
732580301SAttilio Rao  *
832580301SAttilio Rao  * Redistribution and use in source and binary forms, with or without
932580301SAttilio Rao  * modification, are permitted provided that the following conditions
1032580301SAttilio Rao  * are met:
1132580301SAttilio Rao  * 1. Redistributions of source code must retain the above copyright
1232580301SAttilio Rao  *    notice, this list of conditions and the following disclaimer.
1332580301SAttilio Rao  * 2. Redistributions in binary form must reproduce the above copyright
1432580301SAttilio Rao  *    notice, this list of conditions and the following disclaimer in the
1532580301SAttilio Rao  *    documentation and/or other materials provided with the distribution.
1632580301SAttilio Rao  * 4. Neither the name of the University nor the names of its contributors
1732580301SAttilio Rao  *    may be used to endorse or promote products derived from this software
1832580301SAttilio Rao  *    without specific prior written permission.
1932580301SAttilio Rao  *
2032580301SAttilio Rao  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2132580301SAttilio Rao  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2232580301SAttilio Rao  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2332580301SAttilio Rao  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2432580301SAttilio Rao  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2532580301SAttilio Rao  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2632580301SAttilio Rao  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2732580301SAttilio Rao  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2832580301SAttilio Rao  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2932580301SAttilio Rao  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3032580301SAttilio Rao  * SUCH DAMAGE.
3132580301SAttilio Rao  *
3232580301SAttilio Rao  *	from: @(#)isa.c	7.2 (Berkeley) 5/13/91
3332580301SAttilio Rao  */
3432580301SAttilio Rao 
3532580301SAttilio Rao #include <sys/cdefs.h>
3632580301SAttilio Rao __FBSDID("$FreeBSD$");
3732580301SAttilio Rao 
3832580301SAttilio Rao #include "opt_mca.h"
3932580301SAttilio Rao 
4032580301SAttilio Rao #include <sys/types.h>
4132580301SAttilio Rao #include <sys/syslog.h>
4232580301SAttilio Rao #include <sys/systm.h>
4332580301SAttilio Rao 
4432580301SAttilio Rao #include <machine/md_var.h>
4532580301SAttilio Rao 
4632580301SAttilio Rao #ifdef DEV_MCA
4732580301SAttilio Rao #include <i386/bios/mca_machdep.h>
4832580301SAttilio Rao #endif
4932580301SAttilio Rao 
5032580301SAttilio Rao #define NMI_PARITY (1 << 7)
5132580301SAttilio Rao #define NMI_IOCHAN (1 << 6)
5232580301SAttilio Rao #define ENMI_WATCHDOG (1 << 7)
5332580301SAttilio Rao #define ENMI_BUSTIMER (1 << 6)
5432580301SAttilio Rao #define ENMI_IOSTATUS (1 << 5)
5532580301SAttilio Rao 
5632580301SAttilio Rao /*
5732580301SAttilio Rao  * Handle a NMI, possibly a machine check.
5832580301SAttilio Rao  * return true to panic system, false to ignore.
5932580301SAttilio Rao  */
6032580301SAttilio Rao int
6132580301SAttilio Rao isa_nmi(int cd)
6232580301SAttilio Rao {
6332580301SAttilio Rao 	int retval = 0;
6432580301SAttilio Rao 	int isa_port = inb(0x61);
6532580301SAttilio Rao 	int eisa_port = inb(0x461);
6632580301SAttilio Rao 
6732580301SAttilio Rao 	log(LOG_CRIT, "NMI ISA %x, EISA %x\n", isa_port, eisa_port);
6832580301SAttilio Rao #ifdef DEV_MCA
6932580301SAttilio Rao 	if (MCA_system && mca_bus_nmi())
7032580301SAttilio Rao 		return(0);
7132580301SAttilio Rao #endif
7232580301SAttilio Rao 
7332580301SAttilio Rao 	if (isa_port & NMI_PARITY) {
7432580301SAttilio Rao 		log(LOG_CRIT, "RAM parity error, likely hardware failure.");
7532580301SAttilio Rao 		retval = 1;
7632580301SAttilio Rao 	}
7732580301SAttilio Rao 
7832580301SAttilio Rao 	if (isa_port & NMI_IOCHAN) {
7932580301SAttilio Rao 		log(LOG_CRIT, "I/O channel check, likely hardware failure.");
8032580301SAttilio Rao 		retval = 1;
8132580301SAttilio Rao 	}
8232580301SAttilio Rao 
8332580301SAttilio Rao 	/*
8432580301SAttilio Rao 	 * On a real EISA machine, this will never happen.  However it can
8532580301SAttilio Rao 	 * happen on ISA machines which implement XT style floating point
8632580301SAttilio Rao 	 * error handling (very rare).  Save them from a meaningless panic.
8732580301SAttilio Rao 	 */
8832580301SAttilio Rao 	if (eisa_port == 0xff)
8932580301SAttilio Rao 		return(retval);
9032580301SAttilio Rao 
9132580301SAttilio Rao 	if (eisa_port & ENMI_WATCHDOG) {
9232580301SAttilio Rao 		log(LOG_CRIT, "EISA watchdog timer expired, likely hardware failure.");
9332580301SAttilio Rao 		retval = 1;
9432580301SAttilio Rao 	}
9532580301SAttilio Rao 
9632580301SAttilio Rao 	if (eisa_port & ENMI_BUSTIMER) {
9732580301SAttilio Rao 		log(LOG_CRIT, "EISA bus timeout, likely hardware failure.");
9832580301SAttilio Rao 		retval = 1;
9932580301SAttilio Rao 	}
10032580301SAttilio Rao 
10132580301SAttilio Rao 	if (eisa_port & ENMI_IOSTATUS) {
10232580301SAttilio Rao 		log(LOG_CRIT, "EISA I/O port status error.");
10332580301SAttilio Rao 		retval = 1;
10432580301SAttilio Rao 	}
10532580301SAttilio Rao 
10632580301SAttilio Rao 	return(retval);
10732580301SAttilio Rao }
108