Exemplo n.º 1
0
void EsifServices::writeConfigurationUInt32(const std::string& elementPath, UInt32 elementValue)
{
    eEsifError rc = m_esifInterface.fSetConfigFuncPtr(m_esifHandle, m_dptfManager, EsifDataString("dptf"),
        EsifDataString(elementPath), EsifDataUInt32(elementValue), ESIF_SERVICE_CONFIG_PERSIST);

    if (rc != ESIF_OK)
    {
        ManagerMessage message = ManagerMessage(m_dptfManager, FLF,
            "Error returned from ESIF services interface function call");
        message.addMessage("Element Path", elementPath);
        message.addMessage("Element Value", elementValue);
        message.setEsifErrorCode(rc);
        writeMessageWarning(message);
        throw dptf_exception(message);
    }
}
Exemplo n.º 2
0
std::string EsifServices::readConfigurationString(const std::string& elementPath)
{
    EsifDataString esifResult(Constants::DefaultBufferSize);

    eEsifError rc = m_esifInterface.fGetConfigFuncPtr(m_esifHandle, m_dptfManager, EsifDataString("dptf"),
        EsifDataString(elementPath), esifResult);

    if (rc != ESIF_OK)
    {
        ManagerMessage message = ManagerMessage(m_dptfManager, FLF,
            "Error returned from ESIF services interface function call");
        message.addMessage("Element Path", elementPath);
        message.setEsifErrorCode(rc);
        writeMessageWarning(message);
        throw dptf_exception(message);
    }

    return esifResult;
}
Exemplo n.º 3
0
void EsifServices::primitiveExecuteSetAsString(esif_primitive_type primitive, std::string stringValue, 
    UIntN participantIndex, UIntN domainIndex, UInt8 instance)
{
    throwIfParticipantDomainCombinationInvalid(FLF, participantIndex, domainIndex);

    eEsifError rc = m_esifInterface.fPrimitiveFuncPtr(m_esifHandle, m_dptfManager,
        (void*)m_dptfManager->getIndexContainer()->getIndexPtr(participantIndex),
        (void*)m_dptfManager->getIndexContainer()->getIndexPtr(domainIndex),
        EsifDataString(stringValue), EsifDataVoid(), primitive, instance);
    throwIfNotSuccessful(FLF, rc, primitive, participantIndex, domainIndex, instance);
}
Exemplo n.º 4
0
void DptfManager::createDptfManager(const void* esifHandle, EsifInterfacePtr esifInterfacePtr,
    const std::string& dptfHomeDirectoryPath, eLogType currentLogVerbosityLevel, Bool dptfEnabled)
{
    if (m_dptfManagerCreateStarted == true)
    {
        throw dptf_exception("DptfManager::createDptfManager() already executed.");
    }
    m_dptfManagerCreateStarted = true;

    try
    {
#ifdef ESIF_ATTR_OS_WINDOWS
        m_dptfHomeDirectoryPath = dptfHomeDirectoryPath + "\\";
#else
        m_dptfHomeDirectoryPath = dptfHomeDirectoryPath + "/";
#endif

        m_dptfEnabled = dptfEnabled;

        m_indexContainer = new IndexContainer(Constants::Participants::MaxParticipantEstimate);
        m_esifServices = new EsifServices(this, esifHandle, esifInterfacePtr, currentLogVerbosityLevel);
        m_participantManager = new ParticipantManager(this);
        m_policyManager = new PolicyManager(this);

        // Make sure to create these AFTER creating the ParticipantManager and PolicyManager
        m_workItemQueueManager = new WorkItemQueueManager(this);
        m_workItemQueueManagerCreated = true;

        m_dptfStatus = new DptfStatus(this);

        m_policyManager->createAllPolicies(m_dptfHomeDirectoryPath);

        registerDptfFrameworkEvents();

        m_dptfManagerCreateFinished = true;
    }
    catch (std::exception ex)
    {
        std::stringstream message;
        message << "The DPTF application has failed to start." << std::endl;
        message << ex.what() << std::endl;
        esifInterfacePtr->fWriteLogFuncPtr(esifHandle, this, nullptr, nullptr,
            EsifDataString(message.str()), eLogType::eLogTypeFatal);
    }

    if (m_dptfManagerCreateFinished == false)
    {
        shutDown();
        throw dptf_exception("Failed to start DPTF");
    }
}
Exemplo n.º 5
0
void EsifServices::writeMessage(eLogType messageLevel, MessageCategory::Type messageCategory, const std::string& message)
{
    // Do not throw an error here....
    // In general we will write to the log file when an error has been thrown and we don't want to create
    // a recursive mess.  Anyway, if the message isn't written, what can we do about?  We can't write another
    // error message.  So, if this fails, we ignore it.

#ifdef ONLY_LOG_TEMPERATURE_THRESHOLDS
    if ((logType == eLogType::eLogTypeFatal) ||
        (logType == eLogType::eLogTypeError) ||
        (messageCategory == MessageCategory::TemperatureThresholds))
    {
#endif

        m_esifInterface.fWriteLogFuncPtr(m_esifHandle, m_dptfManager, nullptr,
            nullptr, EsifDataString(message), messageLevel);

#ifdef ONLY_LOG_TEMPERATURE_THRESHOLDS
    }

#endif
}