Voici différentes question en rapport avec le CPU et l'instruction CPUID
(Voir le code ci-dessous)
A quoi correspondent L1ICache et L1DCache pour le cache de niveau 1 ?
Alors qu'on a un GetExtendedL2Cache unique pour le cache de niveau 2 ?
Le cache de niveau 1 me renvoie toujours 0 ! que ce soit L1ICache ou L1DCache alors que j'ai 16 Ko par contre pour le niveau 2 il me renvoie bien 2048 Ko (2Mo) ce qui correspond bien. Ya t-il une combinaison arithmétique de L1ICache et L1DCache pour obtenir la valeur du cache de niveau 1 ? ou est-ce la routine qui est en cause dans ce cas je suis preneur pour une autre routine qui fonctionnerais mieux ???
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 type TCPUIDResult = packed record {getCPUInfo} EAX: DWord; EBX: DWord; ECX: DWord; EDX: DWord; end; TCPUInfo =packed record {getCPUInfo} Name: string[48]; Brand: Word; APIC: DWORD; Vendor: string[12]; Frequency: Real; Family: integer; Model: integer; Stepping: integer; EFamily: integer; EModel: integer; EStepping: integer; FPU: Boolean; //Test PSN: Boolean; MMX: Boolean; FXSAVE : Boolean; MMXPlus: Boolean; AMD3DNow: Boolean; AMD3DNowPlus: Boolean; SSE : Boolean; SSE2: Boolean; HTT : Boolean; SSE3: Boolean; IA64: Boolean; X86_64: Boolean; L1DCache:word; //Cache CPU Level 1 L1ICache:word; L2Cache:word; //cache CPU Level 2 end; var CPUID : TCPUID; begin { Détermine le cache CPU de niveau 1 (L1) } ListItem := ListView1.Items.Add; ListItem.Caption := 'Cache de niveau 1'; ListItem.SubItems.Add(inttostr(GetExtendedL1ICache)+ ' Ko'); { Détermine le cache CPU de niveau 2 (L2) } ListItem := ListView1.Items.Add; ListItem.Caption := 'Cache de niveau 2'; ListItem.SubItems.Add(inttostr(GetExtendedL2Cache)+ ' Ko');Je détecte la présence du PSN (Processor Serial Number comme ceci) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113 //**************************************************** // Renvoie la taille des caches de niveau L1 et L2 du CPU //**************************************************** //uses Math (Instruction Power) function GetExtendedL1DCache:word; //L1 cache var L1D,TempL1D:dword; BinArray:array[0..31] of byte; i,p:integer; begin asm push eax push ebx push ecx push edx mov eax,$80000005 mov ebx,0 mov ecx,0 mov edx,0 db $0F,$A2 /// cpuid mov L1D,ecx pop edx pop ecx pop ebx pop eax end; for i:=0 to 31 do begin BinArray[i]:=L1D mod 2; L1D:=L1D div 2; end; TempL1D:=0; p:=0; for i:=24 to 31 do begin TempL1D:=TempL1D+(BinArray[i]*StrToInt(FloatToStr(Power(2,p)))); inc(p); end; GetExtendedL1DCache:=TempL1D; end; function GetExtendedL1ICache:word; var L1I,TempL1I:dword; BinArray:array[0..31] of byte; i,p:integer; begin asm push eax push ebx push ecx push edx mov eax,$80000005 mov ebx,0 mov ecx,0 mov edx,0 db $0F,$A2 /// cpuid mov L1I,edx pop edx pop ecx pop ebx pop eax end; for i:=0 to 31 do begin BinArray[i]:=L1I mod 2; L1I:=L1I div 2; end; TempL1I:=0; p:=0; for i:=24 to 31 do begin TempL1I:=TempL1I+(BinArray[i]*StrToInt(FloatToStr(Power(2,p)))); inc(p); end; GetExtendedL1ICache:=TempL1I; end; function GetExtendedL2Cache:word; var L2,TempL2:dword; BinArray:array[0..31] of byte; i,p:integer; begin asm push eax push ebx push ecx push edx mov eax,$80000006 mov ebx,0 mov ecx,0 mov edx,0 db $0F,$A2 /// cpuid mov L2,ecx pop edx pop ecx pop ebx pop eax end; for i:=0 to 31 do begin BinArray[i]:=L2 mod 2; L2:=L2 div 2; end; TempL2:=0; p:=0; for i:=16 to 31 do begin TempL2:=TempL2+(BinArray[i]*StrToInt(FloatToStr(Power(2,p)))); inc(p); end; GetExtendedL2Cache:=TempL2; end;
Mais j'aimerais adapter le code ci-dessous trouvé sur le net à la syntaxe de mon code (les 2 codes ci-dessus) afin de pouvoir afficher le processor Serial Number (PSN) si existant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 //PSN (Intel Processor Serial Number) ListItem := ListView1.Items.Add; ListItem.Caption := 'PSN'; //bit 23 if CPU.PSN then begin //ListItem.SubItems.Add(GetPSN); end else begin ListItem.SubItems.Add('(Aucun ou désactivé)' ); end;
Merci,
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 var _eax, _ebx, _ecx, _edx: Longword; i: Integer; b: Byte; b1: Word; s, s1, s2, s3, s_all: string; begin b := lo(_ebx shr 16); info(' - ' + 'Count: ', IntToStr(b)); b := hi(_ebx shr 16); info(' - ' + 'APIC ID: ', IntToStr(b)); //Bit 18 =? 1 //is serial number enabled? if (_edx and $40000) = $40000 then info(' - ' + 'Serial Number ', 'Enabled') else info(' - ' + 'Serial Number ', 'Disabled'); s := IntToHex(_eax, 8); asm //determine the serial number mov eax,3 db $0F,$A2 mov _ecx,ecx mov _edx,edx end; s1 := IntToHex(_edx, 8); s2 := IntToHex(_ecx, 8); Insert('-', s, 5); Insert('-', s1, 5); Insert('-', s2, 5); info(' - ' + 'Serial Number: ', s + '-' + s1 + '-' + s2); asm mov eax,1 db $0F,$A2 mov _edx,edx end; info('', ''); //Bit 23 =? 1 if (_edx and $800000) = $800000 then info('MMX ', 'Supported') else info('MMX ', 'Not Supported');
Denis
Partager