Name cpp files with functions
Instead of implementing all the features in one cpp file, we organize
the cpp file according to the specific functionality. Here, we renamed
iei_oem.cpp to asset_info.cpp, and in fact this file only implements the
features related to asset information
Change-Id: I29d29dd40fb6eb353e77fbf8eb7370bf0b84ccb6
Signed-off-by: John Wang <wangzhiqiang02@ieisystem.com>
diff --git a/src/iei_oem.cpp b/src/asset_info.cpp
similarity index 86%
rename from src/iei_oem.cpp
rename to src/asset_info.cpp
index 625bbff..78a7c85 100644
--- a/src/iei_oem.cpp
+++ b/src/asset_info.cpp
@@ -1,6 +1,6 @@
#include "config.h"
-#include "iei_oem.hpp"
+#include "types.hpp"
#include <ipmid/api.hpp>
#include <ipmid/utils.hpp>
@@ -28,12 +28,37 @@
namespace ipmi
{
-#define UNUSED(x) (void)(x)
-
-using namespace iei;
-
static void registerOEMFunctions() __attribute__((constructor));
+struct AssetInfoHeader
+{
+ uint8_t rwFlag;
+ uint8_t deviceType;
+ uint8_t infoType;
+ uint8_t maskAllPresentLen;
+ uint8_t enableStatus;
+ uint8_t maskPresent;
+ uint8_t maskAllPresent;
+ uint8_t allInfoDone;
+ uint16_t totalMessageLen;
+} __attribute__((packed));
+
+enum class bios_version_devname
+{
+ BIOS = 0,
+ ME = 1,
+ IE = 2,
+ PCH = 3,
+ BOARD = 4,
+ MRC = 5,
+ CUSTOM_ID = 6,
+ PCH_STEPPING = 7,
+};
+
+constexpr std::array<std::string_view, 8> bios_devname{
+ "BIOS", "ME", "IE", "PCH", "BOARD", "MRC", "CUSTOM_ID", "PCH_STEPPING",
+};
+
struct ParsedAssetInfo
{
uint8_t rwFlag;
@@ -152,13 +177,12 @@
}
ipmi_ret_t ipmiOemIEIAssetInfo(ipmi_netfn_t /* netfn */, ipmi_cmd_t /* cmd */,
- ipmi_request_t request, ipmi_response_t response,
+ ipmi_request_t request,
+ ipmi_response_t /* response */,
ipmi_data_len_t /* data_len */,
ipmi_context_t /* context */)
{
auto header = reinterpret_cast<AssetInfoHeader*>(request);
- uint8_t* res = reinterpret_cast<uint8_t*>(response);
- UNUSED(res);
auto info = parseAssetInfo(header);
auto deviceType = info->deviceType;
@@ -177,7 +201,7 @@
void registerOEMFunctions(void)
{
- ipmi_register_callback(NETFN_OEM_IEI, CMD_OEM_ASSET_INFO, nullptr,
+ ipmi_register_callback(netFnIei, iei::cmdSetAssetInfo, nullptr,
ipmiOemIEIAssetInfo, SYSTEM_INTERFACE);
}
diff --git a/src/iei_oem.hpp b/src/iei_oem.hpp
deleted file mode 100644
index 6e0005a..0000000
--- a/src/iei_oem.hpp
+++ /dev/null
@@ -1,49 +0,0 @@
-#pragma once
-
-#include <array>
-#include <cstdint>
-#include <string_view>
-
-namespace iei
-{
-
-enum ipmi_iei_net_fns
-{
- NETFN_OEM_IEI = 0x3c,
-};
-
-enum iei_oem_cmds
-{
- CMD_OEM_ASSET_INFO = 0x01,
-};
-
-struct AssetInfoHeader
-{
- uint8_t rwFlag;
- uint8_t deviceType;
- uint8_t infoType;
- uint8_t maskAllPresentLen;
- uint8_t enableStatus;
- uint8_t maskPresent;
- uint8_t maskAllPresent;
- uint8_t allInfoDone;
- uint16_t totalMessageLen;
-} __attribute__((packed));
-
-enum class bios_version_devname
-{
- BIOS = 0,
- ME = 1,
- IE = 2,
- PCH = 3,
- BOARD = 4,
- MRC = 5,
- CUSTOM_ID = 6,
- PCH_STEPPING = 7,
-};
-
-constexpr std::array<std::string_view, 8> bios_devname{
- "BIOS", "ME", "IE", "PCH", "BOARD", "MRC", "CUSTOM_ID", "PCH_STEPPING",
-};
-
-} // namespace iei
diff --git a/src/meson.build b/src/meson.build
index 698258a..d183f6d 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -7,7 +7,7 @@
so_version = '0.1.0'
sources = [
- 'iei_oem.cpp',
+ 'asset_info.cpp',
]
deps = [
diff --git a/src/types.hpp b/src/types.hpp
new file mode 100644
index 0000000..2054d06
--- /dev/null
+++ b/src/types.hpp
@@ -0,0 +1,25 @@
+#pragma once
+#include <ipmid/api-types.hpp>
+
+namespace ipmi
+{
+
+constexpr ipmi::NetFn netFnIei = 0x3C;
+constexpr ipmi::NetFn netFnIntelMe = 0x30;
+
+namespace iei
+{
+
+constexpr ipmi::Cmd cmdSetAssetInfo = 0x01;
+constexpr ipmi::Cmd cmdGetBMCFWInfo = 0x37;
+
+} // namespace iei
+
+namespace intel_me
+{
+
+constexpr ipmi::Cmd cmdGetPsuPinReading = 0xE2;
+
+}
+
+} // namespace ipmi