| #ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_SYSTEM_REGISTRY_IMPL_H_ |
| #define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_SYSTEM_REGISTRY_IMPL_H_ |
| |
| #include <cstdint> |
| #include <memory> |
| #include <string> |
| #include <string_view> |
| |
| #include "gbmc_settings/bios_settings.pb.h" |
| #include "gbmc_settings/gbmc_settings.h" |
| #include "gbmc-hal/api/app/cpu/bios_config.h" |
| #include "gbmc-hal/api/system/registry_configs.h" |
| #include "absl/status/status.h" |
| #include "absl/status/statusor.h" |
| #include "tlbmc/hal/system_registry.h" |
| #include "tlbmc/utils/command_executor.h" |
| |
| // This class will store all of the registries that the system is exposed to via |
| // the HAL. The goal of this registry is to instantiate all of the HAL startup |
| // logic exactly once and have one interface into the HAL registries. |
| |
| // Currently, there may need to be multiple owners here due to tlBMC URLs and |
| // non-tLBMC URLs both needing to access the same registry, but the eventual end |
| // goal is to only have tlBMC store own the registry. |
| |
| namespace milotic_tlbmc { |
| |
| class SystemRegistryImpl : public SystemRegistry { |
| protected: |
| class Token { |
| private: |
| explicit Token() = default; |
| friend class SystemRegistryImpl; |
| }; |
| |
| // Registries here are objects used to interface into the HAL that each have |
| // their own config. |
| // https://source.corp.google.com/piper///depot/google3/gbmc-hal/api/system/registries.h |
| // would be a list of all registries that should be included here. |
| struct AllRegistries { |
| std::unique_ptr<::platforms::gbmc::hal::BiosConfig> bios_config; |
| }; |
| |
| public: |
| struct Config { |
| std::unique_ptr<::platforms::gbmc::hal::BiosConfigConfig> |
| bios_config_config; |
| std::string ifs_base_path = "/run"; |
| }; |
| |
| static absl::StatusOr<std::shared_ptr<SystemRegistryImpl>> Create( |
| const Config& config); |
| |
| absl::StatusOr<uint32_t> GetCoreCount( |
| std::string_view redfish_system_id) override; |
| absl::Status SetCoreCount(std::string_view redfish_system_id, |
| uint32_t core_count) override; |
| absl::Status SetInitialCoreCounts() override; |
| |
| absl::StatusOr<std::string> GetBase64EncodedIfsPattern( |
| std::string_view redfish_system_id) override; |
| |
| absl::Status SetIfsPattern(std::string_view redfish_system_id, |
| std::string_view base64_ifs_pattern) override; |
| |
| absl::Status ResetIfsPattern(std::string_view redfish_system_id) override; |
| |
| absl::StatusOr<std::string> GetBootNext( |
| std::string_view redfish_system_id) override; |
| |
| absl::Status SetBootNext(std::string_view redfish_system_id, |
| std::string_view boot_next) override; |
| |
| absl::StatusOr<uint32_t> GetMemoryCapacityGib( |
| std::string_view redfish_system_id) override; |
| |
| absl::Status SetMemoryCapacityGib(std::string_view redfish_system_id, |
| uint32_t capacity_gib) override; |
| |
| explicit SystemRegistryImpl( |
| Token token, AllRegistries&& all_registries, |
| std::string_view ifs_base_path, |
| std::unique_ptr<const CommandExecutor> command_executor); |
| |
| protected: |
| SystemRegistryImpl() = default; |
| |
| static absl::StatusOr<uint8_t> SystemIdToHostIndex( |
| gbmc::settings::SystemId system_id); |
| static absl::StatusOr<gbmc::settings::SystemId> RedfishSystemIdToSystemId( |
| std::string_view redfish_system_id); |
| static absl::StatusOr<uint8_t> RedfishSystemIdToHostIndex( |
| std::string_view redfish_system_id); |
| |
| struct IfsConfig { |
| std::string_view relative_path; |
| std::string_view service_name; |
| std::string_view stop_service_name; |
| }; |
| |
| static absl::StatusOr<IfsConfig> GetIfsConfig( |
| gbmc::settings::SystemId system_id); |
| |
| AllRegistries all_registries_; |
| std::unique_ptr<gbmc::settings::SettingsManager> settings_manager_; |
| |
| std::string ifs_base_path_; |
| std::unique_ptr<const CommandExecutor> command_executor_; |
| }; |
| |
| } // namespace milotic_tlbmc |
| |
| #endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_SYSTEM_REGISTRY_IMPL_H_ |