void DomainDisplayControl_001::restore(void) { if (m_userPreferredIndex != Constants::Invalid) { try { getParticipantServices()->setUserPreferredDisplayCacheValue(getParticipantIndex(), getDomainIndex(), m_userPreferredIndex); auto displaySet = getDisplayControlSet(getParticipantIndex(), getDomainIndex()); auto upperLimitIndex = getDisplayControlDynamicCaps(getParticipantIndex(), getDomainIndex()).getCurrentUpperLimit(); if (m_userPreferredIndex < upperLimitIndex) { m_userPreferredIndex = upperLimitIndex; } Percentage newBrightness = displaySet[m_userPreferredIndex].getBrightness(); getParticipantServices()->writeMessageDebug(ParticipantMessage( FLF, "Saved the user preferred index of " + StlOverride::to_string(m_userPreferredIndex) + ". Attempting to set the brightness to the user preferred value .")); getParticipantServices()->primitiveExecuteSetAsPercentage( esif_primitive_type::SET_DISPLAY_BRIGHTNESS, newBrightness, getDomainIndex()); } catch (...) { // best effort getParticipantServices()->writeMessageDebug(ParticipantMessage( FLF, "Failed to restore the user preferred display status. ")); } } }
void DomainPerformanceControl_002::throwIfPerformanceControlIndexIsOutOfBounds(UIntN domainIndex, UIntN performanceControlIndex) { auto controlSetSize = getPerformanceControlSet(getParticipantIndex(), domainIndex).getCount(); if (performanceControlIndex >= controlSetSize) { std::stringstream infoMessage; infoMessage << "Control index out of control set bounds." << std::endl << "Desired Index : " << performanceControlIndex << std::endl << "PerformanceControlSet size :" << controlSetSize << std::endl; throw dptf_exception(infoMessage.str()); } auto caps = getPerformanceControlDynamicCaps(getParticipantIndex(), domainIndex); if (performanceControlIndex < caps.getCurrentUpperLimitIndex() || performanceControlIndex > caps.getCurrentLowerLimitIndex()) { std::stringstream infoMessage; infoMessage << "Got a performance control index that was outside the allowable range." << std::endl << "Desired Index : " << performanceControlIndex << std::endl << "Upper Limit Index : " << caps.getCurrentUpperLimitIndex() << std::endl << "Lower Limit Index : " << caps.getCurrentLowerLimitIndex() << std::endl; throw dptf_exception(infoMessage.str()); } }
std::shared_ptr<XmlNode> DomainDisplayControl_001::getXml(UIntN domainIndex) { auto root = XmlNode::createWrapperElement("display_control"); root->addChild(getDisplayControlStatus(getParticipantIndex(), domainIndex).getXml()); root->addChild(getDisplayControlDynamicCaps(getParticipantIndex(), domainIndex).getXml()); root->addChild(getDisplayControlSet(getParticipantIndex(), domainIndex).getXml()); root->addChild(XmlNode::createDataElement("control_knob_version", "001")); return root; }
std::shared_ptr<XmlNode> DomainTemperature_002::getXml(UIntN domainIndex) { auto root = XmlNode::createWrapperElement("temperature_control"); root->addChild(XmlNode::createDataElement("control_knob_version", "002")); root->addChild(getTemperatureStatus(getParticipantIndex(), domainIndex).getXml()); root->addChild(getTemperatureThresholds(getParticipantIndex(), domainIndex).getXml()); return root; }
std::shared_ptr<XmlNode> DomainCoreControl_001::getXml(UIntN domainIndex) { auto root = XmlNode::createWrapperElement("core_control"); root->addChild(XmlNode::createDataElement("control_name", getName())); root->addChild(getCoreControlStatus(getParticipantIndex(), domainIndex).getXml()); root->addChild(getCoreControlStaticCaps(getParticipantIndex(), domainIndex).getXml()); root->addChild(getCoreControlDynamicCaps(getParticipantIndex(), domainIndex).getXml()); root->addChild(getCoreControlLpoPreference(getParticipantIndex(), domainIndex).getXml()); root->addChild(XmlNode::createDataElement("control_knob_version", "001")); return root; }
void WIDomainPlatformRestOfPowerChanged::execute(void) { writeDomainWorkItemStartingInfoMessage(); try { getParticipantPtr()->domainPlatformRestOfPowerChanged(); } catch (std::exception& ex) { writeDomainWorkItemErrorMessage(ex, "Participant::domainPlatformRestOfPowerChanged"); } auto policyManager = getPolicyManager(); UIntN policyListCount = policyManager->getPolicyListCount(); for (UIntN i = 0; i < policyListCount; i++) { try { Policy* policy = policyManager->getPolicyPtr(i); policy->executeDomainPlatformRestOfPowerChanged(getParticipantIndex()); } catch (policy_index_invalid ex) { // do nothing. No item in the policy list at this index. } catch (std::exception& ex) { writeDomainWorkItemErrorMessagePolicy(ex, "Policy::executeDomainPlatformRestOfPowerChanged", i); } } }
void WIDomainPerformanceControlCapabilityChanged::execute(void) { writeDomainWorkItemStartingInfoMessage(); try { getParticipantPtr()->domainPerformanceControlCapabilityChanged(); } catch (std::exception& ex) { writeDomainWorkItemErrorMessage(ex, "Participant::domainPerformanceControlCapabilityChanged"); } auto policyManager = getPolicyManager(); auto policyIndexes = policyManager->getPolicyIndexes(); for (auto i = policyIndexes.begin(); i != policyIndexes.end(); ++i) { try { Policy* policy = policyManager->getPolicyPtr(*i); policy->executeDomainPerformanceControlCapabilityChanged(getParticipantIndex()); } catch (policy_index_invalid& ex) { // do nothing. No item in the policy list at this index. } catch (std::exception& ex) { writeDomainWorkItemErrorMessagePolicy(ex, "Policy::executeDomainPerformanceControlCapabilityChanged", *i); } } }
void WIDomainPowerControlCapabilityChanged::execute(void) { WriteDomainWorkItemStartingDebugMessage(); try { getParticipantPtr()->domainPowerControlCapabilityChanged(); } catch (std::exception ex) { WriteDomainWorkItemErrorMessage_Function("Participant::domainPowerControlCapabilityChanged"); } PolicyManager* policyManager = getPolicyManager(); UIntN policyListCount = policyManager->getPolicyListCount(); for (UIntN i = 0; i < policyListCount; i++) { try { Policy* policy = policyManager->getPolicyPtr(i); policy->executeDomainPowerControlCapabilityChanged(getParticipantIndex()); } catch (policy_index_invalid ex) { // do nothing. No item in the policy list at this index. } catch (std::exception ex) { WriteDomainWorkItemErrorMessage_Function_Policy("Policy::executeDomainPowerControlCapabilityChanged", i); } } }
CoreControlDynamicCaps DomainCoreControl_001::createCoreControlDynamicCaps(UIntN domainIndex) { UInt32 minActiveCoreLimit = 1; UInt32 maxActiveCoreLimit = getCoreControlStaticCaps(getParticipantIndex(), domainIndex).getTotalLogicalProcessors(); return CoreControlDynamicCaps(minActiveCoreLimit, maxActiveCoreLimit); }
void DomainCoreControl_001::verifyCoreControlStatus(UIntN domainIndex, const CoreControlStatus& coreControlStatus) { auto caps = getCoreControlDynamicCaps(getParticipantIndex(), domainIndex); if (coreControlStatus.getNumActiveLogicalProcessors() > caps.getMaxActiveCores() || coreControlStatus.getNumActiveLogicalProcessors() < caps.getMinActiveCores()) { throw dptf_exception("Desired number of cores outside dynamic caps range."); } }
std::shared_ptr<XmlNode> DomainPowerStatus_001::getXml(UIntN domainIndex) { std::shared_ptr<XmlNode> root = XmlNode::createWrapperElement("power_status_set"); root->addChild(getPowerStatus(getParticipantIndex(), domainIndex).getXml()); root->addChild(m_domainPowerFilter.getXml()); root->addChild(XmlNode::createDataElement("control_knob_version", "001")); return root; }
void DomainDisplayControl_001::throwIfControlIndexIsOutOfRange(UIntN displayControlIndex, UIntN domainIndex) { auto dynamicCaps = getDisplayControlDynamicCaps(getParticipantIndex(), domainIndex); auto upperLimit = dynamicCaps.getCurrentUpperLimit(); auto lowerLimit = dynamicCaps.getCurrentLowerLimit(); auto displaySet = getDisplayControlSet(getParticipantIndex(), domainIndex); auto size = displaySet.getCount(); if (displayControlIndex >= size || displayControlIndex < upperLimit || displayControlIndex > lowerLimit) { std::stringstream infoMessage; infoMessage << "Control index is outside the allowable range." << std::endl << "Desired Index : " << displayControlIndex << std::endl << "DisplayControlSet size :" << size << std::endl << "Upper Limit : " << upperLimit << std::endl << "Lower Limit : " << lowerLimit << std::endl; throw dptf_exception(infoMessage.str()); } }
void DomainPerformanceControl_003::capture(void) { try { m_initialStatus.set(getPerformanceControlDynamicCaps(getParticipantIndex(), getDomainIndex())); } catch (dptf_exception& e) { m_initialStatus.invalidate(); std::string warningMsg = e.what(); getParticipantServices()->writeMessageWarning(ParticipantMessage( FLF, "Failed to get the initial graphics performance control dynamic capabilities. " + warningMsg)); } }
PerformanceControlDynamicCaps DomainPerformanceControl_001::createPerformanceControlDynamicCaps(UIntN domainIndex) { //Get dynamic caps UInt32 lowerLimitIndex; UInt32 upperLimitIndex; auto controlSetSize = getPerformanceControlSet(getParticipantIndex(), domainIndex).getCount(); try { lowerLimitIndex = getParticipantServices()->primitiveExecuteGetAsUInt32( esif_primitive_type::GET_PERF_PSTATE_DEPTH_LIMIT, domainIndex); } catch (...) { // If PPDL is not supported, default to Pn. lowerLimitIndex = controlSetSize - 1; } try { // If PPPC is not supported, default to P0 upperLimitIndex = getParticipantServices()->primitiveExecuteGetAsUInt32( esif_primitive_type::GET_PARTICIPANT_PERF_PRESENT_CAPABILITY, domainIndex); } catch (...) { upperLimitIndex = 0; } if (upperLimitIndex >= controlSetSize || lowerLimitIndex >= controlSetSize) { throw dptf_exception("Retrieved control index out of control set bounds."); } if (upperLimitIndex > lowerLimitIndex) { lowerLimitIndex = controlSetSize - 1; getParticipantServices()->writeMessageWarning( ParticipantMessage(FLF, "Limit index mismatch, ignoring lower limit.")); } return PerformanceControlDynamicCaps(lowerLimitIndex, upperLimitIndex); }
void WIDomainCreate::execute(void) { writeDomainWorkItemStartingInfoMessage(); Bool domainCreated = false; try { getParticipantPtr()->createDomain(getDomainIndex(), m_domainDataPtr, m_domainEnabled); domainCreated = true; } catch (std::exception& ex) { writeDomainWorkItemErrorMessage(ex, "Participant::createDomain"); } *m_domainCreated = domainCreated; if (domainCreated == true) { // // Iterate through the list of policies and let them know about the new domain // auto policyManager = getPolicyManager(); UIntN policyListCount = policyManager->getPolicyListCount(); for (UIntN i = 0; i < policyListCount; i++) { try { Policy* policy = policyManager->getPolicyPtr(i); policy->bindDomain(getParticipantIndex(), getDomainIndex()); } catch (policy_index_invalid ex) { // do nothing. No item in the policy list at this index. } catch (std::exception& ex) { writeDomainWorkItemErrorMessagePolicy(ex, "Policy::bindDomain", i); } } } }
void DomainPerformanceControl_002::capture(void) { try { m_initialStatus.set(getPerformanceControlDynamicCaps(getParticipantIndex(), getDomainIndex())); getParticipantServices()->writeMessageDebug(ParticipantMessage( FLF, "Initial performance capabilities are captured. MIN = " + StlOverride::to_string(m_initialStatus.get().getCurrentLowerLimitIndex()) + " & MAX = " + StlOverride::to_string(m_initialStatus.get().getCurrentUpperLimitIndex()))); } catch (dptf_exception& e) { m_initialStatus.invalidate(); std::string warningMsg = e.what(); getParticipantServices()->writeMessageWarning(ParticipantMessage( FLF, "Failed to get the initial processor performance control dynamic capabilities. " + warningMsg)); } }
void WIDomainDestroy::execute(void) { writeDomainWorkItemStartingInfoMessage(); if (getParticipantPtr()->isDomainValid(getDomainIndex()) == false) { writeDomainWorkItemErrorMessage("Received request to remove a domain that is invalid."); } else { auto policyManager = getPolicyManager(); auto policyIndexes = policyManager->getPolicyIndexes(); // Let each policy know that the domain is going away for (auto i = policyIndexes.begin(); i != policyIndexes.end(); ++i) { try { Policy* policy = policyManager->getPolicyPtr(*i); policy->unbindDomain(getParticipantIndex(), getDomainIndex()); } catch (policy_index_invalid& ex) { // do nothing. No item in the policy list at this index. } catch (std::exception& ex) { writeDomainWorkItemErrorMessagePolicy(ex, "Policy::unbindDomain", *i); } } // Let the participant know to remove the domain try { getParticipantPtr()->destroyDomain(getDomainIndex()); } catch (std::exception& ex) { writeDomainWorkItemErrorMessage(ex, "Participant::destroyDomain"); } } }
void DomainCoreControl_001::sendActivityLoggingDataIfEnabled(UIntN participantIndex, UIntN domainIndex) { try { if (isActivityLoggingEnabled() == true) { createCoreControlStaticCaps(domainIndex); UInt32 activeCores = getCoreControlStatus(participantIndex, domainIndex).getNumActiveLogicalProcessors(); if (activeCores == Constants::Invalid) { activeCores = getCoreControlStaticCaps(participantIndex, domainIndex).getTotalLogicalProcessors(); } EsifCapabilityData capability; capability.type = ESIF_CAPABILITY_TYPE_CORE_CONTROL; capability.size = sizeof(capability); capability.data.coreControl.activeLogicalProcessors = activeCores; capability.data.coreControl.minimumActiveCores = 1; capability.data.coreControl.maximumActiveCores = getCoreControlStaticCaps(participantIndex, domainIndex).getTotalLogicalProcessors(); getParticipantServices()->sendDptfEvent( ParticipantEvent::DptfParticipantControlAction, domainIndex, Capability::getEsifDataFromCapabilityData(&capability)); std::stringstream message; message << "Published activity for participant " << getParticipantIndex() << ", " << "domain " << getName() << " " << "(" << "Core Control" << ")"; getParticipantServices()->writeMessageInfo(ParticipantMessage(FLF, message.str())); } } catch (...) { // skip if there are any issue in sending log data } }
void WIParticipantSpecificInfoChanged::execute(void) { writeParticipantWorkItemStartingInfoMessage(); try { getParticipantPtr()->participantSpecificInfoChanged(); } catch (std::exception& ex) { writeParticipantWorkItemErrorMessage(ex, "Participant::participantSpecificInfoChanged"); } auto policyManager = getPolicyManager(); UIntN policyListCount = policyManager->getPolicyListCount(); for (UIntN i = 0; i < policyListCount; i++) { try { Policy* policy = policyManager->getPolicyPtr(i); policy->executeParticipantSpecificInfoChanged(getParticipantIndex()); } catch (policy_index_invalid ex) { // do nothing. No item in the policy list at this index. } catch (temperature_out_of_range ex) { writeParticipantWorkItemWarningMessagePolicy(ex, "Policy::executeParticipantSpecificInfoChanged", i); } catch (std::exception& ex) { writeParticipantWorkItemWarningMessagePolicy(ex, "Policy::executeParticipantSpecificInfoChanged", i); } } }
DisplayControlDynamicCaps DomainDisplayControl_001::createDisplayControlDynamicCaps(UIntN domainIndex) { auto displaySet = getDisplayControlSet(getParticipantIndex(), domainIndex); // Get dynamic caps // The caps are stored in BIOS as brightness percentage. They must be converted // to indices before they can be used. UIntN lowerLimitIndex = getLowerLimitIndex(domainIndex, displaySet); UIntN upperLimitIndex = getUpperLimitIndex(domainIndex, displaySet); auto size = displaySet.getCount(); if (upperLimitIndex >= size) { throw dptf_exception("Upper Limit index is out of control set bounds."); } else if (upperLimitIndex > lowerLimitIndex || lowerLimitIndex >= size) { lowerLimitIndex = size - 1; getParticipantServices()->writeMessageWarning( ParticipantMessage(FLF, "Limit index mismatch, ignoring lower limit.")); } return DisplayControlDynamicCaps(upperLimitIndex, lowerLimitIndex); }
PerformanceControlDynamicCaps DomainPerformanceControl_003::createPerformanceControlDynamicCaps(UIntN domainIndex) { auto controlSetSize = getPerformanceControlSet(getParticipantIndex(), domainIndex).getCount(); return PerformanceControlDynamicCaps(controlSetSize - 1, 0); }
std::shared_ptr<XmlNode> DomainUtilization_001::getXml(UIntN domainIndex) { auto root = getUtilizationStatus(getParticipantIndex(), domainIndex).getXml("utilization"); root->addChild(XmlNode::createDataElement("control_knob_version", "001")); return root; }