| Line |  | 
|---|
| 1 | ; $Id: cpuhlp.asm,v 1.4 2000-10-03 17:28:29 sandervl Exp $ | 
|---|
| 2 |  | 
|---|
| 3 | ;/* | 
|---|
| 4 | ; * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 5 | ; * CPU detection functions | 
|---|
| 6 | ; * | 
|---|
| 7 | ; * Copyright 1999 Sander van Leeuwen | 
|---|
| 8 | ; * | 
|---|
| 9 | ; */ | 
|---|
| 10 | .586 | 
|---|
| 11 | NAME    cpuhlp | 
|---|
| 12 |  | 
|---|
| 13 | DATA32  SEGMENT DWORD PUBLIC USE32 'DATA' | 
|---|
| 14 | ASSUME  DS:FLAT,SS:FLAT | 
|---|
| 15 |  | 
|---|
| 16 | PUBLIC  CPUFeatures | 
|---|
| 17 | CPUFeatures     dd 0 | 
|---|
| 18 |  | 
|---|
| 19 | DATA32  ENDS | 
|---|
| 20 |  | 
|---|
| 21 | CODE32          SEGMENT DWORD PUBLIC USE32 'CODE' | 
|---|
| 22 |  | 
|---|
| 23 | public _SupportsCPUID | 
|---|
| 24 |  | 
|---|
| 25 | _SupportsCPUID proc near | 
|---|
| 26 | pushfd | 
|---|
| 27 | push    ecx | 
|---|
| 28 |  | 
|---|
| 29 | pushfd | 
|---|
| 30 | pop     eax | 
|---|
| 31 | mov     ecx, eax | 
|---|
| 32 | xor     eax, 200000h                    ;flip bit 21 | 
|---|
| 33 | push    eax | 
|---|
| 34 | popfd | 
|---|
| 35 | pushfd | 
|---|
| 36 | pop     eax | 
|---|
| 37 | cmp     eax, ecx                        ;bit 21 changed -> has cpuid support | 
|---|
| 38 | jnz     @supportscpuid | 
|---|
| 39 | xor     eax, eax | 
|---|
| 40 | jmp     short @end | 
|---|
| 41 |  | 
|---|
| 42 | @supportscpuid: | 
|---|
| 43 | mov     eax, 1 | 
|---|
| 44 | @end: | 
|---|
| 45 | pop     ecx | 
|---|
| 46 | popfd | 
|---|
| 47 | ret | 
|---|
| 48 | _SupportsCPUID endp | 
|---|
| 49 |  | 
|---|
| 50 | public _GetCPUVendorString | 
|---|
| 51 |  | 
|---|
| 52 | _GetCPUVendorString proc near | 
|---|
| 53 | push    ebp | 
|---|
| 54 | mov     ebp, esp | 
|---|
| 55 | push    ebx | 
|---|
| 56 | push    ecx | 
|---|
| 57 | push    edx | 
|---|
| 58 | push    esi | 
|---|
| 59 |  | 
|---|
| 60 | mov     esi, [ebp+8]    ;ptr to string | 
|---|
| 61 | mov     eax, 0 | 
|---|
| 62 | cpuid | 
|---|
| 63 |  | 
|---|
| 64 | mov     [esi], ebx | 
|---|
| 65 | mov     [esi+4], edx | 
|---|
| 66 | mov     [esi+8], ecx | 
|---|
| 67 |  | 
|---|
| 68 | pop     esi | 
|---|
| 69 | pop     edx | 
|---|
| 70 | pop     ecx | 
|---|
| 71 | pop     ebx | 
|---|
| 72 | pop     ebp | 
|---|
| 73 | ret | 
|---|
| 74 | _GetCPUVendorString endp | 
|---|
| 75 |  | 
|---|
| 76 | public _GetCPUFeatures | 
|---|
| 77 | _GetCPUFeatures proc near | 
|---|
| 78 | push    ebx | 
|---|
| 79 | push    ecx | 
|---|
| 80 | push    edx | 
|---|
| 81 |  | 
|---|
| 82 | mov     eax, 1 | 
|---|
| 83 | cpuid | 
|---|
| 84 |  | 
|---|
| 85 | mov     eax, edx | 
|---|
| 86 |  | 
|---|
| 87 | mov     [CPUFeatures], eax | 
|---|
| 88 |  | 
|---|
| 89 | pop     edx | 
|---|
| 90 | pop     ecx | 
|---|
| 91 | pop     ebx | 
|---|
| 92 | ret | 
|---|
| 93 | _GetCPUFeatures endp | 
|---|
| 94 |  | 
|---|
| 95 | public _GetCPUSignature | 
|---|
| 96 | _GetCPUSignature proc near | 
|---|
| 97 | push    ebx | 
|---|
| 98 | push    ecx | 
|---|
| 99 | push    edx | 
|---|
| 100 |  | 
|---|
| 101 | mov     eax, 1 | 
|---|
| 102 | cpuid | 
|---|
| 103 |  | 
|---|
| 104 | pop     edx | 
|---|
| 105 | pop     ecx | 
|---|
| 106 | pop     ebx | 
|---|
| 107 | ret | 
|---|
| 108 | _GetCPUSignature endp | 
|---|
| 109 |  | 
|---|
| 110 |  | 
|---|
| 111 | _GetTSC proc near | 
|---|
| 112 | push    ebp | 
|---|
| 113 | mov     ebp, esp | 
|---|
| 114 | push    edx | 
|---|
| 115 | push    esi | 
|---|
| 116 | push    edi | 
|---|
| 117 | rdtsc | 
|---|
| 118 |  | 
|---|
| 119 | mov     esi, [ebp+8]    ;ptr to low dword | 
|---|
| 120 | mov     edi, [ebp+12]   ;ptr to high dword | 
|---|
| 121 | mov     [esi], eax | 
|---|
| 122 | mov     [edi], edx | 
|---|
| 123 |  | 
|---|
| 124 | pop     edi | 
|---|
| 125 | pop     esi | 
|---|
| 126 | pop     edx | 
|---|
| 127 | pop     ebp | 
|---|
| 128 | ret | 
|---|
| 129 | _GetTSC endp | 
|---|
| 130 |  | 
|---|
| 131 | CODE32          ENDS | 
|---|
| 132 |  | 
|---|
| 133 | END | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.