Thank you for providing the code.
I tried converting to C # by referring to this code, but seems to work well so far.
// Define Function Types
[System.Runtime.InteropServices.DllImport("libnvrm.dll", EntryPoint = "NvRmOpen")]
public static extern UInt32 NvRmOpen(ref UInt32 pHandle, UInt32 DeviceId);
[System.Runtime.InteropServices.DllImport("libnvrm.dll", EntryPoint = "NvRmClose")]
public static extern UInt32 NvRmClose(UInt32 hDevice);
[System.Runtime.InteropServices.DllImport("libnvrm.dll", EntryPoint = "NvRmDfsGetClockUtilization")]
public static extern UInt32 NvRmDfsGetClockUtilization(UInt32 hRmDeviceHandle, UInt32 ClockId, ref NvRmDfsClockUsage pClockUsage);
public struct NvRmDfsClockUsage
/// Minimum clock domain frequency.
public UInt32 MinKHz;
/// Maximum clock domain frequency.
public UInt32 MaxKHz;
/// Low corner frequency - current low boundary for DFS control algorithm.
/// Can be dynamically adjusted via APIs: NvRmDfsSetLowCorner() for all DFS
/// domains, NvRmDfsSetCpuEnvelope() for CPU, and NvRmDfsSetEmcEnvelope()
/// for EMC. When all DFS domains hit low corner, DFS stops waking up CPU
/// from low power state.
public UInt32 LowCornerKHz;
/// High corner frequency - current high boundary for DFS control algorithm.
/// Can be dynamically adjusted via APIs: NvRmDfsSetCpuEnvelope() for Cpu,
/// NvRmDfsSetEmcEnvelope() for Emc, and NvRmDfsSetAvHighCorner() for other
// DFS domains.
public UInt32 HighCornerKHz;
/// Current clock domain frequency
public UInt32 CurrentKHz;
/// Average frequency of domain *activity* (not average frequency). For
/// domains that do not have activity monitors reported as unspecified.
public UInt32 AverageKHz;
public void Clear()
MinKHz = 0;
MaxKHz = 0;
LowCornerKHz = 0;
HighCornerKHz = 0;
CurrentKHz = 0;
AverageKHz = 0;
private const UInt32 NvRmDfsClockId_Cpu = 1;
private UInt32 g_rm = 0;
//====== Code to read CPU temperature ======
public UInt32 GetCpuTemperature()
NvRmDfsClockUsage clk_cpu = new NvRmDfsClockUsage();
NvRmOpen(ref g_rm, 0);
// --- This is the actual temperature reading - everything else is initialization ---
NvRmDfsGetClockUtilization(g_rm, NvRmDfsClockId_Cpu, ref clk_cpu);
I have a question about the contents of the output.
(a)MaxKHz is output as 1300000. Why is it different from 1.4 GHz of Apalis T30?
(b)Apalis T30 has heard that the operating frequency is limited to 800MHz when the core temperature exceeds 60°C.
In this case, is it correct with the recognition that CurrentKHz or AverageKHz is output as maximum 800000?