blob: 198a01f3a4f031b89cf228f967f952d80ac1c040 [file] [log] [blame] [edit]
#ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_DETERMINISTIC_BMC_I2C_WALKER_UHMM_I2C_WALKER_H_
#define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_DETERMINISTIC_BMC_I2C_WALKER_UHMM_I2C_WALKER_H_
#include <cstdint>
#include <memory>
#include <ostream>
#include <string>
#include <vector>
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "tlbmc/deterministic_bmc/i2c_walker/i2c_walker_interface.h"
#include "tlbmc/deterministic_bmc/offline_config_parser/proto_reader.h"
#include "fru_i2c.pb.h"
namespace deterministic_bmc {
// A class that does the i2c topology walk with the uhmm offline config.
class UhmmI2cWalker : public I2cWalkerInterface {
public:
struct UhmmI2cWalkerOptions {
std::string root_directory = "/";
std::string uhmm_offline_config_path;
ProtoFormat fru_i2c_config_format;
friend std::ostream& operator<<(std::ostream& os,
const UhmmI2cWalkerOptions& options) {
return os << "root_directory: " << options.root_directory
<< ", uhmm_offline_config_path: "
<< options.uhmm_offline_config_path
<< ", fru_i2c_config_format: "
<< options.fru_i2c_config_format;
}
};
~UhmmI2cWalker() override = default;
static absl::StatusOr<std::unique_ptr<UhmmI2cWalker>> Create(
UhmmI2cWalkerOptions options);
absl::StatusOr<std::vector<HardwareInfo>> GetLogicalI2cAddresses()
const override;
static absl::StatusOr<uint32_t> GetLogicalBusId(
absl::string_view root_directory, uint32_t root_bus,
const fru_i2c::I2CAddress& mux_address_identifier,
absl::string_view mux_model, uint32_t channel_id);
private:
explicit UhmmI2cWalker(fru_i2c::I2cRoot i2c_root, std::string root_directory)
: root_directory_(root_directory), i2c_root_(i2c_root) {}
// The root directory of the target machine where the walker to walk the i2c
// topology tree.
const std::string root_directory_;
// The root of the i2c topology tree.
const fru_i2c::I2cRoot i2c_root_;
};
} // namespace deterministic_bmc
#endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_DETERMINISTIC_BMC_I2C_WALKER_UHMM_I2C_WALKER_H_