27. marts 2001 - 09:37Der er
14 kommentarer og 1 løsning
Størelsen på L1/L2 cachen (900 Point)
Hi,
Hvordan kan man fra Borland 5.02 finde ud af hvor meget L1/L2 cache ens pentium II/III/IV processor har? Jeg skal bruge det til at kunne bestemme hvilen processor der sidder i maskinen.
Manuelle og semi-automatiske strategier for identitetsstyring virker - lige indtil nogen beder om dokumentation. For at undgå denne fare har DKTV taget kontrol over sin identitets- og adgangsstrategi.
Hvis du bare skal vide hvilken processor der sidder i din maskine hvad skal du så bruge L1/L2 cascheens størelse til. En forudsætning for alt dette er at du kan kompilere assembler inde fra din borland compiloer .. Check lige det først
prøv fx :
bool IsCPUID_Available () { __asm { PUSHFD //direct access to flags no possible, only via stack POP EAX //flags to EAX MOV EDX,EAX //save current flags XOR EAX,0x200000 //not ID bit PUSH EAX //onto stack POPFD //from stack to flags, with not ID bit PUSHFD //back to stack POP EAX //get back to EAX XOR EAX,EDX //check if ID bit affected JZ exit //no, CPUID not availavle MOV AL,1 //Result=True exit: } }
int CPUInfo( void ) { /* ---------------------------------------------------------------- */ /* The following Code distinguishes between 286+ (and above) and */ /* the other chips since 286+ (and above) pushes SP prior to */ /* decrementing its value for a PUSH SP instruction... The earlier */ /* processors will decrement SP first... */ /* ---------------------------------------------------------------- */ __emit__(0x8B,0xDC); /* MOV BX, SP */ __emit__(0x54); /* PUSH SP */ __emit__(0x58); /* POP AX */ __emit__(0x87,0xE3); /* XCHG BX, SP */ if ( _AX == _BX ) { /* ---------------------------------------------------------------- */ /* The following Code distinguishes between a 286 and higher */ /* processors since the 286 sets bits 12-14 of the FLAGS to zero */ /* after a PUSHF... */ /* ---------------------------------------------------------------- */ __emit__(0xB8,0x00,0x70); /* MOV AX, 7000h */ __emit__(0x50); /* PUSH AX */ __emit__(0x9D); /* POPF */ __emit__(0x9C); /* PUSHF */ __emit__(0x58); /* POP AX */
/* ---------------------------------------------------------------- */ /* The Following Code singles out the 80186 and 80188 since the Top */ /* three bits in CL are excluded by a shift instruction on those */ /* processors... i.e. Only the lower 5 bits of CL is used.. Using */ /* the value of 33 in CL is guaranteed to clear the register with */ /* the lower processors.. */ /* ---------------------------------------------------------------- */ __emit__(0xB0, 0xFF); /* MOV AL, 0FFh */ __emit__(0xB1, 0x21); /* MOV CL, 21h */ __emit__(0xD2, 0xE8); /* SHR AL, CL */
if ( _AL != 0x00 ) return( _80188 );
/* ---------------------------------------------------------------- */ /* The NEC V20/V30 carry forth a string instruction with REP and */ /* segment override even when Interrupts are enabled (unlike the */ /* 8088/8086)... */ /* ---------------------------------------------------------------- */ enable(); /* Ensure int\'s enabled */ __emit__(0x56); /* PUSH SI */ __emit__(0xB9,0xFF,0xFF); /* MOV CX, 0FFFFh */ __emit__(0xF3,0x26,0xAC); /* REP LODS BPTR ES:[SI]*/ __emit__(0x5E); /* POP SI */ if ( _CX == 0x00 ) return( _NECV20 ); return( _8088 ); }
int main(void) { printf(\"CPU Detection Routine\\n\"); printf(\"--- --------- -------\\n\\n\"); printf(\"Current Processor is: %s\\n\\n\", CPUStrings[ CPUInfo() ]); return( 0 ); }
-> Per. Mit problem er min kode ikke kan finde forskel på en Pentium III og en at de nyeste Celeron processorer. Normalt kan man skelne de enkelte Intel processorer fra hinanden ved hjælp af model, family og stepping nummeret. Intel har bare levet en PIII/Celeron processor med samme model, family og stepping nummer. (6,8,6) Og det er her lorten ligger. Derfor vil jeg bruge størelsen af cachen til at kunne skelne disse 2 processorer fra hinanden.
niepe>> Jeg har et API skrevet i Delphi som kan klare ærterne for dig .. Det er meget svært at porte til C++ fordi det bruger nogle strings ogs ådan noget. Hvis du har en String jeg mår bruge så send den til Jens@Borrisholt.com
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.