| NMI(9) | Kernel Developer's Manual (x86) | NMI(9) |
nmi,
nmi_establish,
nmi_disestablish, —
NMI
#include
<x86/nmi.h>
nmi_handler_t *
nmi_establish(int
(*func)(const struct trapframe *, void *),
void *arg);
void
nmi_disestablish(nmi_handler_t
*handle);
The nmi interface lets the kernel
establish handlers for x86 Non-Maskable Interrupts (NMIs). An NMI signals to
the processor an exception on a processor, memory controller, or I/O bus
that is irrecoverable or else needs attention at a high priority. A
“debug switch” or a performance/watchdog timer may also
trigger an NMI.
An NMI handler will run to completion on the same processor where it began without being preempted by any thread or interrupt except for another NMI. An NMI handler must prepare for re-entry. An NMI handler may run simultaneously on more than one CPU.
Synchronizing access to a shared data structure from an NMI handler is a different challenge than synchronizing access from hardware/software interrupt routines or from kernel threads. An NMI handler may not perform any operation that may sleep, acquire a mutex, or schedule a software interrupt. An NMI handler may use atomic_ops(3). An NMI handler may reference per-CPU storage (percpu(9)).
An NMI handler may not write to the kernel message buffer.
nmi_establish(func,
arg)nmi_establish(), the kernel will call
(*func)(tf,
arg); every time an NMI occurs until the handler is
removed with
nmi_disestablish().
func should return non-zero if it handled a
condition that causes NMI, or zero if it did not. If, for a given NMI, all
handlers return zero, the system will panic or enter the kernel debugger,
ddb(4).
nmi_establish() returns
NULL on failure, and a handle for the NMI handler
on success.nmi_disestablish(handle)nmi_establish().The nmi interface is implemented within
the file sys/arch/x86/x86/nmi.c.
The nmi interface first appeared in
NetBSD 6.0.
YAMAMOTO Takashi <yamt@NetBSD.org>
| March 17, 2011 | NetBSD 11.0 |