Ejemplo n.º 1
0
TemperatureStatus DomainTemperature_002::getTemperatureStatus(UIntN participantIndex, UIntN domainIndex)
{
    try
    {
        Temperature temperature = getParticipantServices()->primitiveExecuteGetAsTemperatureTenthK(
            esif_primitive_type::GET_TEMPERATURE, domainIndex);

        if (!temperature.isValid())
        {
            getParticipantServices()->writeMessageWarning(
                ParticipantMessage(FLF, "Last set temperature for virtual sensor is invalid."));
            return TemperatureStatus(Temperature::minValidTemperature);
        }

        return TemperatureStatus(temperature);
    }
    catch (primitive_destination_unavailable)
    {
        return TemperatureStatus(Temperature::minValidTemperature);
    }
    catch (dptf_exception& ex)
    {
        getParticipantServices()->writeMessageWarning(ParticipantMessage(FLF, ex.what()));
        return TemperatureStatus(Temperature::minValidTemperature);
    }
}
Ejemplo n.º 2
0
CoreControlLpoPreference DomainCoreControl_001::createCoreControlLpoPreference(UIntN domainIndex)
{
	Bool useDefault = false;
	DptfBuffer buffer;
	try
	{
		buffer = getParticipantServices()->primitiveExecuteGet(
			esif_primitive_type::GET_PROC_CURRENT_LOGICAL_PROCESSOR_OFFLINING, ESIF_DATA_BINARY, domainIndex);
	}
	catch (...)
	{
		getParticipantServices()->writeMessageWarning(ParticipantMessage(FLF, "CLPO not found.  Using defaults."));
		useDefault = true;
	}

	if (useDefault == false)
	{
		try
		{
			return CoreControlLpoPreference::createFromClpo(buffer);
		}
		catch (...)
		{
			getParticipantServices()->writeMessageWarning(
				ParticipantMessage(FLF, "Could not parse CLPO data.  Using defaults."));
			useDefault = true;
		}
	}

	return CoreControlLpoPreference(
		true, 0, Percentage(.50), CoreControlOffliningMode::Smt, CoreControlOffliningMode::Core);
}
Ejemplo n.º 3
0
void DomainPerformanceControl_001::setPerformanceControl(UIntN participantIndex, UIntN domainIndex,
    UIntN performanceControlIndex)
{
    if (performanceControlIndex == getCurrentPerformanceControlIndex(participantIndex, domainIndex))
    {
        getParticipantServices()->writeMessageDebug(
            ParticipantMessage(FLF, "Requested limit = current limit.  Ignoring."));
        return;
    }

    try
    {
        throwIfPerformanceControlIndexIsOutOfBounds(domainIndex, performanceControlIndex);
        getParticipantServices()->primitiveExecuteSetAsUInt32(
            esif_primitive_type::SET_PERF_PRESENT_CAPABILITY,
            performanceControlIndex,
            domainIndex);

        // Refresh the status
        m_performanceControlStatus.set(PerformanceControlStatus(performanceControlIndex));
    }
    catch (...)
    {
        // eat any errors
    }
}
Ejemplo n.º 4
0
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. "));
        }
    }
}
Ejemplo n.º 5
0
UIntN DomainDisplayControl_001::getUserPreferredDisplayIndex(UIntN participantIndex, UIntN domainIndex)
{
    if ((getParticipantServices()->isUserPreferredDisplayCacheValid(participantIndex, domainIndex)) == true)
    {
        getParticipantServices()->writeMessageDebug(ParticipantMessage(
            FLF, "Attempting to get the user preferred index from the display cache."));
        m_userPreferredIndex = getParticipantServices()->getUserPreferredDisplayCacheValue(participantIndex, domainIndex);

        getParticipantServices()->writeMessageDebug(ParticipantMessage(
            FLF, "Retrieved the user preferred index of " + StlOverride::to_string(m_userPreferredIndex) + " ."));
        getParticipantServices()->invalidateUserPreferredDisplayCache(participantIndex, domainIndex);
    }
    else
    {
        auto currentStatus = getDisplayControlStatus(participantIndex, domainIndex);
        auto currentIndex = currentStatus.getBrightnessLimitIndex();

        if (m_userPreferredIndex == Constants::Invalid || 
            (m_lastSetDisplayBrightness != Constants::Invalid && currentIndex != m_lastSetDisplayBrightness))
        {
            m_userPreferredIndex = currentIndex;
            m_isUserPreferredIndexModified = true;
        }
        else
        {
            m_isUserPreferredIndexModified = false;
        }
    }

    return m_userPreferredIndex;
}
Ejemplo n.º 6
0
void DomainPerformanceControl_001::setPerformanceControlDynamicCaps(UIntN participantIndex, UIntN domainIndex, 
    PerformanceControlDynamicCaps newCapabilities)
{
    auto upperLimitIndex = newCapabilities.getCurrentUpperLimitIndex();
    auto lowerLimitIndex = newCapabilities.getCurrentLowerLimitIndex();

    if (upperLimitIndex != Constants::Invalid && lowerLimitIndex != Constants::Invalid)
    {
        auto controlSetSize = getPerformanceControlSet(participantIndex, domainIndex).getCount();
        if (upperLimitIndex >= controlSetSize)
        {
            throw dptf_exception("Upper Limit index is out of control set bounds.");
        }
        else if (upperLimitIndex > lowerLimitIndex || lowerLimitIndex >= controlSetSize)
        {
            lowerLimitIndex = controlSetSize - 1;
            getParticipantServices()->writeMessageWarning(
                ParticipantMessage(FLF, "Limit index mismatch, setting lower limit to lowest possible index."));
        }
    }

    m_performanceControlDynamicCaps.invalidate();

    getParticipantServices()->primitiveExecuteSetAsUInt32(
        esif_primitive_type::SET_PERF_PSTATE_DEPTH_LIMIT,
        lowerLimitIndex,
        domainIndex,
        Constants::Esif::NoPersistInstance);

    // TODO: allow DPTF to change the MAX limit
    getParticipantServices()->writeMessageInfo(
        ParticipantMessage(FLF, "Currently DPTF cannot change the MAX limit."));
}
Ejemplo n.º 7
0
void DomainDisplayControl_001::setDisplayControlDynamicCaps(UIntN participantIndex, UIntN domainIndex, 
    DisplayControlDynamicCaps newCapabilities)
{
    auto displaySet = getDisplayControlSet(participantIndex, domainIndex);
    auto upperLimitIndex = newCapabilities.getCurrentUpperLimit();
    auto lowerLimitIndex = newCapabilities.getCurrentLowerLimit();

    if (upperLimitIndex != Constants::Invalid && lowerLimitIndex != Constants::Invalid)
    {
        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, setting lower limit to lowest possible index."));
        }

        m_displayControlDynamicCaps.invalidate();

        Percentage upperLimitBrightness = displaySet[upperLimitIndex].getBrightness();
        UInt32 uint32UpperLimit = upperLimitBrightness.toWholeNumber();
        getParticipantServices()->primitiveExecuteSetAsUInt32(
            esif_primitive_type::SET_DISPLAY_CAPABILITY,
            uint32UpperLimit,
            domainIndex,
            Constants::Esif::NoPersistInstance);

        Percentage lowerLimitBrightness = displaySet[lowerLimitIndex].getBrightness();
        UInt32 uint32LowerLimit = lowerLimitBrightness.toWholeNumber();
        getParticipantServices()->primitiveExecuteSetAsUInt32(
            esif_primitive_type::SET_DISPLAY_DEPTH_LIMIT,
            uint32LowerLimit,
            domainIndex,
            Constants::Esif::NoPersistInstance);
    }
    else
    {
        m_displayControlDynamicCaps.invalidate();

        getParticipantServices()->primitiveExecuteSetAsUInt32(
            esif_primitive_type::SET_DISPLAY_CAPABILITY,
            upperLimitIndex,
            domainIndex,
            Constants::Esif::NoPersistInstance);

        getParticipantServices()->primitiveExecuteSetAsUInt32(
            esif_primitive_type::SET_DISPLAY_DEPTH_LIMIT,
            lowerLimitIndex,
            domainIndex,
            Constants::Esif::NoPersistInstance);
    }
}
Ejemplo n.º 8
0
void DomainPerformanceControl_002::calculateThrottlingStateLimits(UIntN& tStateUpperLimitIndex, 
    UIntN& tStateLowerLimitIndex, UIntN domainIndex)
{
    // Required object if T-states are supported
    try
    {
        tStateUpperLimitIndex =
            getParticipantServices()->primitiveExecuteGetAsUInt32(
            esif_primitive_type::GET_PROC_PERF_THROTTLE_PRESENT_CAPABILITY,
            domainIndex);
    }
    catch (dptf_exception)
    {
        getParticipantServices()->writeMessageWarning(
            ParticipantMessage(FLF, "Bad upper T-state limit."));
        tStateUpperLimitIndex = 0;
    }

    auto throttlingStateSetSize = getThrottlingStateSet(domainIndex).getCount();
    try
    {
        // _TDL is an optional object
        tStateLowerLimitIndex =
            getParticipantServices()->primitiveExecuteGetAsUInt32(
            esif_primitive_type::GET_PROC_PERF_TSTATE_DEPTH_LIMIT,
            domainIndex);
    }
    catch (dptf_exception)
    {
        // Optional object.  Default value is T(n)
        tStateLowerLimitIndex = static_cast<UIntN>(throttlingStateSetSize - 1);
    }

    if (isFirstTstateDeleted(domainIndex) && tStateLowerLimitIndex != 0)
    {
        tStateLowerLimitIndex--;
    }

    if (tStateUpperLimitIndex >= throttlingStateSetSize)
    {
        throw dptf_exception("Retrieved upper T-state index limit out of control set bounds. (T-States)");
    }

    if (tStateLowerLimitIndex >= throttlingStateSetSize)
    {
        throw dptf_exception("Retrieved lower T-state index limit is out of control set bounds. (T-States)");
    }

    if (tStateUpperLimitIndex > tStateLowerLimitIndex)
    {
        // If the limits are bad, ignore the lower limit.  Don't fail this control.
        getParticipantServices()->writeMessageWarning(
            ParticipantMessage(FLF, "Limit index mismatch, ignoring lower limit."));
        tStateLowerLimitIndex = static_cast<UIntN>(throttlingStateSetSize - 1);
    }
}
Ejemplo n.º 9
0
UIntN DomainDisplayControl_001::getLowerLimitIndex(UIntN domainIndex, DisplayControlSet displaySet)
{
    UInt32 uint32val = getParticipantServices()->primitiveExecuteGetAsUInt32(
        esif_primitive_type::GET_DISPLAY_DEPTH_LIMIT, domainIndex);
    Percentage lowerLimitBrightness = Percentage::fromWholeNumber(uint32val);
    return displaySet.getControlIndex(lowerLimitBrightness);
}
Ejemplo n.º 10
0
void DomainDisplayControl_001::sendActivityLoggingDataIfEnabled(UIntN participantIndex, UIntN domainIndex)
{
    if (isActivityLoggingEnabled() == true) 
    {
        auto dynamicCaps = getDisplayControlDynamicCaps(participantIndex, domainIndex);
        auto displaySet = getDisplayControlSet(participantIndex, domainIndex);

        UInt32 displayControlIndex;
        if (m_currentDisplayControlIndex.isInvalid())
        {
            displayControlIndex = dynamicCaps.getCurrentUpperLimit();
        }
        else
        {
            displayControlIndex = m_currentDisplayControlIndex.get();
        }

        EsifCapabilityData capability;
        capability.type = ESIF_CAPABILITY_TYPE_DISPLAY_CONTROL;
        capability.size = sizeof(capability);
        capability.data.displayControl.currentDPTFLimit = displaySet[displayControlIndex].getBrightness().toWholeNumber();
        capability.data.displayControl.lowerLimit = displaySet[dynamicCaps.getCurrentLowerLimit()].getBrightness().toWholeNumber();
        capability.data.displayControl.upperLimit = displaySet[dynamicCaps.getCurrentUpperLimit()].getBrightness().toWholeNumber();

        getParticipantServices()->sendDptfEvent(ParticipantEvent::DptfParticipantControlAction,
            domainIndex, Capability::getEsifDataFromCapabilityData(&capability));
    }
}
Ejemplo n.º 11
0
void DomainPerformanceControlBase::sendActivityLoggingDataIfEnabled(UIntN participantIndex, UIntN domainIndex)
{
    try
    {
        if (isActivityLoggingEnabled() == true)
        {
            UInt32 performanceControlIndex = getCurrentPerformanceControlIndex(participantIndex, domainIndex);

            if (performanceControlIndex == Constants::Invalid)
            {
                performanceControlIndex = 0;
            }
            EsifCapabilityData capability;
            capability.type = ESIF_CAPABILITY_TYPE_PERF_CONTROL;
            capability.size = sizeof(capability);
            capability.data.performanceControl.pStateLimit = performanceControlIndex;
            capability.data.performanceControl.lowerLimit = 
                getPerformanceControlDynamicCaps(participantIndex, domainIndex).getCurrentLowerLimitIndex();
            capability.data.performanceControl.upperLimit = 
                getPerformanceControlDynamicCaps(participantIndex, domainIndex).getCurrentUpperLimitIndex();

            getParticipantServices()->sendDptfEvent(ParticipantEvent::DptfParticipantControlAction,
                domainIndex, Capability::getEsifDataFromCapabilityData(&capability));
        }
    }
    catch (...)
    {
        // skip if there are any issue in sending log data
    }
}
Ejemplo n.º 12
0
void DomainConfigTdpControl_001::checkHWConfigTdpSupport(std::vector<ConfigTdpControl> controls, UIntN domainIndex)
{
    m_configTdpLevelsAvailable = getLevelCount(domainIndex);
    m_configTdpLock = isLockBitSet(domainIndex);

    UIntN currentTdpControl = //ulTdpControl NOT index...
        getParticipantServices()->primitiveExecuteGetAsUInt32(
            esif_primitive_type::GET_PROC_CTDP_CURRENT_SETTING,
            domainIndex);

    // Determine the index...
    Bool controlIdFound = false;
    for (UIntN i = 0; i < controls.size(); i++)
    {
        if (currentTdpControl == controls.at(i).getControlId())
        {
            DELETE_MEMORY_TC(m_configTdpControlStatus);
            m_configTdpControlStatus = new ConfigTdpControlStatus(i);
            controlIdFound = true;
        }
    }

    if (controlIdFound == false)
    {
        throw dptf_exception("cTDP control not found in set.");
    }
}
Ejemplo n.º 13
0
CoreControlStaticCaps DomainCoreControl_001::createCoreControlStaticCaps(UIntN domainIndex)
{
	UInt32 logicalCoreCount = getParticipantServices()->primitiveExecuteGetAsUInt32(
		esif_primitive_type::GET_PROC_LOGICAL_PROCESSOR_COUNT, domainIndex);

	return CoreControlStaticCaps(logicalCoreCount);
}
Ejemplo n.º 14
0
void DomainConfigTdpControl_001::createConfigTdpControlDynamicCaps(UIntN domainIndex)
{
    if (m_configTdpControlSet == nullptr)
    {
        createConfigTdpControlSet(domainIndex);
    }

    // Get dynamic caps
    UInt32 lowerLimitIndex = 0;
    UInt32 upperLimitIndex = 0;

    if (!m_configTdpLock)
    {
        lowerLimitIndex = m_configTdpControlSet->getCount() - 1;  // This is what the 7.0 code does

        upperLimitIndex =
            getParticipantServices()->primitiveExecuteGetAsUInt32(
                esif_primitive_type::GET_PROC_CTDP_CAPABILITY,
                domainIndex);

        if (lowerLimitIndex < upperLimitIndex)
        {
            throw dptf_exception("Config TDP capabilities are incorrect.");
        }
    }

    m_configTdpControlDynamicCaps = new ConfigTdpControlDynamicCaps(lowerLimitIndex, upperLimitIndex);
}
Ejemplo n.º 15
0
PerformanceControlSet DomainPerformanceControl_002::createCombinedPerformanceControlSet(UIntN domainIndex)
{
    PerformanceControlSet performanceStateSet = getPerformanceStateSet(domainIndex);
    PerformanceControlSet throttlingStateSet;

    // Get T-States
    if (performanceStateSet.getCount() > 0)
    {
        throttlingStateSet = getThrottlingStateSet(domainIndex);
    }

    // Create all encompassing set (P and T states)
    //    P-States
    PerformanceControlSet combinedStateSet(performanceStateSet);

    //    T-States
    auto tStateStartIndex = isFirstTstateDeleted(domainIndex) ? 1 : 0;
    combinedStateSet.append(throttlingStateSet, tStateStartIndex);
        
    ParticipantMessage message = ParticipantMessage(FLF, "Performance controls created.");
    message.addMessage("Total Entries", combinedStateSet.getCount());
    message.addMessage("P-State Count", performanceStateSet.getCount());
    message.addMessage("T-State Count", throttlingStateSet.getCount());
    getParticipantServices()->writeMessageDebug(message);

    return PerformanceControlSet(combinedStateSet);
}
Ejemplo n.º 16
0
void DomainPlatformPowerControlBase::updateEnabled(PlatformPowerLimitType::Type limitType)
{
    try
    {
        UInt32 plEnabled = getParticipantServices()->primitiveExecuteGetAsUInt32(
            GET_PLATFORM_POWER_LIMIT_ENABLE, getDomainIndex(), (UInt8)limitType);
        Bool enabled = plEnabled > 0 ? true : false;

        switch (limitType)
        {
        case PlatformPowerLimitType::PSysPL1:
            m_pl1Enabled = enabled;
            break;
        case PlatformPowerLimitType::PSysPL2:
            m_pl2Enabled = enabled;
            break;
        case PlatformPowerLimitType::PSysPL3:
            m_pl3Enabled = enabled;
            break;
        default:
            break;
        }
    }
    catch (...)
    {
    }
}
Ejemplo n.º 17
0
void DomainCoreControl_001::restore(void)
{
	try
	{
		getParticipantServices()->primitiveExecuteSetAsUInt32(
			esif_primitive_type::SET_PROC_NUMBER_OFFLINE_CORES,
			0, // No cores are parked
			getDomainIndex());
	}
	catch (...)
	{
		// best effort
		getParticipantServices()->writeMessageWarning(
			ParticipantMessage(FLF, "Failed to restore the initial core status. "));
	}
}
Ejemplo n.º 18
0
void DomainTemperature_002::setVirtualTemperature(UIntN participantIndex, UIntN domainIndex, 
    const Temperature& temperature)
{
    getParticipantServices()->primitiveExecuteSetAsTemperatureTenthK(
            esif_primitive_type::SET_VIRTUAL_TEMPERATURE, temperature, domainIndex);
    m_lastSetTemperature = temperature;
}
Ejemplo n.º 19
0
void DomainPerformanceControl_003::setPerformanceControlDynamicCaps(UIntN participantIndex, UIntN domainIndex, 
    PerformanceControlDynamicCaps newCapabilities)
{
    auto upperLimitIndex = newCapabilities.getCurrentUpperLimitIndex();
    auto lowerLimitIndex = newCapabilities.getCurrentLowerLimitIndex();

    if (upperLimitIndex == Constants::Invalid && lowerLimitIndex == Constants::Invalid)
    {
        if (m_capabilitiesLocked == false)
        {
            m_performanceControlDynamicCaps.invalidate();
        }

        return;
    }

    auto size = getPerformanceControlSet(participantIndex, domainIndex).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, setting lower limit to lowest possible index."));
    }

    m_performanceControlDynamicCaps.invalidate();
    m_performanceControlDynamicCaps.set(PerformanceControlDynamicCaps(lowerLimitIndex, upperLimitIndex));
}
Ejemplo n.º 20
0
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);
}
Ejemplo n.º 21
0
void DomainPerformanceControl_002::setPerformanceControl(UIntN participantIndex, UIntN domainIndex,
    UIntN performanceControlIndex)
{
    throwIfPerformanceControlIndexIsOutOfBounds(domainIndex, performanceControlIndex);

    auto performanceControlSet = getPerformanceControlSet(participantIndex, domainIndex);
    PerformanceControlType::Type targetType =
        (performanceControlSet)[performanceControlIndex].getPerformanceControlType();

    auto throttlingStateSet = getThrottlingStateSet(domainIndex);
    auto performanceStateSet = getPerformanceStateSet(domainIndex);

    switch (targetType)
    {
        case PerformanceControlType::PerformanceState:
            // Set T0
            if (throttlingStateSet.getCount() > 0)
            {
                getParticipantServices()->primitiveExecuteSetAsUInt32(
                    esif_primitive_type::SET_TSTATE_CURRENT,
                    throttlingStateSet[0].getControlId(),
                    domainIndex);
            }
            getParticipantServices()->primitiveExecuteSetAsUInt32(
                esif_primitive_type::SET_PERF_PRESENT_CAPABILITY,
                performanceControlIndex,
                domainIndex);
            break;
        case PerformanceControlType::ThrottleState:
            // Set Pn
            getParticipantServices()->primitiveExecuteSetAsUInt32(
                esif_primitive_type::SET_PERF_PRESENT_CAPABILITY,
                static_cast<UIntN>(performanceStateSet.getCount()) - 1,
                domainIndex);
            getParticipantServices()->primitiveExecuteSetAsUInt32(
                esif_primitive_type::SET_TSTATE_CURRENT,
                (performanceControlSet)[performanceControlIndex].getControlId(),
                domainIndex);
            break;
        default:
            throw dptf_exception("Invalid performance state requested.");
            break;
    }

    // Refresh the status
    m_performanceControlStatus.set(PerformanceControlStatus(performanceControlIndex));
}
Ejemplo n.º 22
0
Power DomainPowerStatus_001::getPower(UIntN domainIndex)
{
    Power power = Power::createInvalid();

    try
    {
        power = getParticipantServices()->primitiveExecuteGetAsPower(
            esif_primitive_type::GET_RAPL_POWER, domainIndex);
    }
    catch (primitive_try_again)
    {
        power = getParticipantServices()->primitiveExecuteGetAsPower(
            esif_primitive_type::GET_RAPL_POWER, domainIndex);
    }

    return power;
}
Ejemplo n.º 23
0
void DomainRfProfileControl_001::setRfProfileCenterFrequency(
	UIntN participantIndex,
	UIntN domainIndex,
	const Frequency& centerFrequency)
{
	getParticipantServices()->primitiveExecuteSetAsFrequency(
		esif_primitive_type::SET_RFPROFILE_CENTER_FREQUENCY, centerFrequency, domainIndex, Constants::Esif::NoInstance);
}
Ejemplo n.º 24
0
void DomainPerformanceControl_002::calculatePerformanceStateLimits(UIntN& pStateUpperLimitIndex, 
    UIntN& pStateLowerLimitIndex, UIntN domainIndex)
{
    // TODO: Revisit whether we should even call this to get the upper limit as opposed to just defaulting the upper
    // limit to 0 and arbitrate with ConfigTDP.  This primitive simply gives us the last set P-state index.  If 3rd
    // party tools set this or if we have throttled P-states and then crash and reload, our upper limit will be
    // whatever the last set P-state index was, which is wrong.
    pStateUpperLimitIndex =
        getParticipantServices()->primitiveExecuteGetAsUInt32(
        esif_primitive_type::GET_PROC_PERF_PRESENT_CAPABILITY,
        domainIndex);

    auto performanceStateSetSize = getPerformanceStateSet(domainIndex).getCount();
    try
    {
        // _PDL is an optional object
        pStateLowerLimitIndex =
            getParticipantServices()->primitiveExecuteGetAsUInt32(
            esif_primitive_type::GET_PROC_PERF_PSTATE_DEPTH_LIMIT,
            domainIndex);
    }
    catch (dptf_exception)
    {
        // _PDL wasn't supported. Default to P(n)
        pStateLowerLimitIndex = static_cast<UIntN>(performanceStateSetSize - 1);
    }

    if (pStateUpperLimitIndex >= performanceStateSetSize)
    {
        throw dptf_exception("Retrieved upper P-state index limit is out of control set bounds. (P-States)");
    }

    if (pStateLowerLimitIndex >= performanceStateSetSize)
    {
        throw dptf_exception("Retrieved lower P-state index limit is out of control set bounds. (P-States)");
    }

    if (pStateUpperLimitIndex > pStateLowerLimitIndex)
    {
        // If the limits are bad, ignore the lower limit.  Don't fail this control.
        getParticipantServices()->writeMessageWarning(
            ParticipantMessage(FLF, "Limit index mismatch, ignoring lower limit."));
        pStateLowerLimitIndex = static_cast<UIntN>(performanceStateSetSize - 1);
    }
}
Ejemplo n.º 25
0
DisplayControlStatus DomainDisplayControl_001::getDisplayControlStatus(UIntN participantIndex, UIntN domainIndex)
{
    Percentage brightnessPercentage = getParticipantServices()->primitiveExecuteGetAsPercentage(
        esif_primitive_type::GET_DISPLAY_BRIGHTNESS, domainIndex);

    m_currentDisplayControlIndex.set(getDisplayControlSet(participantIndex, domainIndex).getControlIndex(brightnessPercentage));

    return DisplayControlStatus(m_currentDisplayControlIndex.get());
}
Ejemplo n.º 26
0
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));
    }
}
Ejemplo n.º 27
0
UIntN DomainDisplayControl_001::getUpperLimitIndex(UIntN domainIndex, DisplayControlSet displaySet)
{
    UIntN upperLimitIndex;
    try
    {
        UInt32 uint32val = getParticipantServices()->primitiveExecuteGetAsUInt32(
            esif_primitive_type::GET_DISPLAY_CAPABILITY, domainIndex);
        Percentage upperLimitBrightness = Percentage::fromWholeNumber(uint32val);
        upperLimitIndex = displaySet.getControlIndex(upperLimitBrightness);
    }
    catch (...)
    {
        // DDPC is optional
        getParticipantServices()->writeMessageDebug(
            ParticipantMessage(FLF, "DDPC was not present.  Setting upper limit to 100."));
        upperLimitIndex = 0; // Max brightness
    }
    return upperLimitIndex;
}
Ejemplo n.º 28
0
DisplayControlSet DomainDisplayControl_001::createDisplayControlSet(UIntN domainIndex)
{
    // _BCL Table
    DptfBuffer buffer = getParticipantServices()->primitiveExecuteGet(
        esif_primitive_type::GET_DISPLAY_BRIGHTNESS_LEVELS, ESIF_DATA_BINARY, domainIndex);
    auto displayControlSet = DisplayControlSet::createFromBcl(buffer);
    throwIfDisplaySetIsEmpty(displayControlSet.getCount());

    return displayControlSet;
}
Ejemplo n.º 29
0
void DomainPerformanceControl_003::restore(void)
{
    if (m_initialStatus.isValid())
    {
        try
        {
            getParticipantServices()->primitiveExecuteSetAsUInt32(
                esif_primitive_type::SET_PERF_PRESENT_CAPABILITY,
                m_initialStatus.get().getCurrentUpperLimitIndex(),
                getDomainIndex());
        }
        catch (...)
        {
            // best effort
            getParticipantServices()->writeMessageDebug(ParticipantMessage(
                FLF, "Failed to restore the initial performance control status. "));
        }
    }
}
Ejemplo n.º 30
0
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
	}
}