From 46470a38d0a3b8f29cd8efc4af8a76adcace524a Mon Sep 17 00:00:00 2001 From: Patrick Venture Date: Fri, 7 Sep 2018 19:26:25 -0700 Subject: rename headers to match style Moving headers from ".h" to ".hpp" Reworked the header inclusion a bit so that host-ipmid is treated as a library, and local headers aren't. renamed apphandler.h => apphandler.hpp renamed chassishandler.h => chassishandler.hpp renamed globalhandler.h => globalhandler.hpp renamed sensorhandler.h => sensorhandler.hpp renamed storageaddsel.h => storageaddsel.hpp renamed storagehandler.h => storagehandler.hpp renamed systemintfcmds.h => systemintfcmds.hpp Change-Id: I9d4ce3dd57e2e996800f9020a10cc10cdf2c3914 Signed-off-by: Patrick Venture --- app/watchdog.cpp | 3 +- app/watchdog.hpp | 2 +- app/watchdog_service.cpp | 4 +- apphandler.cpp | 6 +- apphandler.h | 40 --- apphandler.hpp | 37 +++ chassishandler.cpp | 9 +- chassishandler.h | 62 ----- chassishandler.hpp | 59 ++++ dcmihandler.cpp | 3 +- dcmihandler.hpp | 5 +- fruread.hpp | 5 +- globalhandler.cpp | 8 +- globalhandler.h | 13 - globalhandler.hpp | 10 + groupext.cpp | 3 +- host-cmd-manager.cpp | 12 +- host-interface.cpp | 11 +- host-ipmid/oemopenbmc.hpp | 4 +- ipmid.cpp | 11 +- ipmid.hpp | 9 +- ipmisensor.cpp | 4 +- ipmiwhitelist.hpp | 5 +- oemrouter.cpp | 3 +- read_fru_data.cpp | 4 +- selutility.cpp | 11 +- sensordatahandler.cpp | 3 +- sensordatahandler.hpp | 5 +- sensorhandler.cpp | 5 +- sensorhandler.h | 642 -------------------------------------------- sensorhandler.hpp | 639 +++++++++++++++++++++++++++++++++++++++++++ storageaddsel.cpp | 7 +- storageaddsel.h | 17 -- storageaddsel.hpp | 19 ++ storagehandler.cpp | 9 +- storagehandler.h | 91 ------- storagehandler.hpp | 89 ++++++ systemintfcmds.cpp | 6 +- systemintfcmds.h | 46 ---- systemintfcmds.hpp | 43 +++ test/oemrouter_unittest.cpp | 4 +- testaddsel.cpp | 4 +- transporthandler.cpp | 4 +- 43 files changed, 974 insertions(+), 1002 deletions(-) delete mode 100644 apphandler.h create mode 100644 apphandler.hpp delete mode 100644 chassishandler.h create mode 100644 chassishandler.hpp delete mode 100644 globalhandler.h create mode 100644 globalhandler.hpp delete mode 100644 sensorhandler.h create mode 100644 sensorhandler.hpp delete mode 100644 storageaddsel.h create mode 100644 storageaddsel.hpp delete mode 100644 storagehandler.h create mode 100644 storagehandler.hpp delete mode 100644 systemintfcmds.h create mode 100644 systemintfcmds.hpp diff --git a/app/watchdog.cpp b/app/watchdog.cpp index f6818cb..3d8e227 100644 --- a/app/watchdog.cpp +++ b/app/watchdog.cpp @@ -4,6 +4,7 @@ #include "watchdog_service.hpp" #include +#include #include #include @@ -12,8 +13,6 @@ #include #include -#include "host-ipmid/ipmid-api.h" - using phosphor::logging::commit; using phosphor::logging::level; using phosphor::logging::log; diff --git a/app/watchdog.hpp b/app/watchdog.hpp index 507695f..268ca92 100644 --- a/app/watchdog.hpp +++ b/app/watchdog.hpp @@ -1,6 +1,6 @@ #pragma once -#include "host-ipmid/ipmid-api.h" +#include /** @brief The RESET watchdog IPMI command. * diff --git a/app/watchdog_service.cpp b/app/watchdog_service.cpp index 923264b..769a70d 100644 --- a/app/watchdog_service.cpp +++ b/app/watchdog_service.cpp @@ -1,5 +1,7 @@ #include "watchdog_service.hpp" +#include + #include #include #include @@ -11,8 +13,6 @@ #include #include -#include "host-ipmid/ipmid-api.h" - using phosphor::logging::elog; using phosphor::logging::entry; using phosphor::logging::level; diff --git a/apphandler.cpp b/apphandler.cpp index 4a2f2da..c77f014 100644 --- a/apphandler.cpp +++ b/apphandler.cpp @@ -1,15 +1,15 @@ -#include "apphandler.h" +#include "apphandler.hpp" #include "app/channel.hpp" #include "app/watchdog.hpp" #include "ipmid.hpp" -#include "nlohmann/json.hpp" #include "sys_info_param.hpp" #include "transporthandler.hpp" #include "types.hpp" #include "utils.hpp" #include +#include #include #include #include @@ -17,7 +17,7 @@ #include #include -#include "host-ipmid/ipmid-api.h" +#include #if __has_include() #include diff --git a/apphandler.h b/apphandler.h deleted file mode 100644 index cbfafb2..0000000 --- a/apphandler.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef __HOST_IPMI_APP_HANDLER_H__ -#define __HOST_IPMI_APP_HANDLER_H__ - -#include - -// IPMI commands for App net functions. -enum ipmi_netfn_app_cmds -{ - // Get capability bits - IPMI_CMD_GET_DEVICE_ID = 0x01, - IPMI_CMD_GET_SELF_TEST_RESULTS = 0x04, - IPMI_CMD_SET_ACPI = 0x06, - IPMI_CMD_GET_DEVICE_GUID = 0x08, - IPMI_CMD_RESET_WD = 0x22, - IPMI_CMD_SET_WD = 0x24, - IPMI_CMD_GET_WD = 0x25, - IPMI_CMD_GET_CAP_BIT = 0x36, - IPMI_CMD_GET_SYS_GUID = 0x37, - IPMI_CMD_SET_CHAN_ACCESS = 0x40, - IPMI_CMD_GET_CHANNEL_ACCESS = 0x41, - IPMI_CMD_GET_CHAN_INFO = 0x42, - IPMI_CMD_GET_CHAN_CIPHER_SUITES = 0x54, - IPMI_CMD_SET_SYSTEM_INFO = 0x58, - IPMI_CMD_GET_SYSTEM_INFO = 0x59, -}; - -enum ipmi_app_sysinfo_params -{ - IPMI_SYSINFO_SET_STATE = 0x00, - IPMI_SYSINFO_SYSTEM_FW_VERSION = 0x01, - IPMI_SYSINFO_SYSTEM_NAME = 0x02, - IPMI_SYSINFO_PRIMARY_OS_NAME = 0x03, - IPMI_SYSINFO_OS_NAME = 0x04, - IPMI_SYSINFO_OS_VERSION = 0x05, - IPMI_SYSINFO_BMC_URL = 0x06, - IPMI_SYSINFO_OS_HYP_URL = 0x07, - IPMI_SYSINFO_OEM_START = 0xC0, // Start of range of OEM parameters -}; - -#endif diff --git a/apphandler.hpp b/apphandler.hpp new file mode 100644 index 0000000..3d377fb --- /dev/null +++ b/apphandler.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include + +// IPMI commands for App net functions. +enum ipmi_netfn_app_cmds +{ + // Get capability bits + IPMI_CMD_GET_DEVICE_ID = 0x01, + IPMI_CMD_GET_SELF_TEST_RESULTS = 0x04, + IPMI_CMD_SET_ACPI = 0x06, + IPMI_CMD_GET_DEVICE_GUID = 0x08, + IPMI_CMD_RESET_WD = 0x22, + IPMI_CMD_SET_WD = 0x24, + IPMI_CMD_GET_WD = 0x25, + IPMI_CMD_GET_CAP_BIT = 0x36, + IPMI_CMD_GET_SYS_GUID = 0x37, + IPMI_CMD_SET_CHAN_ACCESS = 0x40, + IPMI_CMD_GET_CHANNEL_ACCESS = 0x41, + IPMI_CMD_GET_CHAN_INFO = 0x42, + IPMI_CMD_GET_CHAN_CIPHER_SUITES = 0x54, + IPMI_CMD_SET_SYSTEM_INFO = 0x58, + IPMI_CMD_GET_SYSTEM_INFO = 0x59, +}; + +enum ipmi_app_sysinfo_params +{ + IPMI_SYSINFO_SET_STATE = 0x00, + IPMI_SYSINFO_SYSTEM_FW_VERSION = 0x01, + IPMI_SYSINFO_SYSTEM_NAME = 0x02, + IPMI_SYSINFO_PRIMARY_OS_NAME = 0x03, + IPMI_SYSINFO_OS_NAME = 0x04, + IPMI_SYSINFO_OS_VERSION = 0x05, + IPMI_SYSINFO_BMC_URL = 0x06, + IPMI_SYSINFO_OS_HYP_URL = 0x07, + IPMI_SYSINFO_OEM_START = 0xC0, // Start of range of OEM parameters +}; diff --git a/chassishandler.cpp b/chassishandler.cpp index bfc079d..5e86f17 100644 --- a/chassishandler.cpp +++ b/chassishandler.cpp @@ -1,4 +1,6 @@ -#include "chassishandler.h" +#include "config.h" + +#include "chassishandler.hpp" #include "ipmid.hpp" #include "settings.hpp" @@ -7,6 +9,7 @@ #include #include +#include #include #include #include @@ -20,8 +23,6 @@ #include #include #include - -#include "host-ipmid/ipmid-api.h" #if __has_include() #include #elif __has_include() @@ -34,7 +35,6 @@ namespace filesystem = std::experimental::filesystem; #else #error filesystem not available #endif -#include "config.h" #include "timer.hpp" @@ -50,6 +50,7 @@ namespace filesystem = std::experimental::filesystem; #include #include #include + // Defines #define SET_PARM_VERSION 0x01 #define SET_PARM_BOOT_FLAGS_PERMANENT 0x40 // boot flags data1 7th bit on diff --git a/chassishandler.h b/chassishandler.h deleted file mode 100644 index 0c6d5a2..0000000 --- a/chassishandler.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef __HOST_IPMI_CHASSIS_HANDLER_H__ -#define __HOST_IPMI_CHASSIS_HANDLER_H__ - -#include - -#include - -// IPMI commands for Chassis net functions. -enum ipmi_netfn_chassis_cmds -{ - IPMI_CMD_GET_CHASSIS_CAP = 0x00, - // Chassis Status - IPMI_CMD_CHASSIS_STATUS = 0x01, - // Chassis Control - IPMI_CMD_CHASSIS_CONTROL = 0x02, - IPMI_CMD_CHASSIS_IDENTIFY = 0x04, - // Set Power Restore Policy - IPMI_CMD_SET_RESTORE_POLICY = 0x06, - // Get capability bits - IPMI_CMD_SET_SYS_BOOT_OPTIONS = 0x08, - IPMI_CMD_GET_SYS_BOOT_OPTIONS = 0x09, - IPMI_CMD_GET_POH_COUNTER = 0x0F, -}; - -// Command specific completion codes -enum ipmi_chassis_return_codes -{ - IPMI_OK = 0x0, - IPMI_CC_PARM_NOT_SUPPORTED = 0x80, -}; - -// Generic completion codes, -// see IPMI doc section 5.2 -enum ipmi_generic_return_codes -{ - IPMI_OUT_OF_SPACE = 0xC4, -}; - -// Various Chassis operations under a single command. -enum ipmi_chassis_control_cmds : uint8_t -{ - CMD_POWER_OFF = 0x00, - CMD_POWER_ON = 0x01, - CMD_POWER_CYCLE = 0x02, - CMD_HARD_RESET = 0x03, - CMD_PULSE_DIAGNOSTIC_INTR = 0x04, - CMD_SOFT_OFF_VIA_OVER_TEMP = 0x05, -}; -enum class BootOptionParameter : size_t -{ - BOOT_INFO = 0x4, - BOOT_FLAGS = 0x5, - OPAL_NETWORK_SETTINGS = 0x61 -}; - -enum class BootOptionResponseSize : size_t -{ - BOOT_FLAGS = 5, - OPAL_NETWORK_SETTINGS = 50 -}; - -#endif diff --git a/chassishandler.hpp b/chassishandler.hpp new file mode 100644 index 0000000..6535c0e --- /dev/null +++ b/chassishandler.hpp @@ -0,0 +1,59 @@ +#pragma once + +#include + +#include + +// IPMI commands for Chassis net functions. +enum ipmi_netfn_chassis_cmds +{ + IPMI_CMD_GET_CHASSIS_CAP = 0x00, + // Chassis Status + IPMI_CMD_CHASSIS_STATUS = 0x01, + // Chassis Control + IPMI_CMD_CHASSIS_CONTROL = 0x02, + IPMI_CMD_CHASSIS_IDENTIFY = 0x04, + // Set Power Restore Policy + IPMI_CMD_SET_RESTORE_POLICY = 0x06, + // Get capability bits + IPMI_CMD_SET_SYS_BOOT_OPTIONS = 0x08, + IPMI_CMD_GET_SYS_BOOT_OPTIONS = 0x09, + IPMI_CMD_GET_POH_COUNTER = 0x0F, +}; + +// Command specific completion codes +enum ipmi_chassis_return_codes +{ + IPMI_OK = 0x0, + IPMI_CC_PARM_NOT_SUPPORTED = 0x80, +}; + +// Generic completion codes, +// see IPMI doc section 5.2 +enum ipmi_generic_return_codes +{ + IPMI_OUT_OF_SPACE = 0xC4, +}; + +// Various Chassis operations under a single command. +enum ipmi_chassis_control_cmds : uint8_t +{ + CMD_POWER_OFF = 0x00, + CMD_POWER_ON = 0x01, + CMD_POWER_CYCLE = 0x02, + CMD_HARD_RESET = 0x03, + CMD_PULSE_DIAGNOSTIC_INTR = 0x04, + CMD_SOFT_OFF_VIA_OVER_TEMP = 0x05, +}; +enum class BootOptionParameter : size_t +{ + BOOT_INFO = 0x4, + BOOT_FLAGS = 0x5, + OPAL_NETWORK_SETTINGS = 0x61 +}; + +enum class BootOptionResponseSize : size_t +{ + BOOT_FLAGS = 5, + OPAL_NETWORK_SETTINGS = 50 +}; diff --git a/dcmihandler.cpp b/dcmihandler.cpp index 951b6ba..5f13ea2 100644 --- a/dcmihandler.cpp +++ b/dcmihandler.cpp @@ -5,6 +5,7 @@ #include "net.hpp" #include "utils.hpp" +#include #include #include #include @@ -18,8 +19,6 @@ #include #include -#include "host-ipmid/ipmid-api.h" - using namespace phosphor::logging; using InternalFailure = sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; diff --git a/dcmihandler.hpp b/dcmihandler.hpp index 6e64faf..29757ff 100644 --- a/dcmihandler.hpp +++ b/dcmihandler.hpp @@ -1,5 +1,4 @@ -#ifndef __HOST_IPMI_DCMI_HANDLER_H__ -#define __HOST_IPMI_DCMI_HANDLER_H__ +#pragma once #include "nlohmann/json.hpp" @@ -628,5 +627,3 @@ struct GetConfParamsResponse } __attribute__((packed)); } // namespace dcmi - -#endif diff --git a/fruread.hpp b/fruread.hpp index 20f260c..a2fb650 100644 --- a/fruread.hpp +++ b/fruread.hpp @@ -1,5 +1,4 @@ -#ifndef OPENBMC_IPMI_FRU_READ_H -#define OPENBMC_IPMI_FRU_READ_H +#pragma once #include @@ -35,5 +34,3 @@ using FruInstanceVec = std::vector; using FruId = uint32_t; using FruMap = std::map; - -#endif diff --git a/globalhandler.cpp b/globalhandler.cpp index 55761b4..61a2a80 100644 --- a/globalhandler.cpp +++ b/globalhandler.cpp @@ -1,16 +1,16 @@ -#include "globalhandler.h" +#include "globalhandler.hpp" +#include "utils.hpp" + +#include #include #include #include #include -#include #include #include -#include "host-ipmid/ipmid-api.h" - static constexpr auto bmcStateRoot = "/xyz/openbmc_project/state"; static constexpr auto bmcStateIntf = "xyz.openbmc_project.State.BMC"; static constexpr auto reqTransition = "RequestedBMCTransition"; diff --git a/globalhandler.h b/globalhandler.h deleted file mode 100644 index dcdb68d..0000000 --- a/globalhandler.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef __HOST_IPMI_GLOBAL_HANDLER_H__ -#define __HOST_IPMI_GLOBAL_HANDLER_H__ - -#include - -// Various GLOBAL operations under a single command. -enum ipmi_global_control_cmds : uint8_t -{ - IPMI_CMD_COLD_RESET = 0x02, - IPMI_CMD_WARM_RESET = 0x03, -}; - -#endif diff --git a/globalhandler.hpp b/globalhandler.hpp new file mode 100644 index 0000000..23d3b3e --- /dev/null +++ b/globalhandler.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include + +// Various GLOBAL operations under a single command. +enum ipmi_global_control_cmds : uint8_t +{ + IPMI_CMD_COLD_RESET = 0x02, + IPMI_CMD_WARM_RESET = 0x03, +}; diff --git a/groupext.cpp b/groupext.cpp index 0d8bfe0..616f366 100644 --- a/groupext.cpp +++ b/groupext.cpp @@ -1,10 +1,9 @@ #include "ipmid.hpp" +#include #include #include -#include "host-ipmid/ipmid-api.h" - #define GRPEXT_GET_GROUP_CMD 0 void register_netfn_groupext_functions() __attribute__((constructor)); diff --git a/host-cmd-manager.cpp b/host-cmd-manager.cpp index 90e932b..4084910 100644 --- a/host-cmd-manager.cpp +++ b/host-cmd-manager.cpp @@ -1,12 +1,14 @@ -#include -#include +#include "config.h" + +#include "host-cmd-manager.hpp" + +#include "systemintfcmds.hpp" +#include "timer.hpp" +#include "utils.hpp" #include -#include #include #include -#include -#include #include #include diff --git a/host-interface.cpp b/host-interface.cpp index 1f27163..2a3e6ce 100644 --- a/host-interface.cpp +++ b/host-interface.cpp @@ -1,12 +1,15 @@ -#include -#include +#include "config.h" + +#include "host-interface.hpp" + +#include "systemintfcmds.hpp" +#include "utils.hpp" #include -#include #include #include #include -#include + namespace phosphor { namespace host diff --git a/host-ipmid/oemopenbmc.hpp b/host-ipmid/oemopenbmc.hpp index 73a3f9f..02e7e5c 100644 --- a/host-ipmid/oemopenbmc.hpp +++ b/host-ipmid/oemopenbmc.hpp @@ -1,8 +1,8 @@ #pragma once -#include "host-ipmid/oemrouter.hpp" +#include -#include "host-ipmid/ipmid-api.h" +#include namespace oem { diff --git a/ipmid.cpp b/ipmid.cpp index 6da7ff2..c867e3c 100644 --- a/ipmid.cpp +++ b/ipmid.cpp @@ -1,7 +1,10 @@ #include "ipmid.hpp" -#include "host-ipmid/oemrouter.hpp" +#include "host-cmd-manager.hpp" +#include "ipmiwhitelist.hpp" +#include "sensorhandler.hpp" #include "settings.hpp" +#include "timer.hpp" #include #include @@ -16,22 +19,18 @@ #include #include -#include #include +#include #include -#include #include #include #include #include #include #include -#include #include #include -#include "sensorhandler.h" - using namespace phosphor::logging; namespace sdbusRule = sdbusplus::bus::match::rules; diff --git a/ipmid.hpp b/ipmid.hpp index 9d62611..b59cd02 100644 --- a/ipmid.hpp +++ b/ipmid.hpp @@ -1,8 +1,7 @@ -#ifndef __HOST_IPMID_IPMI_H__ -#define __HOST_IPMID_IPMI_H__ -#include +#pragma once -#include "host-ipmid/ipmid-api.h" +#include +#include // When the requester sends in a netfn and a command along with data, this // function will look for registered handlers that will handle that [netfn,cmd] @@ -23,5 +22,3 @@ ipmi_ret_t ipmi_netfn_router(const ipmi_netfn_t, const ipmi_cmd_t, #define MAX_IPMI_BUFFER 64 extern FILE *ipmiio, *ipmidbus, *ipmicmddetails; - -#endif diff --git a/ipmisensor.cpp b/ipmisensor.cpp index b3fac2c..de8b844 100644 --- a/ipmisensor.cpp +++ b/ipmisensor.cpp @@ -1,10 +1,10 @@ +#include "sensorhandler.hpp" + #include #include #include #include -#include "sensorhandler.h" - extern uint8_t find_type_for_sensor_number(uint8_t); struct sensorRES_t diff --git a/ipmiwhitelist.hpp b/ipmiwhitelist.hpp index 7d096c2..fd45a3d 100644 --- a/ipmiwhitelist.hpp +++ b/ipmiwhitelist.hpp @@ -1,5 +1,4 @@ -#ifndef __HOST_IPMID_IPMI_WHITELIST_H__ -#define __HOST_IPMID_IPMI_WHITELIST_H_ +#pragma once #include #include @@ -7,5 +6,3 @@ using netfncmd_pair = std::pair; extern const std::vector whitelist; - -#endif diff --git a/oemrouter.cpp b/oemrouter.cpp index 64944db..ecfe096 100644 --- a/oemrouter.cpp +++ b/oemrouter.cpp @@ -1,7 +1,6 @@ -#include "host-ipmid/oemrouter.hpp" - #include #include +#include #include #include diff --git a/read_fru_data.cpp b/read_fru_data.cpp index 4581a8c..c7ff61b 100644 --- a/read_fru_data.cpp +++ b/read_fru_data.cpp @@ -4,12 +4,12 @@ #include "types.hpp" #include "utils.hpp" +#include + #include #include #include -#include "host-ipmid/ipmid-api.h" - extern const FruMap frus; namespace ipmi { diff --git a/selutility.cpp b/selutility.cpp index 8e04ad4..228bf62 100644 --- a/selutility.cpp +++ b/selutility.cpp @@ -1,5 +1,10 @@ +#include "config.h" + +#include "selutility.hpp" + #include #include + #if __has_include() #include #elif __has_include() @@ -12,17 +17,15 @@ namespace filesystem = std::experimental::filesystem; #else #error filesystem not available #endif -#include "config.h" -#include "selutility.hpp" #include "types.hpp" #include "utils.hpp" +#include + #include #include -#include "host-ipmid/ipmid-api.h" - extern const ipmi::sensor::InvObjectIDMap invSensors; using namespace phosphor::logging; using InternalFailure = diff --git a/sensordatahandler.cpp b/sensordatahandler.cpp index d4f1251..27dd011 100644 --- a/sensordatahandler.cpp +++ b/sensordatahandler.cpp @@ -12,6 +12,7 @@ namespace filesystem = std::experimental::filesystem; #error filesystem not available #endif #include "sensordatahandler.hpp" +#include "sensorhandler.hpp" #include "types.hpp" #include "utils.hpp" @@ -19,8 +20,6 @@ namespace filesystem = std::experimental::filesystem; #include #include -#include "sensorhandler.h" - namespace ipmi { namespace sensor diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp index 7185116..771303d 100644 --- a/sensordatahandler.hpp +++ b/sensordatahandler.hpp @@ -1,13 +1,12 @@ #pragma once +#include "sensorhandler.hpp" #include "types.hpp" #include "utils.hpp" +#include #include -#include "host-ipmid/ipmid-api.h" -#include "sensorhandler.h" - namespace ipmi { namespace sensor diff --git a/sensorhandler.cpp b/sensorhandler.cpp index 7c6a4dc..80f7c4b 100644 --- a/sensorhandler.cpp +++ b/sensorhandler.cpp @@ -1,10 +1,11 @@ -#include "sensorhandler.h" +#include "sensorhandler.hpp" #include "fruread.hpp" #include "ipmid.hpp" #include "types.hpp" #include "utils.hpp" +#include #include #include #include @@ -18,8 +19,6 @@ #include #include -#include "host-ipmid/ipmid-api.h" - static constexpr uint8_t fruInventoryDevice = 0x10; static constexpr uint8_t IPMIFruInventory = 0x02; static constexpr uint8_t BMCSlaveAddress = 0x20; diff --git a/sensorhandler.h b/sensorhandler.h deleted file mode 100644 index 3f2fd99..0000000 --- a/sensorhandler.h +++ /dev/null @@ -1,642 +0,0 @@ -#ifndef __HOST_IPMI_SEN_HANDLER_H__ -#define __HOST_IPMI_SEN_HANDLER_H__ - -#include "types.hpp" - -#include - -#include "host-ipmid/ipmid-api.h" - -// IPMI commands for net functions. -enum ipmi_netfn_sen_cmds -{ - IPMI_CMD_GET_DEVICE_SDR_INFO = 0x20, - IPMI_CMD_GET_DEVICE_SDR = 0x21, - IPMI_CMD_RESERVE_DEVICE_SDR_REPO = 0x22, - IPMI_CMD_GET_SENSOR_READING = 0x2D, - IPMI_CMD_GET_SENSOR_TYPE = 0x2F, - IPMI_CMD_SET_SENSOR = 0x30, - IPMI_CMD_GET_SENSOR_THRESHOLDS = 0x27, -}; - -/** - * @enum device_type - * IPMI FRU device types - */ -enum device_type -{ - IPMI_PHYSICAL_FRU = 0x00, - IPMI_LOGICAL_FRU = 0x80, -}; - -// Discrete sensor types. -enum ipmi_sensor_types -{ - IPMI_SENSOR_TEMP = 0x01, - IPMI_SENSOR_VOLTAGE = 0x02, - IPMI_SENSOR_CURRENT = 0x03, - IPMI_SENSOR_FAN = 0x04, - IPMI_SENSOR_TPM = 0xCC, -}; - -#define MAX_DBUS_PATH 128 -struct dbus_interface_t -{ - uint8_t sensornumber; - uint8_t sensortype; - - char bus[MAX_DBUS_PATH]; - char path[MAX_DBUS_PATH]; - char interface[MAX_DBUS_PATH]; -}; - -int set_sensor_dbus_state_s(uint8_t, const char*, const char*); -int set_sensor_dbus_state_y(uint8_t, const char*, const uint8_t); -int find_openbmc_path(uint8_t, dbus_interface_t*); - -ipmi_ret_t ipmi_sen_get_sdr(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - ipmi_request_t request, ipmi_response_t response, - ipmi_data_len_t data_len, ipmi_context_t context); - -ipmi_ret_t ipmi_sen_reserve_sdr(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - ipmi_request_t request, - ipmi_response_t response, - ipmi_data_len_t data_len, - ipmi_context_t context); - -static const uint16_t FRU_RECORD_ID_START = 256; -static const uint8_t SDR_VERSION = 0x51; -static const uint16_t END_OF_RECORD = 0xFFFF; -static const uint8_t LENGTH_MASK = 0x1F; - -/** - * Get SDR Info - */ - -namespace get_sdr_info -{ -namespace request -{ -// Note: for some reason the ipmi_request_t appears to be the -// raw value for this call. -inline bool get_count(void* req) -{ - return (bool)((uint64_t)(req)&1); -} -} // namespace request - -namespace response -{ -#define SDR_INFO_RESP_SIZE 2 -inline void set_lun_present(int lun, uint8_t* resp) -{ - *resp |= 1 << lun; -} -inline void set_lun_not_present(int lun, uint8_t* resp) -{ - *resp &= ~(1 << lun); -} -inline void set_dynamic_population(uint8_t* resp) -{ - *resp |= 1 << 7; -} -inline void set_static_population(uint8_t* resp) -{ - *resp &= ~(1 << 7); -} -} // namespace response - -struct GetSdrInfoResp -{ - uint8_t count; - uint8_t luns_and_dynamic_population; -}; - -} // namespace get_sdr_info - -/** - * Get SDR - */ -namespace get_sdr -{ - -struct GetSdrReq -{ - uint8_t reservation_id_lsb; - uint8_t reservation_id_msb; - uint8_t record_id_lsb; - uint8_t record_id_msb; - uint8_t offset; - uint8_t bytes_to_read; -} __attribute__((packed)); - -namespace request -{ - -inline uint8_t get_reservation_id(GetSdrReq* req) -{ - return (req->reservation_id_lsb + (req->reservation_id_msb << 8)); -}; - -inline uint16_t get_record_id(GetSdrReq* req) -{ - return (req->record_id_lsb + (req->record_id_msb << 8)); -}; - -} // namespace request - -// Response -struct GetSdrResp -{ - uint8_t next_record_id_lsb; - uint8_t next_record_id_msb; - uint8_t record_data[64]; -} __attribute__((packed)); - -namespace response -{ - -inline void set_next_record_id(uint16_t next, GetSdrResp* resp) -{ - resp->next_record_id_lsb = next & 0xff; - resp->next_record_id_msb = (next >> 8) & 0xff; -}; - -} // namespace response - -// Record header -struct SensorDataRecordHeader -{ - uint8_t record_id_lsb; - uint8_t record_id_msb; - uint8_t sdr_version; - uint8_t record_type; - uint8_t record_length; // Length not counting the header -} __attribute__((packed)); - -namespace header -{ - -inline void set_record_id(int id, SensorDataRecordHeader* hdr) -{ - hdr->record_id_lsb = (id & 0xFF); - hdr->record_id_msb = (id >> 8) & 0xFF; -}; - -} // namespace header - -enum SensorDataRecordType -{ - SENSOR_DATA_FULL_RECORD = 0x1, - SENSOR_DATA_FRU_RECORD = 0x11, -}; - -// Record key -struct SensorDataRecordKey -{ - uint8_t owner_id; - uint8_t owner_lun; - uint8_t sensor_number; -} __attribute__((packed)); - -/** @struct SensorDataFruRecordKey - * - * FRU Device Locator Record(key) - SDR Type 11 - */ -struct SensorDataFruRecordKey -{ - uint8_t deviceAddress; - uint8_t fruID; - uint8_t accessLun; - uint8_t channelNumber; -} __attribute__((packed)); - -namespace key -{ - -inline void set_owner_id_ipmb(SensorDataRecordKey* key) -{ - key->owner_id &= ~0x01; -}; - -inline void set_owner_id_system_sw(SensorDataRecordKey* key) -{ - key->owner_id |= 0x01; -}; - -inline void set_owner_id_bmc(SensorDataRecordKey* key) -{ - key->owner_id |= 0x20; -}; - -inline void set_owner_id_address(uint8_t addr, SensorDataRecordKey* key) -{ - key->owner_id &= 0x01; - key->owner_id |= addr << 1; -}; - -inline void set_owner_lun(uint8_t lun, SensorDataRecordKey* key) -{ - key->owner_lun &= ~0x03; - key->owner_lun |= (lun & 0x03); -}; - -inline void set_owner_lun_channel(uint8_t channel, SensorDataRecordKey* key) -{ - key->owner_lun &= 0x0f; - key->owner_lun |= ((channel & 0xf) << 4); -}; - -} // namespace key - -/** @struct GetSensorThresholdsResponse - * - * Response structure for Get Sensor Thresholds command - */ -struct GetSensorThresholdsResponse -{ - uint8_t validMask; //!< valid mask - uint8_t lowerNonCritical; //!< lower non-critical threshold - uint8_t lowerCritical; //!< lower critical threshold - uint8_t lowerNonRecoverable; //!< lower non-recoverable threshold - uint8_t upperNonCritical; //!< upper non-critical threshold - uint8_t upperCritical; //!< upper critical threshold - uint8_t upperNonRecoverable; //!< upper non-recoverable threshold -} __attribute__((packed)); - -// Body - full record -#define FULL_RECORD_ID_STR_MAX_LENGTH 16 - -static const int FRU_RECORD_DEVICE_ID_MAX_LENGTH = 16; - -struct SensorDataFullRecordBody -{ - uint8_t entity_id; - uint8_t entity_instance; - uint8_t sensor_initialization; - uint8_t sensor_capabilities; // no macro support - uint8_t sensor_type; - uint8_t event_reading_type; - uint8_t supported_assertions[2]; // no macro support - uint8_t supported_deassertions[2]; // no macro support - uint8_t discrete_reading_setting_mask[2]; // no macro support - uint8_t sensor_units_1; - uint8_t sensor_units_2_base; - uint8_t sensor_units_3_modifier; - uint8_t linearization; - uint8_t m_lsb; - uint8_t m_msb_and_tolerance; - uint8_t b_lsb; - uint8_t b_msb_and_accuracy_lsb; - uint8_t accuracy_and_sensor_direction; - uint8_t r_b_exponents; - uint8_t analog_characteristic_flags; // no macro support - uint8_t nominal_reading; - uint8_t normal_max; - uint8_t normal_min; - uint8_t sensor_max; - uint8_t sensor_min; - uint8_t upper_nonrecoverable_threshold; - uint8_t upper_critical_threshold; - uint8_t upper_noncritical_threshold; - uint8_t lower_nonrecoverable_threshold; - uint8_t lower_critical_threshold; - uint8_t lower_noncritical_threshold; - uint8_t positive_threshold_hysteresis; - uint8_t negative_threshold_hysteresis; - uint16_t reserved; - uint8_t oem_reserved; - uint8_t id_string_info; - char id_string[FULL_RECORD_ID_STR_MAX_LENGTH]; -} __attribute__((packed)); - -/** @struct SensorDataFruRecordBody - * - * FRU Device Locator Record(body) - SDR Type 11 - */ -struct SensorDataFruRecordBody -{ - uint8_t reserved; - uint8_t deviceType; - uint8_t deviceTypeModifier; - uint8_t entityID; - uint8_t entityInstance; - uint8_t oem; - uint8_t deviceIDLen; - char deviceID[FRU_RECORD_DEVICE_ID_MAX_LENGTH]; -} __attribute__((packed)); - -namespace body -{ - -inline void set_entity_instance_number(uint8_t n, - SensorDataFullRecordBody* body) -{ - body->entity_instance &= 1 << 7; - body->entity_instance |= (n & ~(1 << 7)); -}; -inline void set_entity_physical_entity(SensorDataFullRecordBody* body) -{ - body->entity_instance &= ~(1 << 7); -}; -inline void set_entity_logical_container(SensorDataFullRecordBody* body) -{ - body->entity_instance |= 1 << 7; -}; - -inline void sensor_scanning_state(bool enabled, SensorDataFullRecordBody* body) -{ - if (enabled) - { - body->sensor_initialization |= 1 << 0; - } - else - { - body->sensor_initialization &= ~(1 << 0); - }; -}; -inline void event_generation_state(bool enabled, SensorDataFullRecordBody* body) -{ - if (enabled) - { - body->sensor_initialization |= 1 << 1; - } - else - { - body->sensor_initialization &= ~(1 << 1); - } -}; -inline void init_types_state(bool enabled, SensorDataFullRecordBody* body) -{ - if (enabled) - { - body->sensor_initialization |= 1 << 2; - } - else - { - body->sensor_initialization &= ~(1 << 2); - } -}; -inline void init_hyst_state(bool enabled, SensorDataFullRecordBody* body) -{ - if (enabled) - { - body->sensor_initialization |= 1 << 3; - } - else - { - body->sensor_initialization &= ~(1 << 3); - } -}; -inline void init_thresh_state(bool enabled, SensorDataFullRecordBody* body) -{ - if (enabled) - { - body->sensor_initialization |= 1 << 4; - } - else - { - body->sensor_initialization &= ~(1 << 4); - } -}; -inline void init_events_state(bool enabled, SensorDataFullRecordBody* body) -{ - if (enabled) - { - body->sensor_initialization |= 1 << 5; - } - else - { - body->sensor_initialization &= ~(1 << 5); - } -}; -inline void init_scanning_state(bool enabled, SensorDataFullRecordBody* body) -{ - if (enabled) - { - body->sensor_initialization |= 1 << 6; - } - else - { - body->sensor_initialization &= ~(1 << 6); - } -}; -inline void init_settable_state(bool enabled, SensorDataFullRecordBody* body) -{ - if (enabled) - { - body->sensor_initialization |= 1 << 7; - } - else - { - body->sensor_initialization &= ~(1 << 7); - } -}; - -inline void set_percentage(SensorDataFullRecordBody* body) -{ - body->sensor_units_1 |= 1 << 0; -}; -inline void unset_percentage(SensorDataFullRecordBody* body) -{ - body->sensor_units_1 &= ~(1 << 0); -}; -inline void set_modifier_operation(uint8_t op, SensorDataFullRecordBody* body) -{ - body->sensor_units_1 &= ~(3 << 1); - body->sensor_units_1 |= (op & 0x3) << 1; -}; -inline void set_rate_unit(uint8_t unit, SensorDataFullRecordBody* body) -{ - body->sensor_units_1 &= ~(7 << 3); - body->sensor_units_1 |= (unit & 0x7) << 3; -}; -inline void set_analog_data_format(uint8_t format, - SensorDataFullRecordBody* body) -{ - body->sensor_units_1 &= ~(3 << 6); - body->sensor_units_1 |= (format & 0x3) << 6; -}; - -inline void set_m(uint16_t m, SensorDataFullRecordBody* body) -{ - body->m_lsb = m & 0xff; - body->m_msb_and_tolerance &= ~(3 << 6); - body->m_msb_and_tolerance |= ((m & (3 << 8)) >> 2); -}; -inline void set_tolerance(uint8_t tol, SensorDataFullRecordBody* body) -{ - body->m_msb_and_tolerance &= ~0x3f; - body->m_msb_and_tolerance |= tol & 0x3f; -}; - -inline void set_b(uint16_t b, SensorDataFullRecordBody* body) -{ - body->b_lsb = b & 0xff; - body->b_msb_and_accuracy_lsb &= ~(3 << 6); - body->b_msb_and_accuracy_lsb |= ((b & (3 << 8)) >> 2); -}; -inline void set_accuracy(uint16_t acc, SensorDataFullRecordBody* body) -{ - // bottom 6 bits - body->b_msb_and_accuracy_lsb &= ~0x3f; - body->b_msb_and_accuracy_lsb |= acc & 0x3f; - // top 4 bits - body->accuracy_and_sensor_direction &= 0x0f; - body->accuracy_and_sensor_direction |= ((acc >> 6) & 0xf) << 4; -}; -inline void set_accuracy_exp(uint8_t exp, SensorDataFullRecordBody* body) -{ - body->accuracy_and_sensor_direction &= ~(3 << 2); - body->accuracy_and_sensor_direction |= (exp & 3) << 2; -}; -inline void set_sensor_dir(uint8_t dir, SensorDataFullRecordBody* body) -{ - body->accuracy_and_sensor_direction &= ~(3 << 0); - body->accuracy_and_sensor_direction |= (dir & 3); -}; - -inline void set_b_exp(uint8_t exp, SensorDataFullRecordBody* body) -{ - body->r_b_exponents &= 0xf0; - body->r_b_exponents |= exp & 0x0f; -}; -inline void set_r_exp(uint8_t exp, SensorDataFullRecordBody* body) -{ - body->r_b_exponents &= 0x0f; - body->r_b_exponents |= (exp & 0x0f) << 4; -}; - -inline void set_id_strlen(uint8_t len, SensorDataFullRecordBody* body) -{ - body->id_string_info &= ~(0x1f); - body->id_string_info |= len & 0x1f; -}; -inline uint8_t get_id_strlen(SensorDataFullRecordBody* body) -{ - return body->id_string_info & 0x1f; -}; -inline void set_id_type(uint8_t type, SensorDataFullRecordBody* body) -{ - body->id_string_info &= ~(3 << 6); - body->id_string_info |= (type & 0x3) << 6; -}; - -inline void set_device_id_strlen(uint8_t len, SensorDataFruRecordBody* body) -{ - body->deviceIDLen &= ~(LENGTH_MASK); - body->deviceIDLen |= len & LENGTH_MASK; -}; - -inline uint8_t get_device_id_strlen(SensorDataFruRecordBody* body) -{ - return body->deviceIDLen & LENGTH_MASK; -}; - -inline void set_readable_mask(uint8_t mask, SensorDataFullRecordBody* body) -{ - body->discrete_reading_setting_mask[1] = mask & 0x3F; -} - -} // namespace body - -// More types contained in section 43.17 Sensor Unit Type Codes, -// IPMI spec v2 rev 1.1 -enum SensorUnitTypeCodes -{ - SENSOR_UNIT_UNSPECIFIED = 0, - SENSOR_UNIT_DEGREES_C = 1, - SENSOR_UNIT_VOLTS = 4, - SENSOR_UNIT_AMPERES = 5, - SENSOR_UNIT_WATTS = 6, - SENSOR_UNIT_JOULES = 7, - SENSOR_UNIT_METERS = 34, - SENSOR_UNIT_REVOLUTIONS = 41, -}; - -struct SensorDataFullRecord -{ - SensorDataRecordHeader header; - SensorDataRecordKey key; - SensorDataFullRecordBody body; -} __attribute__((packed)); - -/** @struct SensorDataFruRecord - * - * FRU Device Locator Record - SDR Type 11 - */ -struct SensorDataFruRecord -{ - SensorDataRecordHeader header; - SensorDataFruRecordKey key; - SensorDataFruRecordBody body; -} __attribute__((packed)); - -} // namespace get_sdr - -namespace ipmi -{ - -namespace sensor -{ - -/** - * @brief Map offset to the corresponding bit in the assertion byte. - * - * The discrete sensors support up to 14 states. 0-7 offsets are stored in one - * byte and offsets 8-14 in the second byte. - * - * @param[in] offset - offset number. - * @param[in/out] resp - get sensor reading response. - */ -inline void setOffset(uint8_t offset, ipmi::sensor::GetReadingResponse* resp) -{ - if (offset > 7) - { - resp->assertOffset8_14 |= 1 << (offset - 8); - } - else - { - resp->assertOffset0_7 |= 1 << offset; - } -} - -/** - * @brief Set the reading field in the response. - * - * @param[in] offset - offset number. - * @param[in/out] resp - get sensor reading response. - */ -inline void setReading(uint8_t value, ipmi::sensor::GetReadingResponse* resp) -{ - resp->reading = value; -} - -/** - * @brief Map the value to the assertion bytes. The assertion states are stored - * in 2 bytes. - * - * @param[in] value - value to mapped to the assertion byte. - * @param[in/out] resp - get sensor reading response. - */ -inline void setAssertionBytes(uint16_t value, - ipmi::sensor::GetReadingResponse* resp) -{ - resp->assertOffset0_7 = static_cast(value & 0x00FF); - resp->assertOffset8_14 = static_cast(value >> 8); -} - -/** - * @brief Set the scanning enabled bit in the response. - * - * @param[in/out] resp - get sensor reading response. - */ -inline void enableScanning(ipmi::sensor::GetReadingResponse* resp) -{ - resp->operation = 1 << 6; -} - -} // namespace sensor - -} // namespace ipmi -#endif diff --git a/sensorhandler.hpp b/sensorhandler.hpp new file mode 100644 index 0000000..b32034f --- /dev/null +++ b/sensorhandler.hpp @@ -0,0 +1,639 @@ +#pragma once + +#include "types.hpp" + +#include +#include + +// IPMI commands for net functions. +enum ipmi_netfn_sen_cmds +{ + IPMI_CMD_GET_DEVICE_SDR_INFO = 0x20, + IPMI_CMD_GET_DEVICE_SDR = 0x21, + IPMI_CMD_RESERVE_DEVICE_SDR_REPO = 0x22, + IPMI_CMD_GET_SENSOR_READING = 0x2D, + IPMI_CMD_GET_SENSOR_TYPE = 0x2F, + IPMI_CMD_SET_SENSOR = 0x30, + IPMI_CMD_GET_SENSOR_THRESHOLDS = 0x27, +}; + +/** + * @enum device_type + * IPMI FRU device types + */ +enum device_type +{ + IPMI_PHYSICAL_FRU = 0x00, + IPMI_LOGICAL_FRU = 0x80, +}; + +// Discrete sensor types. +enum ipmi_sensor_types +{ + IPMI_SENSOR_TEMP = 0x01, + IPMI_SENSOR_VOLTAGE = 0x02, + IPMI_SENSOR_CURRENT = 0x03, + IPMI_SENSOR_FAN = 0x04, + IPMI_SENSOR_TPM = 0xCC, +}; + +#define MAX_DBUS_PATH 128 +struct dbus_interface_t +{ + uint8_t sensornumber; + uint8_t sensortype; + + char bus[MAX_DBUS_PATH]; + char path[MAX_DBUS_PATH]; + char interface[MAX_DBUS_PATH]; +}; + +int set_sensor_dbus_state_s(uint8_t, const char*, const char*); +int set_sensor_dbus_state_y(uint8_t, const char*, const uint8_t); +int find_openbmc_path(uint8_t, dbus_interface_t*); + +ipmi_ret_t ipmi_sen_get_sdr(ipmi_netfn_t netfn, ipmi_cmd_t cmd, + ipmi_request_t request, ipmi_response_t response, + ipmi_data_len_t data_len, ipmi_context_t context); + +ipmi_ret_t ipmi_sen_reserve_sdr(ipmi_netfn_t netfn, ipmi_cmd_t cmd, + ipmi_request_t request, + ipmi_response_t response, + ipmi_data_len_t data_len, + ipmi_context_t context); + +static const uint16_t FRU_RECORD_ID_START = 256; +static const uint8_t SDR_VERSION = 0x51; +static const uint16_t END_OF_RECORD = 0xFFFF; +static const uint8_t LENGTH_MASK = 0x1F; + +/** + * Get SDR Info + */ + +namespace get_sdr_info +{ +namespace request +{ +// Note: for some reason the ipmi_request_t appears to be the +// raw value for this call. +inline bool get_count(void* req) +{ + return (bool)((uint64_t)(req)&1); +} +} // namespace request + +namespace response +{ +#define SDR_INFO_RESP_SIZE 2 +inline void set_lun_present(int lun, uint8_t* resp) +{ + *resp |= 1 << lun; +} +inline void set_lun_not_present(int lun, uint8_t* resp) +{ + *resp &= ~(1 << lun); +} +inline void set_dynamic_population(uint8_t* resp) +{ + *resp |= 1 << 7; +} +inline void set_static_population(uint8_t* resp) +{ + *resp &= ~(1 << 7); +} +} // namespace response + +struct GetSdrInfoResp +{ + uint8_t count; + uint8_t luns_and_dynamic_population; +}; + +} // namespace get_sdr_info + +/** + * Get SDR + */ +namespace get_sdr +{ + +struct GetSdrReq +{ + uint8_t reservation_id_lsb; + uint8_t reservation_id_msb; + uint8_t record_id_lsb; + uint8_t record_id_msb; + uint8_t offset; + uint8_t bytes_to_read; +} __attribute__((packed)); + +namespace request +{ + +inline uint8_t get_reservation_id(GetSdrReq* req) +{ + return (req->reservation_id_lsb + (req->reservation_id_msb << 8)); +}; + +inline uint16_t get_record_id(GetSdrReq* req) +{ + return (req->record_id_lsb + (req->record_id_msb << 8)); +}; + +} // namespace request + +// Response +struct GetSdrResp +{ + uint8_t next_record_id_lsb; + uint8_t next_record_id_msb; + uint8_t record_data[64]; +} __attribute__((packed)); + +namespace response +{ + +inline void set_next_record_id(uint16_t next, GetSdrResp* resp) +{ + resp->next_record_id_lsb = next & 0xff; + resp->next_record_id_msb = (next >> 8) & 0xff; +}; + +} // namespace response + +// Record header +struct SensorDataRecordHeader +{ + uint8_t record_id_lsb; + uint8_t record_id_msb; + uint8_t sdr_version; + uint8_t record_type; + uint8_t record_length; // Length not counting the header +} __attribute__((packed)); + +namespace header +{ + +inline void set_record_id(int id, SensorDataRecordHeader* hdr) +{ + hdr->record_id_lsb = (id & 0xFF); + hdr->record_id_msb = (id >> 8) & 0xFF; +}; + +} // namespace header + +enum SensorDataRecordType +{ + SENSOR_DATA_FULL_RECORD = 0x1, + SENSOR_DATA_FRU_RECORD = 0x11, +}; + +// Record key +struct SensorDataRecordKey +{ + uint8_t owner_id; + uint8_t owner_lun; + uint8_t sensor_number; +} __attribute__((packed)); + +/** @struct SensorDataFruRecordKey + * + * FRU Device Locator Record(key) - SDR Type 11 + */ +struct SensorDataFruRecordKey +{ + uint8_t deviceAddress; + uint8_t fruID; + uint8_t accessLun; + uint8_t channelNumber; +} __attribute__((packed)); + +namespace key +{ + +inline void set_owner_id_ipmb(SensorDataRecordKey* key) +{ + key->owner_id &= ~0x01; +}; + +inline void set_owner_id_system_sw(SensorDataRecordKey* key) +{ + key->owner_id |= 0x01; +}; + +inline void set_owner_id_bmc(SensorDataRecordKey* key) +{ + key->owner_id |= 0x20; +}; + +inline void set_owner_id_address(uint8_t addr, SensorDataRecordKey* key) +{ + key->owner_id &= 0x01; + key->owner_id |= addr << 1; +}; + +inline void set_owner_lun(uint8_t lun, SensorDataRecordKey* key) +{ + key->owner_lun &= ~0x03; + key->owner_lun |= (lun & 0x03); +}; + +inline void set_owner_lun_channel(uint8_t channel, SensorDataRecordKey* key) +{ + key->owner_lun &= 0x0f; + key->owner_lun |= ((channel & 0xf) << 4); +}; + +} // namespace key + +/** @struct GetSensorThresholdsResponse + * + * Response structure for Get Sensor Thresholds command + */ +struct GetSensorThresholdsResponse +{ + uint8_t validMask; //!< valid mask + uint8_t lowerNonCritical; //!< lower non-critical threshold + uint8_t lowerCritical; //!< lower critical threshold + uint8_t lowerNonRecoverable; //!< lower non-recoverable threshold + uint8_t upperNonCritical; //!< upper non-critical threshold + uint8_t upperCritical; //!< upper critical threshold + uint8_t upperNonRecoverable; //!< upper non-recoverable threshold +} __attribute__((packed)); + +// Body - full record +#define FULL_RECORD_ID_STR_MAX_LENGTH 16 + +static const int FRU_RECORD_DEVICE_ID_MAX_LENGTH = 16; + +struct SensorDataFullRecordBody +{ + uint8_t entity_id; + uint8_t entity_instance; + uint8_t sensor_initialization; + uint8_t sensor_capabilities; // no macro support + uint8_t sensor_type; + uint8_t event_reading_type; + uint8_t supported_assertions[2]; // no macro support + uint8_t supported_deassertions[2]; // no macro support + uint8_t discrete_reading_setting_mask[2]; // no macro support + uint8_t sensor_units_1; + uint8_t sensor_units_2_base; + uint8_t sensor_units_3_modifier; + uint8_t linearization; + uint8_t m_lsb; + uint8_t m_msb_and_tolerance; + uint8_t b_lsb; + uint8_t b_msb_and_accuracy_lsb; + uint8_t accuracy_and_sensor_direction; + uint8_t r_b_exponents; + uint8_t analog_characteristic_flags; // no macro support + uint8_t nominal_reading; + uint8_t normal_max; + uint8_t normal_min; + uint8_t sensor_max; + uint8_t sensor_min; + uint8_t upper_nonrecoverable_threshold; + uint8_t upper_critical_threshold; + uint8_t upper_noncritical_threshold; + uint8_t lower_nonrecoverable_threshold; + uint8_t lower_critical_threshold; + uint8_t lower_noncritical_threshold; + uint8_t positive_threshold_hysteresis; + uint8_t negative_threshold_hysteresis; + uint16_t reserved; + uint8_t oem_reserved; + uint8_t id_string_info; + char id_string[FULL_RECORD_ID_STR_MAX_LENGTH]; +} __attribute__((packed)); + +/** @struct SensorDataFruRecordBody + * + * FRU Device Locator Record(body) - SDR Type 11 + */ +struct SensorDataFruRecordBody +{ + uint8_t reserved; + uint8_t deviceType; + uint8_t deviceTypeModifier; + uint8_t entityID; + uint8_t entityInstance; + uint8_t oem; + uint8_t deviceIDLen; + char deviceID[FRU_RECORD_DEVICE_ID_MAX_LENGTH]; +} __attribute__((packed)); + +namespace body +{ + +inline void set_entity_instance_number(uint8_t n, + SensorDataFullRecordBody* body) +{ + body->entity_instance &= 1 << 7; + body->entity_instance |= (n & ~(1 << 7)); +}; +inline void set_entity_physical_entity(SensorDataFullRecordBody* body) +{ + body->entity_instance &= ~(1 << 7); +}; +inline void set_entity_logical_container(SensorDataFullRecordBody* body) +{ + body->entity_instance |= 1 << 7; +}; + +inline void sensor_scanning_state(bool enabled, SensorDataFullRecordBody* body) +{ + if (enabled) + { + body->sensor_initialization |= 1 << 0; + } + else + { + body->sensor_initialization &= ~(1 << 0); + }; +}; +inline void event_generation_state(bool enabled, SensorDataFullRecordBody* body) +{ + if (enabled) + { + body->sensor_initialization |= 1 << 1; + } + else + { + body->sensor_initialization &= ~(1 << 1); + } +}; +inline void init_types_state(bool enabled, SensorDataFullRecordBody* body) +{ + if (enabled) + { + body->sensor_initialization |= 1 << 2; + } + else + { + body->sensor_initialization &= ~(1 << 2); + } +}; +inline void init_hyst_state(bool enabled, SensorDataFullRecordBody* body) +{ + if (enabled) + { + body->sensor_initialization |= 1 << 3; + } + else + { + body->sensor_initialization &= ~(1 << 3); + } +}; +inline void init_thresh_state(bool enabled, SensorDataFullRecordBody* body) +{ + if (enabled) + { + body->sensor_initialization |= 1 << 4; + } + else + { + body->sensor_initialization &= ~(1 << 4); + } +}; +inline void init_events_state(bool enabled, SensorDataFullRecordBody* body) +{ + if (enabled) + { + body->sensor_initialization |= 1 << 5; + } + else + { + body->sensor_initialization &= ~(1 << 5); + } +}; +inline void init_scanning_state(bool enabled, SensorDataFullRecordBody* body) +{ + if (enabled) + { + body->sensor_initialization |= 1 << 6; + } + else + { + body->sensor_initialization &= ~(1 << 6); + } +}; +inline void init_settable_state(bool enabled, SensorDataFullRecordBody* body) +{ + if (enabled) + { + body->sensor_initialization |= 1 << 7; + } + else + { + body->sensor_initialization &= ~(1 << 7); + } +}; + +inline void set_percentage(SensorDataFullRecordBody* body) +{ + body->sensor_units_1 |= 1 << 0; +}; +inline void unset_percentage(SensorDataFullRecordBody* body) +{ + body->sensor_units_1 &= ~(1 << 0); +}; +inline void set_modifier_operation(uint8_t op, SensorDataFullRecordBody* body) +{ + body->sensor_units_1 &= ~(3 << 1); + body->sensor_units_1 |= (op & 0x3) << 1; +}; +inline void set_rate_unit(uint8_t unit, SensorDataFullRecordBody* body) +{ + body->sensor_units_1 &= ~(7 << 3); + body->sensor_units_1 |= (unit & 0x7) << 3; +}; +inline void set_analog_data_format(uint8_t format, + SensorDataFullRecordBody* body) +{ + body->sensor_units_1 &= ~(3 << 6); + body->sensor_units_1 |= (format & 0x3) << 6; +}; + +inline void set_m(uint16_t m, SensorDataFullRecordBody* body) +{ + body->m_lsb = m & 0xff; + body->m_msb_and_tolerance &= ~(3 << 6); + body->m_msb_and_tolerance |= ((m & (3 << 8)) >> 2); +}; +inline void set_tolerance(uint8_t tol, SensorDataFullRecordBody* body) +{ + body->m_msb_and_tolerance &= ~0x3f; + body->m_msb_and_tolerance |= tol & 0x3f; +}; + +inline void set_b(uint16_t b, SensorDataFullRecordBody* body) +{ + body->b_lsb = b & 0xff; + body->b_msb_and_accuracy_lsb &= ~(3 << 6); + body->b_msb_and_accuracy_lsb |= ((b & (3 << 8)) >> 2); +}; +inline void set_accuracy(uint16_t acc, SensorDataFullRecordBody* body) +{ + // bottom 6 bits + body->b_msb_and_accuracy_lsb &= ~0x3f; + body->b_msb_and_accuracy_lsb |= acc & 0x3f; + // top 4 bits + body->accuracy_and_sensor_direction &= 0x0f; + body->accuracy_and_sensor_direction |= ((acc >> 6) & 0xf) << 4; +}; +inline void set_accuracy_exp(uint8_t exp, SensorDataFullRecordBody* body) +{ + body->accuracy_and_sensor_direction &= ~(3 << 2); + body->accuracy_and_sensor_direction |= (exp & 3) << 2; +}; +inline void set_sensor_dir(uint8_t dir, SensorDataFullRecordBody* body) +{ + body->accuracy_and_sensor_direction &= ~(3 << 0); + body->accuracy_and_sensor_direction |= (dir & 3); +}; + +inline void set_b_exp(uint8_t exp, SensorDataFullRecordBody* body) +{ + body->r_b_exponents &= 0xf0; + body->r_b_exponents |= exp & 0x0f; +}; +inline void set_r_exp(uint8_t exp, SensorDataFullRecordBody* body) +{ + body->r_b_exponents &= 0x0f; + body->r_b_exponents |= (exp & 0x0f) << 4; +}; + +inline void set_id_strlen(uint8_t len, SensorDataFullRecordBody* body) +{ + body->id_string_info &= ~(0x1f); + body->id_string_info |= len & 0x1f; +}; +inline uint8_t get_id_strlen(SensorDataFullRecordBody* body) +{ + return body->id_string_info & 0x1f; +}; +inline void set_id_type(uint8_t type, SensorDataFullRecordBody* body) +{ + body->id_string_info &= ~(3 << 6); + body->id_string_info |= (type & 0x3) << 6; +}; + +inline void set_device_id_strlen(uint8_t len, SensorDataFruRecordBody* body) +{ + body->deviceIDLen &= ~(LENGTH_MASK); + body->deviceIDLen |= len & LENGTH_MASK; +}; + +inline uint8_t get_device_id_strlen(SensorDataFruRecordBody* body) +{ + return body->deviceIDLen & LENGTH_MASK; +}; + +inline void set_readable_mask(uint8_t mask, SensorDataFullRecordBody* body) +{ + body->discrete_reading_setting_mask[1] = mask & 0x3F; +} + +} // namespace body + +// More types contained in section 43.17 Sensor Unit Type Codes, +// IPMI spec v2 rev 1.1 +enum SensorUnitTypeCodes +{ + SENSOR_UNIT_UNSPECIFIED = 0, + SENSOR_UNIT_DEGREES_C = 1, + SENSOR_UNIT_VOLTS = 4, + SENSOR_UNIT_AMPERES = 5, + SENSOR_UNIT_WATTS = 6, + SENSOR_UNIT_JOULES = 7, + SENSOR_UNIT_METERS = 34, + SENSOR_UNIT_REVOLUTIONS = 41, +}; + +struct SensorDataFullRecord +{ + SensorDataRecordHeader header; + SensorDataRecordKey key; + SensorDataFullRecordBody body; +} __attribute__((packed)); + +/** @struct SensorDataFruRecord + * + * FRU Device Locator Record - SDR Type 11 + */ +struct SensorDataFruRecord +{ + SensorDataRecordHeader header; + SensorDataFruRecordKey key; + SensorDataFruRecordBody body; +} __attribute__((packed)); + +} // namespace get_sdr + +namespace ipmi +{ + +namespace sensor +{ + +/** + * @brief Map offset to the corresponding bit in the assertion byte. + * + * The discrete sensors support up to 14 states. 0-7 offsets are stored in one + * byte and offsets 8-14 in the second byte. + * + * @param[in] offset - offset number. + * @param[in/out] resp - get sensor reading response. + */ +inline void setOffset(uint8_t offset, ipmi::sensor::GetReadingResponse* resp) +{ + if (offset > 7) + { + resp->assertOffset8_14 |= 1 << (offset - 8); + } + else + { + resp->assertOffset0_7 |= 1 << offset; + } +} + +/** + * @brief Set the reading field in the response. + * + * @param[in] offset - offset number. + * @param[in/out] resp - get sensor reading response. + */ +inline void setReading(uint8_t value, ipmi::sensor::GetReadingResponse* resp) +{ + resp->reading = value; +} + +/** + * @brief Map the value to the assertion bytes. The assertion states are stored + * in 2 bytes. + * + * @param[in] value - value to mapped to the assertion byte. + * @param[in/out] resp - get sensor reading response. + */ +inline void setAssertionBytes(uint16_t value, + ipmi::sensor::GetReadingResponse* resp) +{ + resp->assertOffset0_7 = static_cast(value & 0x00FF); + resp->assertOffset8_14 = static_cast(value >> 8); +} + +/** + * @brief Set the scanning enabled bit in the response. + * + * @param[in/out] resp - get sensor reading response. + */ +inline void enableScanning(ipmi::sensor::GetReadingResponse* resp) +{ + resp->operation = 1 << 6; +} + +} // namespace sensor + +} // namespace ipmi diff --git a/storageaddsel.cpp b/storageaddsel.cpp index 95fcddf..9213481 100644 --- a/storageaddsel.cpp +++ b/storageaddsel.cpp @@ -1,7 +1,10 @@ #include "elog-errors.hpp" #include "error-HostEvent.hpp" +#include "sensorhandler.hpp" +#include "storagehandler.hpp" #include "types.hpp" +#include #include #include #include @@ -16,10 +19,6 @@ #include #include -#include "host-ipmid/ipmid-api.h" -#include "sensorhandler.h" -#include "storagehandler.h" - using namespace std; using namespace phosphor::logging; using namespace sdbusplus::xyz::openbmc_project::Logging::server; diff --git a/storageaddsel.h b/storageaddsel.h deleted file mode 100644 index 113254b..0000000 --- a/storageaddsel.h +++ /dev/null @@ -1,17 +0,0 @@ -#include - -void send_esel(uint16_t recordid); - -/** @brief Read eSEL data into a string - * - * @param[in] filename - filename of file containing eSEL - * - * @return On success return the eSEL data - */ -std::string readESEL(const char* filename); - -/** @brief Create a log entry with maintenance procedure - * - * @param[in] procedureNum - procedure number associated with the log entry - */ -void createProcedureLogEntry(uint8_t procedureNum); diff --git a/storageaddsel.hpp b/storageaddsel.hpp new file mode 100644 index 0000000..c25ead3 --- /dev/null +++ b/storageaddsel.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include + +void send_esel(uint16_t recordid); + +/** @brief Read eSEL data into a string + * + * @param[in] filename - filename of file containing eSEL + * + * @return On success return the eSEL data + */ +std::string readESEL(const char* filename); + +/** @brief Create a log entry with maintenance procedure + * + * @param[in] procedureNum - procedure number associated with the log entry + */ +void createProcedureLogEntry(uint8_t procedureNum); diff --git a/storagehandler.cpp b/storagehandler.cpp index 871eae6..24c9d30 100644 --- a/storagehandler.cpp +++ b/storagehandler.cpp @@ -18,8 +18,12 @@ namespace filesystem = std::experimental::filesystem; #include "fruread.hpp" #include "read_fru_data.hpp" #include "selutility.hpp" +#include "sensorhandler.hpp" +#include "storageaddsel.hpp" +#include "storagehandler.hpp" #include "utils.hpp" +#include #include #include @@ -29,11 +33,6 @@ namespace filesystem = std::experimental::filesystem; #include #include -#include "host-ipmid/ipmid-api.h" -#include "sensorhandler.h" -#include "storageaddsel.h" -#include "storagehandler.h" - void register_netfn_storage_functions() __attribute__((constructor)); unsigned int g_sel_time = 0xFFFFFFFF; diff --git a/storagehandler.h b/storagehandler.h deleted file mode 100644 index 0aef3e3..0000000 --- a/storagehandler.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef __HOST_IPMI_STORAGE_HANDLER_H__ -#define __HOST_IPMI_STORAGE_HANDLER_H__ - -#include - -// IPMI commands for Storage net functions. -enum ipmi_netfn_storage_cmds -{ - // Get capability bits - IPMI_CMD_GET_FRU_INV_AREA_INFO = 0x10, - IPMI_CMD_GET_REPOSITORY_INFO = 0x20, - IPMI_CMD_READ_FRU_DATA = 0x11, - IPMI_CMD_RESERVE_SDR = 0x22, - IPMI_CMD_GET_SDR = 0x23, - IPMI_CMD_GET_SEL_INFO = 0x40, - IPMI_CMD_RESERVE_SEL = 0x42, - IPMI_CMD_GET_SEL_ENTRY = 0x43, - IPMI_CMD_ADD_SEL = 0x44, - IPMI_CMD_DELETE_SEL = 0x46, - IPMI_CMD_CLEAR_SEL = 0x47, - IPMI_CMD_GET_SEL_TIME = 0x48, - IPMI_CMD_SET_SEL_TIME = 0x49, - -}; - -struct ipmi_add_sel_request_t -{ - - uint8_t recordid[2]; - uint8_t recordtype; - uint8_t timestampe[4]; - uint8_t generatorid[2]; - uint8_t evmrev; - uint8_t sensortype; - uint8_t sensornumber; - uint8_t eventdir; - uint8_t eventdata[3]; -}; - -/** - * @struct Read FRU Data command request data - */ -struct ReadFruDataRequest -{ - uint8_t fruID; ///< FRU Device ID. FFh = reserved - uint8_t offsetLS; ///< FRU Inventory Offset to read, LS Byte - uint8_t offsetMS; ///< FRU Inventory Offset ro read, MS Byte - uint8_t count; ///< Count to read -} __attribute__((packed)); - -/** - * @struct Read FRU Data command response data - */ -struct ReadFruDataResponse -{ - uint8_t count; ///< Response data Count. - uint8_t data[]; ///< Response data. -} __attribute__((packed)); - -/** - * @struct Get FRU inventory area info command request data - */ -struct FruInvenAreaInfoRequest -{ - uint8_t fruID; ///< FRU Device ID. FFH = reserved. -} __attribute__((packed)); - -/** - * @struct Get FRU inventory area info command response - */ -struct FruInvenAreaInfoResponse -{ - uint8_t sizels; ///< Fru Inventory area size in bytes, LS Byte - uint8_t sizems; ///< Fru Inventory are size in bytes, MS Byte - uint8_t access; ///< 0b Devices is accessed by bytes, 1b - by words -} __attribute__((packed)); - -/** - * @struct Get Repository info command response - */ -struct GetRepositoryInfoResponse -{ - uint8_t sdrVersion; //< SDR version - uint8_t recordCountLs; //< Record count LS byte - uint8_t recordCountMs; //< Record count MS bte - uint8_t freeSpace[2]; //< Free space in bytes, LS first - uint8_t additionTimestamp[4]; //< Most recent addition timestamp LS first - uint8_t deletionTimestamp[4]; //< Most recent deletion timestamp LS first - uint8_t operationSupport; //< Operation support -} __attribute__((packed)); -#endif diff --git a/storagehandler.hpp b/storagehandler.hpp new file mode 100644 index 0000000..cccd62e --- /dev/null +++ b/storagehandler.hpp @@ -0,0 +1,89 @@ +#pragma once + +#include + +// IPMI commands for Storage net functions. +enum ipmi_netfn_storage_cmds +{ + // Get capability bits + IPMI_CMD_GET_FRU_INV_AREA_INFO = 0x10, + IPMI_CMD_GET_REPOSITORY_INFO = 0x20, + IPMI_CMD_READ_FRU_DATA = 0x11, + IPMI_CMD_RESERVE_SDR = 0x22, + IPMI_CMD_GET_SDR = 0x23, + IPMI_CMD_GET_SEL_INFO = 0x40, + IPMI_CMD_RESERVE_SEL = 0x42, + IPMI_CMD_GET_SEL_ENTRY = 0x43, + IPMI_CMD_ADD_SEL = 0x44, + IPMI_CMD_DELETE_SEL = 0x46, + IPMI_CMD_CLEAR_SEL = 0x47, + IPMI_CMD_GET_SEL_TIME = 0x48, + IPMI_CMD_SET_SEL_TIME = 0x49, + +}; + +struct ipmi_add_sel_request_t +{ + + uint8_t recordid[2]; + uint8_t recordtype; + uint8_t timestampe[4]; + uint8_t generatorid[2]; + uint8_t evmrev; + uint8_t sensortype; + uint8_t sensornumber; + uint8_t eventdir; + uint8_t eventdata[3]; +}; + +/** + * @struct Read FRU Data command request data + */ +struct ReadFruDataRequest +{ + uint8_t fruID; ///< FRU Device ID. FFh = reserved + uint8_t offsetLS; ///< FRU Inventory Offset to read, LS Byte + uint8_t offsetMS; ///< FRU Inventory Offset ro read, MS Byte + uint8_t count; ///< Count to read +} __attribute__((packed)); + +/** + * @struct Read FRU Data command response data + */ +struct ReadFruDataResponse +{ + uint8_t count; ///< Response data Count. + uint8_t data[]; ///< Response data. +} __attribute__((packed)); + +/** + * @struct Get FRU inventory area info command request data + */ +struct FruInvenAreaInfoRequest +{ + uint8_t fruID; ///< FRU Device ID. FFH = reserved. +} __attribute__((packed)); + +/** + * @struct Get FRU inventory area info command response + */ +struct FruInvenAreaInfoResponse +{ + uint8_t sizels; ///< Fru Inventory area size in bytes, LS Byte + uint8_t sizems; ///< Fru Inventory are size in bytes, MS Byte + uint8_t access; ///< 0b Devices is accessed by bytes, 1b - by words +} __attribute__((packed)); + +/** + * @struct Get Repository info command response + */ +struct GetRepositoryInfoResponse +{ + uint8_t sdrVersion; //< SDR version + uint8_t recordCountLs; //< Record count LS byte + uint8_t recordCountMs; //< Record count MS bte + uint8_t freeSpace[2]; //< Free space in bytes, LS first + uint8_t additionTimestamp[4]; //< Most recent addition timestamp LS first + uint8_t deletionTimestamp[4]; //< Most recent deletion timestamp LS first + uint8_t operationSupport; //< Operation support +} __attribute__((packed)); diff --git a/systemintfcmds.cpp b/systemintfcmds.cpp index c39a7af..af646d1 100644 --- a/systemintfcmds.cpp +++ b/systemintfcmds.cpp @@ -1,15 +1,15 @@ #include "config.h" -#include "systemintfcmds.h" +#include "systemintfcmds.hpp" #include "host-cmd-manager.hpp" #include "host-interface.hpp" -#include "host-ipmid/ipmid-host-cmd.hpp" +#include #include #include -#include "host-ipmid/ipmid-api.h" +#include void register_netfn_app_functions() __attribute__((constructor)); diff --git a/systemintfcmds.h b/systemintfcmds.h deleted file mode 100644 index 0243c02..0000000 --- a/systemintfcmds.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef __SYSTEM_INTF_CMDS_HANDLER_H__ -#define __SYSTEM_INTF_CMDS_HANDLER_H__ - -#include - -// These are per skiboot ipmi-sel code - -// OEM_SEL type with Timestamp -#define SEL_OEM_ID_0 0x55 -// SEL type is OEM and -not- general SEL -#define SEL_RECORD_TYPE_OEM 0xC0 -// Minor command for soft shurdown -#define SOFT_OFF 0x00 -// Major command for Any kind of power ops -#define CMD_POWER 0x04 -// Major command for the heartbeat operation (verify host is alive) -#define CMD_HEARTBEAT 0xFF - -// IPMI commands used via System Interface functions. -enum ipmi_netfn_system_intf_cmds -{ - IPMI_CMD_SET_BMC_GLOBAL_ENABLES = 0x2E, - IPMI_CMD_GET_MSG_FLAGS = 0x31, - IPMI_CMD_READ_EVENT = 0x35, -}; - -// A Mechanism to tell host to shtudown hosts by sending this PEM SEL. Really -// the only used fields by skiboot are: -// id[0] / id[1] for ID_0 , ID_1 -// type : SEL_RECORD_TYPE_OEM as standard SELs are ignored by skiboot -// cmd : CMD_POWER for power functions -// data[0], specific commands. example Soft power off. power cycle, etc. -struct oem_sel_timestamped -{ - /* SEL header */ - uint8_t id[2]; - uint8_t type; - uint8_t manuf_id[3]; - uint8_t timestamp[4]; - /* OEM SEL data (6 bytes) follows */ - uint8_t netfun; - uint8_t cmd; - uint8_t data[4]; -}; - -#endif diff --git a/systemintfcmds.hpp b/systemintfcmds.hpp new file mode 100644 index 0000000..c0b3318 --- /dev/null +++ b/systemintfcmds.hpp @@ -0,0 +1,43 @@ +#pragma once + +#include + +// These are per skiboot ipmi-sel code + +// OEM_SEL type with Timestamp +#define SEL_OEM_ID_0 0x55 +// SEL type is OEM and -not- general SEL +#define SEL_RECORD_TYPE_OEM 0xC0 +// Minor command for soft shurdown +#define SOFT_OFF 0x00 +// Major command for Any kind of power ops +#define CMD_POWER 0x04 +// Major command for the heartbeat operation (verify host is alive) +#define CMD_HEARTBEAT 0xFF + +// IPMI commands used via System Interface functions. +enum ipmi_netfn_system_intf_cmds +{ + IPMI_CMD_SET_BMC_GLOBAL_ENABLES = 0x2E, + IPMI_CMD_GET_MSG_FLAGS = 0x31, + IPMI_CMD_READ_EVENT = 0x35, +}; + +// A Mechanism to tell host to shtudown hosts by sending this PEM SEL. Really +// the only used fields by skiboot are: +// id[0] / id[1] for ID_0 , ID_1 +// type : SEL_RECORD_TYPE_OEM as standard SELs are ignored by skiboot +// cmd : CMD_POWER for power functions +// data[0], specific commands. example Soft power off. power cycle, etc. +struct oem_sel_timestamped +{ + /* SEL header */ + uint8_t id[2]; + uint8_t type; + uint8_t manuf_id[3]; + uint8_t timestamp[4]; + /* OEM SEL data (6 bytes) follows */ + uint8_t netfun; + uint8_t cmd; + uint8_t data[4]; +}; diff --git a/test/oemrouter_unittest.cpp b/test/oemrouter_unittest.cpp index b48798b..ec79316 100644 --- a/test/oemrouter_unittest.cpp +++ b/test/oemrouter_unittest.cpp @@ -1,8 +1,8 @@ -#include "host-ipmid/oemrouter.hpp" +#include #include +#include -#include "host-ipmid/ipmid-api.h" #include "sample.h" #include diff --git a/testaddsel.cpp b/testaddsel.cpp index 7f42acb..e44ecb7 100644 --- a/testaddsel.cpp +++ b/testaddsel.cpp @@ -1,3 +1,5 @@ +#include "sensorhandler.hpp" + #include #include #include @@ -6,8 +8,6 @@ #include #include -#include "sensorhandler.h" - extern void send_esel(uint16_t recordid); sd_bus* bus = NULL; diff --git a/transporthandler.cpp b/transporthandler.cpp index a6239ea..92ada92 100644 --- a/transporthandler.cpp +++ b/transporthandler.cpp @@ -26,12 +26,12 @@ namespace filesystem = std::experimental::filesystem; #include "transporthandler.hpp" #include "utils.hpp" +#include + #include #include #include -#include "host-ipmid/ipmid-api.h" - #define SYSTEMD_NETWORKD_DBUS 1 #ifdef SYSTEMD_NETWORKD_DBUS -- cgit v1.2.1