Kunlun OEM commands,The first version add two commands:
1,setCpuInfo:save cpu infomation from bios to file
2,getCpuInfo:load cpu infomation from file
Signed-off-by: Xiuzhi Cheng <xzcheng@zd-tech.com.cn>
diff --git a/src/.kunlun_oem.cpp.swp b/src/.kunlun_oem.cpp.swp
new file mode 100644
index 0000000..e41b7d0
--- /dev/null
+++ b/src/.kunlun_oem.cpp.swp
Binary files differ
diff --git a/src/.uuid b/src/.uuid
new file mode 100644
index 0000000..b77e90c
--- /dev/null
+++ b/src/.uuid
@@ -0,0 +1 @@
+3579f1bb-5c94-4e25-bf66-2bbd53b3674d
\ No newline at end of file
diff --git a/src/kunlun_oem.cpp b/src/kunlun_oem.cpp
new file mode 100644
index 0000000..c82fab3
--- /dev/null
+++ b/src/kunlun_oem.cpp
@@ -0,0 +1,89 @@
+#include <filesystem>
+#include <ipmid/api.hpp>
+#include <phosphor-logging/log.hpp>
+
+#include "config.h"
+#include "kunlun_oem.hpp"
+
+namespace ipmi
+{
+
+using namespace phosphor::logging;
+
+// save cpu infomation from bios to file
+// index[in]: cpu index
+// info[in]: data saving to file
+static int saveInfoToFile(uint8_t index, std::vector<char> &info)
+{
+ char infoPath[PATH_MAX];
+
+ std::snprintf(infoPath, sizeof(infoPath), IPMI_BIOSDATA_DIR"/cpu%02x", index);
+
+ if (!(std::filesystem::exists(IPMI_BIOSDATA_DIR)))
+ {
+ std::filesystem::create_directory(IPMI_BIOSDATA_DIR);
+ }
+
+ std::ofstream ofs(infoPath, std::ios::out | std::ios::binary);
+ ofs.seekp(0);
+ ofs.write(info.data(), info.size());
+ ofs.close();
+
+ return 0;
+}
+
+// load cpu infomation from file
+// index[in]: cpu index
+// info[out]: data loading from file
+static int loadInfoFromFile(uint8_t index, std::vector<char> &info)
+{
+ char infoPath[PATH_MAX];
+
+ std::snprintf(infoPath, sizeof(infoPath), IPMI_BIOSDATA_DIR"/cpu%02x", index);
+
+ if (!(std::filesystem::exists(infoPath)))
+ {
+ std::filesystem::create_directory(infoPath);
+ }
+
+ std::ifstream ifs(infoPath, std::ios::in | std::ios::binary);
+
+ ifs.seekg(0, std::ios::end);
+ auto size = ifs.tellg();
+ ifs.seekg(0, std::ios::beg);
+
+ info.resize(size);
+
+ ifs.read(info.data(), size);
+ ifs.close();
+
+ return 0;
+}
+
+RspType<> setCpuInfo(uint8_t index, std::vector<char> info)
+{
+ saveInfoToFile(index, info);
+
+ return responseSuccess();
+}
+
+RspType<std::vector<char>> getCpuInfo(uint8_t index)
+{
+ std::vector<char> output;
+
+ loadInfoFromFile(index, output);
+
+ return responseSuccess(output);
+}
+
+void register_kunlun_oem_functions(void)
+{
+ registerHandler(prioOemBase, netfnKunlunOem, cmd::cmdSetCpuInfo,
+ Privilege::Admin, setCpuInfo);
+ registerHandler(prioOemBase, netfnKunlunOem, cmd::cmdGetCpuInfo,
+ Privilege::User, getCpuInfo);
+}
+
+void register_kunlun_oem_functions() __attribute__((constructor));
+
+} // namespace ipmi
diff --git a/src/kunlun_oem.hpp b/src/kunlun_oem.hpp
new file mode 100644
index 0000000..acd62db
--- /dev/null
+++ b/src/kunlun_oem.hpp
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <cstdint>
+#include <ipmid/api.hpp>
+
+namespace ipmi
+{
+
+using NetFn = uint8_t;
+using Cmd = uint8_t;
+using Cc = uint8_t;
+
+constexpr NetFn netfnKunlunOem = netFnOemSix;
+namespace cmd
+{
+ constexpr Cmd cmdSetCpuInfo = 0x0;
+ constexpr Cmd cmdGetCpuInfo = 0x1;
+} // namespace cmd
+
+RspType<> setCpuInfo(uint8_t index, std::vector<char> info);
+RspType<std::vector<char>> getCpuInfo(uint8_t index);
+
+} // namespace ipmi
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..cb77ffc
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,19 @@
+configure_file(output: 'config.h',
+ configuration: cdata,
+)
+
+src_inc = include_directories('.')
+
+so_version = '0.0.1'
+
+shared_library(
+ 'kunlun-ipmi-oem',
+ 'kunlun_oem.cpp',
+ dependencies: [
+ phosphor_logging,
+ libipmid,
+ ],
+ version: so_version,
+ install: true,
+ install_dir: get_option('libdir') / 'ipmid-providers'
+ )