summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Kosenkov <NKosenkov@IBS.RU>2022-07-15 11:38:56 +0300
committerNikita Kosenkov <NKosenkov@IBS.RU>2022-07-15 11:38:56 +0300
commit6b4dc67a97ce5ea431749ae3cc3501f13a0ef3ea (patch)
treec4e133963bbd7bdb8e58a8bd54aa9aaa4e76fa9c
parent613e5f0e6cc0c6e2a1e2774d81bc581035fd76f9 (diff)
downloadsmbios-mdrv1-6b4dc67a97ce5ea431749ae3cc3501f13a0ef3ea.tar.xz
Changes for a successful build
-rw-r--r--CMakeLists.txt10
-rw-r--r--include/cpu.hpp82
-rw-r--r--include/smbios.hpp2
-rw-r--r--src/cpu.cpp49
-rw-r--r--src/smbios-main.cpp2
5 files changed, 78 insertions, 67 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 767aac5..5ee3130 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,18 +16,18 @@ 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})
+find_program (SDBUSPLUSPLUS sdbus++)
# 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})
@@ -37,12 +37,6 @@ set (SRC_FILES src/manager.cpp src/smbios-main.cpp src/timer.cpp src/cpu.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_custom_command (OUTPUT ${DBUS_OBJECT_NAME}/server.hpp
OUTPUT ${DBUS_OBJECT_NAME}/server.cpp
COMMAND mkdir -p ${DBUS_OBJECT_NAME}
diff --git a/include/cpu.hpp b/include/cpu.hpp
index 08204da..953c549 100644
--- a/include/cpu.hpp
+++ b/include/cpu.hpp
@@ -15,15 +15,31 @@
*/
#pragma once
-#include <xyz/openbmc_project/Inventory/Item/Cpu/server.hpp>
#include "smbios.hpp"
+
+#include <xyz/openbmc_project/Association/Definitions/server.hpp>
+#include <xyz/openbmc_project/Inventory/Connector/Slot/server.hpp>
+#include <xyz/openbmc_project/Inventory/Decorator/Asset/server.hpp>
+#include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp>
+#include <xyz/openbmc_project/Inventory/Decorator/Revision/server.hpp>
+#include <xyz/openbmc_project/Inventory/Item/Cpu/server.hpp>
+#include <xyz/openbmc_project/Inventory/Item/server.hpp>
+
namespace phosphor
{
namespace smbios
{
+using rev = sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::Revision;
+using asset = sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::Asset;
+using location = sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::LocationCode;
+using connector = sdbusplus::xyz::openbmc_project::Inventory::Connector::server::Slot;
+using processor = sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu;
+using Item = sdbusplus::xyz::openbmc_project::Inventory::server::Item;
+using association = sdbusplus::xyz::openbmc_project::Association::server::Definitions;
+
// Definition follow smbios spec DSP0134 3.0.0
static const std::map<uint8_t, std::string> cpuTypeTable = {
{0x1, "Other"}, {0x2, "Unknown"}, {0x3, "Central Processor"},
@@ -67,25 +83,26 @@ static const std::map<uint8_t, std::string> familyTable = {
};
// Definition follow smbios spec DSP0134 3.0.0
-static const std::string characterTable[16]{"Reserved",
- "Unknown",
- "64-bit Capable",
- "Multi-Core",
- "Hardware Thread",
- "Execute Protection",
- "Enhanced Virtualization",
- "Power/Performance Control",
- "Reserved",
- "Reserved",
- "Reserved",
- "Reserved",
- "Reserved",
- "Reserved",
- "Reserved",
- "Reserved"};
-
-class Cpu : sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu>
+static const std::array<std::optional<processor::Capability>, 16>
+ characteristicsTable{std::nullopt,
+ std::nullopt,
+ processor::Capability::Capable64bit,
+ processor::Capability::MultiCore,
+ processor::Capability::HardwareThread,
+ processor::Capability::ExecuteProtection,
+ processor::Capability::EnhancedVirtualization,
+ processor::Capability::PowerPerformanceControl,
+ std::nullopt,
+ std::nullopt,
+ std::nullopt,
+ std::nullopt,
+ std::nullopt,
+ std::nullopt,
+ std::nullopt,
+ std::nullopt};
+
+class Cpu : sdbusplus::server::object_t<processor, asset, location, connector, rev,
+ Item, association>
{
public:
Cpu() = delete;
@@ -98,9 +115,8 @@ class Cpu : sdbusplus::server::object::object<
Cpu(sdbusplus::bus::bus &bus, const std::string &objPath,
const uint8_t &cpuId, struct ManagedDataRegion *region) :
- sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu>(
- bus, objPath.c_str()),
+ sdbusplus::server::object_t<processor, asset, location, connector, rev,
+ Item, association>(bus, objPath.c_str()),
cpuNum(cpuId), regionS(region)
{
processorInfoUpdate();
@@ -108,16 +124,16 @@ class Cpu : sdbusplus::server::object::object<
void processorInfoUpdate(void);
- std::string processorSocket(std::string value) override;
- std::string processorType(std::string value) override;
- std::string processorFamily(std::string value) override;
- std::string processorManufacturer(std::string value) override;
- uint32_t processorId(uint32_t value) override;
- std::string processorVersion(std::string value) override;
- uint16_t processorMaxSpeed(uint16_t value) override;
- std::string processorCharacteristics(std::string value) override;
- uint16_t processorCoreCount(uint16_t value) override;
- uint16_t processorThreadCount(uint16_t value) override;
+ std::string processorSocket(std::string value);
+ std::string processorType(std::string value);
+ std::string processorFamily(std::string value);
+ std::string processorManufacturer(std::string value);
+ uint32_t processorId(uint32_t value);
+ std::string processorVersion(std::string value);
+ uint16_t processorMaxSpeed(uint16_t value);
+ std::string processorCharacteristics(std::string value) ;
+ uint16_t processorCoreCount(uint16_t value);
+ uint16_t processorThreadCount(uint16_t value);
private:
/** @brief Path of the group instance */
diff --git a/include/smbios.hpp b/include/smbios.hpp
index 390ac9a..a36ff34 100644
--- a/include/smbios.hpp
+++ b/include/smbios.hpp
@@ -16,6 +16,8 @@
#pragma once
#include <map>
+#include <cstdint>
+#include <string>
static constexpr uint16_t mdrSmbiosSize = 32 * 1024; // 32K
static constexpr uint16_t mdrAcpiTableSize = 32 * 1024; // 32K
diff --git a/src/cpu.cpp b/src/cpu.cpp
index a92d9e6..b6ebb3a 100644
--- a/src/cpu.cpp
+++ b/src/cpu.cpp
@@ -17,6 +17,8 @@
#include "cpu.hpp"
#include "manager.hpp"
#include <map>
+#include <cstdint>
+#include <bitset>
namespace phosphor
{
@@ -34,8 +36,7 @@ void Cpu::cpuSocket(uint8_t positionNum, uint8_t structLen, uint8_t *dataIn)
std::string Cpu::processorSocket(std::string value)
{
- return sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu::
- processorSocket(value);
+ return processor::socket(value);
}
void Cpu::cpuType(uint8_t value)
@@ -54,8 +55,7 @@ void Cpu::cpuType(uint8_t value)
std::string Cpu::processorType(std::string value)
{
- return sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu::
- processorType(value);
+ return "";//processor::processorType(value);
}
void Cpu::cpuFamily(uint8_t value)
@@ -73,8 +73,7 @@ void Cpu::cpuFamily(uint8_t value)
std::string Cpu::processorFamily(std::string value)
{
- return sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu::
- processorFamily(value);
+ return processor::family(value);
}
void Cpu::cpuManufacturer(uint8_t positionNum, uint8_t structLen,
@@ -89,14 +88,12 @@ void Cpu::cpuManufacturer(uint8_t positionNum, uint8_t structLen,
std::string Cpu::processorManufacturer(std::string value)
{
- return sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu::
- processorManufacturer(value);
+ return asset::manufacturer(value);
}
uint32_t Cpu::processorId(uint32_t value)
{
- return sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu::
- processorId(value);
+ return processor::id(value);
}
void Cpu::cpuVersion(uint8_t positionNum, uint8_t structLen, uint8_t *dataIn)
@@ -110,47 +107,47 @@ void Cpu::cpuVersion(uint8_t positionNum, uint8_t structLen, uint8_t *dataIn)
std::string Cpu::processorVersion(std::string value)
{
- return sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu::
- processorVersion(value);
+ return rev::version(value);
}
uint16_t Cpu::processorMaxSpeed(uint16_t value)
{
- return sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu::
- processorMaxSpeed(value);
+ return processor::maxSpeedInMhz(value);
}
void Cpu::cpuCharacteristics(uint16_t value)
{
- std::string result = "";
- for (uint8_t index = 0; index < (8 * sizeof(value)); index++)
+ std::vector<processor::Capability> result;
+ std::optional<processor::Capability> cap;
+
+ std::bitset<16> charBits = value;
+ for (uint8_t index = 0; index < charBits.size(); index++)
{
- if (value & 0x01)
+ if (charBits.test(index))
{
- result += characterTable[index];
+ if (cap = characteristicsTable[index])
+ {
+ result.emplace_back(*cap);
+ }
}
- value >>= 1;
}
- processorCharacteristics(result);
+ processor::characteristics(result);
}
std::string Cpu::processorCharacteristics(std::string value)
{
- return sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu::
- processorCharacteristics(value);
+ return "";//processor::characteristics(value);
}
uint16_t Cpu::processorCoreCount(uint16_t value)
{
- return sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu::
- processorCoreCount(value);
+ return processor::coreCount(value);
}
uint16_t Cpu::processorThreadCount(uint16_t value)
{
- return sdbusplus::xyz::openbmc_project::Inventory::Item::server::Cpu::
- processorThreadCount(value);
+ return processor::threadCount(value);
}
static constexpr uint8_t maxOldVersionCount = 0xff;
diff --git a/src/smbios-main.cpp b/src/smbios-main.cpp
index 532163c..eed4cc9 100644
--- a/src/smbios-main.cpp
+++ b/src/smbios-main.cpp
@@ -16,6 +16,8 @@
#include "manager.hpp"
#include "smbios.hpp"
+#include <cstdint>
+#include <string>
#include <systemd/sd-event.h>
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/elog-errors.hpp>