summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Kosenkov <NKosenkov@IBS.RU>2022-08-26 13:25:48 +0300
committerNikita Kosenkov <NKosenkov@IBS.RU>2022-08-26 13:25:48 +0300
commit43505a818a36050ee1a5455b28e94a7ea02a01a9 (patch)
tree2dd251df69e98e5c462862f774b6faf720cf06f8
parent3dce1051f31c53541a0e9e3f2e30528d912e23dc (diff)
downloadsmbios-mdrv1-43505a818a36050ee1a5455b28e94a7ea02a01a9.tar.xz
Changes required to support the latest version of DBUS interfaces
-rw-r--r--include/cpu.hpp11
-rw-r--r--src/cpu.cpp80
-rw-r--r--src/smbios-main.cpp2
3 files changed, 27 insertions, 66 deletions
diff --git a/include/cpu.hpp b/include/cpu.hpp
index 953c549..4f31c93 100644
--- a/include/cpu.hpp
+++ b/include/cpu.hpp
@@ -41,12 +41,6 @@ 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"},
- {0x4, "Math Processor"}, {0x5, "DSP Processor"}, {0x6, "Vodeo Processor"},
-};
-
-// Definition follow smbios spec DSP0134 3.0.0
static const std::map<uint8_t, std::string> familyTable = {
{0x1, "Other"},
{0x2, "Unknown"},
@@ -125,13 +119,8 @@ class Cpu : sdbusplus::server::object_t<processor, asset, location, connector, r
void processorInfoUpdate(void);
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);
diff --git a/src/cpu.cpp b/src/cpu.cpp
index b6ebb3a..552a781 100644
--- a/src/cpu.cpp
+++ b/src/cpu.cpp
@@ -19,6 +19,7 @@
#include <map>
#include <cstdint>
#include <bitset>
+#include <iostream>
namespace phosphor
{
@@ -31,7 +32,9 @@ void Cpu::cpuSocket(uint8_t positionNum, uint8_t structLen, uint8_t *dataIn)
result = positionToString(positionNum, structLen, dataIn);
- processorSocket(result);
+ processor::socket(result);
+
+ location::locationCode(result);
}
std::string Cpu::processorSocket(std::string value)
@@ -39,43 +42,19 @@ std::string Cpu::processorSocket(std::string value)
return processor::socket(value);
}
-void Cpu::cpuType(uint8_t value)
-{
- std::map<uint8_t, std::string>::const_iterator it =
- cpuTypeTable.find(value);
- if (it == cpuTypeTable.end())
- {
- processorType("Unknown Processor Type");
- }
- else
- {
- processorType(it->second);
- }
-}
-
-std::string Cpu::processorType(std::string value)
-{
- return "";//processor::processorType(value);
-}
-
void Cpu::cpuFamily(uint8_t value)
{
std::map<uint8_t, std::string>::const_iterator it = familyTable.find(value);
if (it == familyTable.end())
{
- processorFamily("Unknown Processor Family");
+ processor::family("Unknown Processor Family");
}
else
{
- processorFamily(it->second);
+ processor::family(it->second);
}
}
-std::string Cpu::processorFamily(std::string value)
-{
- return processor::family(value);
-}
-
void Cpu::cpuManufacturer(uint8_t positionNum, uint8_t structLen,
uint8_t *dataIn)
{
@@ -83,12 +62,7 @@ void Cpu::cpuManufacturer(uint8_t positionNum, uint8_t structLen,
result = positionToString(positionNum, structLen, dataIn);
- processorManufacturer(result);
-}
-
-std::string Cpu::processorManufacturer(std::string value)
-{
- return asset::manufacturer(value);
+ asset::manufacturer(result);
}
uint32_t Cpu::processorId(uint32_t value)
@@ -102,12 +76,8 @@ void Cpu::cpuVersion(uint8_t positionNum, uint8_t structLen, uint8_t *dataIn)
result = positionToString(positionNum, structLen, dataIn);
- processorVersion(result);
-}
-
-std::string Cpu::processorVersion(std::string value)
-{
- return rev::version(value);
+ processor::version(result);
+ rev::version(result);
}
uint16_t Cpu::processorMaxSpeed(uint16_t value)
@@ -135,11 +105,6 @@ void Cpu::cpuCharacteristics(uint16_t value)
processor::characteristics(result);
}
-std::string Cpu::processorCharacteristics(std::string value)
-{
- return "";//processor::characteristics(value);
-}
-
uint16_t Cpu::processorCoreCount(uint16_t value)
{
return processor::coreCount(value);
@@ -177,16 +142,23 @@ void Cpu::processorInfoUpdate(void)
auto cpuInfo = reinterpret_cast<struct ProcessorInfo *>(dataIn);
- cpuSocket(cpuInfo->socketDesignation, cpuInfo->length,
- dataIn); // offset 4h
- cpuType(cpuInfo->processorType); // offset 5h
- cpuFamily(cpuInfo->family); // offset 6h
- cpuManufacturer(cpuInfo->manufacturer, cpuInfo->length,
- dataIn); // offset 7h
- processorId(cpuInfo->id); // offset 8h
- cpuVersion(cpuInfo->version, cpuInfo->length, dataIn); // offset 10h
- processorMaxSpeed(cpuInfo->maxSpeed); // offset 14h
- if (cpuInfo->coreCount < maxOldVersionCount) // offset 23h or 2Ah
+ constexpr uint32_t socketPopulatedMask = 1 << 6;
+ if ((cpuInfo->status & socketPopulatedMask) == 0)
+ {
+ // Don't attempt to fill in any other details if the CPU is not present.
+ present(false);
+ return;
+ }
+ present(true);
+
+ cpuSocket(cpuInfo->socketDesignation, cpuInfo->length, dataIn); // offset 4h
+ cpuFamily(cpuInfo->family); // offset 6h
+ cpuManufacturer(cpuInfo->manufacturer, cpuInfo->length, dataIn);// offset 7h
+ processorId(cpuInfo->id); // offset 8h
+ cpuVersion(cpuInfo->version, cpuInfo->length, dataIn); // offset 10h
+ processorMaxSpeed(cpuInfo->maxSpeed); // offset 14h
+
+ if (cpuInfo->coreCount < maxOldVersionCount) // offset 23h or 2Ah
{
processorCoreCount((uint16_t)cpuInfo->coreCount);
}
diff --git a/src/smbios-main.cpp b/src/smbios-main.cpp
index c97a041..75d9408 100644
--- a/src/smbios-main.cpp
+++ b/src/smbios-main.cpp
@@ -70,7 +70,7 @@ int main(void)
sd_event_default(&events);
sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
- sdbusplus::server::manager::manager objManager(bus, "/xyz/openbmc_project");
+ sdbusplus::server::manager::manager objManager(bus, "/xyz/openbmc_project/inventory");
phosphor::watchdog::EventPtr eventP{events,
phosphor::watchdog::EventDeleter()};
bus.attach_event(events, SD_EVENT_PRIORITY_NORMAL);