CoreControlOffliningMode::Type LpmConfigurationReaderV0::readCpuOffliningMode()
{
    string key = "CpuOffLiningMode";
    CoreControlOffliningMode::Type cpuOffliningMode;
    try
    {
        UIntN valueInt = getPolicyServices().platformConfigurationData->readConfigurationUInt32(
            root() + keyPath() + key);
        if (valueInt > CoreControlOffliningMode::Core)
        {
            m_policyServices.messageLogging->writeMessageError(PolicyMessage(FLF,
            "Invalid CoreControlOffliningMode returned (" + to_string(valueInt) + ")" +
                " - defaulting to core", Constants::Invalid));
            cpuOffliningMode = CoreControlOffliningMode::Core;
        }
        else
        {
            cpuOffliningMode = (CoreControlOffliningMode::Type)valueInt;
        }
    }
    catch(dptf_exception& e)
    {
        string msg = e.what();
        m_policyServices.messageLogging->writeMessageDebug(PolicyMessage(FLF,
            "No CoreControlOffliningMode returned - defaulting to core. msg - " + msg,
            Constants::Invalid));
        cpuOffliningMode = CoreControlOffliningMode::Core;
    }

    return cpuOffliningMode;
}
UInt32 LpmConfigurationReaderV0::readCpuPercentageActiveLogicalProcessors()
{
    string key = "CpuPercentageActiveLogicalProcessors";
    UInt32 cpuPercentageActiveLogicalProcessors;
    try
    {
        cpuPercentageActiveLogicalProcessors =
            getPolicyServices().platformConfigurationData->readConfigurationUInt32(
                root() + keyPath() + key);
    }
    catch(dptf_exception& e)
    {
        string msg = e.what();

        m_policyServices.messageLogging->writeMessageDebug(PolicyMessage(FLF,
            "No CpuPercentageActiveLogicalProcessors - defaulting to 1%. msg - " + msg,
            Constants::Invalid));

        // Default to 1% (translates to 1 core).
        cpuPercentageActiveLogicalProcessors = 1;
    }

    if (cpuPercentageActiveLogicalProcessors < 1)
    {
        cpuPercentageActiveLogicalProcessors = 1;
    }
    else if (cpuPercentageActiveLogicalProcessors > 100)
    {
        cpuPercentageActiveLogicalProcessors = 100;
    }

    return cpuPercentageActiveLogicalProcessors;
}
Bool LpmConfigurationReaderV0::readCpuUseTStateThrottling()
{
    string key = "CpuUseTStateThrottling";
    Bool cpuUseTStateThrottling;
    try
    {
        UIntN valueInt =
            getPolicyServices().platformConfigurationData->readConfigurationUInt32(
            root() + keyPath() + key);
        if (valueInt)
        {
            cpuUseTStateThrottling = true;
        }
        else
        {
            cpuUseTStateThrottling = false;
        }
    }
    catch(dptf_exception& e)
    {
        string msg = e.what();
        m_policyServices.messageLogging->writeMessageDebug(PolicyMessage(FLF,
            "No CpuUseTStateThrottling - defaulting to false. msg - " + msg,
            Constants::Invalid));
        cpuUseTStateThrottling = false;
    }

    if ((cpuUseTStateThrottling != true) && (cpuUseTStateThrottling != false))
    {
        cpuUseTStateThrottling = false;
    }

    return cpuUseTStateThrottling;
}
UInt32 LpmConfigurationReaderV0::readGfxTargetFrequency()
{
    string key = "GfxTargetFrequency";
    UInt32 gfxTargetFrequency;
    try
    {
        gfxTargetFrequency =
            getPolicyServices().platformConfigurationData->readConfigurationUInt32(
            root() + keyPath() + key);
    }
    catch(dptf_exception& e)
    {
        string msg = e.what();

        m_policyServices.messageLogging->writeMessageError(PolicyMessage(FLF,
            "Error in reading GfxTargetFrequency, default 100Mhz. msg - " + msg,
            Constants::Invalid));

        //
        // if not found, we default to 100 mhz,
        // which will be the lowest graphics p-state (since we round up)
        //
        gfxTargetFrequency = 100;
    }

    return gfxTargetFrequency;
}
示例#5
0
vector<LpmSet> LpmConfigurationReaderV1::readLpmSets(void)
{
    vector<LpmSet> lpmSets;
    vector<LpmEntry> lpmEntries;

    //
    // Since this configuration does not have the numLpmEntries we loop through
    // till we fail to read. We handle it in the catch block.
    //
    UIntN lpmSetIndex;
    try
    {
        for (lpmSetIndex = LpmEntriesIndexLimit::MinLpmSetIndex; ; lpmSetIndex++)
        {
            setLpmSetsKeyPath(lpmSetIndex);

            lpmEntries = readLpmEntries();
            if (lpmEntries.empty())
            {
                // No more LPM entries to process.
                throw dptf_exception("No more LPM entries");
            }

            lpmSets.push_back(LpmSet(lpmSetIndex, lpmEntries));
            if (lpmSetIndex >= LpmEntriesIndexLimit::MaxLpmSetIndex)
            {
                throw dptf_exception("Number of LPM sets exceeded max value");
            }
        }
    }
    catch (dptf_exception& e)
    {
        string msg = e.what();
        postInfoMessage(PolicyMessage(FLF,
            "Error msg (" + msg + "). Last lpmSetIndex = " + to_string(lpmSetIndex),
            Constants::Invalid));
        return lpmSets;
    }

    // Will come here only if there are no entries/lpmsets.
    return lpmSets;

}
示例#6
0
vector<LpmEntry> LpmConfigurationReaderV1::readLpmEntries(void)
{
    vector<LpmEntry> lpmEntries;

    string target;
    DomainType::Type domainType;
    ControlKnobType::Type controlKnob;
    UInt32 controlValue;

    UIntN lpmEntryIndex;
    string inputKeyPath = keyPath();
    try
    {
        for (lpmEntryIndex = 0; ; lpmEntryIndex++)
        {
            setLpmEntryKeyPath(inputKeyPath, lpmEntryIndex);

            target = readTargetDeviceAcpiScope();
            domainType = readDomainType();
            controlKnob = readControlKnob();
            controlValue = readControlValue();
            
            lpmEntries.push_back(LpmEntry(target, domainType, controlKnob, controlValue));
            if (lpmEntryIndex >= LpmEntriesIndexLimit::MaxLpmEntryIndex)
            {
                throw dptf_exception("LPM entries exceeded max value");
            }
        }
    }
    catch (dptf_exception& e)
    {
        string msg = e.what();
        postInfoMessage(PolicyMessage(FLF,
            "Error msg (" + msg + "). Last lpmEntryIndex = " + to_string(lpmEntryIndex),
            Constants::Invalid));
        return lpmEntries;
    }

    return (lpmEntries);
}
示例#7
0
vector<AppSpecificEntry> LpmConfigurationReaderV1::readAppSpecificEntries(void)
{
    vector<AppSpecificEntry> appSpecificEntries;

    //
    // Since this configuration does not have the numAppSpecificEntries we loop through
    // till we fail to read. We handle it in the catch block.
    //
    UIntN appIndex;
    try
    {
        for (appIndex = 0; ; appIndex++)
        {
            vector<string> appNames = readAppNames(appIndex);

            string key = "LPMSet";
            UIntN lpmSetIndex = getPolicyServices().platformConfigurationData->readConfigurationUInt32(
                root() + keyPath() + key);

            appSpecificEntries.push_back(AppSpecificEntry(appNames, lpmSetIndex));

            if (appIndex >= LpmEntriesIndexLimit::MaxAppEntryIndex)
            {
                throw dptf_exception("App Entries exceeded max value");
            }
        }
    }
    catch (dptf_exception& e)
    {
        string msg = e.what();
        postInfoMessage(PolicyMessage(FLF,
            "Error msg (" + msg + "). Last appIndex = " + to_string(appIndex),
            Constants::Invalid));
        return appSpecificEntries;
    }

    return appSpecificEntries;

}
vector<string> LpmConfigurationReaderV0::readAppNames(UInt32 entryIndex)
{
    string key = "AppName";
    vector<string> appNames;
    string indexAsString = getIndexAsString(entryIndex);

    setKeyPath("AppSpecificMode" + indexAsString + "/");
    try
    {
        // TODO: Error check for appname?
        string appName = getPolicyServices().platformConfigurationData->readConfigurationString(
            root() + keyPath() + key);
        appNames.push_back(appName);
    }
    catch (dptf_exception& e)
    {
        string msg = e.what();
        m_policyServices.messageLogging->writeMessageDebug(PolicyMessage(FLF,
            "Error msg (" + msg + "). Error in reading AppName", Constants::Invalid));
    }

    return appNames;
}
vector<AppSpecificEntry> LpmConfigurationReaderV0::readAppSpecificEntries(void)
{
    m_lpmSets.clear();

    vector<AppSpecificEntry> appSpecificEntries;
    UIntN entryIndex = 0;
    try
    {
        string key = "NumAppSpecificEntries";
        UIntN numEntries = getPolicyServices().platformConfigurationData->readConfigurationUInt32(
            root() + key);

        if (numEntries == 0)
        {
            throw dptf_exception("No app specific entries for v0");
        }

        for (entryIndex = 0; entryIndex < numEntries; entryIndex++)
        {
            vector<string> appNames = readAppNames(entryIndex);
            vector<LpmEntry> lpmEntries = readLpmEntries();

            appSpecificEntries.push_back(AppSpecificEntry(appNames, entryIndex));
            m_lpmSets.push_back(LpmSet(entryIndex, lpmEntries));
        }
    }
    catch (dptf_exception& e)
    {
        string msg = e.what();
        m_policyServices.messageLogging->writeMessageDebug(PolicyMessage(FLF,
            "Error msg (" + msg + "). Last entryIndex = " + to_string(entryIndex),
            Constants::Invalid));
    }

    return appSpecificEntries;
}
示例#10
0
UInt32 LpmConfigurationReaderV0::readPackagePowerLimit()
{
    // TODO: Check regarding PL -> string/uint? Do we need to sku check like 7.0?
    UInt32 packagePowerLimit;
    string key = "PackagePowerLimit";

    try
    {
        string valueString = getPolicyServices().platformConfigurationData->readConfigurationString(
            root() + keyPath() + key);
        packagePowerLimit = extractPowerLimit(valueString);
    }
    catch (dptf_exception& e)
    {
        string msg = e.what();

        m_policyServices.messageLogging->writeMessageError(PolicyMessage(FLF,
            "Error in reading PackagePowerLimit, default 10000000. msg - " + msg,
            Constants::Invalid));
        packagePowerLimit = 10000000; // Max valid power
    }

    return packagePowerLimit;
}
示例#11
0
UInt32 LpmConfigurationReaderV0::readCpuTargetFrequency()
{
    string key = "CpuTargetFrequency";
    UInt32 cpuTargetFrequency;
    try
    {
        cpuTargetFrequency =
          getPolicyServices().platformConfigurationData->readConfigurationUInt32(
              root() + keyPath() + key);
    }
    catch(dptf_exception& e)
    {
        string msg = e.what();

        m_policyServices.messageLogging->writeMessageDebug(PolicyMessage(FLF,
        "No CpuTargetFrequency - defaulting to 800Mhz. msg - " + msg,
        Constants::Invalid));

        // if not found, we default to 800 mhz (MFM or LFM)
        cpuTargetFrequency = 800;
    }

    return cpuTargetFrequency;
}
示例#12
0
// TODO: Might not need this.
UInt32 LpmConfigurationReaderV0::extractPowerLimit(string plString)
{
    UInt32 skuPlValue = 10000000; // Max valid power;
    UInt32 nonSkuPlValue = 10000000;
    Bool skuMatch = false;
    vector<string> plKeyValuePairs = tokenize(plString, ';');

    trim(plString, ' ');
    for (auto entry = plKeyValuePairs.begin(); entry != plKeyValuePairs.end(); entry++)
    {
        if (entry->find(':') != string::npos)
        {
            // There are key PL value pairs in the string.
            vector<string> plKeyValue = tokenize(*entry, ':');
            if (plKeyValue.size() != 2)
            {
                throw dptf_exception("Invalid PL-SKU entry");
            }
            else
            {
                string skuPattern = plKeyValue[0];
                string plString2 = plKeyValue[1];

                // Trim the '"'
                trim(skuPattern, '"');

                std::regex regSkuPattern(skuPattern);
                if (std::regex_match(m_skuData, regSkuPattern))
                {
                    m_policyServices.messageLogging->writeMessageDebug(PolicyMessage(FLF,
                        "SKU matched: m_skuData(" + m_skuData + ")" + " plValue(" + plString2 + ")",
                        Constants::Invalid));
                    if (!(plString2.find_first_not_of("0123456789") == string::npos))
                    {
                        throw dptf_exception("The PL value is not a number (" + plString2 + ")");
                    }

                    try
                    {
                        skuPlValue = std::stoul(plString2);
                        skuMatch = true;
                        break;
                    }
                    catch (...)
                    {
                        throw dptf_exception("Invalid PL value in sku string (" + plString2 + ")");
                    }
                }
            }
        }
        else
        {
            try
            {
                m_policyServices.messageLogging->writeMessageDebug(PolicyMessage(FLF,
                    "Non-SKU PL string: " + *entry, Constants::Invalid));

                nonSkuPlValue = std::stoul(*entry);
            }
            catch (...)
            {
                throw dptf_exception("Invalid PL value in non-sku string (" + *entry + ")");
            }
        }
    }

    if (skuMatch == true)
    {
        return skuPlValue;
    }
    else
    {
        return nonSkuPlValue;
    }
}