summaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorcyang29 <cheng.c.yang@intel.com>2018-10-15 06:00:56 +0300
committercyang29 <cheng.c.yang@intel.com>2018-10-15 06:00:56 +0300
commit95ef585c9602b29f97a349b74a1dc0cd6007129f (patch)
tree66cec88365af470347e86d139c0586ab832af5e1 /services
parent3f2c07b04c6ef4bef6930c67241a6461f85f9716 (diff)
downloadprovingground-95ef585c9602b29f97a349b74a1dc0cd6007129f.tar.xz
Add dbus service to support MDR V2 ipmi command
Add send and get DataInfo function for MDR V2 ipmi command store and get data through dbus interface. Change-Id: I75513807cbd323288c5cb9359ff3710b6da96d4a Signed-off-by: cyang29 <cheng.c.yang@intel.com>
Diffstat (limited to 'services')
-rw-r--r--services/smbios-mdrv2/.clang-format98
-rw-r--r--services/smbios-mdrv2/CMakeLists.txt49
-rw-r--r--services/smbios-mdrv2/cmake-format.json12
-rw-r--r--services/smbios-mdrv2/include/mdrv2.hpp99
-rw-r--r--services/smbios-mdrv2/include/smbios-mdrv2.hpp118
-rw-r--r--services/smbios-mdrv2/src/mdrv2.cpp241
-rw-r--r--services/smbios-mdrv2/src/smbios-mdrv2-main.cpp46
7 files changed, 663 insertions, 0 deletions
diff --git a/services/smbios-mdrv2/.clang-format b/services/smbios-mdrv2/.clang-format
new file mode 100644
index 0000000..dd27708
--- /dev/null
+++ b/services/smbios-mdrv2/.clang-format
@@ -0,0 +1,98 @@
+---
+Language: Cpp
+# BasedOnStyle: LLVM
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlinesLeft: false
+AlignOperands: true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: false
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+ AfterClass: true
+ AfterControlStatement: true
+ AfterEnum: true
+ AfterFunction: true
+ AfterNamespace: true
+ AfterObjCDeclaration: true
+ AfterStruct: true
+ AfterUnion: true
+ BeforeCatch: true
+ BeforeElse: true
+ IndentBraces: false
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Custom
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: AfterColon
+ColumnLimit: 80
+CommentPragmas: '^ IWYU pragma:'
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: true
+PointerAlignment: Left
+DisableFormat: false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: true
+ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
+IncludeBlocks: Regroup
+IncludeCategories:
+ - Regex: '^[<"](gtest|gmock)'
+ Priority: 5
+ - Regex: '^"config.h"'
+ Priority: -1
+ - Regex: '^".*\.hpp"'
+ Priority: 1
+ - Regex: '^<.*\.h>'
+ Priority: 2
+ - Regex: '^<.*'
+ Priority: 3
+ - Regex: '.*'
+ Priority: 4
+IndentCaseLabels: true
+IndentWidth: 4
+IndentWrappedFunctionNames: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+PointerAlignment: Right
+ReflowComments: true
+SortIncludes: true
+SpaceAfterCStyleCast: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard: Cpp11
+TabWidth: 4
+UseTab: Never
+...
diff --git a/services/smbios-mdrv2/CMakeLists.txt b/services/smbios-mdrv2/CMakeLists.txt
new file mode 100644
index 0000000..8cdf8a9
--- /dev/null
+++ b/services/smbios-mdrv2/CMakeLists.txt
@@ -0,0 +1,49 @@
+cmake_minimum_required (VERSION 3.2 FATAL_ERROR)
+include (ExternalProject)
+set (CMAKE_CXX_STANDARD 14)
+set (CMAKE_CXX_STANDARD_REQUIRED ON)
+set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
+set (DBUS_OBJECT_NAME "xyz/openbmc_project/Smbios/MDR_V2")
+set (DBUS_INTF_NAME "xyz.openbmc_project.Smbios.MDR_V2")
+
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
+
+include_directories (
+ ${CMAKE_CURRENT_SOURCE_DIR}/include/phosphor-dbus-interfaces
+)
+include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
+link_directories (${DBUSINTERFACE_LIBRARIES})
+
+find_package (PkgConfig REQUIRED)
+pkg_check_modules (SYSTEMD libsystemd REQUIRED)
+include_directories (${SYSTEMD_INCLUDE_DIRS})
+link_directories (${SYSTEMD_LIBRARY_DIRS})
+
+# import sdbusplus
+find_package (PkgConfig REQUIRED)
+pkg_check_modules (SDBUSPLUSPLUS sdbusplus REQUIRED)
+include_directories (${SDBUSPLUSPLUS_INCLUDE_DIRS})
+link_directories (${SDBUSPLUSPLUS_LIBRARY_DIRS})
+
+# phosphor-dbus-interfaces
+find_package (PkgConfig REQUIRED)
+pkg_check_modules (DBUSINTERFACE phosphor-dbus-interfaces REQUIRED)
+include_directories (${DBUSINTERFACE_INCLUDE_DIRS})
+link_directories (${DBUSINTERFACE_LIBRARY_DIRS})
+
+set (SRC_FILES src/mdrv2.cpp src/smbios-mdrv2-main.cpp)
+
+include_directories (${CMAKE_CURRENT_BINARY_DIR})
+
+find_package (PkgConfig REQUIRED)
+pkg_check_modules (SDBUSPLUSPLUS sdbusplus REQUIRED)
+include_directories (${SDBUSPLUSPLUS_INCLUDE_DIRS})
+link_directories (${SDBUSPLUSPLUS_LIBRARY_DIRS})
+find_program (SDBUSPLUSPLUS sdbus++)
+
+add_executable (smbiosmdrv2app ${SRC_FILES})
+target_link_libraries (smbiosmdrv2app ${SYSTEMD_LIBRARIES})
+target_link_libraries (smbiosmdrv2app ${DBUSINTERFACE_LIBRARIES})
+target_link_libraries (smbiosmdrv2app ${SDBUSPLUSPLUS_LIBRARIES})
+
+install (TARGETS smbiosmdrv2app DESTINATION sbin)
diff --git a/services/smbios-mdrv2/cmake-format.json b/services/smbios-mdrv2/cmake-format.json
new file mode 100644
index 0000000..4a701ae
--- /dev/null
+++ b/services/smbios-mdrv2/cmake-format.json
@@ -0,0 +1,12 @@
+{
+ "enum_char": ".",
+ "line_ending": "unix",
+ "bullet_char": "*",
+ "max_subargs_per_line": 99,
+ "command_case": "lower",
+ "tab_size": 4,
+ "line_width": 80,
+ "separate_fn_name_with_space": true,
+ "dangle_parens": true,
+ "separate_ctrl_name_with_space": true
+}
diff --git a/services/smbios-mdrv2/include/mdrv2.hpp b/services/smbios-mdrv2/include/mdrv2.hpp
new file mode 100644
index 0000000..6377277
--- /dev/null
+++ b/services/smbios-mdrv2/include/mdrv2.hpp
@@ -0,0 +1,99 @@
+/*
+// Copyright (c) 2018 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+
+#pragma once
+#include "smbios-mdrv2.hpp"
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/log.hpp>
+#include <sdbusplus/server.hpp>
+#include <xyz/openbmc_project/Smbios/MDR_V2/server.hpp>
+
+namespace phosphor
+{
+namespace smbios
+{
+
+static constexpr const char *mdrV2Path = "/xyz/openbmc_project/Smbios/MDR_V2";
+
+class MDR_V2 : sdbusplus::xyz::openbmc_project::Smbios::server::MDR_V2
+{
+ public:
+ MDR_V2() = delete;
+ MDR_V2(const MDR_V2 &) = delete;
+ MDR_V2 &operator=(const MDR_V2 &) = delete;
+ MDR_V2(MDR_V2 &&) = delete;
+ MDR_V2 &operator=(MDR_V2 &&) = delete;
+ ~MDR_V2() = default;
+
+ MDR_V2(sdbusplus::bus::bus &bus, const char *path) :
+ sdbusplus::xyz::openbmc_project::Smbios::server::MDR_V2(bus, path),
+ bus(bus)
+ {
+
+ smbiosDir.agentVersion = smbiosAgentVersion;
+ smbiosDir.dirVersion = 1;
+ smbiosDir.dirEntries = 1;
+ directoryEntries(smbiosDir.dirEntries);
+ smbiosDir.status = 1;
+ smbiosDir.remoteDirVersion = 0;
+
+ std::copy(smbiosTableId.begin(), smbiosTableId.end(),
+ smbiosDir.dir[smbiosDirIndex].common.id.dataInfo);
+ }
+
+ std::vector<uint8_t> getDirectoryInformation(uint8_t dirIndex) override;
+
+ std::vector<uint8_t> getDataInformation(uint8_t idIndex) override;
+
+ bool sendDirectoryInformation(uint8_t dirVersion, uint8_t dirIndex,
+ uint8_t returnedEntries,
+ uint8_t remainingEntries,
+ std::vector<uint8_t> dirEntry) override;
+
+ std::vector<uint8_t> getDataOffer() override;
+
+ bool sendDataInformation(uint8_t idIndex, uint8_t flag, uint32_t dataLen,
+ uint32_t dataVer, uint32_t timeStamp) override;
+
+ int findIdIndex(std::vector<uint8_t> dataInfo) override;
+
+ bool agentSynchronizeData() override;
+
+ std::vector<uint32_t>
+ synchronizeDirectoryCommonData(uint8_t idIndex, uint32_t size) override;
+
+ uint8_t directoryEntries(uint8_t value) override;
+
+ private:
+ sdbusplus::bus::bus &bus;
+
+ Mdr2DirStruct smbiosDir;
+
+ const std::array<uint8_t, 16> smbiosTableId{
+ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 0x42};
+ uint8_t smbiosTableStorage[smbiosTableStorageSize];
+
+ bool smbiosIsAvailForUpdate(uint8_t index);
+ inline uint8_t smbiosValidFlag(uint8_t index);
+};
+
+} // namespace smbios
+} // namespace phosphor
diff --git a/services/smbios-mdrv2/include/smbios-mdrv2.hpp b/services/smbios-mdrv2/include/smbios-mdrv2.hpp
new file mode 100644
index 0000000..50482cb
--- /dev/null
+++ b/services/smbios-mdrv2/include/smbios-mdrv2.hpp
@@ -0,0 +1,118 @@
+/*
+// Copyright (c) 2018 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+
+#pragma once
+
+#include <array>
+
+static constexpr const char *mdrType2File = "/etc/smbios/smbios2";
+static constexpr const char *smbiosPath = "/etc/smbios";
+
+static constexpr uint16_t mdrSmbiosSize = 32 * 1024;
+
+constexpr uint16_t smbiosAgentId = 0x0101;
+constexpr int firstAgentIndex = 1;
+
+constexpr uint8_t maxDirEntries = 4;
+constexpr uint32_t mdr2SMSize = 0x00100000;
+constexpr uint32_t mdr2SMBaseAddress = 0x9FF00000;
+
+constexpr uint8_t mdrTypeII = 2;
+
+constexpr uint8_t mdr2Version = 2;
+constexpr uint8_t smbiosAgentVersion = 1;
+
+constexpr uint32_t pageMask = 0xf000;
+constexpr int smbiosDirIndex = 0;
+
+constexpr uint32_t smbiosTableVersion = 15;
+constexpr uint32_t smbiosTableTimestamp = 0x45464748;
+constexpr uint32_t smbiosSMMemoryOffset = 0;
+constexpr uint32_t smbiosSMMemorySize = 1024 * 1024;
+constexpr uint32_t smbiosTableStorageSize = 64 * 1024;
+constexpr uint32_t defaultTimeout = 200;
+
+enum class MDR2SMBIOSStatusEnum
+{
+ mdr2Init = 0,
+ mdr2Loaded = 1,
+ mdr2Updated = 2,
+ mdr2Updating = 3
+};
+
+enum class MDR2DirLockEnum
+{
+ mdr2DirUnlock = 0,
+ mdr2DirLock = 1
+};
+
+enum class DirDataRequestEnum
+{
+ dirDataNotRequested = 0x00,
+ dirDataRequested = 0x01
+};
+
+enum class FlagStatus
+{
+ flagIsInvalid = 0,
+ flagIsValid = 1,
+ flagIsLocked = 2
+};
+
+typedef struct
+{
+ uint8_t dataInfo[16];
+} DataIdStruct;
+
+typedef struct
+{
+ DataIdStruct id;
+ uint32_t size;
+ uint32_t dataSetSize;
+ uint32_t dataVersion;
+ uint32_t timestamp;
+} Mdr2DirEntry;
+
+typedef struct
+{
+ Mdr2DirEntry common;
+ MDR2SMBIOSStatusEnum stage;
+ MDR2DirLockEnum lock;
+ uint16_t lockHandle;
+ uint32_t xferBuff;
+ uint32_t xferSize;
+ uint32_t maxDataSize;
+ uint8_t *dataStorage;
+} Mdr2DirLocalStruct;
+
+typedef struct
+{
+ uint8_t agentVersion;
+ uint8_t dirVersion;
+ uint8_t dirEntries;
+ uint8_t status; // valid / locked / etc
+ uint8_t remoteDirVersion;
+ uint16_t sessionHandle;
+ Mdr2DirLocalStruct dir[maxDirEntries];
+} Mdr2DirStruct;
+
+struct MDRSmbiosHeader
+{
+ uint8_t dirVer;
+ uint8_t mdrType;
+ uint32_t timestamp;
+ uint32_t dataSize;
+} __attribute__((packed));
diff --git a/services/smbios-mdrv2/src/mdrv2.cpp b/services/smbios-mdrv2/src/mdrv2.cpp
new file mode 100644
index 0000000..92492bb
--- /dev/null
+++ b/services/smbios-mdrv2/src/mdrv2.cpp
@@ -0,0 +1,241 @@
+/*
+// Copyright (c) 2018 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+
+#include "mdrv2.hpp"
+
+#include <sys/mman.h>
+
+#include <fstream>
+#include <phosphor-logging/elog-errors.hpp>
+#include <sdbusplus/exception.hpp>
+#include <xyz/openbmc_project/Smbios/MDR_V2/error.hpp>
+
+namespace phosphor
+{
+namespace smbios
+{
+
+std::vector<uint8_t> MDR_V2::getDirectoryInformation(uint8_t dirIndex)
+{
+}
+
+bool MDR_V2::smbiosIsAvailForUpdate(uint8_t index)
+{
+ bool ret = false;
+ if (index > maxDirEntries)
+ {
+ return ret;
+ }
+
+ switch (smbiosDir.dir[index].stage)
+ {
+ case MDR2SMBIOSStatusEnum::mdr2Updating:
+ ret = false;
+ break;
+
+ case MDR2SMBIOSStatusEnum::mdr2Init:
+ // This *looks* like there should be a break statement here,
+ // as the effects of the previous statement are a noop given
+ // the following code that this falls through to.
+ // We've elected not to change it, though, since it's been
+ // this way since the old generation, and it would affect
+ // the way the code functions.
+ // If it ain't broke, don't fix it.
+
+ case MDR2SMBIOSStatusEnum::mdr2Loaded:
+ case MDR2SMBIOSStatusEnum::mdr2Updated:
+ if (smbiosDir.dir[index].lock == MDR2DirLockEnum::mdr2DirLock)
+ {
+ ret = false;
+ }
+ else
+ {
+ ret = true;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return ret;
+}
+
+std::vector<uint8_t> MDR_V2::getDataOffer()
+{
+ std::vector<uint8_t> offer(sizeof(DataIdStruct));
+ if (smbiosIsAvailForUpdate(0))
+ {
+ std::copy(smbiosDir.dir[0].common.id.dataInfo,
+ &smbiosDir.dir[0].common.id.dataInfo[16], offer.data());
+ }
+ else
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "smbios is not ready for update");
+ throw sdbusplus::xyz::openbmc_project::Smbios::MDR_V2::Error::
+ UpdateInProgress();
+ }
+ return offer;
+}
+
+inline uint8_t MDR_V2::smbiosValidFlag(uint8_t index)
+{
+ FlagStatus ret = FlagStatus::flagIsInvalid;
+ MDR2SMBIOSStatusEnum stage = smbiosDir.dir[index].stage;
+ MDR2DirLockEnum lock = smbiosDir.dir[index].lock;
+
+ switch (stage)
+ {
+ case MDR2SMBIOSStatusEnum::mdr2Loaded:
+ case MDR2SMBIOSStatusEnum::mdr2Updated:
+ if (lock == MDR2DirLockEnum::mdr2DirLock)
+ {
+ ret = FlagStatus::flagIsLocked; // locked
+ }
+ else
+ {
+ ret = FlagStatus::flagIsValid; // valid
+ }
+ break;
+
+ case MDR2SMBIOSStatusEnum::mdr2Updating:
+ case MDR2SMBIOSStatusEnum::mdr2Init:
+ ret = FlagStatus::flagIsInvalid; // invalid
+ break;
+
+ default:
+ break;
+ }
+
+ return static_cast<uint8_t>(ret);
+}
+
+std::vector<uint8_t> MDR_V2::getDataInformation(uint8_t idIndex)
+{
+ std::vector<uint8_t> responseInfo;
+ responseInfo.push_back(mdr2Version);
+
+ if (idIndex >= maxDirEntries)
+ {
+ throw sdbusplus::xyz::openbmc_project::Smbios::MDR_V2::Error::
+ InvalidParameter();
+ }
+
+ for (uint8_t index = 0; index < sizeof(DataIdStruct); index++)
+ {
+ responseInfo.push_back(
+ smbiosDir.dir[idIndex].common.id.dataInfo[index]);
+ }
+ responseInfo.push_back(smbiosValidFlag(idIndex));
+ responseInfo.push_back(smbiosDir.dir[idIndex].common.size);
+ responseInfo.push_back(smbiosDir.dir[idIndex].common.dataVersion);
+ responseInfo.push_back(smbiosDir.dir[idIndex].common.timestamp);
+
+ return responseInfo;
+}
+
+bool MDR_V2::sendDirectoryInformation(uint8_t dirVersion, uint8_t dirIndex,
+ uint8_t returnedEntries,
+ uint8_t remainingEntries,
+ std::vector<uint8_t> dirEntry)
+{
+}
+
+bool MDR_V2::sendDataInformation(uint8_t idIndex, uint8_t flag,
+ uint32_t dataLen, uint32_t dataVer,
+ uint32_t timeStamp)
+{
+ if (idIndex >= maxDirEntries)
+ {
+ throw sdbusplus::xyz::openbmc_project::Smbios::MDR_V2::Error::
+ InvalidParameter();
+ }
+ int entryChanged = 0;
+ if (smbiosDir.dir[idIndex].common.dataSetSize != dataLen)
+ {
+ entryChanged++;
+ smbiosDir.dir[idIndex].common.dataSetSize = dataLen;
+ }
+
+ if (smbiosDir.dir[idIndex].common.dataVersion != dataVer)
+ {
+ entryChanged++;
+ smbiosDir.dir[idIndex].common.dataVersion = dataVer;
+ }
+
+ if (smbiosDir.dir[idIndex].common.timestamp != timeStamp)
+ {
+ entryChanged++;
+ smbiosDir.dir[idIndex].common.timestamp = timeStamp;
+ }
+ if (entryChanged == 0)
+ {
+ return false;
+ }
+ return true;
+}
+
+int MDR_V2::findIdIndex(std::vector<uint8_t> dataInfo)
+{
+ if (dataInfo.size() != sizeof(DataIdStruct))
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Length of dataInfo invalid");
+ throw sdbusplus::xyz::openbmc_project::Smbios::MDR_V2::Error::
+ InvalidParameter();
+ }
+ std::array<uint8_t, 16> arrayDataInfo;
+
+ std::copy(dataInfo.begin(), dataInfo.end(), arrayDataInfo.begin());
+
+ for (int index = 0; index < smbiosDir.dirEntries; index++)
+ {
+ int info = 0;
+ for (; info < arrayDataInfo.size(); info++)
+ {
+ if (arrayDataInfo[info] !=
+ smbiosDir.dir[index].common.id.dataInfo[info])
+ {
+ break;
+ }
+ }
+ if (info == arrayDataInfo.size())
+ {
+ return index;
+ }
+ }
+ throw sdbusplus::xyz::openbmc_project::Smbios::MDR_V2::Error::InvalidId();
+}
+
+uint8_t MDR_V2::directoryEntries(uint8_t value)
+{
+ value = smbiosDir.dirEntries;
+ return sdbusplus::xyz::openbmc_project::Smbios::server::MDR_V2::
+ directoryEntries(value);
+}
+
+bool MDR_V2::agentSynchronizeData()
+{
+}
+
+std::vector<uint32_t> MDR_V2::synchronizeDirectoryCommonData(uint8_t idIndex,
+ uint32_t size)
+{
+}
+
+} // namespace smbios
+} // namespace phosphor
diff --git a/services/smbios-mdrv2/src/smbios-mdrv2-main.cpp b/services/smbios-mdrv2/src/smbios-mdrv2-main.cpp
new file mode 100644
index 0000000..e96da8e
--- /dev/null
+++ b/services/smbios-mdrv2/src/smbios-mdrv2-main.cpp
@@ -0,0 +1,46 @@
+/*
+// Copyright (c) 2018 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+
+#include "mdrv2.hpp"
+
+#include <systemd/sd-event.h>
+
+#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/elog.hpp>
+
+int main(void)
+{
+ sd_event *events = nullptr;
+ sd_event_default(&events);
+ sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
+ bus.attach_event(events, SD_EVENT_PRIORITY_NORMAL);
+ bus.request_name("xyz.openbmc_project.Smbios.MDR_V2");
+
+ phosphor::smbios::MDR_V2 mdrV2(bus, phosphor::smbios::mdrV2Path);
+
+ while (true)
+ {
+ int r = sd_event_run(events, (uint64_t)-1);
+ if (r < 0)
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Failure processing request",
+ phosphor::logging::entry("errno=0x%X", -r));
+ return -1;
+ }
+ }
+ return 0;
+}