⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpu检测.txt

📁 大量Delphi开发资料
💻 TXT
📖 第 1 页 / 共 2 页
字号:
   bit 9 (APIC)  APIC #2
   bit 8 (CX8)  CMPXCHG8B
   bit 7 (MCE)  MCAR/MCTR MSRs, CR4.MCE, #MC
   bit 6 (PAE)  64bit PDPTE/PDE/PTEs, CR4.PAE
   bit 5 (MSR)  MSRs, RDMSR/WRMSR
   bit 4 (TSC)  TSC, RDTSC, CR4.TSD (doesn't imply MSR=1)
   bit 3 (PSE)  PDE.PS, PDE/PTE.res, CR4.PSE, #PF(1xxxb)
   bit 2 (DE)  CR4.DE, DR7.RW=10b, #UD on MOV from/to DR4/5
   bit 1 (VME)  CR4.VME/PVI, EFLAGS.VIP/VIF, TSS32.IRB
   bit 0 (FPU)  FPU
说明  内容
#0  Intel 处理器不支持; 返回值EAX, EBX, ECX, 和 EDX都是0.
#1  AMD K6 处理器, model 6, uses 使用第十位指示SEP.
#2  如果APIC是无效的,那么APIC读到的是0.
#3  AMD CPUID=0662h的K7 处理器如果是具有多处理器能力的版本可能也报告时0
 EAX= 8000_0002h, 8000_0003h, and 8000_0004h 
输入  EAX=8000_0002h  得到处理器名称的第一部分
 EAX=8000_0003h  得到处理器名称的第二部分
 EAX=8000_0004h  得到处理器名称的第三部分
输出  EAX
EBX
ECX
EDX  处理器名称字符串#1
   AMD K5  AMD-K5(tm) 处理器
   AMD K6  AMD-K6tm w/ multimedia extensions
   AMD K6-2  AMD-K6(tm) 3D 处理器
AMD-K6(tm)-2 处理器
   AMD K6-III  AMD-K6(tm) 3D+ 处理器
AMD-K6(tm)-III 处理器
   AMD K6-2+  AMD-K6(tm)-III 处理器 (?)
   AMD K6-III+  AMD-K6(tm)-III 处理器 (?)
   AMD K7  AMD-K7(tm) 处理器 (model 1)
AMD Athlon(tm) 处理器 (model 2)
AMD Athlon(tm) 处理器 (models 3/4, 6/7, and 8 -- programmable) 
AMD K8 programmable via MSRs C001_0030h..C001_0035h, default is 48x 00h 
   Centaur C2 #2  IDT WinChip 2
IDT WinChip 2-3D
   VIA Cyrix III  CYRIX III(tm) (?)
VIA Samuel (?)
VIA Ezra (?)
   Intel P4  Intel(R) Pentium(R) 4 CPU xxxxMHz (right-justified, leading whitespaces)顺便说一句,Intel只有P4以上才支持。
   Transmeta  Transmeta(tm) Crusoe(tm) 处理器 TMxxxx
说明  内容
#1  是一个字符数组,以0H结尾.
#2  WinChip是否支持决定于是否支持3D Now!.
 EAX= 8000_0005h 
输入  EAX=8000_0005h  得到L1缓存容量和入口数量 #1
输出  EAX  4/2 MB L1 入口信息
   EAX的位  描述
   31..24  data TLB associativity (FFh=full)
   23..16  data TLB entries
   15..8  code TLB associativity (FFh=full)
   7..0  code TLB entries
 EBX  4 KB L1入口信息
   bits  description
   31..24  data TLB associativity (FFh=full)
   23..16  data TLB entries
   15..8  code TLB associativity (FFh=full)
   7..0  code TLB entries
 ECX  data L1 信息描述
   bits  description
   31..24  data L1 cache size in KBs
   23..16  data L1 cache associativity (FFh=full)
   15..8  data L1 cache lines per tag
   7..0  data L1 cache line size in bytes
 EDX  code L1信息描述
   bits  description
   31..24  code L1 cache size in KBs
   23..16  code L1 cache associativity (FFh=full)
   15..8  code L1 cache lines per tag
   7..0  code L1 cache line size in bytes
说明  description
#1  Cyrix 处理器使用0000_0002h做类似的描述
 EAX= 8000_0006h 
输入  EAX=8000_0006h  得到L1缓存容量和入口数量
输出  EAX  4/2 MB L2 入口信息 #1
   位  描述
   31..28  data TLB associativity #2
   27..16  data TLB entries
   15..12  code TLB associativity #2
   11..0  code TLB entries
 EBX  4 KB L2 入口信息 
   位  描述
   31..28  data TLB associativity #1
   27..16  data TLB entries
   15..12  code TLB associativity #1
   11..0  code TLB entries
 ECX  统一 L2 cache 信息 #32
   bits  description
   31..16 #4  unified L2 cache size in KBs #3
   15..12 #4  unified L2 cache associativity #1
   11..8 #4  unified L2 cache lines per tag
   7..0  unified L2 cache line size in bytes
说明  描述
#1  0000b=L2 off, 0001b=direct mapped, 0010b=2-way, 0100b=4-way, 0110b=8-way, 1000b=16-way, 1111b=full
#2  AMD K7 处理器 L2 cache 必须依赖于此信息.
#3  AMD PUID=0630h 的K7 处理器(Duron) 具有 64 KB二级缓存,但是却报告只有1KB.
#4  VIA Cyrix III CPUID=0670..068Fh (C5B/C5C)的处理器错误报告bits 31..24, 23..16, and 15..8.
 EAX 8000_0007h 
输入  EAX=8000_0007h  电源管理信息(EPM)
输出  EDX  EPM flags
   位  说明
   31..3  保留
   2 (VID)  voltage ID control supported
   1 (FID)  frequency ID control supported
   0  temperature sensing diode supported
EAX= 8000_0008h 
输入  EAX=8000_0008h  得到地址大小信息
输出  EAX  地址大小信息
   位  说明
   31..16  保留
   15..8  virtual address bits
   7..0  physical address bits
 Transmeta EAX= 8086_0000h 
输入  EAX=8086_0000h  得到CPUID的最大支持和厂商字符串
输出  EAX=xxxx_xxxxh  最大支持 EAX=l
 EBX-EDX-ECX  厂商字符串
   TransmetaCPU  Transmeta processor
 Transmeta EAX= 8086_0001h 
输入  EAX=8086_0001h  得到处理器信息
输出  EAX=0000_0xxxh  处理器信息
   family  The family is encoded in bits 11..8.
       5  Transmeta Crusoe TM3x00 and TM5x00 
   model  The model is encoded in bits 7..4.
     Transmeta  4  Crusoe TM3x00 and TM5x00
   stepping  The stepping is encoded in bits 3..0.
     The stepping values are processor-specific.
 EBX=aabb_ccddh  hardware revision (a.b-c.d), if 2000_0000h: see EAX=l 8086_0002h register EAX instead
 ECX=xxxx_xxxxh  nominal core clock frequency (MHz)
 EDX=xxxx_xxxxh  feature flags  description of indicated feature
   bits 31..4  reserved
   bit 3 (LRTI)  LongRun Table Interface
   bit 2 (???)  unknown
   bit 1 (LR)  LongRun
   bit 0 (BAD)  recovery CMS active (due to a failed upgrade)
 Transmeta EAX= 8086_0002h 
输入  EAX=8086_0002h  得到处理器信息
输出  EAX  xxxx_xxxxh  reserved or hardware revision (xxxxxxxxh)
see EAX=l 8086_0001h register EBX for details 
 EBX  aabb_ccddh  software revision, part 1/2 (a.b.c-d-x)
 ECX  xxxx_xxxxh  software revision, part 2/2 (a.b.c-d-x)
 Transmeta EAX=8086_0003h, 8086_0004h, 8086_0005h, and 8086_0006h 
输入  EAX=8086_0003h  得到信息字符串第一部分
 EAX=8086_0004h  得到信息字符串第一部分
 EAX=8086_0005h  得到信息字符串第一部分
 EAX=8086_0006h  得到信息字符串第一部分
输出  EAX-EBX-ECX-EDX  信息字符串 #1
   Transmeta  20000805 23:30 official release 4.1.4#2 (例子)
说明  说明
#1  以00h为结尾的字符串.
 Transmeta EAX= 8086_0007h 
输入  EAX=8086_0007h  得到处理器信息
输出  EAX  xxxx_xxxxh  当前时钟频率 (MHz)
 EBX  xxxx_xxxxh  当前电压 (mV)
 ECX  xxxx_xxxxh  当前占用率 (0..100%)
 EDX  xxxx_xxxxh  当前的延迟 (fs)
 神秘的功能 EAX= 8FFF_FFFEh 
输入  EAX=8FFF_FFFEh  未知 #1
输出  EAX  0049_4544h  DEI (according to one source: Divide Et Impera = Divide And Rule)
 EBX  0000_0000h  保留
 ECX  0000_0000h  保留
 EDX  0000_0000h  保留
说明  说明
#1  这个方法仅仅被 AMD K6 支持.
 神秘的功能EAX= 8FFF_FFFFh 
输入  EAX=8FFF_FFFFh  未知 #1
输出  EAX
EBX
ECX
EDX  string  NexGenerationAMD
说明  说明
#1  这个方法只被he AMD K6支持.
其他
输入  EAX=xxxx_xxxxh  其他
输出  EAX=xxxx_xxxxh
EBX=xxxx_xxxxh
ECX=xxxx_xxxxh
EDX=xxxx_xxxxh  不明确
代码如下:
type
  TCPUIDResult = packed record
    EAX: DWord;
    EBX: DWord;
    ECX: DWord;
    EDX: DWord;
  end;
  TCPUInfo =packed record
    Name: string[48];
    Brand: Word;
    APIC: DWORD;
    Vendor: string[12];
    Frequency: Real;
    Family: integer;
    Model: integer;
    Stepping: integer;
    EFamily: integer;
    EModel: integer;
    EStepping: integer;
    MMX: Boolean;
    MMXPlus: Boolean;
    AMD3DNow: Boolean;
    AMD3DNowPlus: Boolean;
    SSE: Boolean;
    SSE2: Boolean;
    IA64: Boolean;
    X86_64: Boolean;
  end;

function CPUID(EAX: DWord): TCPUIDResult;
var
  rEAX, rEBX, rECX, rEDX: DWord;
begin
  asm
    push EAX
    push EBX
    push ECX
    push EDX
    mov EAX,EAX
    //******************************************************
    //cpuid指令,因为Delphi的汇编编译器没有内置该指令,
    //所以用该指令的机器语言代码$0F,$A2来实现
    //******************************************************
    db $0F,$A2
    mov rEAX,EAX
    mov rEBX,EBX
    mov rECX,ECX
    mov rEDX,EDX
    pop EDX
    pop ECX
    pop EBX
    pop EAX
  end;
  Result.EAX := rEAX;
  Result.EBX := rEBX;
  Result.ECX := rECX;
  Result.EDX := rEDX;
end;

function GetCPUSpeed: Real;
const
  timePeriod        = 1000;
var
  HighFreq, TestFreq, Count1, Count2: int64;
  TimeStart         : integer;
  TimeStop          : integer;
  ElapsedTime       : dword;
  StartTicks        : dword;
  EndTicks          : dword;
  TotalTicks        : dword;
begin
  StartTicks := 0;
  EndTicks := 0;
  if QueryPerformanceFrequency(HighFreq) then
  begin

    TestFreq := HighFreq div 100;

    QueryPerformanceCounter(Count1);
    repeat
      QueryPerformanceCounter(Count2);
    until Count1 <> Count2;
    asm
      push ebx
      xor eax,eax
      xor ebx,ebx
      xor ecx,ecx
      xor edx,edx
      db $0F,$A2               /// cpuid
      db $0F,$31               /// rdtsc
      mov StartTicks,eax
      pop ebx
    end;

    repeat
      QueryPerformanceCounter(Count1);
    until Count1 - Count2 >= TestFreq;

    asm
      push ebx
      xor eax,eax
      xor ebx,ebx
      xor ecx,ecx
      xor edx,edx
      db $0F,$A2               /// cpuid
      db $0F,$31               /// rdtsc
      mov EndTicks,eax
      pop ebx
    end;

    ElapsedTime := MulDiv(Count1 - Count2, 1000000, HighFreq);
  end
  else
  begin
    timeBeginPeriod(1);
    TimeStart := timeGetTime;

    repeat
      TimeStop := timeGetTime;
    until TimeStop <> TimeStart;

    asm
      push ebx
      xor eax,eax
      xor ebx,ebx
      xor ecx,ecx
      xor edx,edx
      db $0F,$A2               /// cpuid
      db $0F,$31               /// rdtsc
      mov StartTicks,eax
      pop ebx
    end;

    repeat
      TimeStart := timeGetTime;
    until TimeStart - TimeStop >= timePeriod;

    asm
      push ebx
      xor eax,eax
      xor ebx,ebx
      xor ecx,ecx
      xor edx,edx
      db $0F,$A2               /// cpuid
      db $0F,$31               /// rdtsc
      mov EndTicks,eax
      pop ebx
    end;
    timeEndPeriod(1);

    ElapsedTime := (TimeStart - TimeStop) * 1000;
  end;
  TotalTicks := EndTicks - StartTicks;
  result := TotalTicks / ElapsedTime;
end;

function getCPUInfo: TCPUInfo;
type
  TRegChar = array[0..3] of char;
var
  lvCPUID           : TCPUIDResult;
  I                 : Integer;
begin
  lvCPUID := CPUID(0);
  Result.Vendor := TRegChar(lvCPUID.EBX) + TRegChar(lvCPUID.EDX) +
    TRegChar(lvCPUID.ECX);
  lvCPUID := CPUID(1);
  Result.Frequency := GetCPUSpeed;
  Result.Family := (lvCPUID.EAX and $F00) shr 8;
  Result.Model := (lvCPUID.EAX and $78) shr 4;
  Result.Stepping := (lvCPUID.EAX and $F);
  Result.EFamily := (lvCPUID.EAX and $7800000) shr 20;
  Result.EModel := (lvCPUID.EAX and $78000) shr 16;
  Result.EStepping := (lvCPUID.EAX and $F);
  Result.APIC := (lvCPUID.EBX and $1FE00000) shr 23;
  Result.Brand := lvCPUID.EBX and $7F;
  Result.MMX := (lvCPUID.EDX and $800000) = $800000;
  Result.SSE := (lvCPUID.EDX and $2000000) = $2000000;
  Result.SSE2 := (lvCPUID.EDX and $4000000) = $4000000;
  Result.IA64 := (lvCPUID.EDX and $40000000) = $40000000;
  lvCPUID := CPUID($80000001);
  Result.MMXPlus := (lvCPUID.EDX and $800000) = $800000;
  Result.AMD3DNow := (lvCPUID.EDX and $10000000) = $10000000;
  Result.AMD3DNowPlus := (lvCPUID.EDX and $8000000) = $8000000;
  Result.X86_64 := (lvCPUID.EDX and $40000000) = $40000000;
  if (Result.Vendor = 'GenuineIntel') and ((Result.Family <> 15) or
    (Result.EFamily <> 0)) then
    Result.Name := Result.Vendor + ' Processor'
  else
  begin
    Result.Name := '';
    for i := 2 to 4 do
    begin
      lvCPUID := CPUID($80000000 + i);
      Result.Name := Result.Name +
        TRegChar(lvCPUID.EAX) +
        TRegChar(lvCPUID.EBX) +
        TRegChar(lvCPUID.ECX) +
        TRegChar(lvCPUID.EDX);
    end;
    Result.Name := Trim(Result.Name);
  end;
end;

procedure TForm1.FormShow(Sender: TObject);

  procedure WriteSupport(Edit: TEdit; Sup: Boolean);
  begin
    if Sup then
      edit.Text := '支持'
    else
      edit.Text := '不支持';
  end;
var
  CPU               : TCPUInfo;
begin
  CPU := getCPUInfo;
  EditCPUName.Text := CPU.Name;
  EditVendor.Text := CPU.Vendor;
  EditF.Text := Inttostr(CPU.Family);
  EditM.Text := Inttostr(CPU.Model);
  EditStep.Text := Inttostr(CPU.Stepping);
  EditFE.Text := Inttostr(CPU.EFamily);
  EditME.Text := Inttostr(CPU.EModel);
  EditStepE.Text := Inttostr(CPU.EStepping);
  Edit33.Text := Inttostr(CPU.APIC);
  EditBrand.Text := Inttostr(CPU.Brand);
  EditSpeed.Text := FormatFloat('###.##', CPU.Frequency);
  WriteSupport(EditMMX, CPU.MMX);
  WriteSupport(EditSSE, CPU.SSE);
  WriteSupport(EditSSE2, CPU.SSE2);
  WriteSupport(EditIA64, CPU.IA64);
  WriteSupport(EditMMXp, CPU.MMXPlus);
  WriteSupport(Edit3DNow, CPU.AMD3DNow);
  WriteSupport(Edit3DNowp, CPU.AMD3DNowPlus);
  WriteSupport(EditX86_64, CPU.X86_64);
end;

一个真正的CPU检测软件还要能够检测到缓存信息等等。大家可以参考上面表格所示的参数,在这些代码中作扩展。

CPU的资料好难找啊。Intel和AMD得还好一些,其他公司的简直是大海捞针。我尽力了,只能整理到这些了。  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -