Ignore:
Timestamp:
Oct 3, 2000, 7:28:32 PM (25 years ago)
Author:
sandervl
Message:

misc updates + fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/cpu.cpp

    r4074 r4407  
    1 /* $Id: cpu.cpp,v 1.10 2000-08-23 18:03:33 sandervl Exp $ */
     1/* $Id: cpu.cpp,v 1.11 2000-10-03 17:28:29 sandervl Exp $ */
    22/*
    33 * Odin win32 CPU apis
     
    139139                        GetCPUVendorString(buf);
    140140                        RegSetValueExA(xhkey,"VendorIdentifier",0,REG_SZ,(LPBYTE)buf,strlen(buf));
    141                 }
    142 
     141#ifdef __WIN32OS2__
     142                        if(i==0) {
     143                                DWORD mhz;
     144                                features = GetCPUFeatures();
     145                                if(features & CPUID_TIME_STAMP_COUNTER) {
     146                                        LARGE_INTEGER tsc1, tsc2, freq, time1, time2;
     147                                        double clockticks, millisec, frequency, tmp, tmp1, mhertz;
     148
     149                                        QueryPerformanceFrequency(&freq);
     150
     151                                        GetTSC((LONG *)&tsc1.LowPart, &tsc1.HighPart);
     152                                        QueryPerformanceCounter(&time1);
     153
     154                                        Sleep(32);      //sleep for about 32 ms
     155                                       
     156                                        GetTSC((LONG *)&tsc2.LowPart, &tsc2.HighPart);
     157                                        QueryPerformanceCounter(&time2);
     158                                        tmp  = (double)time2.LowPart + (double)time2.HighPart*4.0*1024.0*1024.0;
     159                                        tmp1 = (double)time1.LowPart + (double)time1.HighPart*4.0*1024.0*1024.0;
     160                                        millisec = tmp - tmp1;
     161                                        frequency= (double)freq.LowPart;
     162                                        frequency= frequency / 1000.0;
     163                                        millisec = millisec / frequency;
     164
     165                                        tmp  = (double)tsc2.LowPart + (double)tsc2.HighPart*4.0*1024.0*1024.0;
     166                                        tmp1 = (double)tsc1.LowPart + (double)tsc1.HighPart*4.0*1024.0*1024.0;
     167                                        clockticks = tmp - tmp1;
     168
     169                                        tmp = 1000 / millisec;
     170                                        clockticks = clockticks * tmp;  //ticks per second
     171                                        mhertz = clockticks / 1000000.0;
     172                                        mhz = (DWORD)mhertz;
     173                                }
     174                                else    mhz = 100;
     175                                RegSetValueExA(xhkey,"~Mhz",0,REG_DWORD, (LPBYTE)&mhz, sizeof(DWORD));
     176                        }
     177#endif
     178                }
    143179//TODO: FPU fdiv bug
    144180#if 0
Note: See TracChangeset for help on using the changeset viewer.