Rev | Line | |
---|
[4407] | 1 | ; $Id: cpuhlp.asm,v 1.4 2000-10-03 17:28:29 sandervl Exp $
|
---|
[1815] | 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
|
---|
[2613] | 11 | NAME cpuhlp
|
---|
[1815] | 12 |
|
---|
[2613] | 13 | DATA32 SEGMENT DWORD PUBLIC USE32 'DATA'
|
---|
| 14 | ASSUME DS:FLAT,SS:FLAT
|
---|
| 15 |
|
---|
[21916] | 16 | PUBLIC _CPUFeatures
|
---|
| 17 | _CPUFeatures dd 0
|
---|
[2613] | 18 |
|
---|
| 19 | DATA32 ENDS
|
---|
| 20 |
|
---|
[1815] | 21 | CODE32 SEGMENT DWORD PUBLIC USE32 'CODE'
|
---|
| 22 |
|
---|
[2798] | 23 | public _SupportsCPUID
|
---|
[1815] | 24 |
|
---|
[2798] | 25 | _SupportsCPUID proc near
|
---|
[1815] | 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
|
---|
[2798] | 48 | _SupportsCPUID endp
|
---|
[1815] | 49 |
|
---|
[2798] | 50 | public _GetCPUVendorString
|
---|
[1815] | 51 |
|
---|
[2798] | 52 | _GetCPUVendorString proc near
|
---|
[1815] | 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
|
---|
[2798] | 74 | _GetCPUVendorString endp
|
---|
[1815] | 75 |
|
---|
[2798] | 76 | public _GetCPUFeatures
|
---|
| 77 | _GetCPUFeatures proc near
|
---|
[1815] | 78 | push ebx
|
---|
| 79 | push ecx
|
---|
| 80 | push edx
|
---|
| 81 |
|
---|
| 82 | mov eax, 1
|
---|
| 83 | cpuid
|
---|
| 84 |
|
---|
| 85 | mov eax, edx
|
---|
| 86 |
|
---|
[21916] | 87 | mov [_CPUFeatures], eax
|
---|
[2613] | 88 |
|
---|
[1815] | 89 | pop edx
|
---|
| 90 | pop ecx
|
---|
| 91 | pop ebx
|
---|
| 92 | ret
|
---|
[2798] | 93 | _GetCPUFeatures endp
|
---|
[1815] | 94 |
|
---|
[2798] | 95 | public _GetCPUSignature
|
---|
| 96 | _GetCPUSignature proc near
|
---|
[1815] | 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
|
---|
[2798] | 108 | _GetCPUSignature endp
|
---|
[1815] | 109 |
|
---|
| 110 |
|
---|
[4407] | 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 |
|
---|
[1815] | 131 | CODE32 ENDS
|
---|
| 132 |
|
---|
| 133 | END
|
---|
Note:
See
TracBrowser
for help on using the repository browser.