#include "tpm_device.hpp" #include "tpm2/tpm2.hpp" #include #include PHOSPHOR_LOG2_USING; TPMDevice::TPMDevice(sdbusplus::async::context& ctx, enum TPMType tpmType, uint8_t tpmIndex, SoftwareConfig& config, ManagerInf::SoftwareManager* parent) : Device(ctx, config, parent, {RequestedApplyTimes::OnReset}) { switch (tpmType) { case TPMType::TPM2: tpmInterface = std::make_unique(ctx, tpmIndex); break; default: tpmInterface = nullptr; error("Unsupported TPM type: {TYPE}", "TYPE", static_cast(tpmType)); break; } } sdbusplus::async::task TPMDevice::updateDevice(const uint8_t* image, size_t imageSize) { if (tpmInterface == nullptr) { error("TPM interface is not initialized"); co_return false; } setUpdateProgress(10); if (!co_await tpmInterface->updateFirmware(image, imageSize)) { error("Failed to update TPM firmware"); co_return false; } setUpdateProgress(100); debug("Successfully updated TPM"); co_return true; } sdbusplus::async::task TPMDevice::getVersion() { std::string version = "Unknown"; if (tpmInterface == nullptr) { error("TPM interface is not initialized"); co_return version; } if (!co_await tpmInterface->getVersion(version)) { error("Failed to get TPM version"); } co_return version; }