From 43505a818a36050ee1a5455b28e94a7ea02a01a9 Mon Sep 17 00:00:00 2001 From: Nikita Kosenkov Date: Fri, 26 Aug 2022 13:25:48 +0300 Subject: Changes required to support the latest version of DBUS interfaces --- include/cpu.hpp | 11 -------- src/cpu.cpp | 80 +++++++++++++++++------------------------------------ src/smbios-main.cpp | 2 +- 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 @@ -40,12 +40,6 @@ 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 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 familyTable = { {0x1, "Other"}, @@ -125,13 +119,8 @@ class Cpu : sdbusplus::server::object_t #include #include +#include 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::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::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(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); -- cgit v1.2.3