From http://blog.csdn.net/Treeyan
In fact, it is not original. The materials are mostly from the Internet through Google.
Some time ago I bought a hp-dv1702 laptop, core Single Core CPU, 5400 turn hard disk, watch a movie very good. the core CPU supports the speedstep technology. When you are not busy, it always works at around 800 MHz, with a low calorific value. The BIOS sets the fan start temperature to 75 degrees CPU, and the fan rarely turns around during normal work, hard Disk temperature is relatively high, from the Internet to find the left side hot is a common problem of this.
The author's idea is to let the fan rotate when the hard drive reaches 48 or 9 degrees, stop at the set temperature, and see the temperature of the motherboard, CPU, and hard disk. After the fan control is complete, the problem of system temperature detection is highlighted, while using other software to view the system temperature, while manually controlling the fan stop and rotation, tired.
1. motherboard Temperature Detection
There are some differences between the bios and the desktop of a laptop. Generally, the bios acpi has a temperature detection area (thermalzone) or other ACPI defined by Temperature Detection area. Read the value of this area, the temperature sensor value on the current motherboard is obtained. XP/2000 supports ACPI, so it is easy to read. However, the desktop basically does not have thermalzone. To monitor the temperature, you need to scan the system bus.
How can I read the values in the ACPI area? Windows Driver reads these values for management, so WMI can read them. For more information about how to connect to the WMI namespace, see msdn 'wmi C ++ application examples '. We will not describe it here.
The motherboard temperature has two names in WMI: 1. Root/cimv2/win32_temperatureprobe 2. Root/WMI/msacpi_thermalzonetemperature first checks whether win32_temperatureprobe has objects, if msacpi_thermalzonetemperature is not detected, the reader reads the member currenttemperature as the current temperature, and the criticaltrippoint is the critical temperature. The temperature starts with an absolute 0 degree and increases with 1/10 degrees. The formula is as follows:
Current degree Celsius = (currenttemperature-2732)/10
2. Hard Disk Temperature Monitoring
The tool or software used to detect the hard disk temperature is through S. m.a. r. t to read the data. You can obtain the smart value for the hard disk through deviceiocontrol or WMI. smart data is stored in the root/WMI/msstoragedriver_atapismartdata namespace in WMI. The attribute 'vendorspeciti' contains hard disk temperature data, which is defined by Ata standards. It may be confusing to read the data. In fact, this is a structure. The first and second bytes represent the smart version information and define the smart attribute from the third byte, each attribute is 12 bytes long. The first byte of each attribute is defined as the current attribute. The value 0x09 indicates the number of hours in use, 0xc2 indicates the temperature attribute, and the fifth byte indicates the current temperature. The structure is as follows:
Struct smartattriubtes
{
Char attrib;
Char flags;
Char worst;
Char normal;
Char current;
Char current1;
Char current2;
Char current3;
Char current4;
Char current5;
Char current6;
Char current7;
}
Struct vendorspecific
{
Unsigned short version;
Smartattriubtes smartattrib [1];
}
For example, if the author reads the following values from the hard disk, some will omit {0xa, 0x00, 0x09, 0x32, 0, 0x63, 0x63, 0xc2, 0x03, 0, 0, 0, 0, 0, 0xc2, 0x22, 0, 0x2e, 0x3b, 0x2e, 0, 0, 0, 0x05, 0, 0 ,...};
Arranged as follows
{
0xa, 0x00 version information
0x09, 0x32, 0, 0x63, 0x63, [0xc2, 0x03], 0, 0, 0, 0, 0, 0 hard disk usage hours, which is 0x3c2 = 962 hours
0xc2, 0x22, 0, 0x2e, 0x3b, [0x2e], 0, 0, 0, 0x05, 0, 0, 0. The current temperature is 0x2e = 46 degrees.
}
Win2000 does not support this WMI attribute and can only be obtained through deviceiocontrol. for how to implement it, see the opensource connection of smart in appendix.
3. CPU Temperature Detection
The new coolui CPU and amd cpu are integrated with a temperature sensor DTS (Digital thermal sensor). Each core has one, and the previous mobile CPU seems to support temperature detection, however, there is no such CPU available for testing. the amd temperature value is stored in the Nb register, and the DTs value of coolui CPU is stored in MSR 0x19c, which can be read through rdmsr.
Here we only talk about the core CPU reading process.
Intel defines eax = 6 to execute cpuid, and then tests whether the first eax is 1. If it is 1, the CPU supports DTs, of course, we should use eax = 0 to execute cpuid to check the maximum number of commands supported by eax. If it is smaller than 6, DTS is certainly not supported.
Read DTS: 1 run the rdmsr command with ECx = 0xEE to test whether the 30th bits of eax are 1. If it is 1, the initial value of the temperature calculation is 85 degrees. Otherwise, the calculation starts from 100 degrees, this value is called tjunction. run the rdmsr command with ECx = 0x19c. The 16-23 bits of eax indicate the current DTS value. This value does not represent the current temperature, but must be calculated using the following surface formula.
Current CPU temperature = tjunction-DTS
Note that the signature is 0x6f1, And the cpu dts value of 0x6f0 directly represents the current temperature without the tjunction subtraction. the tjunction of signature less than or equal to 0x6f4 is always 100. If you are a dual-core CPU, you can use setprocessaffinitymask API to specify the CPU to be executed to check the temperature of the core. Oh, I don't need it anymore. It's a single core.
In addition, the rdmsr command can be executed only by running code of level 0. Therefore, it is necessary to write a simple driver.
If you want to see the effect, you can download fan1702ii.rar from my shared resources and do not operate the fan. He can still work.
Http://download.csdn.net/source/185999
Treeyan Email: yanjiafu33@163.com QQ: 42412685
Haha, I rarely write text. If it is not fluent, please include it. Enjoy!
Appendix reference
Opensource of S. m.a. R. T
Http://smartlinux.sourceforge.net/smart/index.php
On the Intel website, you can see some information about DTS and tjunction.
Http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231056.aspx
Core temp tells how she works.
Http://www.thecoolest.zerobrains.com/CoreTemp/howitworks.html
About msstoragedriver_atapismartdata
Http://www.hardforum.com/showthread.php? T = 1162248
Test CPU speed, Open Source
Http://www.diefer.de/speedswitchxp/index.html