master
h 74 lines 2.32 KB
Raw
1 /*
2 * NMI monitor handler class and helpers definitions.
3 *
4 * Copyright IBM Corp., 2014
5 *
6 * Author: Alexey Kardashevskiy <aik@ozlabs.ru>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License,
11 * or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef NMI_H
23 #define NMI_H
24
25 #include "qom/object.h"
26
27 #define TYPE_NMI "nmi"
28
29 typedef struct NMIClass NMIClass;
30 DECLARE_CLASS_CHECKERS(NMIClass, NMI,
31 TYPE_NMI)
32 #define NMI(obj) \
33 INTERFACE_CHECK(NMIState, (obj), TYPE_NMI)
34
35 typedef struct NMIState NMIState;
36
37 struct NMIClass {
38 InterfaceClass parent_class;
39
40 /**
41 * raise_nmi: Callback to handle NMI notifications.
42 * @ns: Class #NMIState state
43 *
44 * Called by nmi_inject() to perform the machine-specific
45 * action when a NMI is requested.
46 */
47 void (*raise_nmi)(NMIState *ns);
48 };
49
50 /**
51 * nmi_inject: Inject an NMI, in a machine-specific way
52 * @errp: pointer to error object
53 *
54 * This function injects an NMI, in a machine-specific way. The
55 * intention is that this should typically trigger a guest kernel
56 * dump or reboot, and might happen as a result of user request
57 * from the monitor, watchdog timeouts, and similar events.
58 * (For example on the x86 PC it triggers an NMI on all CPUs,
59 * and on s390 it triggers the RESTART interrupt on the first CPU.)
60 *
61 * The NMI is injected by looking for a QOM object which implements
62 * the TYPE_NMI interface, and calling its raise_nmi method. Usually
63 * it is the machine model class that implements this interface.
64 *
65 * Not all machines implement NMI handling; this function
66 * will return an error if used on a machine which does not
67 * implement NMIs.
68 *
69 * On success, return %true.
70 * On failure, store an error through @errp and return %false.
71 */
72 bool nmi_inject(Error **errp);
73
74 #endif /* NMI_H */