如何用汇编读取cpu温度过高风扇正常及风扇

3062人阅读
最近在研究怎样获取CPU的温度,网上也有一些办法,但都不算完整,没有清晰的解决方案,现在把我的方法完整的说一下,其实是很简单的东西,没有什么很复杂的。有些地方班门弄斧,各位大侠多多担待。因为我用的是Intel的CPU,所以只做了Intel的,APU的没办法测试,感兴趣的可以研究。
Intel从Core Duo处理器开始,每一个物理核心都有一个温度传感器(DTS-Digital Thermal Sensor)用来获取核心温度,这是Intel推荐的获取温度的方法,因为DTS处在每个物理核心温度最高的位置。这个传感器的温度值是通过MSR寄存器来获得的。MSR是什么大家都知道吧,具体可以参考Developer's manual第3卷第35章。在我的下载里面有Intel的manual。
通过DTS获取温度并不是直接得到CPU的实际温度,而是两个温度的差。第一个叫做Tjmax,这个Intel叫TCC activation temperature,意思是当CPU温度达到或超过这个值时,就会触发相关的温度控制电路,系统此时会采取必要的动作来降低CPU的温度,或者直接重启或关机。所以CPU的温度永远不会超过这个值。这个值一般是100℃或85℃(也有其他值),对于具体的处理器来说就是一个固定的值。第二个就是DTS获取的CPU温度相对Tjmax的偏移值,暂且叫Toffset,那CPU的实际温度就是:currentTemp=Tjmax
- Toffset。
这两个温度值都是通过MSR来获得,获得MSR寄存器中的值用汇编指令rdmsr,Tjmax值相关的MSR的Signature是1A2H,执行
mov ecx, 0x1A2
后,eax中16~23位就是Tjmax的值。
同理,Toffset值相关的MSR的Signature是19CH,执行
mov ecx, 0x19C
后,eax中16~22(注意这里是7位)位就是Toffset的值。
问题在于,rdmsr指令需要ring0权限,而Windows下应用程序的权限都是ring3,所以如果在C中直接build-in汇编执行,程序立即停止工作。
于是我在网上猛搜怎样获取CPU的ring0权限,可惜没有找到相关的代码。这时我参考了Open Hardware Monitor这个软件,Open Hardware Monitor是用C sharp写的,可以检测各个硬件的温度和频率等,可惜我看不懂C#代码。但在里面找到了WinRing0.sys,WinRing0也是开源的,看到它的实现之后顿时大吃一惊,里面直接提供rdmsr指令的C函数,已经帮你绕过了Windows的重重城墙,当时下巴就掉下来了。
所以直接调用Rdmsr()函数就可以了,没有其它。当然要具体了解Winring0是怎样获得ring0权限的,可以直接看它的代码。
在执行MSR读取时,要先用CPUID判断处理器是否支持DTS,最近的处理器都是支持的。具体是CPUID.06H:EAX[bit0]是否被置位。置1时就是可以的。
另外,我的是处理器是4核,每个物理核心都应该对应一个温度,可我只获得了一个。跟Open Hardware Monitor对比之后,这个值总是4个核心中最小的那个,怎样获得4个核心加一个package的温度,还需要再研究。无聊还跟鲁大娘对比了一下,大娘不太靠谱,在我的处理器上低了大概10度。CPU负载突然变大时,温度会瞬间提高,大娘基本没反应。
网上还有另处一种方法我觉得是可行的,是读PMU值,端口号是68H和6CH,同样是绕过Windows来获得ring0权限,用的是WinI/O,不过我没有试。
还有一种方法说是用WMI,CSDN里面也有相关内容,但这个是哄人的,光一个架子,得不到数据。原因是WMI是通过SMBios来读DMI信息的,微软在做WMI时可能参考了SMBios协议,认为硬件厂商会往DMI里面写信息,但“幼稚”的微软并没有想到“任性”的硬件厂商并没有这么做。。。所有传感器数据都是null。但WMI在获取硬件其它信息时还是很方便的。
提到的相关的Open Hardware Monitor,Winring0,WinI/O,都在我的下载里面。最后提供一张Console里面程序的运行画面。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:3550次
排名:千里之外读取CPU核心温度 - 北漂_IT_boy - 推酷
读取CPU核心温度 - 北漂_IT_boy
最近在搞一个读取CPU温度的驱动,网上翻了好多资料,可发现全是copy的,原稿也就两三篇,可经实践发现其中不乏错误与片面,让人着实走弯路,燃起了我要总结一番的欲望。
这个驱动搞了一个多星期,总算可以运行了,测试了几台Intel和AMD的机器也都测试通过,测试对比用的是CPUID HWMonitor和Core Temp。
Intel和AMD的CPU中都有温度传感器(DTS),每个核心都有一个,温度就是由此获取来的,多核cpu可以使用 SetProcessAffinityMask API 来指定执行的CPU。
首先是利用CPUID来区分是Intel型号还是AMD型号,利用汇编和函数都可实现,考虑到64位系统不支持嵌入汇编,所以还是直接利用API函数就行。
CPUID其实就是对eax执行cpuid指令,返回信息储存在eax,ebx,ecx,edx中,令eax=0,可将CPU厂商信息返回在ebx,ecx,edx中,
int CPUInfo[4];
__cpuid(CPUInfo,0);&
Intel信息字符串为GenuineIntel,AMD为AuthenticAMD,只判断前4个字符就可以,只需与CPUInfo[1](ebx)比较就可得出型号。
接下来说如何获取温度,先从简单的说起,Intel实现起来比较简单:
先以eax=0 执行 cpuid 检测 eax 支持的最大命令数,如果小于6就肯定不支持DTS。然后以eax=6 执行 cpuid,& 然后测试 eax 第一位是否为1,如果为1表示CPU支持DTS。
&读取DTS:以 ecx=0x1A2 执行 rdmsr 指令, 测试 eax 的第30位是否为 1, 如果为 1 表示温度计算的初始值为 85 度否则表示从100度开始计算,这个值称为 Tjunction.
eax=__readmsr(0x01A2)
& & & 然后以 ecx=0x19c 执行 rdmsr 指令,& eax 的 16-23 位为表示当前DTS 值,当前温度要以下面公式计算.
&&&&&& 当前cpu温度 = Tjunction - DTS
&&&&&& 注意& signature 为 0x6f1, 0x6f0的 CPU DTS 值直接代表当前温度而不用Tjunction 相减. 而 signature 小于等于 0x6f4 的 Tjunction 一直为100。
AMD就比较恶心了,研究了挺长时间:
AMD温度存储在NB寄存器中,这是一个热传感寄存器。AMD的CPU分为K8和K10,K8的温度存储在这个寄存器的23-14位,K10的在31-21位。
要访问这个状态寄存器,需要对PCI进行读写。
先介绍俩个PCI用到的寄存器,CF8h和CFCh
CF8h: 存放配置空间的地址(CONFIG-ADDRESS)
CFCh: 保存配置空间的读写数据(CONFIG-DATA)
这两个空间对应于PCI桥路的两个寄存器,当桥路看到CPU在局部总线对这两个 I/O空间进行双字操作时,就将该I/O操作转变为PCI总线
的配置操作。
& & & & & & & & & & & & &&
如果是K8的话,可以忽略低俩位,读取23-16就可以了,当然也可以读23-14,然后\4或者&&2;
如果是K10的话,那就读取31-21
如何判断K8,K10
__cpuid(CPUInfo,1); //cpuid执行1,取出eax
t=CPUInfo[0];
family=((t&&20)&0xFF) + ((t&&8)&0xF);
model=((t&&12)&0xF0) + ((t&&4)&0xF);
stepping=t&0xF;
如果Family ==0xf 而除了
&&&&&&&&&&&&&& (((model == 4) && (stepping == 0)) ||
&&&&&&&&&&&&&&&&&&& ((model == 5) && (stepping &= 1)))
如果Family & 0xf,一般是G。那就是K10
温度的计算公式
K8 Temp = Value - 49'.&& 49这个值需要修正的:if (model &= 0x69 && model != 0xc1 && model != 0x6c && model != 0x7c) &temp=Value-49+21;
K10 Temp = Value / 8'.
IO访问PCI总线设备配置空间
配置空间地址寄存器的格式:
31&&&&& 24 23&&&&&&&& 16 15&&&&&&&&&&& 11 10&&&&&&&&&&&&& 8 7&&&&&&&&&&&&&& 2 1&& 0
| reserve | bus number | device number | function number | register number | 0 | 1/0 |
所以知道 bus number, device number, function number, register number后,可以这么来构造配置空间地址寄存器
IOADDR = 0x+bus*0x10000 +(device*8)*0x100 + uFunction&0x07 + register number&~3;
为什么需要0x呢,因为
当CPU发出对I/O空间CFCh的操作时,PCI桥路将检查配置空间地址寄存器CF8h的31位。如果为1,就在PCI总线上产生一个相应的配置空
间读或写操作,0x就是使配置空间地址寄存器为1。
经过上面的讨论后,可以写成
#define DeviceSlot(uDevice, uFunction) ((((uDevice)&0x1f)&&3)|((uFunction)&0x07))
#define GetDevice(uBus,uSlot,uAddress) (0xL |((uBus&0xff)&&16)|(uSlot&&8)|(uAddress&~3));
这样知道 uBus, uDevice, uFunction, uAddress后就可以通过IO指令来读写了。
对于K8, uAddress为0xE4,对于K10 uAddress为0xA4
怎样获取uBus, uDevice, uFunction
从上面知道GetDevice需要 uBus, uDevice, uFunction的。
可以扫描PCI总线来获取,对于AMD K8来说,设备ID为0x1103,对于K10来说,设备ID为0x1203。 二者的uFunction都为3.
通过扫描PCI总线,匹配设备ID来获取。
BOOL get_bus_dev( int devieid,int *BUS, int *DEV ) //遍历PCI得到bus和dev
ULONG func=3; //K8 K10 fun为3
unsigned long S
PCI_COMMON_CONFIG PciC
PCI_SLOT_NUMBER SlotN
for(bus = 0; bus &= 255; ++bus)
for(dev = 0; dev &= 31; ++dev)
SlotNumber.u.AsULONG = 0;
SlotNumber.u.bits.DeviceNumber =
SlotNumber.u.bits.FunctionNumber =
RtlZeroMemory(&PciConfig, sizeof(PCI_COMMON_CONFIG));
Size = HalGetBusData(PCIConfiguration,
SlotNumber.u.AsULONG,
&PciConfig,
PCI_COMMON_HDR_LENGTH); //API函数
if (Size==PCI_COMMON_HDR_LENGTH)
if ( devieid==PciConfig.DeviceID )
DbgPrint(&BUS:%d \n&,bus);
DbgPrint(&DEV:%d \n&,dev);
return TRUE;
然后进行IO读写就可以获取温度了,K8:
static once =1;
int bus,dev,
if ( !get_bus_dev(0x1103,&bus,&dev) )
DbgPrint(&获取BUS、DEV失败! \n&);
slot=DeviceSlot(dev,0x3); &//上面定义的宏
IO_ADDRE=GetDevice(bus,slot,0xE4);&&//上面定义的宏
_outpd(0xCF8,IO_ADDRE);//端口读写
CPUTemp=_inpd(0xCFC);//端口读写
CPUTemp=(CPUTemp&&16)&0xFF;
CPUTemp=CPUTemp - g_O//g_Offset为49-21
DbgPrint(&CPUTemp: %d \n&,CPUTemp);
已发表评论数()
请填写推刊名
描述不能大于100个字符!
权限设置: 公开
仅自己可见
正文不准确
标题不准确
排版有问题
主题不准确
没有分页内容
图片无法显示
视频无法显示
与原文不一致2860人阅读
这是文章最后一次更新,加入了TLB与Cache信息等资料
前言:论坛上面有人不明白CPUID指令的用法,于是就萌生写这篇文章的想法,
若有错误话请大侠指出,谢谢了 ^^
论坛的式样貌似有问题,若式样问题导致阅读问题的话,可以在文章尾下载txt文档阅读.
论坛上面有人不明白CPUID指令的用法,于是就萌生写这篇文章的想法,
若有错误话请大侠指出,谢谢了 ^^
CPUID是Intel Pentium以上级CPU内置的一个指令(486级及以下的CPU不支持),它用于识别某一类型的CPU,它能返回CPU的级别(family),型号(model),CPU步进(Stepping ID)及CPU字串等信息,从此命令也可以得到CPU的缓存与TLB信息.
CPUID返回数据类型是在EAX寄存器里面定义的,而指令返回的数值则在存储在EAX,EBX,ECX和EDX寄存器里面.
返回的信息分两部分:基本信息与扩展信息.在EAX输入0-3参数时,它返回的CPU的基本信息;而在EAX输入0xx800000x时,它返回的是CPU的扩展信息(extended function information).扩展信息只包含在Pentium 4及以后的CPU上,Pentium 4以前的CPU无法取得它的扩展信息.
如下面的表:
CPU级别&&&&&&&& 基本信息&& 扩展信息
486及以前的CPU&&&&& 不可用&&& 不可用
Pentium&&&&&&& 0x1&&& 不可用
Pentium Pro,Pentium 2&&& 0x2&&& 不可用
Pentium 3&&&&& 0x3&&& 不可用
Pentium 4&&&&& 0x2&&& 0x
Xeon(至强)&&&&& 0x2&&& 0x
假若输入高于该处理器的值时,CPUID指令返回的是该CPU的输入最高值的返回值(这一句不知道怎么说才好),
比如在在Pentium 4上输入0x4,则CPU返回值与输入0x2的返回值一样.
下面的表是输入值与返回值的关系:
输入值&&&&&&& 返回值
-----------------------------------------------------------------
0x0&&&&& EAX& CPU基本参数的输入值
&&&&& EBX& &Genu&
&&&&& ECX& &Intel&
&&&&& EDX& &inel&
------------------------------------------------------------------
0x1&&&&& EAX& CPU的级别,型号及步进
&&&&& EBX& 信息很多,下面介绍
&&&&& ECX& 保留
&&&&& EDX& 特征信息(Feature Information)
------------------------------------------------------------------
0x2&&&&& EAX到EDX返回的都是缓存和TLB的信息
------------------------------------------------------------------
0x3&&&&& EAX& 保留
&&&&& EBX& 保留
&&&&& ECX& CPU序列号(0 - 31bit) (只是在Pentium 3中才有效)
&&&&& EDX& CPU序列号(32 - 63bit) (只是在Pentium 3 中才有效)
------------------------------------------------------------------
0x&&& EAX& 扩展信息输入数最大值(具有扩展信息的CPU才能返回)
&&&&& EBX& 保留
&&&&& ECX& 保留
&&&&& EDX& 保留
------------------------------------------------------------------
0x&&& EAX& CPU特征(Signature)和扩展特征位(Extended Feature Bits)
&&&&& EBX 到 ECX& 保留
------------------------------------------------------------------
0x&&& EAX& 处理器字串(Processor Brand String)
&&&&& EBX& 处理器字串(续)
&&&&& ECX& 处理器字串(续)
&&&&& EDX& 处理器字串(续)
------------------------------------------------------------------
0x&&& EAX& 处理器字串(续)
&&&&& EBX& 处理器字串(续)
&&&&& ECX& 处理器字串(续)
&&&&& EDX& 处理器字串(续)
------------------------------------------------------------------
0x&&& EAX& 处理器字串(续)
&&&&& EBX& 处理器字串(续)
&&&&& ECX& 处理器字串(续)
&&&&& EDX& 处理器字串(续)
------------------------------------------------------------------
当输入0x1时,EBX返回值是:
第 0 -& 7位: CPU字串索引 (Brand Index)
第 8 - 15位: CLFLUSH线大小(CLFLUSH line size) (返回值*8 = cache line size)
第16 - 23位: 保留
第24 - 31位: 处理器APIC物理标号 (Processor local APIC physical ID)
当输入0x1时,EDX返回的扩展信息解释如下:
位& 标号&&& 解释
0& FPU& Floating Point Unit On-Chip. CPU是否内置浮点计算单元
1& VME& Virtual 8086 Mode Enhancements. 是否支持虚拟8086模式
2& DE& Debugging Extensions. 是否支持调试功能.
3& PSE& Page Size Extension. 是否支持大于4MB的分页.
4& TSC& Time Stamp Counter. 是否支持RDTSC指令.(注:RDTSC指令可以计算出CPU的频率)
5& MSR& Module Specific Registers RDMSR and WRMSR Instructions. 是否支持RDMSR与WRMSR (*注1)
6& PAE& Physical Address Extension. 是否支持大于32bit的物理地址.
7& MCE& Machine Check Exception. (*注2)
8& CX8& CMPXCHG8B Instruction. 是否支持8bytes(64bit)数的比较与交换指令.
9& APIC& APIC On-Chip.是否支持APIC(Advanced Programmable Interrupt Controller)
11& SEP& SYSENTER and SYSEXIT Instructions.是否支持SYSENTER与SYSEXIT指令.(*注3)
12& MTRR& Memory Type Range Registers. 是否支持MTTR(*注4)
13& PGE& PTE Global Bit. 是否支持全局页面目录入口标志位 (global bit in page directory entries)
14& MCA& Machine Check Architecture. 是否支持MCA,MCA是Pentium4,Xeon,P6级处理器的一个错误报告机制
15& CMOV& Conditional Move Instructions. CMOV指令是否可用.(请问谁可以解释一下CMOV是什么命令?)
16& PAT& Page Attribute Table. 是否支持PAT,PAT允许操作系统指定4K大小的线性内存空间
17& PSE-36& 32-bit Page Size Extension. 是否支持4GB的扩展内存
18& PSN& Processor Serial Number. 是否支持处理器序列号.(P3有效)
19& CLFSH& CLFLUSH Instruction.是否支持CLFLUSH.(*注5)
21& DS& Debug Store. 是否支持把调试信息写入缓存,
22& ACPI& ACPI Processor Performance Modulation Registers. 处理器使用特别的寄存器以允许软件控制处理器的运行周期.
23&& MMX& Inter MMX Technology.是否支持MMX
24& FXSR& FXSAVE and FXRSTOR Instructions. FXSAVE与FXRSTOR指令是否可用(*注6)
25& SSE& SSE.是否支持SSE.
26& SSE2& 是否支持SSE2.
27& SS& Self Snoop. 处理器是否支持总线监视,以防止储存器冲突.
29& TM& Thermal Monitor.CPU是否支持温度控制.
30 & 31& 保留
--------------------------------------------------------------
注1: RDMSR: Load MSR specified by ECX into EDX:EAX
&&&& WRMSR: Write the value in EDX:EAX to MSR specified by ECX
原文是Exception 18 is defined for Machine Checks,including CR4.MCE for controlling the feature. This feature does not define themodel-specific implementations of machine-check error logging, reporting, andprocessor shutdowns. Machine Check exception handlers may
have to depend onprocessor version to do model specific processing of the exception, or test for thepresence of the Machine Check feature.
注3: SYSENTER: Fast call to privilege level 0 system procedures
&&&& SYSEXIT:& Fast return to privilege level 3 user code.
原文是The MTRRcap MSR contains feature bits that describe what memory types are supported, how manyvariable MTRRs are supported, and whether fixed MTRRs are supported.
注5: CLFLUSH: Flushes cache line containing m8.
注6: FXSAVE: Save the x87 FPU, MMX, XMM, and MXCSR register
&&&& FXSTOR: Restore the x87 FPU, MMX, XMM, and MXCSR register
按照这个,就可以自己写一个CPU检测程序了;
#include &stdio.h&
void main()
& unsigned long DBaseIndex, DFeInfo, DFeInfo2, DCPUBaseI
& unsigned long DFeIndex, DCPUExInfo,
& unsigned long DOther[4], DTLB[4], DProceSN[2];
& char cCom[13];
& char cProStr[49];
&&& xor eax, eax
&&& mov DBaseIndex&&&&& ,eax
&&& mov dword ptr cCom&&& ,ebx
&&& mov dword ptr cCom+4& ,ecx //AMD CPU要把ecx改为edx
&&& mov dword ptr cCom+8& ,edx //AMD CPU要把edx改为ecx
&&& mov eax, 1
&&& mov DCPUBaseInfo, eax
&&& mov DFeInfo, ebx&
&&& mov DFeInfo2, edx
&&& mov eax, 0x
&&& mov DFeIndex, eax
&&& mov eax, 0x
&&& mov DCPUExInfo, eax
&&& mov eax, 0x
&&& mov dword ptr cProStr&&& , eax
&&& mov dword ptr cProStr + 4& , ebx
&&& mov dword ptr cProStr + 8& , ecx
&&& mov dword ptr cProStr + 12& ,edx
&&& mov eax, 0x
&&& mov dword ptr cProStr + 16& , eax
&&& mov dword ptr cProStr + 20& , ebx
&&& mov dword ptr cProStr + 24& , ecx
&&& mov dword ptr cProStr + 28& , edx
&&& mov eax, 0x
&&& mov dword ptr cProStr + 32& , eax
&&& mov dword ptr cProStr + 36& , ebx
&&& mov dword ptr cProStr + 40& , ecx
&&& mov dword ptr cProStr + 44& , edx
& if( DBaseIndex &= 2 )
&&&&& mov eax, 2
&&&&& cpuid
&&&&& mov DTLB[0], eax
&&&&& mov DTLB[2], ebx
&&&&& mov DTLB[3], ecx
&&&&& mov DTLB[4], edx
& if(DBaseIndex == 3)
&&&&& mov eax, 3
&&&&& cpuid
&&&&& mov DProceSN[0], ecx
&&&&& mov DProceSN[1], edx
& cCom[12] = '/0'; //加一个结尾符
& printf( &CPU厂商:& %s/n&, cCom );
& printf( &CPU字串:& %s/n&, cProStr );
& printf( &CPU基本参数: Family:%X& Model:%X& Stepping ID:%X/n&, (DCPUBaseInfo & 0x0F00) && 8,
&&&&& (DCPUBaseInfo & 0xF0) && 4, DCPUBaseInfo & 0xF );
& printf( &CPU扩展参数: Family:%X& Model:%X& Stepping ID:%X/n&, (DCPUExInfo & 0x0F00) && 8,
&&&&& (DCPUExInfo & 0xF0) && 4, DCPUExInfo & 0xF );
& printf( &CPU字串索引: 0x%X/n&, DFeInfo & 0xFF );
& printf( &CLFLUSH线大小: 0x%X/n&, ( DFeInfo & 0xFF00 ) && 8 );
& printf ( &处理器APIC物理标号:0x%X/n&, ( DFeInfo & 0xF000 ) && 24 );
& if( DBaseIndex &= 2)
&&& printf( &CPU Cache & TLB Information: & );
&&& for(j = 0; j & 4; j++)
&&&&& if( !(DTLB[j] & 0xFF) ) printf( &%.2X &, DTLB[j] & 0xFF );
&&&&& if( !((DTLB[j] & 0xFF) && 8) ) printf( &%.2X &, (DTLB[j] & 0xFF00) && 8 );
&&&&& if( !((DTLB[j] & 0xFF0000) && 16) ) printf( &%.2X &,( DTLB[j] & 0xFF0000) && 16);
&&&&& if( !((DTLB[j] & 0xFF000000) && 24) ) printf( &%.2X &,( DTLB[j] & 0xFF000000) && 24);
&&& printf(&/n&);
& if( DBaseIndex == 3 )
&&& printf( &CPU序列号是:%X%X/n&, DProceSN[0], DProceSN[1] );
&&& printf( &FPU:& %d/t/t&, DFeInfo2 & 0x ); //下面是调用某BLOG上面的代码,懒得写了 ^^
&&& printf( &VME:& %d/t/t&, (DFeInfo2 & 0x ) && 1 );
&&& printf( &DE:& %d/n&, (DFeInfo2 & 0x ) && 2 );
&&& printf( &PSE:& %d/t/t&, (DFeInfo2 & 0x ) && 3 );
&&& printf( &TSC:& %d/t/t&, (DFeInfo2 & 0x ) && 4 );
&&& printf( &MSR:& %d/n&, (DFeInfo2 & 0x ) && 5 );
&&& printf( &PAE:& %d/t/t&, (DFeInfo2 & 0x ) && 6 );
&&& printf( &MCE:& %d/t/t&, (DFeInfo2 & 0x ) && 7 );
&&& printf( &CX8:& %d/n&, (DFeInfo2 & 0x ) && 8 );
&&& printf( &APIC:& %d/t&, (DFeInfo2 & 0x ) && 9 );
&&& printf( &SEP:& %d/t/t&, (DFeInfo2 & 0x ) && 11 );
&&& printf( &MTRR:& %d/n&, (DFeInfo2 & 0x ) && 12 );
&&& printf( &PGE:& %d/t/t&, (DFeInfo2 & 0x ) && 13 );
&&& printf( &MCA:& %d/t/t&, (DFeInfo2 & 0x ) && 14 );
&&& printf( &CMOV:& %d/n&, (DFeInfo2 & 0x ) && 15 );
&&& printf( &PAT:& %d/t/t&, (DFeInfo2 & 0x ) && 16 );
&&& printf( &PSE-36:& %d/t&, (DFeInfo2 & 0x ) && 17 );
&&& printf( &PSN:& %d/n&, (DFeInfo2 & 0x ) && 18 );
&&& printf( &CLFSN:& %d/t&, (DFeInfo2 & 0x ) && 19 );
&&& printf( &DS:& %d/t/t&, (DFeInfo2 & 0x ) && 21 );
&&& printf( &ACPI:& %d/n&, (DFeInfo2 & 0x ) && 22 );
&&& printf( &MMX:& %d/t/t&, (DFeInfo2 & 0x ) && 23 );
&&& printf( &FXSR:& %d/t&, (DFeInfo2 & 0x ) && 24 );
&&& printf( &SSE:& %d/n&, (DFeInfo2 & 0x ) && 25 );
&&& printf( &SSE2:& %d/t&, (DFeInfo2 & 0x ) && 26 );
&&& printf( &SS:& %d/t/t&, (DFeInfo2 & 0x ) && 27 );
&&& printf( &TM:& %d/n&, (DFeInfo2 & 0x ) && 29 );
printf(&/n其它信息:/n&);
& printf(&----------------------------------------/n&);
& printf(&In /t/tEAX /t/tEBX /t/tECX /t/tEDX&);
& for( i = 0x; i &= DFeI ++i )
&&& DOther[0] = DOther[1] = DOther[2] = DOther[3] = 0;
&&&&& mov eax, i
&&&&& cpuid
&&&&& mov DOther[0], eax
&&&&& mov DOther[1], ebx
&&&&& mov DOther[2], ecx
&&&&& mov DOther[3], edx
&&& printf( &/n0x%.8X/t0x%.8X/t0x%.8X/t0x%.8X/t0x%.8X&, i, DOther[0], DOther[1], DOther[2], DOther[3] );
& printf( &/n& );
& system( &pause& );
TLB与Cache信息详解:
0x00& Null descriptor
0x01& Instruction TLB: 4K-Byte Pages, 4-way set associative, 32 entries
0x02& Instruction TLB: 4M-Byte Pages, 4-way set associative, 2 entries
0x03& Data TLB: 4K-Byte Pages, 4-way set associative, 64 entries
0x04& Data TLB: 4M-Byte Pages, 4-way set associative, 8 entries
0x06& 1st-level instruction cache: 8K Bytes, 4-way set associative, 32 byte line size
0x08& 1st-level instruction cache: 16K Bytes, 4-way set associative, 32 byte line size
0x0A& 1st-level data cache: 8K Bytes, 2-way set associative, 32 byte line size
0x0C& 1st-level data cache: 16K Bytes, 4-way set associative, 32 byte line size
0x22& 3rd-level cache: 512K Bytes, 4-way set associative, 64 byte line size
0x23& 3rd-level cache: 1M Bytes, 8-way set associative, 64 byte line size
0x25& 3rd-level cache: 2M Bytes, 8-way set associative, 64 byte line size
0x29& 3rd-level cache: 4M Bytes, 8-way set associative, 64 byte line size
0x40& No 2nd-level cache or, if processor contains a valid 2nd-level cache, no 3rd-level cache
0x41& 2nd-level cache: 128K Bytes, 4-way set associative, 32 byte line size
0x42& 2nd-level cache: 256K Bytes, 4-way set associative, 32 byte line size
0x43& 2nd-level cache: 512K Bytes, 4-way set associative, 32 byte line size
0x44& 2nd-level cache: 1M Byte, 4-way set associative, 32 byte line size
0x45& 2nd-level cache: 2M Byte, 4-way set associative, 32 byte line size
0x50& Instruction TLB: 4-KByte and 2-MByte or 4-MByte pages, 64 entries
0x51& Instruction TLB: 4-KByte and 2-MByte or 4-MByte pages, 128 entries
0x52& Instruction TLB: 4-KByte and 2-MByte or 4-MByte pages, 256 entries
0x5B& Data TLB: 4-KByte and 4-MByte pages, 64 entries
0x5C& Data TLB: 4-KByte and 4-MByte pages,128 entries
0x5D& Data TLB: 4-KByte and 4-MByte pages,256 entries
0x66& 1st-level data cache: 8KB, 4-way set associative, 64 byte line size
0x67& 1st-level data cache: 16KB, 4-way set associative, 64 byte line size
0x68& 1st-level data cache: 32KB, 4-way set associative, 64 byte line size
0x70& Trace cache: 12K-μop, 8-way set associative
0x71& Trace cache: 16K-μop, 8-way set associative
0x72& Trace cache: 32K-μop, 8-way set associative
0x79& 2nd-level cache: 128KB, 8-way set associative, sectored, 64 byte line size
0x7A& 2nd-level cache: 256KB, 8-way set associative, sectored, 64 byte line size
0x7B& 2nd-level cache: 512KB, 8-way set associative, sectored, 64 byte line size
0x7C& 2nd-level cache: 1MB, 8-way set associative, sectored, 64 byte line size
0x82& 2nd-level cache: 256K Bytes, 8-way set associative, 32 byte line size
0x84& 2nd-level cache: 1M Byte, 8-way set associative, 32 byte line size
0x85& 2nd-level cache: 2M Byte, 8-way set associative, 32 byte line size
举一个例子,一个CPU执行
mov eax, 2
返回值如下:
EAX 0x665B5001
EDX 0x007A7000
就代表了这个CPU的Cache信息是:
1. 0x66:1st-level data cache: 8KB, 4-way set associative, 64 byte line size
2. 0x5B:Data TLB: 4-KByte and 4-MByte pages, 64 entries
3. 0x50:Instruction TLB: 4-KByte and 2-MByte or 4-MByte pages, 64 entries
4. 0x01:Instruction TLB: 4K-Byte Pages, 4-way set associative, 32 entries
5. 0x7A:2nd-level cache: 256KB, 8-way set associative, sectored, 64 byte line size
6. 0x70:Trace cache: 12K-μop, 8-way set associative
CPU字串索引 (Brand Index)详解:
0x0: CPU不支持Brand Index
0x1: Celeron CPU
0x2: Pentium 3
0x3: Pentium 3 Xeon
0x4-0x7: 未用
0x8: Pentium 4
可惜我是用AMD CPU的,有好些功能都不能亲自试验
参考资料:IA-32 Intel Architecture Software Developer’s Manual
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:243532次
积分:3058
积分:3058
排名:第9937名
原创:35篇
转载:232篇
评论:17条
(2)(25)(2)(1)(13)(15)(13)(3)(5)(1)(3)(7)(7)(7)(1)(1)(1)(1)(1)(9)(2)(7)(4)(3)(6)(5)(1)(2)(4)(4)(4)(2)(4)(2)(3)(3)(7)(2)(3)(1)(3)(8)(11)(3)(6)(1)(1)(2)(2)(1)(9)(29)(3)(2)(1)}

我要回帖

更多关于 cpu温度风扇监测软件 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信