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