blob: 6e083bccb80eb19fa0ff5c99f4172bacb905e141 [file] [log] [blame] [edit]
#pragma once
#include <atomic>
#include <string>
#include "smbios.grpc.pb.h"
#include "smbios_file.h"
#include "grpcpp/server_context.h"
#include "grpcpp/support/status.h"
namespace blobs {
constexpr auto objectPrefix = "/xyz/openbmc_project/grpcblobs/system";
class SmbiosTransferServiceImpl final
: public phosphor::smbios::grpc_gen::SmbiosTransferService::Service {
public:
explicit SmbiosTransferServiceImpl(int instanceNumber,
const std::string& basePath)
: phosphor::smbios::grpc_gen::SmbiosTransferService::Service(),
instance(instanceNumber),
basePath_(basePath),
smbiosAppPidFile_(basePath + "/var/run/smbiosmdrv2app.pid") {}
grpc::Status SmbiosTransfer(
grpc::ServerContext* context,
const phosphor::smbios::SmbiosTransferRequest* request,
[[maybe_unused]] phosphor::smbios::SmbiosTransferResponse* response);
bool acceptEntry(const SmbiosEntry& entry, bool isWrite);
protected:
[[nodiscard]] bool claimLinkBusy();
void writeThenStart(const SmbiosEntry& entry, bool isWrite);
void sendSignalToSmbiosApp();
private:
int instance;
std::atomic_flag linkBusy;
std::string basePath_;
std::string smbiosAppPidFile_;
};
} // namespace blobs