Integrate BIOS configuration updates into memory capacity registry operations. This change updates SystemRegistryImpl to write memory capacity settings to the BIOS configuration (via SetBiosSetting) in addition to GbmcSettings. It also adds validation to ensure the BIOS configuration registry is initialized before getting or setting memory capacity, and adds corresponding unit tests to verify these behaviors and error paths. Google-Bug-Id:541287798 PiperOrigin-RevId: 978107994 Change-Id: I6d018711baa325f65ddf0217f4fb69e1093649ba
diff --git a/tlbmc/hal/system_registry_impl.cc b/tlbmc/hal/system_registry_impl.cc index dffadfb..b189b72 100644 --- a/tlbmc/hal/system_registry_impl.cc +++ b/tlbmc/hal/system_registry_impl.cc
@@ -276,6 +276,11 @@ absl::StatusOr<uint32_t> SystemRegistryImpl::GetMemoryCapacityGib( std::string_view redfish_system_id) { + if (all_registries_.bios_config == nullptr) { + return absl::FailedPreconditionError( + "BIOS config is not initialized, cannot get BIOS memory capacity."); + } + ECCLESIA_ASSIGN_OR_RETURN(SystemId system_id, RedfishSystemIdToSystemId(redfish_system_id)); @@ -295,9 +300,20 @@ absl::Status SystemRegistryImpl::SetMemoryCapacityGib( std::string_view redfish_system_id, uint32_t capacity_gib) { + if (all_registries_.bios_config == nullptr) { + return absl::FailedPreconditionError( + "BIOS config is not initialized, cannot set BIOS memory capacity."); + } + + ECCLESIA_ASSIGN_OR_RETURN(uint8_t host_index, + RedfishSystemIdToHostIndex(redfish_system_id)); + ECCLESIA_RETURN_IF_ERROR(all_registries_.bios_config->SetBiosSetting( + host_index, BiosSettingType::MemoryCapacityGib, + std::to_string(capacity_gib))); + ECCLESIA_ASSIGN_OR_RETURN(SystemId system_id, RedfishSystemIdToSystemId(redfish_system_id)); - // Write the settings directly to GbmcSettings. + // Write the settings to GbmcSettings. return settings_manager_->SetBiosSettingsMemoryCapacityGib(system_id, capacity_gib); }