25
#include "qemu/osdep.h"
26
#include "hw/ipmi/ipmi.h"
27
#include "hw/qdev-properties.h"
28
#include "qom/object_interfaces.h"
29
#include "sysemu/runstate.h"
30
#include "qapi/error.h"
31
#include "qemu/module.h"
34
static uint32_t ipmi_current_uuid = 1;
36
uint32_t ipmi_next_uuid(void)
38
return ipmi_current_uuid++;
41
static int ipmi_do_hw_op(IPMIInterface *s, enum ipmi_op op, int checkonly)
44
case IPMI_RESET_CHASSIS:
48
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
51
case IPMI_POWEROFF_CHASSIS:
55
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
63
nmi_monitor_handle(0, NULL);
66
case IPMI_SHUTDOWN_VIA_ACPI_OVERTEMP:
70
qemu_system_powerdown_request();
73
case IPMI_POWERCYCLE_CHASSIS:
74
case IPMI_PULSE_DIAG_IRQ:
75
case IPMI_POWERON_CHASSIS:
77
return IPMI_CC_COMMAND_NOT_SUPPORTED;
81
static void ipmi_interface_class_init(ObjectClass *class, void *data)
83
IPMIInterfaceClass *ik = IPMI_INTERFACE_CLASS(class);
85
ik->do_hw_op = ipmi_do_hw_op;
88
static const TypeInfo ipmi_interface_type_info = {
89
.name = TYPE_IPMI_INTERFACE,
90
.parent = TYPE_INTERFACE,
91
.class_size = sizeof(IPMIInterfaceClass),
92
.class_init = ipmi_interface_class_init,
95
static void isa_ipmi_bmc_check(const Object *obj, const char *name,
96
Object *val, Error **errp)
98
IPMIBmc *bmc = IPMI_BMC(val);
101
error_setg(errp, "BMC object is already in use");
104
void ipmi_bmc_find_and_link(Object *obj, Object **bmc)
106
object_property_add_link(obj, "bmc", TYPE_IPMI_BMC, bmc,
108
OBJ_PROP_LINK_STRONG);
111
static Property ipmi_bmc_properties[] = {
112
DEFINE_PROP_UINT8("slave_addr", IPMIBmc, slave_addr, 0x20),
113
DEFINE_PROP_END_OF_LIST(),
116
static void bmc_class_init(ObjectClass *oc, void *data)
118
DeviceClass *dc = DEVICE_CLASS(oc);
120
device_class_set_props(dc, ipmi_bmc_properties);
123
static const TypeInfo ipmi_bmc_type_info = {
124
.name = TYPE_IPMI_BMC,
125
.parent = TYPE_DEVICE,
126
.instance_size = sizeof(IPMIBmc),
128
.class_size = sizeof(IPMIBmcClass),
129
.class_init = bmc_class_init,
132
static void ipmi_register_types(void)
134
type_register_static(&ipmi_interface_type_info);
135
type_register_static(&ipmi_bmc_type_info);
138
type_init(ipmi_register_types)