| #ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_PECI_PECI_ACCESS_INTERFACE_H_ |
| #define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_PECI_PECI_ACCESS_INTERFACE_H_ |
| |
| #include <array> |
| #include <cstdint> |
| #include <memory> |
| |
| #include "absl/status/status.h" |
| #include "absl/status/statusor.h" |
| #include "absl/strings/string_view.h" |
| #include "peci.h" |
| |
| namespace milotic_tlbmc { |
| |
| // An interface to access PECI devices. |
| class PeciAccessInterface { |
| public: |
| PeciAccessInterface() = default; |
| virtual ~PeciAccessInterface() = default; |
| |
| // Calls the underlying peci_Ping() function to check the status of the CPU |
| // at the target address. |
| // https://gerrit.openbmc.org/plugins/gitiles/openbmc/libpeci/+/refs/heads/master/peci.c#249 |
| virtual absl::Status Ping(uint8_t target) const = 0; |
| |
| // Calls the underlying peci_RdPkgConfig() function to read the package |
| // configuration of the processor at the target address. |
| // https://gerrit.openbmc.org/plugins/gitiles/openbmc/libpeci/+/refs/heads/master/peci.c#394 |
| virtual absl::StatusOr<std::array<uint8_t, 8>> RdPkgConfig( |
| uint8_t target, uint8_t index, uint16_t value, |
| uint8_t read_len) const = 0; |
| |
| // Calls the underlying peci_SetDevName() function to set the name of the PECI |
| // device file to use. |
| // https://gerrit.openbmc.org/plugins/gitiles/openbmc/libpeci/+/refs/heads/master/peci.c#40 |
| virtual void SetDevName(absl::string_view dev_name) const = 0; |
| |
| // Calls the underlying peci_Lock() function to lock the PECI interface with |
| // the specified timeout, returning the file descriptor if successful. |
| // https://gerrit.openbmc.org/plugins/gitiles/openbmc/libpeci/+/refs/heads/master/peci.c#86 |
| virtual absl::StatusOr<int> Lock(EPECITimeout timeout) const = 0; |
| |
| // Calls the underlying peci_Unlock() function to unlock the PECI interface. |
| // https://gerrit.openbmc.org/plugins/gitiles/openbmc/libpeci/+/refs/heads/master/peci.c#75 |
| virtual void Unlock(int peci_fd) const = 0; |
| }; |
| |
| // Factory function to create a PeciAccessInterface that uses the openbmc |
| // libpeci library. |
| std::unique_ptr<PeciAccessInterface> CreateLibPeciWrapper(); |
| |
| } // namespace milotic_tlbmc |
| |
| #endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_PECI_PECI_ACCESS_INTERFACE_H_ |