blob: 7ec3b231471ba324684bcda68a0b7144d1495c6c [file] [log] [blame]
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include "dbus.hpp"
#include <function2/function2.hpp>
#include <stdplus/cancel.hpp>
#include <xyz/openbmc_project/Control/Hoth/server.hpp>
#include <cstdint>
#include <string_view>
#include <vector>
namespace ipmi_hoth
{
namespace internal
{
/** @class DbusUpdate
* @brief Overridable D-Bus interface for command handler
*/
class DbusUpdate : public virtual Dbus
{
public:
using FirmwareUpdateStatus = sdbusplus::xyz::openbmc_project::Control::
server::Hoth::FirmwareUpdateStatus;
using Cb = fu2::unique_function<void(FirmwareUpdateStatus)>;
/** @brief Implementation for UpdateFirmware
* Executes hothd's updateFirmware with the given firmware binary. This
* is an asynchronous call and should not return anything. Poll the status
* of the update with GetFirmwareUpdateStatus.
*
* @param[in] hothId - The identifier of the targeted hoth instance.
* @param[in] firmwareData - Firmware binary to write to Hoth's
* firmware update SPI partition
* @param[in] cb - The callback to execute when the request completes.
* @return cancelable[stdplus::Cancel] - Drop to cancel the command early.
*/
virtual stdplus::Cancel
UpdateFirmware(std::string_view hothId,
const std::vector<uint8_t>& firmwareData, Cb&& cb) = 0;
/** @brief Implementation for GetFirmwareUpdateStatus
* Executes hothd's getFirmwareUpdateStatus. This is an asynchronous call
* that returns the status of the write to Hoth's firmware update SPI
* partition.
*
* @param[in] hothId - The identifier of the targeted hoth instance.
* @param[in] cb - The callback to execute when the request completes.
* @return cancelable[stdplus::Cancel] - Drop to cancel the command early.
*/
virtual stdplus::Cancel
GetFirmwareUpdateStatus(std::string_view hothId, Cb&& cb) = 0;
};
} // namespace internal
} // namespace ipmi_hoth