Beispiel #1
0
DptfBuffer ThermalRelationshipTable::toTrtBinary() const
{
    DptfBuffer packages;
    UInt32 offset = 0;
    for (auto entry = m_entries.begin(); entry != m_entries.end(); entry++)
    {
        auto trtEntry = std::dynamic_pointer_cast<ThermalRelationshipTableEntry>(*entry);
        if (trtEntry)
        {
            UInt32 sourceScopeLength = (UInt32)(*entry)->getSourceDeviceScope().size();
            UInt32 targetScopeLength = (UInt32)(*entry)->getTargetDeviceScope().size();

            DptfBuffer packageBuffer;
            packageBuffer.allocate(sizeof(EsifDataBinaryTrtPackage) + sourceScopeLength + targetScopeLength);

            EsifDataBinaryTrtPackage entryPackage;
            UInt32 dataAddress = 0;

            // Source Scope
            entryPackage.sourceDevice.string.length = sourceScopeLength;
            entryPackage.sourceDevice.type = esif_data_type::ESIF_DATA_STRING;
            packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.sourceDevice)), sizeof(entryPackage.sourceDevice));
            dataAddress += sizeof(entryPackage.sourceDevice);
            packageBuffer.put(dataAddress, (UInt8*)((*entry)->getSourceDeviceScope().c_str()), sourceScopeLength);
            dataAddress += sourceScopeLength;

            // Target Scope
            entryPackage.targetDevice.string.length = targetScopeLength;
            entryPackage.targetDevice.type = esif_data_type::ESIF_DATA_STRING;
            packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.targetDevice)), sizeof(entryPackage.targetDevice));
            dataAddress += sizeof(entryPackage.targetDevice);
            packageBuffer.put(dataAddress, (UInt8*)((*entry)->getTargetDeviceScope().c_str()), targetScopeLength);
            dataAddress += targetScopeLength;

            // Thermal Influence
            entryPackage.thermalInfluence.integer.type = esif_data_type::ESIF_DATA_UINT64;
            entryPackage.thermalInfluence.integer.value = trtEntry->thermalInfluence();
            packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.thermalInfluence)),
                sizeof(entryPackage.thermalInfluence));
            dataAddress += sizeof(entryPackage.thermalInfluence);

            // Sampling Period
            entryPackage.thermalSamplingPeriod.integer.type = esif_data_type::ESIF_DATA_UINT64;
            entryPackage.thermalSamplingPeriod.integer.value = trtEntry->thermalSamplingPeriod().asTenthSecondsInt();
            packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.thermalSamplingPeriod)),
                sizeof(entryPackage.thermalSamplingPeriod));
            dataAddress += sizeof(entryPackage.thermalSamplingPeriod);

            // Reserved1
            entryPackage.reserved1.integer.type = esif_data_type::ESIF_DATA_UINT64;
            entryPackage.reserved1.integer.value = 0;
            packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.reserved1)), sizeof(entryPackage.reserved1));
            dataAddress += sizeof(entryPackage.reserved1);

            // Reserved2
            entryPackage.reserved2.integer.type = esif_data_type::ESIF_DATA_UINT64;
            entryPackage.reserved2.integer.value = 0;
            packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.reserved2)), sizeof(entryPackage.reserved2));
            dataAddress += sizeof(entryPackage.reserved2);

            // Reserved3
            entryPackage.reserved3.integer.type = esif_data_type::ESIF_DATA_UINT64;
            entryPackage.reserved3.integer.value = 0;
            packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.reserved3)), sizeof(entryPackage.reserved3));
            dataAddress += sizeof(entryPackage.reserved3);

            // Reserved4
            entryPackage.reserved4.integer.type = esif_data_type::ESIF_DATA_UINT64;
            entryPackage.reserved4.integer.value = 0;
            packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.reserved4)), sizeof(entryPackage.reserved4));
            dataAddress += sizeof(entryPackage.reserved4);

            packages.put(offset, packageBuffer.get(), packageBuffer.size());
            offset += packageBuffer.size();
        }
    }

    DptfBuffer buffer(packages.size());
    buffer.put(0, packages.get(), packages.size());
    return buffer;
}
Beispiel #2
0
DptfBuffer ActiveRelationshipTable::toArtBinary() const
{
	esif_data_variant revisionField;
	revisionField.integer.type = esif_data_type::ESIF_DATA_UINT64;
	revisionField.integer.value = 1;

	DptfBuffer packages;
	UInt32 offset = 0;
	for (auto entry = m_entries.begin(); entry != m_entries.end(); entry++)
	{
		auto artEntry = std::dynamic_pointer_cast<ActiveRelationshipTableEntry>(*entry);
		if (artEntry)
		{
			UInt32 sourceScopeLength = (UInt32)(*entry)->getSourceDeviceScope().size();
			UInt32 targetScopeLength = (UInt32)(*entry)->getTargetDeviceScope().size();

			DptfBuffer packageBuffer;
			packageBuffer.allocate(sizeof(EsifDataBinaryArtPackage) + sourceScopeLength + targetScopeLength);

			EsifDataBinaryArtPackage entryPackage;
			UInt32 dataAddress = 0;

			// Source Scope
			entryPackage.sourceDevice.string.length = sourceScopeLength;
			entryPackage.sourceDevice.type = esif_data_type::ESIF_DATA_STRING;
			packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.sourceDevice)), sizeof(entryPackage.sourceDevice));
			dataAddress += sizeof(entryPackage.sourceDevice);
			packageBuffer.put(dataAddress, (UInt8*)((*entry)->getSourceDeviceScope().c_str()), sourceScopeLength);
			dataAddress += sourceScopeLength;

			// Target Scope
			entryPackage.targetDevice.string.length = targetScopeLength;
			entryPackage.targetDevice.type = esif_data_type::ESIF_DATA_STRING;
			packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.targetDevice)), sizeof(entryPackage.targetDevice));
			dataAddress += sizeof(entryPackage.targetDevice);
			packageBuffer.put(dataAddress, (UInt8*)((*entry)->getTargetDeviceScope().c_str()), targetScopeLength);
			dataAddress += targetScopeLength;

			// Weight
			entryPackage.weight.integer.type = esif_data_type::ESIF_DATA_UINT64;
			entryPackage.weight.integer.value = artEntry->getWeight();
			packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.weight)), sizeof(entryPackage.weight));
			dataAddress += sizeof(entryPackage.weight);

			// AC0
			entryPackage.ac0MaxFanSpeed.integer.type = esif_data_type::ESIF_DATA_UINT64;
			entryPackage.ac0MaxFanSpeed.integer.value = artEntry->ac(0);
			packageBuffer.put(
				dataAddress, (UInt8*)(&(entryPackage.ac0MaxFanSpeed)), sizeof(entryPackage.ac0MaxFanSpeed));
			dataAddress += sizeof(entryPackage.ac0MaxFanSpeed);

			// AC1
			entryPackage.ac1MaxFanSpeed.integer.type = esif_data_type::ESIF_DATA_UINT64;
			entryPackage.ac1MaxFanSpeed.integer.value = artEntry->ac(1);
			packageBuffer.put(
				dataAddress, (UInt8*)(&(entryPackage.ac1MaxFanSpeed)), sizeof(entryPackage.ac1MaxFanSpeed));
			dataAddress += sizeof(entryPackage.ac1MaxFanSpeed);

			// AC2
			entryPackage.ac2MaxFanSpeed.integer.type = esif_data_type::ESIF_DATA_UINT64;
			entryPackage.ac2MaxFanSpeed.integer.value = artEntry->ac(2);
			packageBuffer.put(
				dataAddress, (UInt8*)(&(entryPackage.ac2MaxFanSpeed)), sizeof(entryPackage.ac2MaxFanSpeed));
			dataAddress += sizeof(entryPackage.ac2MaxFanSpeed);

			// AC3
			entryPackage.ac3MaxFanSpeed.integer.type = esif_data_type::ESIF_DATA_UINT64;
			entryPackage.ac3MaxFanSpeed.integer.value = artEntry->ac(3);
			packageBuffer.put(
				dataAddress, (UInt8*)(&(entryPackage.ac3MaxFanSpeed)), sizeof(entryPackage.ac3MaxFanSpeed));
			dataAddress += sizeof(entryPackage.ac3MaxFanSpeed);

			// AC4
			entryPackage.ac4MaxFanSpeed.integer.type = esif_data_type::ESIF_DATA_UINT64;
			entryPackage.ac4MaxFanSpeed.integer.value = artEntry->ac(4);
			packageBuffer.put(
				dataAddress, (UInt8*)(&(entryPackage.ac4MaxFanSpeed)), sizeof(entryPackage.ac4MaxFanSpeed));
			dataAddress += sizeof(entryPackage.ac4MaxFanSpeed);

			// AC5
			entryPackage.ac5MaxFanSpeed.integer.type = esif_data_type::ESIF_DATA_UINT64;
			entryPackage.ac5MaxFanSpeed.integer.value = artEntry->ac(5);
			packageBuffer.put(
				dataAddress, (UInt8*)(&(entryPackage.ac5MaxFanSpeed)), sizeof(entryPackage.ac5MaxFanSpeed));
			dataAddress += sizeof(entryPackage.ac5MaxFanSpeed);

			// AC6
			entryPackage.ac6MaxFanSpeed.integer.type = esif_data_type::ESIF_DATA_UINT64;
			entryPackage.ac6MaxFanSpeed.integer.value = artEntry->ac(6);
			packageBuffer.put(
				dataAddress, (UInt8*)(&(entryPackage.ac6MaxFanSpeed)), sizeof(entryPackage.ac6MaxFanSpeed));
			dataAddress += sizeof(entryPackage.ac6MaxFanSpeed);

			// AC7
			entryPackage.ac7MaxFanSpeed.integer.type = esif_data_type::ESIF_DATA_UINT64;
			entryPackage.ac7MaxFanSpeed.integer.value = artEntry->ac(7);
			packageBuffer.put(
				dataAddress, (UInt8*)(&(entryPackage.ac7MaxFanSpeed)), sizeof(entryPackage.ac7MaxFanSpeed));
			dataAddress += sizeof(entryPackage.ac7MaxFanSpeed);

			// AC8
			entryPackage.ac8MaxFanSpeed.integer.type = esif_data_type::ESIF_DATA_UINT64;
			entryPackage.ac8MaxFanSpeed.integer.value = artEntry->ac(8);
			packageBuffer.put(
				dataAddress, (UInt8*)(&(entryPackage.ac8MaxFanSpeed)), sizeof(entryPackage.ac8MaxFanSpeed));
			dataAddress += sizeof(entryPackage.ac8MaxFanSpeed);

			// AC9
			entryPackage.ac9MaxFanSpeed.integer.type = esif_data_type::ESIF_DATA_UINT64;
			entryPackage.ac9MaxFanSpeed.integer.value = artEntry->ac(9);
			packageBuffer.put(
				dataAddress, (UInt8*)(&(entryPackage.ac9MaxFanSpeed)), sizeof(entryPackage.ac9MaxFanSpeed));
			dataAddress += sizeof(entryPackage.ac9MaxFanSpeed);

			packages.put(offset, packageBuffer.get(), packageBuffer.size());
			offset += packageBuffer.size();
		}
	}

	UInt32 sizeOfRevision = (UInt32)sizeof(revisionField);
	DptfBuffer buffer(sizeOfRevision + packages.size());
	buffer.put(0, (UInt8*)&revisionField, sizeOfRevision);
	buffer.put(sizeOfRevision, packages.get(), packages.size());
	return buffer;
}