void DomainPowerControl_001::validatePowerControlStatus(const PowerControlStatusSet& powerControlStatusSet, UIntN domainIndex) { if (powerControlStatusSet.getCount() > PowerControlType::max) { throw dptf_exception("Too many power controls in the set!"); } for (UIntN i = 0; i < powerControlStatusSet.getCount(); i++) { // Verify max was not passed in if (powerControlStatusSet[i].getPowerControlType() == PowerControlType::max) { throw dptf_exception("Invalid power control type."); } // Verify the desired power control is within the dynamic caps initializePowerControlDynamicCapsSetIfNull(domainIndex); if (powerControlStatusSet[i].getCurrentPowerLimit() > (*m_powerControlDynamicCaps)[powerControlStatusSet[i].getPowerControlType()].getMaxPowerLimit()) { throw dptf_exception("Requested power limit too large."); } if (powerControlStatusSet[i].getCurrentPowerLimit() < (*m_powerControlDynamicCaps)[powerControlStatusSet[i].getPowerControlType()].getMinPowerLimit()) { throw dptf_exception("Requested power limit too small."); } if (powerControlStatusSet[i].getCurrentTimeWindow() > (*m_powerControlDynamicCaps)[powerControlStatusSet[i].getPowerControlType()].getMaxTimeWindow()) { throw dptf_exception("Requested time window is too large."); } if (powerControlStatusSet[i].getCurrentTimeWindow() < (*m_powerControlDynamicCaps)[powerControlStatusSet[i].getPowerControlType()].getMinTimeWindow()) { throw dptf_exception("Requested time window is too small."); } } }
void DomainPowerControl_001::setPowerControl(UIntN participantIndex, UIntN domainIndex, const PowerControlStatusSet& powerControlStatusSet) { checkAndCreateControlStructures(domainIndex); if (powerControlStatusSet.getCount() > PowerControlType::max) { throw dptf_exception("Too many power controls in the set!"); } for (UIntN i = 0; i < powerControlStatusSet.getCount(); i++) { validatePowerControlStatus(powerControlStatusSet[i]); programPowerControl(powerControlStatusSet[i], domainIndex); } // Update control set delete m_powerControlStatusSet; m_powerControlStatusSet = new PowerControlStatusSet(powerControlStatusSet); }
void DomainPowerControl_001::programPowerControl(const PowerControlStatusSet& powerControlStatusSet, UIntN domainIndex) { for (UIntN i = 0; i < powerControlStatusSet.getCount(); i++) { if (powerControlStatusSet[i].getPowerControlType() == PowerControlType::pl1) { m_participantServicesInterface->primitiveExecuteSetAsPower( esif_primitive_type::SET_RAPL_POWER_LIMIT, powerControlStatusSet[i].getCurrentPowerLimit(), domainIndex, static_cast<UInt8>(powerControlStatusSet[i].getPowerControlType())); try { m_participantServicesInterface->primitiveExecuteSetAsUInt32( esif_primitive_type::SET_RAPL_POWER_LIMIT_ENABLE, 1, //Enable the bit domainIndex, static_cast<UInt8>(powerControlStatusSet[i].getPowerControlType())); } catch (dptf_exception& ex) { // It is expected to hit this for the CPU's PL1 enable. It is read only. ParticipantMessage message = ParticipantMessage(FLF, "Power limit enabled ignored."); message.setEsifPrimitive(esif_primitive_type::SET_RAPL_POWER_LIMIT_ENABLE, powerControlStatusSet[i].getPowerControlType()); message.setExceptionCaught("primitiveExecuteSetAsUInt32", ex.what()); m_participantServicesInterface->writeMessageWarning(message); } } else { std::stringstream msg; msg << PowerControlType::ToString(powerControlStatusSet[i].getPowerControlType()) << " power control is not programmable. Ignoring."; m_participantServicesInterface->writeMessageDebug(ParticipantMessage(FLF, msg.str())); } } }