diff options
-rw-r--r-- | core/ipmi.c | 5 | ||||
-rw-r--r-- | hw/ipmi/ipmi-power.c | 6 | ||||
-rw-r--r-- | include/ipmi.h | 3 |
3 files changed, 14 insertions, 0 deletions
diff --git a/core/ipmi.c b/core/ipmi.c index 51908cd..67086d6 100644 --- a/core/ipmi.c +++ b/core/ipmi.c @@ -96,3 +96,8 @@ void ipmi_register_backend(struct ipmi_backend *backend) assert(backend->dequeue_msg); ipmi_backend = backend; } + +bool ipmi_present(void) +{ + return ipmi_backend != NULL; +} diff --git a/hw/ipmi/ipmi-power.c b/hw/ipmi/ipmi-power.c index ae3c577..05c0e4c 100644 --- a/hw/ipmi/ipmi-power.c +++ b/hw/ipmi/ipmi-power.c @@ -22,6 +22,9 @@ int ipmi_chassis_control(uint8_t request) { struct ipmi_msg *msg; + if (!ipmi_present()) + return OPAL_CLOSED; + if (request > IPMI_CHASSIS_SOFT_SHUTDOWN) return OPAL_PARAMETER; @@ -44,6 +47,9 @@ int ipmi_set_power_state(uint8_t system, uint8_t device) uint8_t device; } power_state; + if (!ipmi_present()) + return OPAL_CLOSED; + power_state.system = system; power_state.device = device; diff --git a/include/ipmi.h b/include/ipmi.h index c64e1bd..6a438fb 100644 --- a/include/ipmi.h +++ b/include/ipmi.h @@ -18,6 +18,7 @@ #define __IPMI_H #include <stdint.h> +#include <stdbool.h> /* * IPMI codes as defined by the standard. @@ -136,6 +137,8 @@ struct ipmi_backend { /* Initialise the IPMI interface */ void ipmi_init(void); +bool ipmi_present(void); + void ipmi_free_msg(struct ipmi_msg *msg); struct ipmi_msg *ipmi_mkmsg_simple(uint32_t code, void *req_data, size_t req_size); |