blob: b4b306177f9856c80df76695af09f2e780b92c1b [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 "google3/host_commands.h"
#include "ec_util_interface.hpp"
#include "host_command.hpp"
namespace google
{
namespace hoth
{
namespace internal
{
class EcUtilImpl : public EcUtil
{
public:
explicit EcUtilImpl(HostCommand* hostCmd) : hostCmd(hostCmd)
{}
// Get the Hoth statistics by issuing an EC_PRV_CMD_HOTH_GET_STATISTICS
// Command.
ec_response_statistics getHothStatistics() const override;
// Get the Hoth persistent panic info by issuing a series of
// EC_PRV_CMD_HOTH_PERSISTENT_PANIC_INFO commands.
std::optional<ec_response_persistent_panic_info>
getHothPersistentPanicInfo() const;
// Check the presence of Hoth peresistent panic info by issuing a single
// EC_PRV_CMD_HOTH_PERSISTENT_PANIC_INFO command.
bool checkHothPersistentPanicInfo() const override;
// Get the Hoth auth record.
// Only supports record id = 0, which is the only one currently used.
ec_authz_record_get_response getHothAuthRecord() const override;
private:
[[nodiscard]] static std::span<const uint8_t>
getResponseBody(std::vector<uint8_t> &response);
/** @brief Connection to Hoth for sending and receiving host commands */
HostCommand* hostCmd;
};
} // namespace internal
} // namespace hoth
} // namespace google