#include #include #include #include #include namespace ipmi { PHOSPHOR_LOG2_USING; uint64_t bigEndianToHost(uint64_t bigEndianValue) { if (std::endian::native == std::endian::little) { return std::byteswap(bigEndianValue); } return bigEndianValue; } void registerSBMRFunctions() __attribute__((constructor)); ipmi::RspType<> ipmiSBMRSendBootProgress(ipmi::Context::ptr ctx, std::vector data) { using postcode_t = std::tuple>; std::optional hostId = findHost(ctx->hostIdx); if (!hostId) { error("Invalid Host Id received"); return ipmi::responseInvalidCommand(); } if (data.size() != 9) { error("Invalid request of boot progress length received: {LENGTH}", "LENGTH", data.size()); return ipmi::responseReqDataLenInvalid(); } try { auto primaryPostCode = reinterpret_cast(data.data()); auto secondaryPostCode = std::vector(data.begin() + 8, data.end()); auto postCode = postcode_t(bigEndianToHost(*primaryPostCode), secondaryPostCode); auto conn = getSdBus(); auto hostbootRawObj = std::string(bootRawObjPrefix) + std::to_string(*hostId); auto method = conn->new_method_call(bootRawBusName, hostbootRawObj.data(), "org.freedesktop.DBus.Properties", "Set"); method.append(bootRawIntf, "Value", std::variant(postCode)); conn->call_noreply(method); } catch (std::exception& e) { error("postcode handler error: {ERROR}", "ERROR", e); return ipmi::responseResponseError(); } return ipmi::responseSuccess(); } void registerSBMRFunctions() { ipmi::registerGroupHandler( ipmi::prioOemBase, ipmi::groupSBMR, ipmi::sbmr::cmdSendBootProgress, ipmi::Privilege::Admin, ipmiSBMRSendBootProgress); return; } } // end of namespace ipmi