



免费预览已结束,剩余1页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
最近搞cpu 内核温度,总算是有点成就了。需要参考的文献有:PCI Local Bus SpecificationAMD相关:BIOS and Kernel Developers Guide for AMD Athlon 64 and AMD Opteron ProcessorsBIOS and Kernel Dvelopers Guide (BKDG) For AMD Family 10h ProcessorBIOS and Kernel Dvelopers Guide ( For AMD NPT Family 0Fh ProcessorAMD CPUID Specification.Intel相关:Intel A3.Core Temp软件相关说明:Intel and AMD recently published detailed, public information about the DTS (Digital Thermal Sensor), which provides much higher accuracy and more relevant temperature reading than the standard thermal diode sensors doCore Temp lets you monitor Intel Core Duo, Core Solo (Yonah), Core 2 Duo, Core 2 Extreme, Core 2 Quad, Pentium E2000 series, Celeron 400/500 series (Allendale, Conroe, Merom, Kentsfield, Conroe-L respectively), Xeon 3000/3200/5100/5300 series (Woodcrest, Clovertown respectively) and all AMD K8 (AMD64) and K10 (Phenom, Opteron) series die temperature.The temperature readings are very accurate as the data is collected from a Digital Thermal Sensor (or DTS) which is located in each individual processing core, near the hottest part. This sensor is digital, which means it doesnt rely on an external circuit located on the motherboard to report temperature, its value is stored in a special register in the processor so any software can access and read it. This eliminates any inaccuracy that can be caused by external motherboard circuits and sensors and then different types of programs trying to read those sensors.This is how the program works:Intel defines a certain Tjunction temperature for the processor. In the case of Yonah it is 85C or 100C. First of all the program reads from a Model Specific Register (or MSR), and detects the Tjunction temperature. A different MSR contains the temperature data, this data is represented as Delta in C between current temperature and Tjunction.So the actual temperature is calculated like this Core Temp = Tjunction - DeltaThe size of the data field is 7 bits. This means a Delta of 0 - 127C can be reported in theory. But from preliminary tests, the reported temperature doesnt go below 0C, no matter what kind of cooling was used.AMD chips report the temperature by a special register in the CPUs NB. Core Temp reads that register and uses a formula provided by AMD to calculate the current temperature.The formula for the K8 is: Core Temp = Value - 49.The formula for the K10* is: CPU Temp* = Value / 8.The sensor in AMD CPUs can report temperatures between -49C and 206C.*K10 = Phenom (Agena), Opteron (Barcelona). The K10 reports a temperature value that is relative to a certain predefined value, it doesnt report the actual processor temperature! So take that into consideration.*CPU Temp is because the Phenom/Opteron (K10) have only one sensor per package, meaning there is only one reading per processor. 刚接手这个的时候,可以说是一头雾水,完全不知道该怎么搞。首先接触到的就是hwmonitor和core temp 这两款软件,同时看到上面core temp 的说明,可以说知道一点东西了。可以它其中说的amd是在nb的特殊寄存器中,这个到底是什么寄存器了。当时没有去看amd的一些文档,就直接看是逆向hwmonitor和core temp软件,通过动态和静态分析了这两个软件的驱动和应用程序,只能说知道其中他们是在不断的进行端口读写分别是0XCF8和0xCFC这两个端口。你可以上网查找这两个端口是干什么的,之前由于我左右pci 配置空间读取问题,所以对这个两个端口不是很陌生。pci 配置空间相关说明就要看pci 规范了,说的很详细。 之后,看是学习cpu 手册了,因为我的机器是amd的,所以就先或许amd的温度吧。看了很多,刚开始还不知道什么事,慢慢的,就知道其中有一个thermal status register,这个寄存器中保存了当前核心温度。这个寄存器就是core temp所说的nb中的特殊寄存器。那么这个寄存器是如何读取的呢,看来了amd bios and kernel guid 。中我们知道这个基础器是Fn3 E4.其中会说的pci配置空间。Fn3 是指读取pci配置空间时要用的到fun 3,而E4就是对应于这个fun 3的偏移为E4。读取这个32bit数据。然后我们就可以解析获取原始的当前温度了。 由于amd对这个寄存器有过修改,因而在解析的时候我们需要知道这是那种型号的。我们看到core temp是能获取k8和k10 的amd内核温度计算公式。那么是什么是k8什么是k10呢。 使用cpuid (eax = 0x1)得到的eax中的family,model,和stepping进行判断。 The Family is an 8-bit value and is defined as: Family7:0 = (0000b,BaseFamily3:0 + ExtendedFamily7:0). For example, if BaseFamily3:0 = 0Fh and ExtendedFamily7:0 = 01h, then Family7:0 = 10h. If BaseFamily3:0 is less than 0Fh then ExtendedFamily7:0 is reserved and Family is equal to BaseFamily3:0. Model is an 8-bit value and is defined as: Model7:0 = ExtendedModel3:0,BaseModel3:0. For example,if ExtendedModel3:0 = 0Eh and BaseModel3:0 = 08h, then Model7:0 = E8h. If BaseFamily3:0 is lessthan 0Fh then ExtendedModel3:0 is reserved and Model is equal to BaseModel3:0. 如果family 0xF,那么就是k10. 而对于k8的是怎么判断的呢,family为0xF,而除了 /* feature available since SH-C0, exclude older revisions */(model = 4) & (stepping = 0) | (model = 5) & (stepping = 1) 这些类型的cpu都可以算是k8的。 如何读pci,应该也清楚了,就是通过0xcf8和0xcfc进行读取,但是需要busno,devno,funno和reg,这样才能读取到指定的数据。但是我们并不知道busno和devno啊。而funno就是0x3,而reg就是E4或A4. 首先我们根据cpu类型获取到时k8还是k10.这两种类型的cpu对应的deviceid是不同。k8 为0x1103而k10为1203.通过这两个数据以及baseclass,就可以在遍历过程中得到busno和devno了。后面就是对数据进行解析了。哦。还有一点就是在看了bios and kernel书之后,按照它的方式我们发现需要有个diodeoffset来进行校正。而temp(23-14bit)/(23-16bit),diodeOffset的值也是不同的。不管哪种,得到的数据总是有点问题。郁闷了。你想core temp算法确实是按照上面的方式进行的。currtemp =rawtemp/4 - 49 + basetemp;后来,偶然机会发现在linux的内核中有一个k8temp.c这个东西,这个就是获取k8的温度。认真的学习了代码。发现可以正确的获取内核温度。他的方法并不是上面先除4在减49的。而是用上面coretemp说明中的value -49进行的。这个value就是读取的(23-16bit)数据,这个让我有点奇怪,amd温度中说了,currenttemp添加为(23-14bit)。真是搞不清楚。 既然可以通过linux的k8temp.c中的方法获取到,那就这样吧。现在这个k8temp.c已经支持k10了。所以完全可以借用了。有一点需要说的就是,k8temp.c中不断的写端口,以获取其他sensor和core的温度(因为amd有每个core都有2个sensor),但是这个寄存器总是不能写成功。那如何获取其他的core温度呢。这就要使用windows api了。可以通过GetProcessAffinityMask和SetProcessAffinityMask进行。不断改变当前进程所在的核心,来获取不同核的温度。 新的酷瑞CPU和AMD的CPU 内部都集成有温度传感器DTS (Digital Thermal Sensor),每个核心有一个,以前的移动CPU好像也支持温度探测,但手头没有这样的CPU没法做测试AMD 的温度值保存在 NB 寄存器中,酷瑞CPU 的 DTS 值保存在 MSR 0x19c 中,可以通过 rdmsr 来读取 这里只说酷睿CPU的读取过程 Intel 定义 eax=6 执行 cpuid, 然后测试 eax 第一位是否为1,如果为1表示CPU支持DTS ,当然之前应该以 eax=0 执行 cpuid 检测 eax 支持的最大命令数,如果小于6就肯定不支持DTS。 读取DTS: 以 ecx=0xee 执行 rdmsr 指令, 测试 eax 的第30位是否为 1, 如果为 1 表示温度计算的初始值为 85 度否则表示从100度开始计算,这个值称为 Tjunction. 然后以 ecx=0x19c 执行 rdmsr 指令, eax 的 16:23 位为表示当前DTS 值,这个值并不代表当前温度,而要以下面公式计
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 办公室项目管理简明教程
- 2024年秋九年级化学下册 第七章 溶液 7.3 溶液浓稀的表示 7.3.3 溶质质量分数的综合计算教学实录 (新版)粤教版
- 1 春夏秋冬 教学设计-2024-2025学年统编版语文一年级下册
- 红酒基本知识培训
- 2024-2025学年新教材高中物理 微专题三 共点力平衡中的四类典型问题教学实录 新人教版必修第一册
- 2024年八年级生物上册 4.4.1《遗传的物质基础》教学实录 (新版)济南版
- 找春天教学设计教案
- 2024-2025学年高中化学下学期第八周 乙醛教学实录
- 20 雾在哪里(教学设计)2024-2025学年部编版语文二年级上册
- 2024年秋九年级历史上册 第21课《日本明治维新》教学实录 中图版
- 2025年常州机电职业技术学院单招职业适应性考试题库及答案1套
- 聘请常年法律顾问合同样本7篇
- 2025年中考英语热点话题预测-哪吒(含答案)
- 2024年环北部湾广西水资源配置有限公司招聘考试真题
- 【2025新教材】教科版一年级科学下册全册教案【含反思】
- 2023-2024年演出经纪人之演出经纪实务考前冲刺模拟试卷附答案(研优卷)
- 第16课《有为有不为 》课件-2024-2025学年统编版语文七年级下册
- 上海市建设工程施工图设计文件勘察设计质量疑难问题汇编(2024 版)
- 危险化学品生产企业安全生产标准化标准2024
- 胸腔闭式引流护理-中华护理学会团体标准
- 2024年考研英语真题及答案(完整版)
评论
0/150
提交评论